Inventory pattern not matching in runbook

27 views
Skip to first unread message

titlei...@gmail.com

unread,
Dec 5, 2014, 5:14:17 PM12/5/14
to ansible...@googlegroups.com
Hello,

I've got a simple inventory file setup and am using Ansible 1.8

[tl-prod-mongo]
tl
-prod-mgdb-[01:06]

[tl-prod-web]
tl
-prod-aweb-[01:06]
tl
-prod-bweb-[01:06]
tl
-prod-cweb-[01:06]

However, the following runbook fails to match any hosts

---
- name: ping test
  hosts
: tl-prod-aweb-[01:02]
  tasks
:
    ping
:


What have I possibly missed?  Is this an invalid pattern I'm trying?

Thanks,
Jay

Brian Coca

unread,
Dec 8, 2014, 12:28:02 PM12/8/14
to ansible...@googlegroups.com
try removing the - from the names, use _ instead.


--
Brian Coca

titlei...@gmail.com

unread,
Dec 8, 2014, 4:37:57 PM12/8/14
to ansible...@googlegroups.com
Thanks, that works for the group names.  But what if I'm just trying to specify 2 hosts inside a group of 6?  Would I have to put them all in groups to get around this?

Is a - (dash) an invalid character for hostnames in Ansible?  Or is it splitting on that somewhere when it shouldn't be?

Jay 

Brian Coca

unread,
Dec 8, 2014, 4:46:46 PM12/8/14
to ansible...@googlegroups.com
the - is problematic with python dictionaries, which is what group
names end up being, hosts should be fine.

list slices (hostgroup[:2]) should work

--
Brian Coca

titlei...@gmail.com

unread,
Dec 8, 2014, 5:16:11 PM12/8/14
to ansible...@googlegroups.com
Well, when I try with hosts

ansible -m ping tl-prod-mgdb-[01:03]
No hosts matched

ansible -m ping tl-prod-mgdb-[:03]
No hosts matched

But...this works as long as I change the group name
ansible -m ping tl_prod_mongo

Maybe the dash is problematic for hosts as well?

Jay
Reply all
Reply to author
Forward
0 new messages