have a little lxc playbook making reverse proxies from one container to the others. it reads from a dictionary of container definitions, and i only want it to proxy the containers acting as web servers, which are in the group “web” in the inventory. how can i do this? the reverse proxy runs nginx and the host forwards port 80 to it.
heres the containers file,
`
containers:
reverseproxy:
hostname: reverseproxy.lan
address: 192.168.114.10
forwards:
- { transport: tcp, host: 80, container: 80 }
web1:
hostname: web1.lan
address: 192.168.114.11
web2:
hostname: web2.lan
address: 192.168.114.12
`
heres the inventory
`
[lxc]
lxctest
[containers]
reverseproxy ansible_ssh_host=192.168.114.10
web1 ansible_ssh_host=192.168.114.11
web2 ansible_ssh_host=192.168.114.12
[web]
web1
web2
`
and this calls the include that makes the pair of includes from the reverseproxy playbook
`
- include: make_reverseproxy.yml
vars:
hostname: “{{ item.value.hostname }}”
address: “{{ item.value.address }}”
with_dict: “{{ containers }}”
`
item.key is also the ansible hostname, so maybe some kind of “when item.key in group web?”
i realize i could just make a list, but i hate repeating.