On Fri, 06 Feb 2015 03:27 -0800, Alexey Lesovsky <
leso...@gmail.com>
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