sudo yum install ansible
- In Master generate ssh keypair using:
ssh-keygen -t rsa
- copy the public key of Master to ~/.ssh/authorized_keys file in node
cat ~/.ssh/id_rsa.pub
(copy the output)
- In node open the file in ~/.ssh/authorized_keys and paste the public key of Master :
vi authorized_keys
After completing the above process we can directly ssh to the node(EC2 instance)
- In Master go to /etc/ansible/hosts
vi /etc/ansible/hosts
- add the group name with in "[ ]" (square brackets) and add the details of the node in the next line (username@ip)
- After completing the above configuration process, run a command from Master to node
ansible -i hosts nodes -a "cat /etc/passwd"
ansible-playbook -v createafile.yml