Created
June 6, 2014 09:49
-
-
Save halberom/fd9663a3d54db57b4b1c to your computer and use it in GitHub Desktop.
ansible - example of multiple plays, one creating a new group
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
| # roles/do_something/tasks/main.yml | |
| --- | |
| - name: do something | |
| command: grep foo /tmp/bar | |
| register: result | |
| - name: add host to new group based on result | |
| add_host: hostname=inventory_hostname group_name=mynewgroup | |
| when: result.stdout == 'whatever' |
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
| # roles/do_something/tasks/newgroup.yml | |
| --- | |
| - name: do something | |
| ... |
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
| --- | |
| - hosts: somegroup | |
| roles: | |
| - do_something | |
| - hosts: mynewgroup | |
| tasks: | |
| - include: roles/do_something/tasks/newgroup.yml | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment