Ansible is an agentless automation tool; means no need to install any agent on the nodes which Ansible manages. Instead, Ansible control machine communicates to the nodes via SSH. We have to enable SSH communication between control machine and nodes before executing any playbook.
There are 2 ways this ssh communication can be setup:
We will setup both ways now.
Via inventory file
In the inventory file, pass ansible_ssh_user and ansible_ssh_pass along with the node's IP address or FQDN as below.
1[node1]188.8.131.52 ansible_ssh_user=root ansible_ssh_pass=password
Via SSH key
1$ ssh-keygen -t rsa -b 4096
2. Copy the ssh key that is created to the node using the following command
1$ ssh-copy-id email@example.com
3. Verify connection once
1$ ssh firstname.lastname@example.org
Now that ssh connection is successfully established
Test the communication
Now we can test the communication between control machine and and the node using few ansible modules as below
1$ ansible -m ping node1
1$ ansible -m command -a uptime node1
SSH Connection established successfully !!!! Now the Control machine can communicate to the node.
No spam, ever. Unsubscribe anytime.