Last active
January 29, 2017 13:05
-
-
Save mohclips/c46e4b5037c04dd636db6027c2be3d54 to your computer and use it in GitHub Desktop.
testing add_host across multiple plays in playbook
This file contains hidden or 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
$ ansible-playbook test-add_host.yml | |
[WARNING]: provided hosts list is empty, only localhost is available | |
PLAY [Play 1] ****************************************************************** | |
TASK [Show inventory - play 1a] ************************************************ | |
ok: [localhost] => { | |
"groups": { | |
"all": [], | |
"ungrouped": [ | |
"localhost" | |
] | |
} | |
} | |
TASK [add_host] **************************************************************** | |
changed: [localhost] | |
TASK [add_host] **************************************************************** | |
changed: [localhost] | |
TASK [Show inventory - play 1b] ************************************************ | |
ok: [localhost] => { | |
"groups": { | |
"all": [ | |
"box1", | |
"box2" | |
], | |
"boxes": [ | |
"box1", | |
"box2" | |
], | |
"ungrouped": [ | |
"localhost" | |
] | |
} | |
} | |
PLAY [Play 2] ****************************************************************** | |
TASK [Show inventory - play 2a] ************************************************ | |
ok: [box1] => { | |
"groups": { | |
"all": [ | |
"box1", | |
"box2" | |
], | |
"boxes": [ | |
"box1", | |
"box2" | |
], | |
"ungrouped": [ | |
"localhost" | |
] | |
} | |
} | |
ok: [box2] => { | |
"groups": { | |
"all": [ | |
"box1", | |
"box2" | |
], | |
"boxes": [ | |
"box1", | |
"box2" | |
], | |
"ungrouped": [ | |
"localhost" | |
] | |
} | |
} | |
TASK [add_host] **************************************************************** | |
changed: [box1] | |
TASK [add_host] **************************************************************** | |
changed: [box1] | |
TASK [Show inventory - play 2b] ************************************************ | |
ok: [box2] => { | |
"groups": { | |
"all": [ | |
"box1", | |
"box2", | |
"box3", | |
"box4" | |
], | |
"boxes": [ | |
"box1", | |
"box2", | |
"box3", | |
"box4" | |
], | |
"ungrouped": [ | |
"localhost" | |
] | |
} | |
} | |
ok: [box1] => { | |
"groups": { | |
"all": [ | |
"box1", | |
"box2", | |
"box3", | |
"box4" | |
], | |
"boxes": [ | |
"box1", | |
"box2", | |
"box3", | |
"box4" | |
], | |
"ungrouped": [ | |
"localhost" | |
] | |
} | |
} | |
PLAY RECAP ********************************************************************* | |
box1 : ok=4 changed=2 unreachable=0 failed=0 | |
box2 : ok=2 changed=0 unreachable=0 failed=0 | |
localhost : ok=4 changed=2 unreachable=0 failed=0 | |
Show inventory - play 1b ------------------------------------------------ 0.04s | |
Show inventory - play 2b ------------------------------------------------ 0.04s | |
Show inventory - play 2a ------------------------------------------------ 0.03s | |
Show inventory - play 1a ------------------------------------------------ 0.03s | |
------------------------------------------------------------------------ 0.01s | |
Playbook finished: Sun Jan 29 13:02:17 2017, 5 total tasks. 0:00:00 elapsed. |
This file contains hidden or 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
--- | |
- name: "Play 1" | |
hosts: localhost | |
gather_facts: no | |
tasks: | |
- name: "Show inventory - play 1a" | |
debug: var=groups | |
- add_host: | |
name: "box1" | |
group: "boxes" | |
- add_host: | |
name: "box2" | |
group: "boxes" | |
- name: "Show inventory - play 1b" | |
debug: var=groups | |
- name: "Play 2" | |
hosts: boxes | |
gather_facts: no | |
tasks: | |
- name: "Show inventory - play 2a" | |
debug: var=groups | |
- add_host: | |
name: "box3" | |
group: "boxes" | |
- add_host: | |
name: "box4" | |
group: "boxes" | |
- name: "Show inventory - play 2b" | |
debug: var=groups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment