Ansible Installation

 

Installation of Ansible on Centos 7

1. sudo -i

2. Open /etc/hostname and enter ansible.test.org for server and client.test.org for client machine

3. Also set hostname ansible.test.org; exit and sudo -i again on server

4. Also set hostname client.test.org; exit and sudo -i again on client

5. Edit /etc/hosts file on server and client and add the IP address and hostname of both on both server and client

172.31.21.33 ansible.test.org

172.31.23.202 client.test.org

6. Ping the client from server and server from client.

7. Create a user ‘test’ with password ‘test’ on both server and client VMs

useradd test

passwd test

8. We need to have this user run sudo commands without entering password. Open sudoers and add the following text:

vi /etc/sudoers

test ALL=(ALL) NOPASSWD: ALL

9. Save the file and run the following command to check test user is at the end of the result

cat /etc/passwd

10. Go to server and client terminals and run the following:

cd /etc/ssh

vi /etc/ssh/sshd_config

Remove # from these

PasswordAuthentication yes

PermitRootLogin yes

systemctl restart sshd

11. Let’s establish SSH connection by running this command on server and client

su test –login

12. We need to generate ssh certificates on server; press enter when prompted

ssh-keygen

ssh-copy-id test@client.test.org

ssh-copy-id test@ansible.test.org

13. Run the following command on server

ssh test@ansible.test.org

exit

ssh test@client.test.org

exit

14. Do all these steps on client also.

15. Now lets install Ansible on server and client VMs

sudo yum install -y epel-release

sudo yum install -y ansible

ansible --version

16. Now lets configure ansible hosts file on server

cd /etc/ansible

sudo mv hosts hosts.original

sudo vi hosts

[local]

ansible.test.org

[webserver]

client.test.org

17. Run the following command on server

ansible all -m ping

ansible all --list-hosts

Comments

Popular posts from this blog

Terraform

Different Types of Reports in Scrum - Agile

Scrum Master Interview help - Bootcamp