
LAB: 2 EC2 Servers + Group-Based Deployment
Objective Inventory groups Deploy different software to different servers Run playbook against specific group Use variables per group Understand real-world environment separation Architecture Control Node (Mac) ↓ SSH EC2-1 → Web Server EC2-2 → DB Server Step 1 — Launch 2 EC2 Instances Both: Ubuntu 22.04 Port 22 open Port 80 open (for web) Same key pair Example IPs: Web: 3.141.22.178 DB: 3.141.25.200 Step 2 — Create Inventory with Groups Edit inventory.ini [web] 3.141.22.178 ansible_user = ubuntu ansible_ssh_private_key_file=~/Downloads/pem/key.pem [db] 3.141.25.200 ansible_user = ubuntu ansible_ssh_private_key_file=~/Downloads/pem/key.pem Test: ansible all -i inventory.ini -m ping Both should return pong. Step 3 — Create Group-Based Playbook Create: vim multi-server.yml Paste: - name : Configure Web Server hosts : web become : yes tasks : - name : Install nginx apt : name : nginx state : present - name : Start nginx service : name : nginx state : started enabled : yes - name : Configur
Continue reading on Dev.to DevOps
Opens in a new tab

![[MM’s] Boot Notes — The Day Zero Blueprint — Test Smarter on Day One](/_next/image?url=https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1368%2F1*AvVpFzkFJBm-xns4niPLAA.png&w=1200&q=75)

