🙏 Introduction:
In this blog, Today we will write a blog explanation for the Ansible Tutorial for DevOps Engineers
🎯Task: 1
Write a Blog explanation for the ansible video
- Create an EC2 instance
- Connect to your EC2 instance using SSH
- Add the Ansible PPA repository
- Update the package
- Install Ansible
- check the version of Ansible
- Launch three new EC2 instances with same private key as Ansible-master-node EC2 instance.
- Copy the private key to master server where Ansible is setup
- In master node where ansible is setup, create a new file at location /home/ubuntu/.ssh and paste private key to that file.
- SSH into Ansible server instances from master instance by using private key
sudo ssh -i /key-path ubuntu@public-ip-address
Create an inventory file for Ansible that lists the IP addresses of the Ansible server
Create a new folder named ansible, inside folder create hosts file which is inventory file for ansible. add the IP addresses of the servers inside hosts file.
[servers]
server1 ansible_host=34.218.229.216
server2 ansible_host=54.200.111.227
server3 ansible_host=34.216.221.116
[all:vars]
ansible_python_interpreter=/usr/bin/python3
- To verify the inventory of hosts
ansible-inventory --list -y -i <inventory-file-path>
- Change the private key permission (ansible_key)
- Specify the private key file to use for authentication using the --private-key option when running the Ansible command
ansible -i <inventory_file> all -m ping --private-key=<path_to_private_key>
- Ansible command to check the free memory
ansible -i /home/ubuntu/ansible/hosts all -a "free -m" --private-key=/home/ubuntu/.ssh/ansible_key
- Ansible command to check uptime
ansible -i /home/ubuntu/ansible/hosts all -a "uptime" --private-key=/home/ubuntu/.ssh/ansible_key
👋 Conclusion :
In this blog, we write a blog explanation for an ansible video. We will cover advanced topics in a future post.
Thank you for reading!
Contact me on Linkedin
Check out my GitHub for more resources 📚