So I'm using a role to configure my postgresql server. That tole has a way of specifying server users & databases, like so:
postgresql_users:
- name: baz
My hosts.yaml:
all:
hosts:
children:
django:
hosts:
django_1:
username: django1
userpass: django1_pass
django_2:
username: django2
userpass: django2_pass
db:
hosts:
db1:
Any my playbook.yaml:
- hosts: db
become: true
roles:
- role: anxs.postgresql
What I want to do with this information is to get all django hosts and get their username & userpass variables.
Then, from this information compose the postgresql_users variable as if it were written by hand (relevant (desired result) section of hosts.yaml below):
db:
hosts:
db1:
postgresql_users:
- name: django1
password: django1_pass
encrypted: true
- name: django2
password: django2_pass
encrypted: true
I have found this question dealing with my problem, but unfortunately I'm too new to Ansible to really understand what's being suggested there.
So how can I make an appropriate iteration that would compose my postgresql_users variable as I want it?