theres a globally available 'groups' so, as usual, its easy once you know 
it.

  - include: make_reverseproxy.yml
    vars:
      hostname: "{{ item.value.hostname }}"
      address: "{{ item.value.address }}"
    with_dict: "{{ containers }}"
    when: item.key in groups['web']




On Saturday, December 12, 2015 at 6:26:18 PM UTC-8, pixel fairy wrote:
>
> 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.
>
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0c0b82e8-fd54-460d-a191-4fcf48264377%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to