Ansible Installation On AWS

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Varaprasad

Varaprasad

Ansible Installation & 



Configuration on
AWS

1 Vara
Varaprasad

1. Connect to ec2-instance using putty/terminal


2. Perform yum update

# sudo yum update
Varaprasad

3. Change hostname on root user on master and client



# hostnamectl set-hostname master (on master)

# hostnamectl set-hostname client1 (on client)

Reboot the machine and login again to view the hostname changes

# reboot

2 Vara
Varaprasad

Installation:
1. Install epel-release on both master and client machines

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Varaprasad

2. Install ansible on master


# yum install ansible

Check ansible version and ansible-playbook version



# ansible —version

# ansible-playbook —version
3 Vara
Varaprasad

Configuration:
1. Create a new user on master & client machines

# useradd ansadmin

Varaprasad

# passwd ansadmin

2. Grant admin access to created user for master & client machines

# visudo

3. Allow password authentication to yes so that ldap users can login using 

username & password on master & client machines
4 Vara
Varaprasad

# vi /etc/ssh/sshd_config
Enable Password authentication to yes
Varaprasad

Restart the service


# service sshd restart

4. Login as ansadmin user on master and generate ssh key


# ssh-keygen
Press enter for file location, passphrase as shown in below:

5 Vara
Varaprasad

5. Copy ssh keys from master to client 



On Client find ip address:
Varaprasad

# ifconfig -a

On Master:
# ssh-copy-id <client-ipaddress>

Test the above functionality on master

6 Vara
Varaprasad

5. Edit the default inventory file


# sudo vi /etc/ansible/hosts
Enter the client ip addresses under the section accordingly as shown 

Varaprasad

Perform ping test on client machines from master

Package installation on client machines from master

Verify httpd package on client machines


7 Vara
Varaprasad

6. Creating custom inventory file on master



# vi ansinventoryfile.yml
Varaprasad

Insert client machines into the inventory file:



ec2client1 ansible_host=172.31.44.218 ansible_connection=ssh 

ansible_port=22 ansible_user=ansadmin ansible_ssh_pass=vara868@ 

ansible_become=yes

(i) Ping test:

8 Vara
Varaprasad

(ii) Package Installation test:


# ansible ec2client1 -a "yum install -y finger" -i ansinventory.yml
Verify finger installation on client machines
Varaprasad

# rpm -qi finger

7. Playbook creation and execution on master


# vi tomcat_playbook.yml
Tomcat package installation playbook:

9 Vara
Varaprasad

Playbook execution:
# ansible-playbook tomcat_playbook.yml
Varaprasad

Verify tomcat installation on client machines:


# rpm -qi tomcat

10 Vara

You might also like