I have a TASK
to create some postgres user with password
- name: create users, set hashed passwords
community.postgresql.postgresql_user:
name: "{{ item.name }}"
password: "{{ item.pw }}"
encrypted: true
comment: "{{ item.comment }}"
role_attr_flags: "{{ item.attr }}"
login_unix_socket: '/tmp'
become: true
become_user: postgres
loop: "{{ pg_roles }}"
{{ pg_roles }}
comes from host_vars
file
now, there are other roles needed that are not specific to a singular host, but are equal for all hosts in the current group.
so there is adm_roles
variable defined in group_vars
file.
Now, I am wondering whether I can loop though both lists (pg_roles
& adm_roles
) inside the same TASK or whether there must be a second identical TASK for each list?
I tried:
...
login_unix_socket: '/tmp'
become: true
become_user: postgres
loop:
- "{{ pg_roles }}"
- "{{ adm_roles }}"
but that didn’t work (list item has no attribute ‘name’, I think)