The primary objective of this experiment is to understand the concept of configuration management and implement infrastructure automation using Ansible. This experiment also aims to compare Chef Solo and Ansible in terms of architecture, execution model, scalability, and real-world usability.
Configuration management is a crucial DevOps practice that ensures consistency across systems by automating the deployment, configuration, and maintenance of infrastructure. In modern distributed environments, manual configuration is error-prone and inefficient. Tools like Ansible provide automation capabilities that enable reproducible and scalable infrastructure management.
This experiment demonstrates how Ansible can be used as a configuration management tool to automate the installation and configuration of services. It also compares Ansible with Chef Solo to highlight differences in architecture and operational efficiency.
Configuration management refers to the process of maintaining consistency of a system’s performance, functional attributes, and physical attributes with its requirements, design, and operational information.
Infrastructure as Code allows infrastructure to be defined using code, making it version-controlled, reproducible, and automated.
Agent-based systems require software installed on each node, while agentless systems operate remotely without requiring additional software on managed nodes.
The control node is the machine where Ansible is installed and from which automation tasks are executed.
The managed node is the target system where tasks are executed. In this experiment, localhost is used as the managed node.
sudo apt update sudo apt upgrade -y
sudo apt –fix-broken install -y
sudo apt install ansible -y
ansible –version
An inventory file is created to define the managed nodes.
[local] localhost ansible_connection=local
ansible -i inventory local -m ping
Expected Output: SUCCESS => “pong”
name: Experiment 8 Demo hosts: local become: yes
tasks:
name: Install nginx apt: name: nginx state: present
name: Start nginx service: name: nginx state: started
ansible-playbook -i inventory playbook.yml
Expected Output: ok=3 failed=0
During execution, a 502 Bad Gateway error was encountered while accessing the service.
The default Nginx configuration was acting as a reverse proxy instead of serving static content.
The Nginx configuration was modified to serve static files.
server { listen 80; server_name localhost;
root /var/www/html;
index index.html;
location / {
try_files $uri $uri/ =404;
} }
echo “Hello from Nitanshu Experiment 8” | sudo tee /var/www/html/index.html curl localhost
Expected Output: Hello from Nitanshu Experiment 8
This experiment successfully demonstrates the implementation of configuration management using Ansible. The automation of Nginx installation and configuration validates the effectiveness of Ansible as a DevOps tool. The comparison with Chef Solo highlights the advantages of Ansible in terms of simplicity, scalability, and centralized control.
Experiment-8/ ├── inventory ├── playbook.yml ├── README.md
Name: Nitanshu Tak Program: B.Tech Computer Science Engineering Specialization: Cloud Computing and Virtualization Technology