Deprecate the connections parameter of the inventory plugin. For now
this adds only a warning message while keeping the functionality.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This enables the inventory to list stopped VMs by refactoring
the add_from_namespace method. The method is now looking up the related
VM and VMIs for a host and adds all status attributes of both objects
to the host's vars. To distinguish the origin of vars an appropriate
prefix (vm_ or vmi_) is applied to their name. The inventory now supports
hosts comprising just a VM (stopped), just a VMI or both.
This changes some of the hostvars previously reported by the inventory
plugin:
Dropped:
- object_type
- cluster_name
Now prefixed with vm_ or vmi_ according to the origin:
- labels
- annotations
- resource_version
- uid
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>
This consolidates fetching of resources with K8SClient by introducing
the get_resources method, which is can be called by getters for certain
kinds of objects.
The former get_vmis_for_namespace method, which contains the main logic
of the inventory is renamed to populate_inventory_from_namespace.
This refactors the following getters:
- get_available_namespaces
- get_ssh_services_for_namespace
This introduces the following getters:
- get_vms_for_namespace (to be used in the following commit)
- get_vmis_for_namespace
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
... and ensure base_domain is always initialized with the cluster
domain. This is done in preparation for a major refactoring of the
inventory plugin.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Make the logic in the following methods more robust and add type hints
where appropriate.
- get_host_from_service
- get_port_from_service
- is_windows
- setup
- fetch_objects
- set_ansible_host_and_port
- set_composable_vars
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>
Ensure compatibility with kubernetes.core >=3.10,<4.1.0 by replacing
deprecated imports of HAS_K8S_MODULE_HELPER and k8s_import_exception.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Fix the for loop ranging over vmi labels. This loop is missing the
.items() statement, which it causes the following error:
```
for key, value in vmi.metadata.labels:
ValueError: too many values to unpack (expected 2)
```
Signed-off-by: Javier Cano Cano <jcanocan@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>
This changes the inventory plugin so that it sets the ansible_connection
to winrm if it detected a Windows host. If it did not detect a Windows
host the ansible_connection is no longer set, so Ansible falls back to
its default value of ssh. The detection of SSH services for hosts using
winrm is disabled.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Docs seem to indicate compose variables should work, but they aren't actually set.
Fix that by adding the composite variables to the inventory.
Signed-off-by: matt <l3acon@gmail.com>
To give secondary interfaces a higher priority over services the use of
services is disabled if a network_name was provided.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This option allows to append the base domain of a cluster to host names
constructed from SSH services of type NodePort. Also add the missing
documentation for option base_domain.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Explicitly set ansible_port so it is reset in AWX inventories if the
value changes from set to unset.
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>
Bump the dependency on kubernetes.core to versions >=3.0.1 and remove
the workaround introduced by 4429ac8c03.
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>
Since the minimum required version of the kubernetes python client was
updated to a version not requiring this workaround anymore, the
workaround is replaced with the to_dict() method found in the new
client.
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>
This adds yamllint to the CI linter job and sets the maximum line
length to 140 like in kubevirt/kubevirt.
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>