tosin2013.kvm_cloud_init_vm
Ansible Role: Deploy Cloud Init Image on KVM
This role is designed to help you deploy a new CentOS 7 virtual machine (VM) on KVM.
Details
- Downloads the cloud-init image.
- Creates cloud-init user and meta data along with a booting ISO.
- Increases the root storage size to 20GB.
- Cleans up the CD-ROM, booting ISO, user, and meta data.
- Ensures compatibility with OVS (Open vSwitch).
- Includes a
deploy_kvm.shscript in the repository.
New Usage
- Edit the generic_server template.
- Run the
deploy_kvm.shscript:sudo ./deploy_kvm.sh kvm_generation_configs/generic_server - Execute the Ansible playbook:
ansible-playbook exampleplaybook.yml
Tested Cloud Init Image
- CentOS
Requirements
None
Role Variables
| Name | Default Value | Required | Description |
|---|---|---|---|
| kvm_install_host | localhost | no | The host where KVM is installed |
| kvm_vm_pool_dir | /var/lib/libvirt/images | no | Path where KVM VM images are stored |
| vm_data_dir | /root/kvm/vms | no | Path where VM information is stored |
| vm_recreate | true | no | Set to false if the same VM already exists |
| cloud_init_vm_image | CentOS-7-x86_64-GenericCloud.qcow2 | no | The name of the cloud-init image |
| cloud_init_vm_image_link | https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1809.qcow2 | no | Link to download the cloud-init image |
| cloud_init_user_data | {{vm_data_dir}}/{{vm_name}}/user-data | no | File for cloud-init user data |
| cloud_init_meta_data | {{vm_data_dir}}/{{vm_name}}/meta-data | no | File for cloud-init meta data |
| cloud_init_iso_image | {{vm_data_dir}}/{{vm_name}}/cidata.iso | no | Booting image for cloud-init |
| vm_name | CentOS_Base | no | Name of the virtual machine |
| vm_local_hostname | base.example.com | no | Internal VM hostname (can be the same as vm_hostname) |
| vm_hostname | base.example.com | no | Public hostname for the VM |
| vm_public_key | {{lookup('file','~/.ssh/id_rsa.pub')}} | no | SSH public key for logging into the VM |
| vm_cpu | 2 | no | Number of CPUs for the VM |
| vm_memory | 2048 | no | Amount of memory for the VM |
| vm_network_br | virbr0 | no | Default bridge name for the VM |
| vm_root_disk_size | 20G | no | Size of the root disk for the VM |
Dependencies
None
Example Playbook
- name: Example Playbook
hosts: localhost
gather_facts: false
tasks:
- import_role:
name: tosin2013.kvm_cloud_init_vm
License
BSD/MIT
Author Information
This role was created in 2018 by Jooho Lee and modified by Tosin Akinosho.
Installa
ansible-galaxy install tosin2013.kvm_cloud_init_vmLicenza
bsd-3-clause
Download
84
Proprietario
Principal Solution Architect RedHat. Enthusiast in Cloud, DevOps, and AI. Specializing in AWS, GCP, Azure, Docker, Kubernetes, and Terraform.
