Eventually I rewrote playbook using groups and include statements for 
tasks, and it works fine. But, in the current circumstances I'm not quite 
satisfied, I need to make a single file playbook. Yes, I know it's not 
quite right and not a best practice )))

пятница, 6 февраля 2015 г., 17:48:02 UTC+5 пользователь Giovanni Tirloni 
написал:
>
> On Fri, 06 Feb 2015 03:27 -0800, Alexey Lesovsky <[email protected] 
> <javascript:>> 
> 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/35e3f2ef-d2a8-43cf-8ce6-e36b55cc7882%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to