A quick blog today. I’ve been wrestling with the ovirt_vms module in Ansible 2.5. I wanted to deploy a RHEL VM from a template on a RHV 4.1 cluster and use cloud-init to customize the VM.
The ovirt_vms module offers a cloud_init option that takes a custom_script parameter. According to the docs, you can feed this parameter your script like so:
What this does not tell you, is that this userdata is never touched if you just drop it in the playbook like this. I mean, it makes sense, because you have to tell cloud-init to do something with the script, but the ovirt_vms documentation doesn’t tell you how to do that. Therefore, the
/tmp/my-userdata.sh script will be created, but it will not be executed.
After some experimenting, it turns out you have to pass the custom_script parameter a second statement after
write_files. You need to pass it
So if anyone is stumbling across this like I did, here’s how to make your cloud-init work with ovirt_vms:
This may be obvious if you write cloud-init things all day, but I don’t usually spend much time doing that :)