Created
June 8, 2023 08:42
-
-
Save zeitounator/3f106f520226ea8d5f5f299610b8940c 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
$ ansible --version | |
ansible [core 2.14.2] | |
config file = None | |
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] | |
ansible python module location = /home/user/.local/lib/python3.9/site-packages/ansible | |
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections | |
executable location = /home/user/.local/bin/ansible | |
python version = 3.9.5 (default, Nov 23 2021, 15:27:38) [GCC 9.3.0] (/usr/bin/python3.9) | |
jinja version = 3.1.2 | |
libyaml = True | |
$ tree | |
. | |
├── inventories | |
│ └── default | |
│ └── hosts.yaml | |
└── playbook.yml | |
2 directories, 2 files | |
$ cat inventories/default/hosts.yaml | |
--- | |
my_original_servers: | |
hosts: | |
dev01: | |
dev02: | |
$ cat playbook.yml | |
--- | |
- name: Choose start hosts | |
hosts: my_original_servers | |
gather_facts: false | |
tasks: | |
- name: Add hosts | |
ansible.builtin.add_host: | |
name: "{{ groups.my_original_servers.0 }}" | |
groups: mock_host | |
- name: Do something with my app | |
hosts: mock_host | |
gather_facts: false | |
tasks: | |
- name: Dummy task | |
ansible.builtin.debug: | |
msg: Do something | |
$ ansible-playbook -i inventories/default/ playbook.yml | |
PLAY [Choose start hosts] ***************************************************************************************************************************************************************************************** | |
TASK [Add hosts] ************************************************************************************************************************************************************************************************** | |
changed: [dev01] | |
PLAY [Do something with my app] *********************************************************************************************************************************************************************************** | |
TASK [Dummy task] ************************************************************************************************************************************************************************************************* | |
ok: [dev01] => { | |
"msg": "Do something" | |
} | |
PLAY RECAP ******************************************************************************************************************************************************************************************************** | |
dev01 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment