# host-pattern and wild cards

**URL:** <https://forum.ansible.com/t/host-pattern-and-wild-cards/21460>\
**Category:** Ansible Project\
**Created:** [May 17, 2016, 4:40pm UTC](https://forum.ansible.com/t/host-pattern-and-wild-cards/21460 "2016-05-17T16:40:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenny\_Serrine](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@Kenny\_Serrine](https://forum.ansible.com/u/Kenny_Serrine)\
**Post date:** [May 17, 2016, 4:40pm UTC](https://forum.ansible.com/t/host-pattern-and-wild-cards/21460/1 "2016-05-17T16:40:32Z")

</div>

I’m using wildcards to match my hosts, and it works in one case but not in another. I’ve figured out that if I use a regex pattern, I can get consistency. But, for just simple wildcard, I’m wondering if this is a bug or if I’m just doing something that the command line parser wasn’t designed to handle. Maybe the documentation just needs to be clear about the limits of wildcards?  
I have version 2.0.2.0 of ansible.

**Here is the example hosts file I’m using:**

`[root@ap01 Scripts]# cat /tmp/killthis.txt`

[group1]  
[myproxy1.example.net](http://myproxy1.example.net)  
[mysync1.example.com](http://mysync1.example.com)

[group2]  
[myproxy2.example.net](http://myproxy2.example.net)  
[mysync2.example.com](http://mysync2.example.com)

**And, here are the commands I’m using. As you can see, _proxy_ seems to work, but _sync_ fails, and _ync_ really fails**.

`[root@p01 Scripts]# ansible *proxy* -i /tmp/killthis.txt --list-hosts`

hosts (2):  
[myproxy1.example.net](http://myproxy1.example.net)  
[myproxy2.example.net](http://myproxy2.example.net)

`[root@01 Scripts]# ansible *sync* -i /tmp/killthis.txt --list-hosts`

[WARNING]: provided hosts list is empty, only localhost is available

hosts (0):

`[root@p01 Scripts]# ansible *ync* -i /tmp/killthis.txt --list-hosts`

Usage: ansible [options]

Options:  
-a MODULE\_ARGS, --args=MODULE\_ARGS  
[snip]  
–version show program’s version number and exit  
ERROR! Missing target hosts

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [May 17, 2016, 8:32pm UTC](https://forum.ansible.com/t/host-pattern-and-wild-cards/21460/2 "2016-05-17T20:32:45Z")

</div>

The problem is most likely shell expansion of `*`. You probably have some files in your directory that have `sync` in the name.

echo _proxy_  
echo _sync_

When using chars in a command that could be interpreted by the shell, you should ensure you use quoting such as:

ansible ‘_sync_’ -i /tmp/killthis.txt --list-hosts
