Create the ansible inventory file for kubernets 3 nodes cluster

sample inventory file.

Add the follow line in the hosts file.

localhost              ansible_connection=local

worker01     ansible_connection=ssh        ansible_user=root
worker02     ansible_connection=ssh        ansible_user=root


Generate the ssh key in the master server and copy the public key in the work node root user. Also enable the root user ssh access for the worker nodes.

ssh-keygen -t rsa -b 4096  -N '' -f ~/.ssh/id_rsa

ssh-copy-id  -i ~/.ssh/ user@hostname

Test the ssh connection

ansible -i inventory workers  -m ping

ansible -m command -a "df -h" servers

ansible -i inventory all -m ping -u <username>

ansible -i inventory all -m ping -u <username> -b

Copyright © 2004, Software Groups