Prepare an Ansible testing environment

We will have 2 Centos 8 hosts: controller and host1

On controller add to the /etc/hosts file:
192.168.122.y controller.example.com controller
192.168.122.x node1.example.com node1

Copy the hosts file to node1:
scp /etc/hosts node1:/etc/

On both nodes install EPEL and python3:
yum install -y python3 epel-release

On controller install Ansible:
yum install ansible

On both nodes add Ansible user to wheel group to allow elevating privileges:
usermod -aG wheel dmitritelinov

On both nodes create a sudoers snap-in file to allow sudo without password. /etc/sudoers.d/dmitritelinov:
dmitritelinov ALL=(ALL) NOPASSWD: ALL

On controller node as user dmitritelinov:
ssh-keygen
ssh-copy-id node1
ssh-copy-id controller
mkdir testproject
cd testproject

Create a inventory file inside testproject directory on controller host:
[all]
controller
node1

(Optional) Create an ansible.cfg file inside testproject directory on controller host:
[privilege_escalation]
become=True
become_method=sudo
become_user=root
become_ask_pass=False

Test Ansible configuration from controller host:
ansible all -i inventory -m command -a id

To add another host (node2 for example):
- modify /etc/hosts file and copy it on all servers
- install python3 and epel-release on the node2
- add Ansible user to the wheel group
- add sudo snap-in file for Ansible user
- copy public key of Ansible user to node2 with ssh-copy-id