Skip to main content

Posts

Showing posts from October, 2024

Explore Ansible Playbook

Ansible Playbook Guide What is an Ansible Playbook? An Ansible Playbook is a YAML file that contains plays , or groups of tasks, which describe actions to be performed on managed nodes (hosts). Each play in a playbook is executed sequentially on specified hosts. Sample Playbook Here’s an example playbook that installs the tree package on all hosts: --- - name: Install tree Package hosts: all become: true tasks: - name: Install tree yum: name: tree state: present Explanation of Each Part --- : Start of the YAML file. name : Title of the play for readability. hosts : Specifies which hosts to run tasks on (here, all hosts). become: true : Enables privilege escalation. tasks : List of actions to be performed. Running the Playbook To execute the playbook, use the following command: ansible-playbook install_tree.yml

Steps to Set Up Ansible on AWS EC2 Instances

Ansible Setup on AWS Ansible Setup on AWS Step 1: Launch Instances Launch Amazon Linux instances on AWS: Control Node: The server to install Ansible. Managed Nodes: Servers managed by Ansible. Step 2: Install Ansible on the Control Node Update the system: sudo yum update -y Install EPEL Repository: sudo amazon-linux-extras install epel -y Install Ansible: sudo yum install ansible -y Step 3: Create a User on All Servers Create a user, for example, ansibleuser : sudo useradd ansibleuser sudo passwd ansibleuser Step 4: Grant Sudo Permission to the User Edit the sudoers file: sudo visudo Add this line: ansibleuser ALL=(ALL) NOPASSWD: ALL Step 5: Setup Passwordless Authentication on All Servers Edit SSH configuration: sudo vim /etc/ssh/sshd_config Set PasswordAuthentication to yes and restart SSH: sudo service ssh...