Have you though about creating another play and just including those tasks
under that play?
- hosts: all
tasks:
- name: do task A
...
- hosts: webservers
tasks:
- name: do tasks A only for webservers
I maybe oversimplifying your workflow but it could help decouple your tasks
for re-usability later on.
On 15 November 2015 at 07:40, Adithya Khamithkar <[email protected]>
wrote:
> Thanks got it working!
>
>
> ---
>
>
>
>
>
> Adithya Khamithkar
>
>
>
> [image: http://]about.me/adithyakhamithkar
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> <http://about.me/adithyakhamithkar?promo=email_sig>
>
>
>
>
>
>
> On Sun, Nov 15, 2015 at 9:06 PM, Matt Martz <[email protected]> wrote:
>
>> when: '"web-server" in group_names'
>>
>> group_names is an array/list so you have to check if 'web-server' exists
>> within it.
>>
>> On Sunday, November 15, 2015, Adithya Khamithkar <[email protected]>
>> wrote:
>>
>>> Hi,
>>>
>>> I would like to use the when condition to execute tasks based on group
>>> names in ansible.
>>>
>>> I am using this code snipit
>>>
>>> when: ({{group_names}} == "web-server")
>>>
>>> But it always skips.
>>>
>>> Can someone please correct me.
>>>
>>> --
>>> 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/da3e21ec-38f5-44d2-ab6d-a1fc62f9866c%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/da3e21ec-38f5-44d2-ab6d-a1fc62f9866c%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Matt Martz
>> @sivel
>> sivel.net
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/ansible-project/YEKoGn-GsS0/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/CAD8N0v_J46vR8NOYh%2BBhy0%2ByhyUjTDjREXMb3sqPtOjPynVU%2Bg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CAD8N0v_J46vR8NOYh%2BBhy0%2ByhyUjTDjREXMb3sqPtOjPynVU%2Bg%40mail.gmail.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/CALeNQPE9i0nW6MqZ5YSTuY2nEjn2PzAfD%3DHnMOx5_q%2B_poVdVw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CALeNQPE9i0nW6MqZ5YSTuY2nEjn2PzAfD%3DHnMOx5_q%2B_poVdVw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
Steve
--
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%2BemtqukSxivHDdFYq86GHgNks2LNq_J3CKdpUKSDRMU13tiYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.