csmart / ansible-role-virt-infra

Define and manage guests and networks on a KVM host with Ansible
GNU General Public License v3.0
68 stars 48 forks source link

support for complex --limit options #24

Closed csmart closed 4 years ago

csmart commented 4 years ago

We must run against the KVM host in order to do anything. If no limit option is set to specify which hosts or hostgroups to run against, we're fine as kvmhost will be included.

However, if --limit is specified we have to make sure that the KVM host will be in that list.

Currently we check if either 'kvmhost' is in the limit option or the limit option is equal to 'all'. However, this does not cater for more complex limits like 'all,!not-this-vm' and cases where 'kvmhost' and 'all' are anywhere in the option.

This patch makes the check more robust, by converting the option into a list. This way we can just check that 'all' or 'kvmhost' are in there.