CloudSeeders Workshop - To Join our amazing community please visit, https://cloudseeders.org/
This demo is designed to demostrate Ansible basics.
It consists of the following files:
Dockerfile
- to build docker images for control and host nodesMakefile
- for operations listed belowplay/myhosts
- inventory fileplay/site.yml
- sample playbook
The Makefile can be used for the following operations:
- build docker image for control node -
make control
- build docker image for host node -
make host
- spawn control and host nodes -
make spawn
- list the running containers -
make list
- exec into the control node -
make exec_control
- exec into the host01 -
make exec_host01
- exec into the host02 -
make exec_host02
- delete the containers -
make clean
After the setup is completed,
add ssh key from the control node cat ~/.ssh/id_rsa.pub
to the host nodes ~centos/.ssh/authorized_keys
to authorize the control node to ssh to the host nodes.
- Test if the control node can ssh into the host nodes,
ansible all -i myhosts -m ping
- Run the supplied playbook,
ansible-playbook -i myhosts site.yml
- Run Ad-Hoc command to verify the package has been installed
ansible all -i myhosts -m command -a "rpm -q sysstat"
- Change the playbook to ensure the package is removed,
sed -i -e 's/state: latest/state: absent/' -e 's/ensure.*/ensure sysstat is removed/' site.yml
- Run the playbook again:
ansible-playbook -i myhosts site.yml
- Verify the package has been removed,
ansible all -i myhosts -m command -a "rpm -q sysstat"