Cloud Computing & IaC in DevOps (Ansible Playbook)
Sahil Kasekar
DevOps Engineer @Philips | Ex-Intern @ZoHo | Software Development and Testing | Embedded Systems Enthusiast |
?? What is a Playbook? ??
An Ansible playbook is a YAML file that defines a set of tasks to run on target machines. It describes what to do, not how to do it, making infrastructure automation readable and easy to understand.
??? Your First Ansible Playbook: Installing Nginx
1. Create the Playbook File (nginx_install.yaml):
(yaml)
- name: Install and start Nginx
hosts: webservers
become: yes # Run as root
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
- name: Start Nginx service
service:
name: nginx
state: started
2. Create the Inventory File (inventory.ini):
(ini)
[webservers]
192.168.1.10
3. Run the Playbook:
(bash)
ansible-playbook -i inventory.ini nginx_install.yaml
?? What This Playbook Does:
?? Key Benefits: