From 2a3514b60b1882df7ae24f377f36da8ca7e60e8b Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Mon, 14 Apr 2014 19:05:44 -0400 Subject: [PATCH] Support hosts without private ip without errors Not all Linode hosts have a private ip. This fixes an actual error that was happening because the generated list of private ips is empty when there isn't one. --- plugins/inventory/linode.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/inventory/linode.py b/plugins/inventory/linode.py index e68bf5d8b3..cbce5f8a69 100755 --- a/plugins/inventory/linode.py +++ b/plugins/inventory/linode.py @@ -279,7 +279,11 @@ class LinodeInventory(object): node_vars["datacenter_city"] = self.get_datacenter_city(node) node_vars["public_ip"] = [addr.address for addr in node.ipaddresses if addr.is_public][0] - node_vars["private_ip"] = [addr.address for addr in node.ipaddresses if not addr.is_public][0] + + private_ips = [addr.address for addr in node.ipaddresses if not addr.is_public] + + if private_ips: + node_vars["private_ip"] = private_ips[0] return self.json_format_dict(node_vars, True)