From 3714be293601c38e7ace543193946b22ed95f049 Mon Sep 17 00:00:00 2001 From: John Jarvis Date: Fri, 18 Aug 2023 13:55:50 +0200 Subject: [PATCH] fix: check for labels in json dict --- plugins/inventory/gcp_compute.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/inventory/gcp_compute.py b/plugins/inventory/gcp_compute.py index 355f768..f4743b2 100644 --- a/plugins/inventory/gcp_compute.py +++ b/plugins/inventory/gcp_compute.py @@ -237,7 +237,8 @@ class GcpInstance(object): for order in self.hostname_ordering: name = None if order.startswith("labels."): - name = self.json["labels"].get(order[7:]) + if "labels" in self.json: + name = self.json["labels"].get(order[7:]) elif order == "public_ip": name = self._get_publicip() elif order == "private_ip":