You could possibly consider passing ansible-playbook a --limit to only run
on the servers you want to run on.

Others may have better suggestions.




On Thu, Apr 10, 2014 at 3:47 AM, Hagai Kariti <[email protected]> wrote:

> Hi all.
>
> I have a master deployment playbook that more or less includes all of my
> servers, which I use with tags to deploy only the apps/configs I want at
> the time. Hosts are grouped into hostgroups by roles and each hostgroup has
> it's own pre/post tasks for handling load-balancers, etc. It looks
> something like this:
>
> - hosts: tag_role_hostgroup1
>   serial: 1
>   pre_tasks:
>     - name: Remove from lb
>        ...
>        tags: pre_tasks
>   roles:
>      - { role: app1, tags: app1 }
>      - { role: app2, tags: app2 }
>   post_tasks:
>     - name: Register to lb
>       ...
>       tags: post_tasks
>
> - hosts: tag_role_hostgroup2
>   serial: 1
>   pre_tasks:
>     - name: Some preps
>        ...
>        tags: pre_tasks
>   roles:
>      - { role: app2, tags: app2 }
>      - { role: app3, tags: app3 }
>   post_tasks:
>     - name: Cleanup
>       ...
>       tags: post_tasks
>
> So far so good. It works pretty well as I can think about applications
> when deploying, and each hostgroup will take care of itself regarding
> load-balancers and all. Problem is when deploying for example app1 or app3.
> In this case one play will have no roles selected, but since I'm including
> "pre_tasks,post_tasks" as tags its pre/post tasks will still run, bringing
> machines down and up again with no work done.
>
> Do you have an idea of how to tackle this? I prefer to not create a
> playbook per app as it's a lot less powerful and flexible. I was thinking
> of making ansible run pre/post tasks only if some task in roles/tasks is
> going to run, but that's kind of a last resort.
>
> Thanks for Ansible, btw!
>
> --
> 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/c0f38e58-db47-4e16-9fa0-c1c9c47b4e2c%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/c0f38e58-db47-4e16-9fa0-c1c9c47b4e2c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BnsWgxTZVxqr%3Da7sFNw0DWpViP028eiJbNBeRsNcBp4W9X3hw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to