π LAB: Deploy Nginx with Variables, Templates & Handlers
π― Objective Use common modules ( apt , template , service ) Understand variables See variable precedence in action Use Jinja2 template Trigger handler on config change Observe idempotency π Architecture Flow: Mac (Control Node) β SSH β 2 Ubuntu EC2 Instances β Install & Configure Nginx πΉ Step 1 β Launch 2 EC2 Instances AMI: Ubuntu 22.04 Instance type: t2.micro Security Group: Port 22 (SSH) Port 80 (HTTP) πΉ Step 2 β Install Ansible (Control Node) brew install ansible Verify: ansible --version πΉ Step 3 β Create Inventory inventory.ini [web] node1 ansible_host = 3.x.x.x node2 ansible_host = 18.x.x.x [web:vars] ansible_user = ubuntu ansible_ssh_private_key_file = ~/Downloads/key.pem Test: ansible web -i inventory.ini -m ping πΉ Step 4 β Create Project Structure ansible-nginx-lab/ β βββ inventory.ini βββ deploy.yml βββ group_vars/ β βββ web.yml βββ templates/ βββ nginx.conf.j2 πΉ Step 5 β Variables (Group Level) group_vars/web.yml app_port : 80 server_name : jumptotech.local welcome_message :
Continue reading on Dev.to Tutorial
Opens in a new tab

.jpg&w=1200&q=75)


