Ansible Installation Process
qMainly, there are two types of machines when we talk about deployment:
- Control Machine − Machine from where we can manage other machines.
- Remote Machine − Machines that are handled/controlled by the control machine.
qThere can be multiple remote machines that are handled by one control machine.
qAnsible Control Machine Requirements:
I.Install Python 2 (2.6 or 2.7) or Python 3 (3.5 or Higher).
II.Install Python 2 or 3 on Remote Machines.
III.Windows does not support as a Control Machine (Just by WSL).
- Ansible Does not add any database or any daemons for managing remote machines.
- Ansible Does not need any software installation on remote machines also.
1)Add a “Ansible” user on each machine.
2)Configure SSH private key login between machines.
3)Install Ansible:
[root@controller ~] # yum install ansible -y
root@controller:~# apt install ansible -y
root@controller:~# ansible --version
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
- In the following, we will add the Ansible user on all machines:
root@controller:~# useradd -m -s /bin/bash -c “Ansible User” ansible
root@controller:~# passwd ansible
root@remote-1:~# useradd -m -s /bin/bash -c “Ansible User” ansible
root@remote-1:~# passwd ansible
root@remote-2:~# useradd -m -s /bin/bash -c “Ansible User” ansible
root@remote-2:~# passwd ansible
- Then, start to send the Controller’s Public Key to remote machines:
ansible@controller:~# ssh-keygen
ansible@controller:~# ssh-copy-id ansible@remote-1
ansible@controller:~# ssh-copy-id ansible@remote-2
- Finally just add Ansible users on all machines in the Sudoers group:
root@controller:~# usermod -aG sudo ansible
root@controller:~# vi /etc/sudoers
%ansible ALL=(ALL:ALL) NOPASSWD: ALL
root@remote-1:~# usermod -aG sudo ansible
root@remote-1:~# vi /etc/sudoers
%ansible ALL=(ALL:ALL) NOPASSWD: ALL
root@remote-2:~# usermod -aG sudo ansible
root@remote-2:~# vi /etc/sudoers
%ansible ALL=(ALL:ALL) NOPASSWD: ALL