Skip to content

Create KVM virtual machines using Ansible playbook

Notifications You must be signed in to change notification settings

ali-foroughi/ansible-kvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual machine creation

This playbook uses Ansible to create virtual machines on host server. Create your own XML file for the VM and then run this playbook to create as many VMs as you like.

Requirements

  • The following packages should be installed on the host server
apt install ansible libguestfs-tool python3-libvirt
  • Install the latest version of Ansible community general
ansible-galaxy collection install community.general
  • You should create your own XML file for the VM to use as template.

Steps to create virtual machine

  1. Enter the VM hostnames in the vm_name.txt file. For example:
srv16-mme-1
srv16-mme-2
.
.
.
  1. Edit the kvm_provision.yaml file and specify the resources for the server.
  2. Place the .qcow2 base image in the /var/lib/libvirt/images and rename it to sample-mme-image.qcow2
  3. Place the sample coredump .qcow2 image in the /data directory and rename it to sample-coredump.qcow2
  4. Edit the VM template file under roles/kvm_provision/templates/vm-template.xml.j2 to match your desired state.
  5. Execute the create_vm script to start creating VMs.

Network configuration

  1. Edit the configure_network.sh file and specify the gateways for all intefaces. (OM,s1mme,s11,db)
  2. Edit the mme_name.txt file in this directory and specify the information in this format:
MME_NAME OM_IP S1MME_IP S11_IP DB_IP

An example would be like this:

srv16-mme-1 172.17.93.80/22 172.17.80.194/27 172.17.56.34/27 172.17.88.194/27
  1. Make sure that all hostnames (e,g srv16-mme-1) resolve to the IP of the host machine libvirt interface. You can edit the /etc/hosts as so:
srv16-mme-1     192.168.10.1
  1. Execute the configure_network.sh script to start the configuration proccess.

About

Create KVM virtual machines using Ansible playbook

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published