User Name must be same on Master and all client
Install python on master and all client
[root@ip-172-31-91-21 ~]# yum install python3 -y
[root@ip-172-31-91-21 ~]# python3 --version
Python 3.6.8
Install python on master and all client
[root@ip-172-31-91-21 ~]# yum install python3 -y
[root@ip-172-31-91-21 ~]# python3 --version
Python 3.6.8
If you want to use just python in place of python3 then
[root@ip-172-31-91-21 ~]# alternatives --set python /usr/bin/python3 ----Both master and client
Now python is also working
[root@ip-172-31-91-21 ~]# python --version
Python 3.6.8
Now install pip -------Only on Master
[root@ip-172-31-91-21 ~]# yum -y install python3-pip
Create a new user (on Master and client )
[root@ip-172-31-91-21 ~]# useradd ansadmin
[root@ip-172-31-91-21 ~]# passwd ansadmin
Now add in visudo file (on Master and client )
[root@ip-172-31-91-21 ~]# echo "ansadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
Now for password base communication run the below command on both master and client
[root@ip-172-31-91-21 ~]# sed -ie 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
[root@ip-172-31-91-21 ~]# sudo service sshd reload
Redirecting to /bin/systemctl reload sshd.service
[root@ip-172-31-91-21 ~]#
Install Ansible as a ansadmin user (on Master)
[root@ip-172-31-91-21 ~]# su - ansadmin
[ansadmin@ip-172-31-91-21 ~]$ pip3 install ansible --user
[ansadmin@ip-172-31-91-21 ~]$ ansible --version
ansible 2.8.3
Log in as a ansadmin user on master and generate ssh key (on Control node)
[ansadmin@ip-172-31-91-21 ~]$ ssh-keygen
Copy keys onto all ansible managed hosts (on Control node)
ssh-copy-id ansadmin@<target-server-ip>
Validation test
-
Create a directory /etc/ansible and create an inventory file called "hosts" add control node IP address in it.(Because it is not avable by default in RHEL8)
-
Run ansible command as ansadmin user it should be successful (Master)
ansible all -m ping
No comments:
Post a Comment