On 04/01/18 07:11, Kai Stian Olstad wrote:
> On 03.01.2018 18:03, Frank Thommen wrote:
>> I assumed, that host ranges could be used with ansible-playbook's
>> --limit as they can be used in the inventory itself. However this
>> doesn't seem to be possible:
>
> It's called patterns
>
http://docs.ansible.com/ansible/latest/intro_patterns.html
>
>
>> $ ansible-playbook site.yml --limit='host[010:027]'
>
> According to the documentation this is the syntax to get index 10 to 27
> from group named host.
I see. It seems a bad idea to implement the seemingly identical syntax
for two things with completely different meaning: A range in the
inventory and indexes elsewhere
>> [WARNING]: Could not match supplied host pattern, ignoring: host
>>
>> ERROR! Specified --limit does not match any hosts
>> $
>>
>> All hosts host010 - host027 are listed in the inventory.
>>
>> The same happens with double quotes and witout quotes around the limit
>> pattern.
>>
>> How can I use host ranges witn --limit?
>
> I think you best option is to switch to regex, and that can be done with
> tilde
>
> ansible-playbook site.yml --limit='~host0(1[0-9]|2[0-7])'
I hoped to avoid that. regexes tend to become quite complex and
unreadable very quickly. The usecase in the post is a very simplified
breakdown of the "real" term we need. But I'll give it a try anyway. :-)
Thanks
frank