On Fri, 06 Feb 2015 03:27 -0800, Alexey Lesovsky <[email protected]>
wrote:
> Hello all!
> I have playbook with following parts:
> 
> vars:
>   servers:
>     - { address: "192.168.122.12", role: "upstream" }
>     - { address: "192.168.122.13", role: "downstream" }
>     - { address: "192.168.122.14", role: "downstream" }
> task:
>   - name: Task
>      command: "/usr/sbin/somecommand"

IMHO, it's better to work with groups in this scenario:

# inventory
[downstream]
192.168.122.12
192.168.122.14

[upstream]
192.168.122.12

You can either define multiple plays targeting each group with a set of
tasks/roles:

# playbook
---
- name: deploy downstream
  hosts: downstream
  tasks:
    -- name: something
        somemodule:

- name: deploy upstream
  hosts: upstream
  tasks:
    -- name: something else
        someothermodule:


Or limit your whole playbook to some groups only. For example:

$ ansible-playbook -l upstream playbook.yml

I'm thinking doing this with a dictionary is going to be replicating
functionality that already exists (to be honest, don't even know if the
conditionals can do this, probably yes).

If you want to define variables per group, I'd consider using group_vars
(http://docs.ansible.com/intro_inventory.html#group-variables)

Giovanni

-- 
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/1423226873.1055757.223936609.63FB44EA%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to