DevOps Classroom Series – 08/Mar/2020

Ansible User Configuration

  • In this series, lets create a user called as admin.
  • If your vm is in AWS or any other virtualization provider with only key based authentication, we need to enable password based authentication.
File Location: /etc/ssh/sshd_config
Content: Password Authentication no => yes
service sshd restart

  • Create a user devops
adduser devops
  • This user devops needs to have sudo permissions and it is for automation
visudo

and add the following line
devops  ALL=(ALL:ALL) NOPASSWD:ALL
  • Repeat the above steps for node1
  • Now login into the acs and create a key pair
ssh-keygen
  • To copy the generated public key to node the following command is used. (If machines belong to same network prefer private ip addresses)
ssh-copy-id devops@<nodeipaddress>

  • If the copy is succesful, then you can login from acs to node1 directly by ipaddress or hostname
ssh <nodeipdaddress>
  • Ensure you are in acs and create a file called as inventory with node’s ip address
touch inventory
echo '172.31.25.93' >> inventory
  • Now lets test whether ansible can connect to node
ansible -i <path to inventory> -m ping all

# This should be success
  • Now lets add one more entry to inventory and test using ansible ping
echo 'localhost' >> inventory
ansible -i inventory -m ping all

# ping will be successful for node and failed for localhost
  • It has failed for localhost, because the user ‘devops’ is not configured to login. to fix this lets do the following
ssh-copy-id devops@localhost

ansible -i inventory -m ping all
# success for node and localhost
  • Exercise: Create a centos machine and configure it to acs.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube