I have an inventory of hosts that defines "my_groups" hash:
my_groups:
group1=val1
group2=val2
...
Note - it's a dynamic inventory which in fact produces valid JSON that
works otherwise.
Then I try to use it to auto-populate groups via:
- hosts: all
tasks:
- debug: var=hostvars[inventory_hostname]['my_groups'].keys()
- set_fact: my_group_list="{{
hostvars[inventory_hostname]['my_groups'].keys() }}"
when: hostvars[inventory_hostname].my_groups is defined
- debug: var=my_group_list
- group_by: key={{ item }}_group
with_items: hostvars[inventory_hostname].my_group_list
when: my_group_list is defined
and receive lovely:
...
TASK: [group_by key={{ item }}_group]
*****************************************
fatal: [moo.foo.com] => with_items expects a list or a set
...
even though last debug confirms that my_group_list is a proper list. When I
used "my_group_list" instead - it acted as if "my_group_list" was the item
to iterate over rather than variable:
TASK: [group_by key={{ item }}_group]
*****************************************
<moo.foo.com> ESTABLISH CONNECTION FOR USER: root
created 'group_by' ActionModule: key=my_group_list_group
changed: [moo.foo.com] => (item=my_group_list) => {"changed": true,
"groups": {"my_group_list_group": ["moo.foo.com", "bar.foo.com"]}, "item":
"my_group_list"}
Am I doing something wrong or am I facing a bug?
$ rpm -q redhat-release-server
redhat-release-server-6Server-6.6.0.2.el6.x86_64
$ rpm -q ansible
ansible-1.7.2-2.el6.noarch
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/f8c220ae-b56d-4a0c-b9d8-10136f7269af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.