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
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.
Like this:
Like Loading...