New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
list concatenation using "set_fact" and "with_items" not working (regression) #80404
Comments
Files identified in the description: If these files are incorrect, please update the |
This is not a bug. You are doing concatenation outside of a Jinja expression, which used to work due to a bug but was never intended behavior. As noted in the porting guide |
Thanks for the clarification. |
The lazy way is to just put it in a separate variable. - name: create vars for nfs role
set_fact:
nfs_exports: "{{ nfs_exports | default([]) + [new_export] }}"
loop: "{{ shares }}"
vars:
new_export: /share/{{item.from[ansible_host].path.split('/')[-1]}} {% for client in item.to | default([]) %}{{ips_intern[client]}} {% endfor %}{% for host in item.from[ansible_host].hosts | default([]) %}{{host}}({{item.from[ansible_host].options}}) {% endfor %}
when:
- "'nfs_servers' in group_names"
- "ansible_host in item.from"
- "item.from[ansible_host].hosts is defined" |
True that is an easy solution. Thx alot. I am closing this issue. |
Summary
Loops with set_fact do not behave like they used to. Unless this change is intended or documented somewhere, it is a regression. Maybe it is related to breaking changes with jinja3.
Issue Type
Bug Report
Component Name
core, jinja
Ansible Version
Configuration
OS / Environment
Debian bullseye
Steps to Reproduce
Vars:
Task:
Expected Results
"nfs_exports": ['/share fd75:5a92:ipv6 fd75:5a92:ipv6 ', '/share fd75:5a92:ipv6 fd75:5a92:ipv6 ']
Actual Results
"nfs_exports": "[] + ['/share fd75:5a92:ipv6 fd75:5a92:ipv6 '] + ['/share fd75:5a92:ipv6 fd75:5a92:ipv6 ']"
Since update to this ansible Version a string is generated. Concat of lists does not work any more. With {{ nfs_exports | default([]) | list }} it works as expected, but the list filter breaks the wrong interpretated string into single characters: ["[", "]"]
Code of Conduct
The text was updated successfully, but these errors were encountered: