---
# System prepended metadata

title: Ansible Installation and Configuration

---

# Ansible Installation and Configuration

#### Step 1: Ansible Installation (On Controller Node)
````go=1
sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible

**Validation**
ansible --version
````

### Passwordless authentication between Controller and Worker nodes

#### Step 1: Reset password for labsuser (All nodes)
````go=1
Become root by using one of the following command:

sudo su - 
OR
sudo -i

Change the password using the following command:

Syntax:
passwd <username>
Example:
passwd labsuser

Note: You need to perform this step on all 3 nodes in order to know the password for "labsuser"
````

#### Step 2: Edit sshd_config file (On worker nodes)
````go=1
Note: This step is needed to enable Password based authentication for first time SSH login:

vi /etc/ssh/sshd_config

change
PasswordAuthentication no
to
PasswordAuthentication yes

--> Restart the service:
sudo systemctl restart sshd
OR
sudo service sshd restart

````

#### Step 3: Setup Passwordless authentication between controller and worker nodes
````go=1
Run the following command on Controller and complete the wizard:

ssh-keygen -t rsa

Note(s):
1. Just press enter multiple times to complete the wizard
2. Don't use any passphrase when it prompts you. Leave it blank.
````
:mag: Above mentioned command will create a public/private key pair under $home/.ssh/ directory. Next step would copy the public key from above mentioned location to authorized_keys file using the following command:
````go=1
cat .ssh/id_rsa.pub >> .ssh/authorized_keys
````
:mag: You also need to copy public key to both worker nodes using the following commands. Note that you have to change the IP addresses at the end to your respective worker node's IP addresses:
````go=1
ssh-copy-id -i .ssh/id_rsa.pub labsuser@172.31.49.9
ssh-copy-id -i .ssh/id_rsa.pub labsuser@172.31.57.187

**Validation**

ansible -m ping all
````

