GyaaniGuy

- self made 💻 😎

Linux Automation with ansible - Part 1: Basics

I used to struggle with linux automation, fixing the same thing again and again. Coming back to old servers and not remembering how I had fixed something.

Same issue with deploying websites. It used to take like 20 commands changing permissions, making users, configuring services just to get some site running.

Not anymore.

Ansible - The last linux automation tool I’ll use.

Its old, battle tested, handle permission pains with ease. Joy to configure especially with ai. LLMs are great at making ansible scripts.

First I’ll show the anatomy of ansible, then how to install and use it, finally I’ll share my ansible scripts

What can Ansible do

Everything ! Setup a linux server from scratch - setup ssh, new users, permissions. deploy websites, install, and configure services.

Instead of manual commands, try to do everything with ansible. Do once, use again and again.

Anatomy of Ansible

  • hosts file: has info about servers on which commands will be run
  • yml scripts (playbooks): Commands to run
  • execute the playbook script ansible-playbook ./playbooks/zsh.yml -i ./inventory/hosts -l buyvm --user=aa

That’s it.

Install Ansible

  1. Local Ubuntu - sudo apt install ansible
  2. Remote Server - Make sure python is installed 3. Setup ssh. You should be able to ssh like - ssh user@server.

dated July 2025