I have to create a haproxy config file with data from an unknown number of 
backend servers. The number is unknown, because based on the environment I 
need to run the playbook in, the number of backend servers could be 1 to 
several. My backend servers in haproxy.cfg need to defined something like 
this:

backend                       backend_nodes
    description               Web Servers
    balance                   roundrobin   
    server                    web01 10.0.2.1:8080 check
    server                    web02 10.0.2.3:8080 check
    server                    web03 10.0.2.3:8080 check

So on any given run of the playbook, I need to define the dict 
'backend_servers' for X items (to generate the server lines above):

  - name: <server_name>
    ip: <server_IP>
    port: <http_port>
    params: <params>

With that block repeated for every server in groups['web_servers']. I tried 
using set_facts, but that can't define dict types. I have to do this as a 
dict, because different inventories will have different numbers of hosts in 
groups['web_servers'], and I can't hard-code this into my playbook or 
template, because the playbook will be used to configure different haproxy 
roles with different parameters, so this role needs to remain generic.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/95c5422a-e604-4742-b282-0dc9c8265117%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to