Ansible installation
1.Creating environment
a.Create 3 servers : 1 for server and 2 for client machines
b. Login with root access and create ansadmin user in all the servers as below
c. Provide root privileges' to ansadmin user in all servers.
for this open first server with visudo and add below highlighted line
Add the same line in all the servers , so that ansadmin user will have root privileges'.
d. Make sure that Passwordauthenticaation Yes in all servers under /etc/ssh/sshd_config file
so, repeat this step in all the servers.
login with root
vi /etc/ssh/sshd_config
if you know other server passoword , you are allowed to connect with password.
then you need to execute below command to restart ssh server
systemctl restart sshd
So, this process for login to the client servers with password
Now connect with one server to other server using password of ansadmin as below
Till now , we have tried to access other servers from one server with password, Now lets use password-less authentication.
Password-less authentication:
1.Generate ssh keys using ssh-keygen with ansadmin access.
2. copy ssh public key using ssh-copy-id <hostname> from /home/ansadmin/.ssh location
Here host name: client server (to where you would like to copy the ssh key.)
execute the command below to connect with other server
ssh username@client server address
Now you try to connect with other server like below , it won't prompt you for password.
Now let see Installation of Ansible in RHEL linux server
This process needs to be done only on server(master)
sudo yum update
sudo yum install ansible -y
once it successful , you can check the version
Configuration
You have to add client server IP address/DNS names to the inventory.
you can access with root permission
Now you can plug and play with ansible playbooks and run /execute commands from server to clients.
No comments:
Post a Comment