+1
+1
+1
+1
+1
DAY 33- Ansible For Everyone(Practical) – Part 2 – Day Thirty Three
100 days of Cloud on GitHub – Read On iCTPro.co.nz – Read on Dev.to
📘 Please read Part one to understand bits and basics of ANSIBLE.
Ansible For Everyone – Part 1Anuvindh Sankaravilasam for AWS Community Builders ・ May 21 ・ 2 min read#devops #webdev #productivity #opensource
☁️ Lets setup the environment in AWS
- We will spin up one EC2 as slave and one EC2 as the Master Node or the control center for ansible.
- Then we use this Master node to connect the other EC2 instance (Slave).
🪛 Prerequsite
- Access and privilages to launch EC2 with Ubuntu
- Putty or any other SSH tools
- Security group with ports ssh open (Port 22)
Setup environment
Lets launch 2 EC2 instances
- Use AWS EC2 console or CLI.
aws ec2 run-instances \
--image-id <ami-id> \
--instance-type <instance-type> \
--subnet-id <subnet-id> \
--security-group-ids <security-group-id>\
--key-name <ec2-key-pair-name> \
--count 2
Set up Ansible Control Center
- Rename one EC2 to Ansible Control Center on console
- Now lets SSH into Ansible Control Center EC2
- Rename the server
sudo hostnamectl set-hostname Ansible-Control-Center
- Now lets update and install ANSIBLE
Run these commands
sudo apt-get update
sudo apt install software-properties-common -y
sudo apt-add-repository ppa:ansible/ansible
sudo apt update
sudo apt install ansible -y
Set up Ansible Slaves – Your ProdServer
- Rename one EC2 to Ansible Slaves – Your ProdServer on console
- Rename the server
sudo hostnamectl set-hostname AnsibleSlaves-YourProdServer
- Install Python
sudo apt-get update
sudo apt-get install python3 -y
Configure SSH access
On Ansible Control Center
- Genarate a rsa key.
cd .ssh
ssh-keygen
- Press enter ,we donot require any changes.
- Now if we
ls
we will be able to seeid_rsa
&id_rsa.pub
, lets cat id_rsa.pub.
cat id_rsa.pub
Note down this key
On Ansible Slaves
- ssh into your slave server then,
cd .ssh
sudo nano authorized_keys
- Now on next line paste the key we previously noted & save it.
Now its play time.
Goto your Ansible Control Center EC2.
- lets ssh into ansible slave
✅Connect with me on Twitter
🤝🏽Connect with me on Linkedin
🧑🏼🤝🧑🏻 Read more post on dev.to or iCTPro.co.nz
💻 Connect with me on GitHub