From 9f33a3059ca657c7600ec09a4026f0a7c2c75c51 Mon Sep 17 00:00:00 2001 From: Felix Matouschek Date: Wed, 3 Apr 2024 15:39:42 +0200 Subject: [PATCH] fix: Explicity set ansible_port Explicitly set ansible_port so it is reset in AWX inventories if the value changes from set to unset. Signed-off-by: Felix Matouschek --- plugins/inventory/kubevirt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/inventory/kubevirt.py b/plugins/inventory/kubevirt.py index d37f0fd..587d7a1 100644 --- a/plugins/inventory/kubevirt.py +++ b/plugins/inventory/kubevirt.py @@ -639,6 +639,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): Secondary interfaces have priority over a service exposing SSH """ ansible_host = None + ansible_port = None if opts.kube_secondary_dns and opts.network_name is not None: # Set ansible_host to the kubesecondarydns derived host name if enabled # See https://github.com/kubevirt/kubesecondarydns#parameters @@ -654,10 +655,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): port = self.get_port_from_service(service) if host is not None and port is not None: ansible_host = host - self.inventory.set_variable(vmi_name, "ansible_port", port) + ansible_port = port # Default to the IP address of the interface if ansible_host was not set prior if ansible_host is None: ansible_host = ip_address self.inventory.set_variable(vmi_name, "ansible_host", ansible_host) + self.inventory.set_variable(vmi_name, "ansible_port", ansible_port)