Simple Ansible master slave setup on ubuntu.
Commands uses -:
On Master
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt update
sudo apt install ansible
ansible --version
Step 2: on Worker
sudo apt-get update
Step 3: Configure SSH Key-Based Authentication
On Master: ssh-keygen
id_ed25519.pub
on Slave: sudo nano .ssh/authorized_keys
Then add the key
4. Test SSH connection: from master
ssh azureserver@your_server_ip
Step 5: Configure Ansible Inventory
sudo nano /etc/ansible/hosts
[webservers]
node1 ansible_host=your_server_ip ansible_user=azureserver
Step 6: Run a test
ansible webservers -m ping
ansible all -m ping
Playbook yaml
---
- hosts: webservers
become: yes
tasks:
- name: install apache2
apt:
name: apache2
update_cache: yes
state: latest