If the KVM virtual machine we want to deploy is hosted on a CentOS KVM host and hosted within the Community Cage
(Red Hat) DC, same thing as for bare-metal host : add it in the Internal Inventory, and start also "reserving" IP address[es] for Operating System.
Then add the new node to <inventory>/host_vars/<new_node> and also in the <inventory>/kvm file/group (for inheritance).
Ensure that all the variables explained in adhoc-deploy-kvm-guest playbook are set correctly.
Note
We can deploy both CentOS and RHEL so if you define rhel_version
it will be deploying RHEL but otherwise it will default to CentOS and kvm_guest_distro_release
, which is normally 8-stream for now
Then you can call it like that :
ansible-playbook playbooks/adhoc-deploy-kvm-guest.yml [WARNING] KVM guests to be deployed with CentOS => : <kvm_guest[s]>
The process will go like this :
virt-install
script that will inject the kickstart into initrd on demandvirt-install
wrapper script for the kvm guestTip
As now in the ansible inventory we know where the VM is hosted, in case you need to reset a node you can use the adhoc-reset-vm.yml
that will destroy the VM (through delegate_to: ansible task) and restart it