There are a number of ways to do this.

1. Set "hosts" to "web*01" or whatever the pattern is to target only those
servers in the play
2. In your when statement use 'inventory_hostname.endswith("01")'
3. inventory_hostname|search('01$')

Those are just a few of the many ways.

On Thursday, October 8, 2015, Tom Vernon <[email protected]> wrote:

> Hi there, slowly learning ansible here and having issues with a simple
> conditional.  I want to run something against all hosts in group
> "webservers" that end in "01".  The following doesnt seem to match any
> hosts (they get skipped), but looks right to me. Any ideas?
>
> - hosts: webservers
>   tasks:
>     - name: check cluster status
>       command: 'echo $hostname'
>       when: inventory_hostname == "*01"
>
>
>
> Thanks
>
> --
> 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]
> <javascript:_e(%7B%7D,'cvml','ansible-project%[email protected]');>
> .
> To post to this group, send email to [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/33d06b07-bb1a-4d31-92fd-8009d5bbb3b5%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/33d06b07-bb1a-4d31-92fd-8009d5bbb3b5%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 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/CAD8N0v9MNL%2B4wg%2Bp0Q01sHi0Bd-QNpEhFfRadkiM%3Dvw1150NfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to