How to install Ansible in RHEL and CentOS using Amazon AWS

Definition: Ansible is a program which deploys applications. It automates software provisioning, configuring management and application deployment.
To install Ansible using AWS you need to follow few steps.

Prerequisites to install ansible: Python, EPEL Repository, Ansible.

Useful commands: # hostnamectl set-hostname (name) To identify master and node you need to give some names to it. Ex: # hostnamectl set-hostname master

Step 1: Change your machine name to identify which is maser and which is node.

# hostnamectl set-hostname master - (For master)

# hostnamectl set-hostname node - (For node)

Step 2: Now go to master ssh connection to do so you need to give his command

# cd .ssh

Step 3: You need to generate key in master by giving command

# ssh-keygen

Step 4:  Now to visit generated key go to

# cat

Step 5: Now go to node machine and open same ssh and edit authorized key.

IN node go to # cd .ssh

 And give # vi authorized_keys

Step 6: Now paste the master's key in node authorized keys and save it with :wq.

Step 7: In node you need to edit sshd file and start ssh service

To Edit ssh files
# vi /etc/ssh/sshd_config

Then edit permitrootlogin to yes to do this you need to
untag '#' symbol for PermitRootLogin
untag '#' symbol for PasswordAuthentication
tag '#' symbol for PasswordAuthentication in next second line
exit with :wq

To Start ssh give # service sshd start

Step 8: Now install Ansible in your master server by

# yum install ansible -y

Step 9: Install EPEL Repository in your master machine if you would like to see how to install EPEL repo check [HERE]

# wget

Step 10: Go to ansible in master

# cd /etc/ansible

Step 11: Go to Hosts to edit with our node ip address

#vi hosts
 and add IP address of your node and exit

Step 12: Now you can ping your node from master by command

# ansible -m ping all

Step 13: Now you need to write a playbook with .yml format

# vi myplaybook.yml

Setp 14: Basic ansible Playbook for installing java in node

 - hosts: app
     - name: install java
       yum: name=java state=installed

save it.

Step 15: To run playbook you need to give

# ansible-playbook (playbookname.yml)

Ex: ansible-playbook myplaybook.yml

To watch clearly the above commands please check below youtube video which is done with the same commands.


Popular posts from this blog

How to install MySQL on RHEL Or CentOS

Learn useful Devops Port Numbers