- hosts: localhost
connection: local
vars:
# THIS does not work as it's interpreted as a string, would have to split in a new var?
# is there anything I can do here to keep a similar syntax but return a list?
users: >-
{% set cusers = ['user1', 'user2'] %}
{% if ansible_distribution == "RedHat" %}
{{ cusers.append('redhat_user') }}
{% else %}
{{ cusers.append('other_user') }}
{% endif %}
{{ cusers | list }}
# THIS works but a little ugly with the newline
users2: "{% set cusers = ['user1', 'users2'] %}\
{% if ansible_distribution == 'RedHat' %}\
{{ cusers.append('redhat_user') }}\
{% else %}\
{{ cusers.append('other_user') }}\
{% endif %}\
{{ cusers }}"
tasks:
- debug:
msg: "user: {{ item }}"
loop: "{{ users2 }}"--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/14fa6ba6-67c2-4113-9d75-4c2312f0dc7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/14fa6ba6-67c2-4113-9d75-4c2312f0dc7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.