Ad Code

✨🎆 Diwali Dhamaka Offer! 🎆✨

Get 20% OFF on All Courses at Shiva Concept Solution click

Ansible Tutorial in DEVOPS | What is Ansible in DEVOPS

 



Ansible is an open-source automation tool used for:

  • Configuration Management (installing & configuring software)

  • Application Deployment (deploying apps to multiple servers)

  • IT Orchestration (managing complete workflows across servers)

It allows you to automate tasks on many servers at once using simple YAML playbooks.


📌 Key Points in the Definition:

  1. Agentless → Unlike tools like Puppet or Chef, Ansible doesn’t need any special agent software installed on the target machines.

  2. Uses SSH/WinRM → Connects to Linux servers via SSH and to Windows servers via WinRM.

  3. Idempotent → If you run a playbook multiple times, it won’t break anything—it ensures the system reaches the desired state.

  4. Human-Readable → Uses YAML syntax, easy for beginners.


📌 Example in One Line:

👉 Ansible is like a remote controller for your servers—it lets you install, configure, and manage 1000+ systems just by writing a few lines of YAML code.

Step 1: Install Minimal Ubuntu in WSL

Run in PowerShell (Admin):

wsl --install -d Ubuntu

if already isntall then check it

wsl -l -v


launch ubuntu

wsl -d Ubuntu


or

ubuntu


🔹 Step 2: Update System (minimal way)

Open Ubuntu (from Start Menu) → run:

sudo apt update sudo apt upgrade -y



🔹 Step 3: Install Only Core Ansible

Instead of full Ansible (which pulls in docs + optional packages), install only the

core package:

sudo apt install --no-install-recommends ansible-core -y

Step 4: (Optional) Install pywinrm for Windows

Automation

If you plan to control your Windows machine:

pip install pywinrm


🔹 Step 5: Check Install

ansible --version


Create Playbook to print Hello World


1) cd ~/home

2) nano ~/hosts.ini

Write this code
[local] localhost ansible_connection=local

Save and exit:

Press Ctrl + O → Enter → Ctrl + X


3) nano ~/hello.yml

- name: Hello World Playbook hosts: local tasks: - name: Create hello.txt in home directory copy: content: "Hello from Ansible (minimal setup on Windows WSL)!" dest: ~/hello.txt


run this playbook
ansible-playbook -i hosts.ini hello.yml

Post a Comment

0 Comments