Allow switching between running and run_strategy by always clearing the
other value. E.g. if run_strategy was provided then running set to None
to clear it or vice versa.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Fix the change detection of kubernetes.core temporarily by monkey
patching the service.diff_objects function. This fix should be removed
once it was merged into kubernetes.core. A dummy _patch_diff_objects
function is introduced to satisfy ansible linters.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Add the hidden_fields argument to kubevirt_vm and kubevirt_{vm,vmi}_info
which allows to hide and ignore certain fields in the returned definition
of a VM or VMI. By default this argument is set to ignore changes to the
kubemacpool.io/transaction-timestamp annotation and managed fields, which
may change at any time and cause the modules to return a changed status
although nothing has changed other than their values.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Add the kubevirt_vmi_info module which allows to fetch information about
VirtualMachineInstance(s).
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Extract the execute_module function from the kubevirt_vm_info module to
make it available for other modules.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This change adds support for setting the RunStrategy of a VM.
Depending on the value set the wait condition for the VM is adjusted.
For the values Always, RerunOnFailure or Once the wait condition will
wait for the VM to run and be ready. For the value Halted the wait
condition will wait for the VM to not exist. For the value Manual
the wait condition is not set.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Drop the dependency on Jinja2 in the kubevirt_vm module by using dicts
to construct a VM instead of rendering jinja templates internally.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Change the license of the collection to Apache 2.0 to be compliant with
the CNCF licensing requirements.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Drop the vendored document fragments from kubernetes.core to slightly
enhance the documented options and to allow changing the license of the
collection.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Improve the generated documentations by adding Ansible documentation markup
where appropriate.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Add the running parameter to kubevirt_vm_info from which the
wait_condition is derived from when parameter wait is set to
yes.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
To properly wait for a state change in the kubevirt_vm module the
wait_condition needs to adapted to the state of running.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Cleanup the YAML passed to the k8s module so it conforms to yaml output
you would expect from yaml.dump. Also refactor the tests to get rid of
duplicate definitions and make use of pytest.mark.parametrize and
yaml.dump.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Vendor the kubernetes.core doc_fragments used by this collection because
it is not possible to refer to doc_fragments of dependency collections.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Update the requirements throughout the project to be in sync and to
reflect the current state of dependencies.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Update README.md to include all modules of the collection and keep
module descriptions in sync.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Ensure compatibility with KubeVirt >=1.1.0 by monkey patching
kubernetes.core to handle apis of the format a/b/c and requiring
kubernetes>=28.1.0.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This adds the kubevirt_vm_info module, which returns the same results as
the kubevirt_vm module, but is limited to read-only functionality.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This removes the unnecessary whitespace from the rendered VirtualMachine
template and adds a unit test for it.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
By allowing to specify DataVolume templates VMs with persistent storage
can be created using the kubevirt_vm module.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
By allowing to specify the template spec unnecessary abstraction is
avoided.
The following module args are replaced by the 'spec' arg:
- termination_grace_period
- interfaces
- networks
- volumes
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Use InstancetypeMatchers and PreferenceMatchers directly instead of
providing multiple arguments to prevent unnecessary abstraction.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>