Can anybody help me on this: http://stackoverflow.com/questions/24798382/how-to-assign-an-array-to-a-variabel-in-an-ansible-playbook
If you’re going to reask questions from Stack Overflow please paste the question here and save us the click.
We’re not going to answer over on StackOverflow.
It’s also much better to just ask here as you’ll get quicker answers - much larger audience reading things.
I’m also unclear what you are having problems with so maybe you can elaborate a bit.
Thanks!
I have a DB Server and a bunch of webservers (also running the application as of now). All the servers are connected via private networking on eth1. Now I need to configure postgresql (I am using the role Ansibles.postgresql) to accept password authenticated requests on eth1. The way to do this in Ansibles.postgresql role is to set value of variable to an array containing all the IPs of hosts that should be allowed to auth like so:
`
postgresql_pg_hba_passwd_hosts: [‘10.129.181.241/32’, ‘my_other_ip’, …]
`
What I need to do now is to figure out a (the best) way to assign all the IPs on eht1 of all the servers in the group web to this variable and suffix them all with “/32”
I know I can get the IPs via
`
{% for host in groups[‘web’] %}
{{ hostvars[host][‘ansible_eth1’][‘ipv4’][‘address’] }}
{% endfor %}
`
But this only works in a template, right? (Since jinja2 is not interpreted in playbookfiles?)
So I am looking for a complete answer of how to best achieve this in a most (Ansible-)standard way. I am sure this is a fairly common task, but right now I just can’t see it.
Can I ask why you think you can’t just template the postgresql security file?
I try to use as many roles from galaxy as possible. Doing my own template just to solve this problem seems not like the best solution to me. The role works perfect for me otherwise.
You will need to template the file and may need to customize an existing role then.
Galaxy is full of great examples and starting points, but it not meant to be 100% turnkey.
OK, thanks a lot!
I wanted to ask a followup question, but it was so far off topic that I decided to open a new topic for it.