The doc (http://ansible.cc/docs/patterns.html) says:
"Individual host names (or IPs), but not groups, can also be referenced using wildcards:"
And sure enough this is the case in a plyabook, but, the command line ansible is happy to use wildcards on groups.
Two questions:
-Why not supporting wildcards on groups?
I suspect the issue a possible mix between groups and hostnames... but is this really a problem?
-shouldn't ansible and ansible-playbook be consistent?
Thanks.
I'm actually not convinced what you say is true, seeing they use
common inventory class.
I'd have to see an example.
I can verify this.
ansible corp-puppet* --list-hosts returned the members of
corp-puppetmaster group, a group in my inv script. The names of the
servers in that group were not corp-puppet*, they were varied.
I'm actually not convinced what you say is true, seeing they use
common inventory class.
I'd have to see an example.
Fair enough... It's not ansible, it's yaml!
- hosts: *proxies
Returns an error:
ERROR: Syntax Error while loading YAML script, x.yaml
Note: The error may actually appear before this position: line 3, column 10
While both of these work fine (assuming the corresponding groups exist in $ANSIBLE_HOSTS):
- hosts: proxies*
- hosts: "*proxies"
The doc says it shouldn't work:
> "Individual host names (or IPs), but not groups, can also be referenced
using wildcards:"
So now the question is do we fix the documentation or the behaviour (I vote for fixing the documentation!)?
jrichardson@jimmeh:~/repos/puppet_etc/modules/puppet/manifests
[master] $ ansible --version
ansible 1.1
jrichardson@jimmeh:~/repos/puppet_etc/modules/puppet/manifests
[master] $ cat > /tmp/foo
[foobar]
host1
host2
host3
[bar]
host4
jrichardson@jimmeh:~/repos/puppet_etc/modules/puppet/manifests
[master] $ ls foob*
ls: cannot access foob*: No such file or directory
jrichardson@jimmeh:~/repos/puppet_etc/modules/puppet/manifests
[master] $ ansible -i /tmp/foo foob* --list-hosts
host1
host2
host3
jrichardson@jimmeh:~/repos/puppet_etc/modules/puppet/manifests
[master] $ ansible -i /tmp/foo foob* --list-hosts
host1
host2
host3
Yes, the issue was yaml, I needed to quote the the pattern.
Fair enough... It's not ansible, it's yaml!
- hosts: *proxies
Returns an error:
ERROR: Syntax Error while loading YAML script, x.yaml
Note: The error may actually appear before this position: line 3, column
10
While both of these work fine (assuming the corresponding groups exist in
$ANSIBLE_HOSTS):
- hosts: proxies*
- hosts: "*proxies"
The doc says it shouldn't work:
"Individual host names (or IPs), but not groups, can also be referenced
using wildcards:"
So now the question is do we fix the documentation or the behaviour (I vote
for fixing the documentation!)?
What I meant here is that what the doc says is not correct. it does work both with host names and groups. Should we fix the doc to reflect that?
Or is there any reason for wanting patterns not to work with groups (and therefor fix the behaviour)?
I like this behaviour, don't see any downsides. But maybe I am
missing something.
Same here. I submitted a pull request with a change to the doc (it can't just be closed if there is a good reason to change the behaviour instead).
I am not certain groups should be wildcarded as it's a potential
source of confusion.
I understand your concern there, but that really boils down to the
admins not making confusing group names. The same issue already
exists with sloppy wildcards. I'd use this feature as is, but if
it's going to go away, I'll skip it
For me, it's a nice to have. But not a big deal either way.
I don't know, I want to make sure we don't get into a case where a
group name wildcard match is a problem.
That being said, I vaguely recall (misrecall) making group wildcard
matching actually work.
Seeing you have to ask for it by saying "*", I think maybe it's
reasonable to leave as is and just tweak the docs after all.
I can't think of too many cases where it would be a problem now that I
think about it, and it's never been a problem for me, anyway.