# \--limit with \[nnn:nnn\] not working

**URL:** <https://forum.ansible.com/t/limit-with-nnn-nnn-not-working/15022>\
**Category:** Ansible Project\
**Created:** [April 15, 2014, 4:28pm UTC](https://forum.ansible.com/t/limit-with-nnn-nnn-not-working/15022 "2014-04-15T16:28:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Cavedon](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Mike\_Cavedon](https://forum.ansible.com/u/Mike_Cavedon)\
**Post date:** [April 15, 2014, 4:28pm UTC](https://forum.ansible.com/t/limit-with-nnn-nnn-not-working/15022/1 "2014-04-15T16:28:39Z")

</div>

I have the following hosts file.

(skytap\_env)[jenkins@rts-loadgen02 dxansible]$ cat hosts\_file  
[router\_hosts]  
rts-rr[201:203].slsin.dataxu.net  
rts-rr[301:303].slsin.dataxu.net

The following --limit works correctly.

(skytap\_env)[jenkins@rts-loadgen02 dxansible]$ ansible-playbook -v -i hosts\_file realtime\_system\_router\_matcher\_hosts\_stop.yml --list-hosts --limit router\_hosts

playbook: realtime\_system\_router\_matcher\_hosts\_stop.yml

play #1 (router\_hosts:matcher\_hosts): host count=6  
[rts-rr201.slsin.dataxu.net](http://rts-rr201.slsin.dataxu.net)  
[rts-rr202.slsin.dataxu.net](http://rts-rr202.slsin.dataxu.net)  
[rts-rr203.slsin.dataxu.net](http://rts-rr203.slsin.dataxu.net)  
[rts-rr301.slsin.dataxu.net](http://rts-rr301.slsin.dataxu.net)  
[rts-rr302.slsin.dataxu.net](http://rts-rr302.slsin.dataxu.net)  
[rts-rr303.slsin.dataxu.net](http://rts-rr303.slsin.dataxu.net)

play #2 (router\_hosts): host count=6  
[rts-rr201.slsin.dataxu.net](http://rts-rr201.slsin.dataxu.net)  
[rts-rr202.slsin.dataxu.net](http://rts-rr202.slsin.dataxu.net)  
[rts-rr203.slsin.dataxu.net](http://rts-rr203.slsin.dataxu.net)  
[rts-rr301.slsin.dataxu.net](http://rts-rr301.slsin.dataxu.net)  
[rts-rr302.slsin.dataxu.net](http://rts-rr302.slsin.dataxu.net)  
[rts-rr303.slsin.dataxu.net](http://rts-rr303.slsin.dataxu.net)

play #3 (matcher\_hosts): host count=0

I’m expecting the following --limit to also work.

(skytap\_env)[jenkins@rts-loadgen02 dxansible]$ ansible-playbook -v -i hosts\_file realtime\_system\_router\_matcher\_hosts\_stop.yml --list-hosts --limit rts-rr[201:203].slsin.dataxu.net

ERROR: provided hosts list is empty

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 15, 2014, 9:40pm UTC](https://forum.ansible.com/t/limit-with-nnn-nnn-not-working/15022/2 "2014-04-15T21:40:04Z")

</div>

Yep, that’s not a thing.

The syntax above for populating inventory via patterns is not accepted directly by limit.

What it does accept with brackets are slices, such as the first four servers in a group, as:

–limt groupfoo[0:4]

---

<div class="post-metadata">

**Author:** ![Mike\_Cavedon](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Mike\_Cavedon](https://forum.ansible.com/u/Mike_Cavedon)\
**Post date:** [April 16, 2014, 3:40pm UTC](https://forum.ansible.com/t/limit-with-nnn-nnn-not-working/15022/3 "2014-04-16T15:40:09Z")

</div>

If I can define it in the hosts file it should be support by “–limit”. Do you have a place for enhancement requests?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 17, 2014, 2:26am UTC](https://forum.ansible.com/t/limit-with-nnn-nnn-not-working/15022/4 "2014-04-17T02:26:54Z")

</div>

"If I can define it in the hosts file it should be support by “–limit”.

Disagree. [0:5] has traditionally been for slicing, and this would be confusing. What the INI host file uses is not the only inventory source, and creation of inventory records is different from slicing against them.

However, it is true that --limit accepts fnmatch patterns, which is what the system is running.

[https://docs.python.org/2/library/fnmatch.html](https://docs.python.org/2/library/fnmatch.html)

Do you have a place for enhancement requests?"

Yes, but don’t want this one for above reasons of being ambigious with the slicing of groups already supported.

This could still be solved by adding each thing you’d want to limit to as a group, or specifying an fnmatch pattern that did match some of them.

–Michael
