Hi Jeremy,
Can someone tell me what sealing does to a Linux VM?
In short, "sealing is the process of removing all system-specific details from a
virtual machine before creating a template based on that virtual
machine". In entails actions such as removing SSH host keys, removing MAC address information from the system, changing the hostname to a generic etc. You could do all this manually, but as far as Linux VMs are concerned, you don't have to. oVirt can do this for you when you create a teamplate.
So, if I want to manage a VM created from a template would this general process work?-
Seal the VM
Install CloudInit and keys, accounts, etc
Shut off VM and create template from it.
Create new VM using Ansbile & CloudInit
CloudInit would have just enough info so that you could manage the VM with Ansible.
I think the better order would be:
- Upload a disk that you want to use as a basis for your template (RHEL, CentOS, whatever you use)
- Create a VM with that disk attached
- Start the VM
- Do all the necessary configuration that you want to be part of your future template. That means for example enabling repositories, updating packages etc. If you want to start your future VMs using cloud-init, you need to install (and enable it!) here.
- Stop the VM
- Create template out of this VM (Don't forget to check the Seal Template option during template creation)
- Create a new VM out of that template (using Ansible if you wish so)
Sample Ansible playbook creating a single VM would look like this:
---
- name: Create VM using Ansible role
hosts: localhost
connection: local
gather_facts: false
vars:
engine_fqdn: my_enging.my_domain.com
engine_user: admin@internal
engine_password: mypass
my_vm_profile:
template: cloud_init_enabled_template
ssh_key: "your_public_ssh_key"
vms:
- name: test_vm
cluster: my_cluster
profile: "{{ my_vm_profile }}"
state: running
cloud_init:
host_name: sandbox
root_password: sandbox
custom_script: |
packages:
- vim-enhanced
- screen
roles:
- ovirt.vm-infra
All the variables that may be provided to ovirt.vm-infra role can be found
here. Pay special attention to the
cloud_init key in the test_vm
dictionary. This dictionary is used to control cloud-init setup on VM. It natively supports many of the cloud-init parameters and you can find them all in the previous link. Should this not be sufficient for you,
cloud_init dictionary may also contain
custom_script key. To that key, you simply provide a string which holds raw cloud-init script. Examples of raw cloud-init scripts can be found in cloud-init's
doc page.
Hope this was helpful. Best regards!
Jan