Reputation: 21243
I have inventory file as
# file: production_hosts
[my_servers]
myserver0[1:4].google.com
When I try to run the playbook on subset of these hosts, it gives only first and last host.
$ ansible-playbook -i production_hosts -l 'myserver0[1:3].google.com' yum_update_all.yaml --list-hosts
playbook: yum_update_all.yaml
play #1 (all): all TAGS: []
pattern: [u'all']
hosts (2):
myserver01.google.com
myserver03.google.com
When I tried other way, by giving each number, it gives all.
$ ansible-playbook -i production_hosts -l 'myserver0[1:2:3].google.com' yum_update_all.yaml --list-hosts
playbook: yum_update_all.yaml
play #1 (all): all TAGS: []
pattern: [u'all']
hosts (3):
myserver02.google.com
myserver01.google.com
myserver03.google.com
Pattern similar pattern hosts will not work in limit ?
Upvotes: 0
Views: 6417
Reputation: 68509
ansible-playbook -i production_hosts -l 'myserver0[123].google.com' yum_update_all.yaml --list-hosts
or (what you actually request):
ansible-playbook -i production_hosts -l 'myserver0[1-3].google.com' yum_update_all.yaml --list-hosts
yield:
playbook: playbook.yml
play #1 (all): all TAGS: []
pattern: [u'all']
hosts (3):
myserver02.google.com
myserver01.google.com
myserver03.google.com
Upvotes: 3