Skip to content

Commit 6916585

Browse files
authored
Inventory: Move extracted_primary_ip* on top of _fill_host_variables (#377)
1 parent bccfd3c commit 6916585

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

plugins/inventory/nb_inventory.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,18 @@ def _add_region_groups(self):
13061306
)
13071307

13081308
def _fill_host_variables(self, host, hostname):
1309+
extracted_primary_ip = self.extract_primary_ip(host=host)
1310+
if extracted_primary_ip:
1311+
self.inventory.set_variable(hostname, "ansible_host", extracted_primary_ip)
1312+
1313+
extracted_primary_ip4 = self.extract_primary_ip4(host=host)
1314+
if extracted_primary_ip4:
1315+
self.inventory.set_variable(hostname, "primary_ip4", extracted_primary_ip4)
1316+
1317+
extracted_primary_ip6 = self.extract_primary_ip6(host=host)
1318+
if extracted_primary_ip6:
1319+
self.inventory.set_variable(hostname, "primary_ip6", extracted_primary_ip6)
1320+
13091321
for attribute, extractor in self.group_extractors.items():
13101322
extracted_value = extractor(host)
13111323

@@ -1338,18 +1350,6 @@ def _fill_host_variables(self, host, hostname):
13381350
else:
13391351
self.inventory.set_variable(hostname, attribute, extracted_value)
13401352

1341-
extracted_primary_ip = self.extract_primary_ip(host=host)
1342-
if extracted_primary_ip:
1343-
self.inventory.set_variable(hostname, "ansible_host", extracted_primary_ip)
1344-
1345-
extracted_primary_ip4 = self.extract_primary_ip4(host=host)
1346-
if extracted_primary_ip4:
1347-
self.inventory.set_variable(hostname, "primary_ip4", extracted_primary_ip4)
1348-
1349-
extracted_primary_ip6 = self.extract_primary_ip6(host=host)
1350-
if extracted_primary_ip6:
1351-
self.inventory.set_variable(hostname, "primary_ip6", extracted_primary_ip6)
1352-
13531353
def _get_host_virtual_chassis_master(self, host):
13541354
virtual_chassis = host.get("virtual_chassis", None)
13551355

0 commit comments

Comments
 (0)