Hi,
I’m wishing to use various Roles from Galaxy, and they often require configuration via variables.
My question is: is it possible to dynamically build these files?
For instance, let’s say I want to configure a few backend servers for HAProxy. The variables typically look like this:
`
haproxy_backends:
- name: ‘be-mysupersite’
description: ‘mysupersite is really cool’
servers: - name: “be-mysupersite-01”
ip: “123.123.123.124”
port: 8080 - name: “be-mysupersite-02”
ip: “123.123.123.125”
port: 8080 - name: “be-mysupersite-03”
ip: “123.123.123.126”
port: 8080
`
What I’m hoping to do is build this with loops, for example, something like this:
`
haproxy_backends:
-
name: ‘be-mysupersite’
description: ‘mysupersite is really cool’
servers: -
name: “{{ item.name }}”
ip: “{{ item.ip }}”
port: 8080
with_items: -
{ name: ‘be-mysupersite-01’, ip: ‘123.123.123.124’ }
-
{ name: ‘be-mysupersite-02’, ip: ‘123.123.123.125’ }
-
{ name: ‘be-mysupersite-03’, ip: ‘123.123.123.126’ }
`
The config file ends up with something like {# item.name #} instead of the actual name.
Can anybody point me in the right direction?
Much appreciated,
Kelvin