Jooho.kvm_cloud_init_vm

Ansible Role: Deploy Cloud Init Image on KVM

This role helps you set up a new CentOS 7 virtual machine (VM) on KVM.

Details

  • Download a cloud init image.
  • Create cloud init user and meta data, and a boot ISO.
  • Increase root storage size to 20 GB.
  • Remove temporary files like the CD-ROM, boot ISO, and user/meta data.

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 for storing KVM VM images
vm_data_dir /root/kvm/vms No Path for storing VM information
vm_recreate true No Set to false if the same VM exists
cloud_init_vm_image CentOS-7-x86_64-GenericCloud.qcow2 No 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 VM
vm_local_hostname base.example.com No Internal hostname of the VM
vm_hostname base.example.com No Public hostname of 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 CPU cores for the VM
vm_memory 2048 No Amount of memory for the VM
vm_network_br virbr0 No Name of the default network bridge 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: ansible-role-kvm-cloud-init-vm

License

BSD/MIT

Author Information

This role was created in 2018 by Jooho Lee.

Informazioni sul progetto

Deploy a VM(CentOS7) using cloud-init on KVM

Installa
ansible-galaxy install Jooho.kvm_cloud_init_vm
Licenza
bsd-3-clause
Download
137
Proprietario