Created
November 20, 2014 15:50
-
-
Save droopy4096/98864a10359f5cf27bab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [all] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
<defined.host.com> REMOTE_MODULE setup | |
<undefined.host.com> REMOTE_MODULE setup | |
ok: [defined.host.com] | |
ok: [undefined.host.com] | |
TASK: [debug var=hostvars[inventory_hostname]['my_groups'].keys()] ************ | |
skipping: [undefined.host.com] | |
ok: [defined.host.com] => { | |
"hostvars[inventory_hostname]['my_groups'].keys()": [ | |
"baremetal", | |
"hypervisors", | |
"alfresco" | |
] | |
} | |
TASK: [set_fact my_group_list="{{ hostvars[inventory_hostname]['my_groups'].keys() }}"] *** | |
skipping: [undefined.host.com] | |
ok: [defined.host.com] => {"ansible_facts": {"my_group_list": "[u'baremetal', u'hypervisors', u'alfresco']"}} | |
TASK: [set_fact my_group_list=["nogroup"]] ************************************ | |
skipping: [defined.host.com] | |
ok: [undefined.host.com] => {"ansible_facts": {"my_group_list": "[\"nogroup\"]"}} | |
TASK: [debug var=my_group_list] *********************************************** | |
ok: [undefined.host.com] => { | |
"my_group_list": [ | |
"nogroup" | |
] | |
} | |
ok: [defined.host.com] => { | |
"my_group_list": [ | |
"baremetal", | |
"hypervisors", | |
"alfresco" | |
] | |
} | |
TASK: [debug var=item] ******************************************************** | |
ok: [undefined.host.com] => (item=nogroup) => { | |
"item": "nogroup" | |
} | |
ok: [defined.host.com] => (item=baremetal) => { | |
"item": "baremetal" | |
} | |
ok: [defined.host.com] => (item=hypervisors) => { | |
"item": "hypervisors" | |
} | |
ok: [defined.host.com] => (item=alfresco) => { | |
"item": "alfresco" | |
} | |
TASK: [group_by key={{ item }}_group] ***************************************** | |
created 'group_by' ActionModule: key=nogroup_group | |
changed: [undefined.host.com] => (item=nogroup) => {"changed": true, "groups": {"nogroup_group": ["undefined.host.com", "defined.host.com"]}, "item": "nogroup"} | |
PLAY [baremetal_group] ******************************************************** | |
skipping: no hosts matched |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
tasks: | |
- debug: var=hostvars[inventory_hostname]['my_groups'].keys() | |
when: hostvars[inventory_hostname].my_groups is defined | |
- set_fact: my_group_list="{{ hostvars[inventory_hostname]['my_groups'].keys() }}" | |
when: hostvars[inventory_hostname].my_groups is defined | |
- set_fact: my_group_list=["nogroup"] | |
when: not hostvars[inventory_hostname].my_groups is defined | |
- debug: var=my_group_list | |
when: hostvars[inventory_hostname].my_group_list is defined | |
- debug: var=item | |
with_items: hostvars[inventory_hostname].my_group_list | |
when: hostvars[inventory_hostname].my_group_list is defined | |
- group_by: key={{ item }}_group | |
when: hostvars[inventory_hostname].my_group_list is defined | |
with_items: hostvars[inventory_hostname].my_group_list | |
- hosts: baremetal_group | |
tasks: | |
- ping: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment