Shutting down hosts
Creating the playbook
Executed:
aadmin@uvm0:~/code/it-wiz/devops/ansible/projects/playbooks$ touch shutdown.yml
Brought shutdown.yml to the following form:
- name: Shut down target hosts
hosts : all
gather_facts : false
tasks:
- name: Shutting down Linux hosts
community.general.shutdown:
Equivalent Bash commands
root@uvm26:~# poweroff
root@uvm27:~# poweroff
Execution of the playbook
Executed:
aadmin@uvm0:~/code/it-wiz/devops/ansible/projects$ ansible-playbook playbooks/shutdown.yml --ask-vault-pass
Details
aadmin@uvm0:~/code/it-wiz/devops/ansible/projects$ ansible-playbook playbooks/shutdown.yml --ask-vault-pass
Vault password:
PLAY [Shut down target hosts] ************************************************************************************
TASK [Shutting down Linux hosts] *********************************************************************************
changed: [uvm26]
changed: [uvm27]
PLAY RECAP *******************************************************************************************************
uvm26 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
uvm27 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Result
All target hosts got shut down.