Commit Graph

8 Commits

Author SHA1 Message Date
Jathavedhan M
04946028b7 fix: respect user-configured strict option in _set_composite_vars
Previously, `_set_composable_vars` hardcoded `strict=True` for the
`_set_composite_vars` call while correctly passing the user-configured
value to `_add_host_to_composed_groups` and `_add_host_to_keyed_groups`.
This meant `strict: false` had no effect on compose expressions.

Pass `strict=strict` consistently to all three calls, matching the
behavior of Ansible's own `constructed` inventory plugin.

Adds a unit test verifying that compose errors are suppressed when
`strict: false` is configured.

Signed-off-by: Jathavedhan M <jathavedhan.m@ibm.com>
Assisted-by: Claude <noreply@anthropic.com>
2026-04-16 20:22:49 +05:30
Felix Matouschek
effb8140b6 chore(formatting): Run make format
Black changed it's mind about whitespace in some files.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2026-01-19 12:08:43 +01:00
Felix Matouschek
17ddb44b8a feat(inventory): Lookup winrm services for Windows hosts
This feature adds looking up winrm services and tries to populate the
ansible_host and ansible_port variables with the values from a
found service for the host. It looks up both winrm HTTP and HTTPS
services and prefers HTTPS if it found both for a given host.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2025-04-03 15:24:34 +02:00
Felix Matouschek
9029574f7c cleanup(inventory): Mark methods as private
Mark all methods of the inventory which should be private with a underscore
prefix in their name.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-12 11:09:23 +02:00
Felix Matouschek
060ac97b68 fix(inventory): Fix inventory source caching
Fix inventory source caching by separating the fetching of objects and
populating the inventory. This way objects can be fetched from the K8S
API or from a configured cached and the cache related parameters on the
plugin now actually work.

The inventory source cache was tested with the ansible.builtin.jsonfile
cache plugin and 100k hosts (~2G JSON file). Though it took a noticeable
amount of time for the inventory plugin to run it worked fine and no
failures could be observed.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-12 10:32:24 +02:00
Felix Matouschek
c4570b2089 cleanup(inventory): Use dicts where possible
Use dicts instead of ResourceFields where possible to allow
easier serialization/deserialization of objects fetched from the K8S
API.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-11 12:07:09 +02:00
Felix Matouschek
3d501de002 test(inventory): Add blackbox unit test for stopped VMs
Add a blackbox unit test that ensures that the inventory supports looking up
stopped VMs.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-03 16:04:51 +02:00
Felix Matouschek
be65833724 cleanup(tests): Major rework of inventory unit tests
Rework the inventory unit tests by splitting up
tests/unit/plugins/inventory/test_kubevirt.py into multiple files,
by trying to simplify the test code and making it more robust and by
using appropriate fixtures. This also adds new tests or test cases to
improve code coverage. Tests that work from the black box perspective
are now located in a subdirectory.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-03 16:04:51 +02:00