What I want to share today is how to implement Ansible Automation Lab on KVM (Kernel Based Virtual Machine).
It can also be implemented on VirtualBox, VMWare Workstation. Procedures are the same.
Ansible Automation Lab Minimum Hardware Requirements a
- 1GB RAM & 40GB HDD for control node
- 512MB RAM & 20GB HDD for Managed node
I use RHEL 8 (Ootpa) for Linux VM
For the Lab
Control Node = 1 VM
Managed Node = 4 VM (2VM or 1VM up to you)
> vim / etc / hosts
First, mark the FQDN and IP in our Host VM / etc / hosts file.
** We will first create a Local Repo on the Control Node
** Prerequisite **
- Red Hat Developer Subscription
- https://developers.redhat.com
- RHEL 8 DVD ISO
** We must first register the control node vm RHEL Developer Subscription
- [email protected] # subscription-manager register
- [email protected] # subscription-manager repos –enable = rhel-8-server-ansible-2-rpms
- [email protected] # yum install ansible
** If you can’t install with yum, you can install with pip
- [email protected] # pip install ansible == 2.8.0
# First create a local repo using the apache server on the control node
- [email protected] # yum repolist & yum update -y
- [email protected] # yum install httpd
- [email protected] # mkdir /tmp/repo
- [email protected] # mount -t iso9660 /dev/sr0 /tmp/repo
- [email protected] # mkdir -p /var/www/html/repo
- [email protected] # cp -avr /tmp/repo/* /var/www/html/repo
** Create a local.repo file at #etc/yum.repos.d/
- [email protected] # rm -rf /etc/httpd/conf.d/welcome.conf
- [email protected] # vi /etc/httpd/conf/httpd.conf
** Enter ALL after Options **
- [email protected] # systemctl restart httpd.service
- [email protected] # yum repolist -v
** If you no longer need the RHEL Developer Subscription
- [email protected] # subscription-manager unregister
- [email protected] # yum repolist -v
** Copy local.repo on managed node vm using scp
- [email protected] # for i in node {1..4}; do scp /etc/yum.repos.d/local.repo root @ $ i.lab.example.com: /etc/yum.repos.d/
** http port must be opened on control node vm
- [email protected] # firewall-cmd –permanent –add-service = http && firewall-cmd –reload
- [email protected] # firewall-cmd –list-all
** In managed node vm
- [email protected] # yum clean all && yum repolist -v
** Now the http local repo creation part is done
** Ansible Lab **
- For ansible lab, you must first create a ssh-keygen and sudoers file for student user
** You must create an ansible config file & inventory file **
- [email protected] # mkdir ansible_lab
- [email protected] # vim ansible.cfg
[email protected] # vim inventory
** ansible lab testing (localhost) **
- [email protected] # ansible localhost -m ping -c local ”
- [email protected] # ansible-playbook main.yml -c local -i “localhost,”
** ansible lab testing managed hosts (remote) **
- [email protected] # ansible all -m ping
- [email protected] # ansible-playbook main.yml
** Example Ansible Playbook **

** Ansible playbook use cases can be found at the following github links **
** Thanks For Your Time Mate ^. ^ **