Originally this role was only designed to run on a single host, but it
seems useful to be able to use the one inventory across multiple KVM
hosts.
This change introduces the ability to specify multiple KVM hosts in the
kvmhost group. To do so, add hosts to the kvmhost group in your
kvmhost inventory.
If no kvmhost is specified for a VM it will default to the first KVM
host in the kvmhost group (i.e. kvmhost[0]) which matches the original
behaviour for the role.
Validation checks have been updated to make sure that all of the KVM
hosts are valid and that any specified KVM host for a VM is in the
kvmhost group.
To group VMs on certain KVM hosts, consider making child groups and
specify kvmhost at the child group level.
Originally this role was only designed to run on a single host, but it seems useful to be able to use the one inventory across multiple KVM hosts.
This change introduces the ability to specify multiple KVM hosts in the kvmhost group. To do so, add hosts to the
kvmhost
group in your kvmhost inventory.For example, here we specify three KVM hosts.
kvmhost: hosts: kvmhost1: kvmhost2: kvmhost3: vars: ansible_python_interpreter: /usr/bin/python3 virt_infra_host_networks: absent: [] present:
To have a VM land on a specific KVM host, you must add the variable
kvmhost
with a string that matches a KVM host from thekvmhost
group.For example, six CentOS and six Fedora hosts across three KVM hosts:
simple: hosts: simple-centos-[1:2]: kvmhost: kvmhost1 simple-centos-[3:4]: kvmhost: kvmhost2 simple-centos-[5:6]: kvmhost: kvmhost3 simple-fedora-[1:2]: kvmhost: kvmhost1 simple-fedora-[3:4]: kvmhost: kvmhost2 simple-fedora-[5:6]: kvmhost: kvmhost3 vars: ansible_python_interpreter: /usr/libexec/platform-python virt_infra_distro_image: "CentOS-Stream-GenericCloud-8-20210603.0.x86_64.qcow2"
If no kvmhost is specified for a VM it will default to the first KVM host in the
kvmhost
group (i.e. kvmhost[0]) which matches the original behaviour for the role.Validation checks have been updated to make sure that all of the KVM hosts are valid and that any specified KVM host for a VM is in the
kvmhost
group.To group VMs on certain KVM hosts, consider making child groups and specify kvmhost at the child group level.
For example, those CentOS and Fedora hosts again:
simple: hosts: simple-centos-[1:6]: simple-fedora-[1:6]: vars: ansible_python_interpreter: /usr/libexec/platform-python virt_infra_distro_image: "CentOS-Stream-GenericCloud-8-20210603.0.x86_64.qcow2" children: simple_kvmhost1: hosts: simple-centos-[1:2]: simple-fedora-[1:2]: vars: kvmhost: kvmhost1 simple_kvmhost2: hosts: simple-centos-[3:4]: simple-fedora-[3:4]: vars: kvmhost: kvmhost2 simple_kvmhost3: hosts: simple-centos-[5:6]: simple-fedora-[5:6]: vars: kvmhost: kvmhost3
Closes #37