Learning by example – various examples of using Ansible with KVM

Now that we’ve covered simple and more complex Ansible tasks, let’s think about how to use Ansible to further our configuration skills and overall compliance based on some kind of policy. The following are some things that we are going to leave as exercises for you:

  • Task 1: 

    We configured and ran one machine per KVM host. Create a playbook that will form a pair of hosts – one running a website and another running a database. You can use any open source CMS for this.

  • Task 2: 

    Use Ansible and the virt-net module to reconfigure the network so that the entire cluster can communicate. KVM accepts .xml configuration for networking, and virt-net can both read and write XML. Hint: If you get confused, use a separate RHEL8 machine to create a virtual network in the GUI and then use the virsh net-dumpxml syntax to output a virtual network configuration to standard output, which you can then use as a template.

  • Task 3:

    Use ansible and virsh to auto-start a specific VM that you created/imported on the host.

  • Task 4: 

    Based on our LAMP deployment playbook, improve on it by doing the following:

    a) Create a playbook that will run on a remote machine.

    b) Create a playbook that will install different roles on different servers.

    c) Create a playbook that will deploy a more complex application, such as WordPress.

If you managed to solve these five tasks, then congratulations – you’re en route to becoming an administrator who can use Automation, with a capital A.

Related Articles

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

read more

Lorem ipsum dolor sit amet consectetur

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

11 + fifteen =