host-pattern and wild cards

32 views
Skip to first unread message

Kenny Serrine

unread,
May 17, 2016, 4:24:25 PM5/17/16
to Ansible Project
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]

[group2]


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):
    
[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 <host-pattern> [options]

Options:
  -a MODULE_ARGS, --args=MODULE_ARGS
[snip]
  --version             show program's version number and exit
ERROR! Missing target hosts



Matt Martz

unread,
May 17, 2016, 4:33:32 PM5/17/16
to ansible...@googlegroups.com
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

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3f7b60c3-0dc7-4f8f-b8d6-645ea76ba17e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages