From 652a41df9da812713f083300955681da7338ba29 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Mon, 24 Jul 2023 14:44:52 +0200 Subject: [PATCH] fix!: don't set inventory image vars if server image is undefined (#275) Related to #116 Don't set "No Image * found" string if the server image is not defined. This is not an intuitive behavior. This is a breaking change. --- ...ot-set-inventory-server-image-variables-when-undefined.yml | 4 ++++ plugins/inventory/hcloud.py | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/do-not-set-inventory-server-image-variables-when-undefined.yml diff --git a/changelogs/fragments/do-not-set-inventory-server-image-variables-when-undefined.yml b/changelogs/fragments/do-not-set-inventory-server-image-variables-when-undefined.yml new file mode 100644 index 0000000..1538f85 --- /dev/null +++ b/changelogs/fragments/do-not-set-inventory-server-image-variables-when-undefined.yml @@ -0,0 +1,4 @@ +breaking_changes: + - > + inventory plugin - Don't set the server image variables (`image_id`, + `image_os_flavor` and `image_name`) when the server image is not defined. diff --git a/plugins/inventory/hcloud.py b/plugins/inventory/hcloud.py index 856e613..e1d9083 100644 --- a/plugins/inventory/hcloud.py +++ b/plugins/inventory/hcloud.py @@ -270,10 +270,6 @@ class InventoryModule(BaseInventoryPlugin, Constructable): self.inventory.set_variable(server.name, "image_name", to_native(server.image.name)) else: self.inventory.set_variable(server.name, "image_name", to_native(server.image.description)) - else: - self.inventory.set_variable(server.name, "image_id", to_native("No Image ID found")) - self.inventory.set_variable(server.name, "image_name", to_native("No Image Name found")) - self.inventory.set_variable(server.name, "image_os_flavor", to_native("No Image OS Flavor found")) # Labels self.inventory.set_variable(server.name, "labels", dict(server.labels))