Prerequisites:
- Ansible control server has to be installed on Linux server (I used Ubuntu)
- Minimum one node with Linux OS
- Control Server and node should be reachable on network
Setup
Once basic Ubuntu OS installation is done and able to ssh to server and node need to login to server and set root user
STEP1: Admin user for ansible
sudo -i
adduser ansible
STEP:2 Change key based authentication to support password based authentication
nano /etc/ssh/sshd_config
# change passwordAuthentication from no to yes & save the file
service sshd restart
STEP3: Making ansible user admin
sudo visudo
# scroll to the line where you see %sudo or wheel
# and add the below line
ansible ALL=(ALL:ALL) NOPASSWD:ALL
:wq
STEP4: Install Python & Ansible
##To configure the PPA on your machine and install ansible run these commands:
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo apt-add-repository --yes --update ppa:ansible/ansible
$ sudo apt install python
Repeat the steps from step1 to step 4 on Ansible node
STEP5: Install Ansible
$ sudo apt install ansible
STEP6: Inventory
System Level Inventory:
/etc/ansible created during ansible installation
/etc/ansible/hosts => default inventory
#need to add the node IP or host name to hosts file on server
sudo vi /etc/ansible/hosts
localhost
node-IP
:wq
STEP7: Configure nodes for ansible access
Give no password access
Create a key pair
master01:~$ cd .ssh/
ssh-keygen
copy public key to nodes
ssh-copy-id ansible@<node-ip>
Ansible ping command to validate the connectivity between server and node
ansible -m ping all