Ansible
- Ansible deals with two types of nodes
- Control Node:
- This is where we install ansible. This has to be a linux instance
- Node:
- This is where we want to deploy applications, This can be any os or even networking devices

- We have three inputs that we need to provide to ansible
- inventory:
- list of nodes (ip addresses/name)
- This is mostly static
- credentials:
- credential for ansible to login into node and execute configuraions
- This is also mostly static
- desired state:
- What we want
- This changes from application to application and also across releases in the same application
- Ways to express desired state:
- command: This option expects you to express desired state in command line form
- yaml: This is referred as playbook, where we create a yaml file which is version controlled
- Ansible Product lines:
- Ansible core: This is free opensource tool
- Ansible Automation Platform (Paid):
- Ansible
- Ansible Tower
- User Management
- RBAC
- Automation Mesh
- AWX (free ansible tower equivelent): No Redhat support
Ansible Components
- Inventory
- Playbook: Desired state in yaml form
- Module
- Role
- Collection
- Plugin
- Vault
- galaxy
Find me steps to install lamp stack on ubuntu 24.04
sudo apt update -y
sudo apt install apache2 -y
sudo systemctl start apache2
sudo systemctl enable apache2
sudo apt install php libapache2-mod-php php-mysql -y
# create a file
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
- Now access
http://<ip>/info.php
- Ansible playbook (rough)
---
- name: install lamp
hosts: all
become: yes
tasks:
- name: install apache
ansible.builtin.apt:
name: apache2
update_cache: yes
state: present
- name: enable and start apache
ansible.builtin.systemd:
name: apache2
enabled: yes
state: started
- name: create a sample page
ansible.builtin.copy:
src: info.php
dest: /var/www/html/info.php
Ways of Working
- Get the manual commands for doing the configuration and ensure they are working
- For each command try to find how to express desired state
- Now create a inventory, configure credentials, and execute using ansible.
What we need to have
- Cloud Accounts
- Softwares: