Configuration

Create the ansible inventory file for kubernets 3 nodes cluster

sample inventory file.

Add the follow line in the hosts file.

[master]
localhost              ansible_connection=local

[workers]
worker01     ansible_connection=ssh        ansible_user=root
worker02     ansible_connection=ssh        ansible_user=root

[cluster:children]
master
workers

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/id_rsa.pub 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