โ This guide will walk you through setting up Ansible, establishing SSH connections, managing users and privileges, and understanding host patterns. By the end, youโll have a solid foundation to automate your infrastructure with Ansible. Letโs dive in! ๐ ๏ธ
To get started, you need to install Ansible on your Ansible Server. Hereโs how:
Access Your AWS EC2 Instances:
Install Ansible:
Switch to the root user:
ec2-user
sudo su
wget
ls
Download and install the necessary packages:
yum install epel-release -y # epel = extra packages for enterprise linux
yum update -y
yum install git python python-level python-pip openssl ansible -y
Verify Installation:
Check the Ansible version to confirm installation:
ansible --version
The hosts file is where you define your nodes (target machines). Hereโs how to set it up: Go to hosts file inside ansible server and paste private-ip of node1 & node2
Open the hosts file:
vi /etc/ansible/hosts
Add the private IPs of your nodes under a group (e.g., demo
):
[demo]
172.31.41.240
172.31.42.228