How to setup Ansbile Engine or Ansible Master node ??

Ansible Engine or Master node setup  : 

 1.Create ansible user in all nodes and setup password
 2.Provide root previlege to all ansible users on all servers
 3.Enable Password authentication in sshd config file 
 3.Password authentication setup for ansible user ( from master node)  
 4.Add inventory file entry with target nodes 
 5.Test the ansible engine 
 
 
 Consider our ansible master (engine) node IP: 192.168.24.1
 
 Target nodes are : 192.168.24.2 , 192.168.24.3 , 192.168.24.4       


 STEP 1: Create ansible user in all nodes and setup password
  
  Login to All nodes create below ansible user 
  
  #useradd ansadmin
  #passwd ansadmin
  
 STEP 2: Provide root privilege to ansadmin user in all nodes.
 
 Add the below line in sudoers file and save it . Do this in all nodes.
 
 #visudo 
  
 ansadmin ALL=(ALL) NOPASSWD: ALL
 
 : wq! (save and exit) 
 
 
STEP 3: Enable Password authentication in sshd config file 
 
 Edit the file /etc/ssh/sshd_config and enable password authentication as "yes".
 
 #vi /etc/ssh/sshd_config
 
  PasswordAuthentication yes 
  
 :wq! ( save & exit ) 
 
 Restart sshd service 
 
 #systemctl sshd restart 
  
  STEP 4 : create ssh key and setup password less login from ansible engine to target nodes 
  
  Login as "ansadmin" user in master node and generate the ssh key.

  Note : Login as "ansadmin" user and run below commands.
   
   #cd /home/ansadmin/
   #ssh-keygen -t rsa  ( this command will generate pair of keys) 
   
   Copy that key file to target nodes and setup password less login from master node. 
   
   #cd /home/ansadmin/.ssh
   #ssh-copy-id targetnode.company.com
   
  To test login to target node from master node ( from ansadmin user)
  
  #ssh targetnode
 
 
 STEP 5:  Add target nodes into inventory file in master node ( ansible engine)
 
 By default host or inventory file is /etc/ansible/hosts
 
 #vi /etc/ansible/hosts
 
 192.168.24.1
 192.168.24.3
 192.168.24.4 
 
 :wq!
 
 STEP 6 : Test the ansible connection 
 
 #ansible all -m ping 

Post a Comment

0 Comments