Skip to content

Commit

Permalink
Skip non-management Packet IP addresses (ansible#48168)
Browse files Browse the repository at this point in the history
Non-management (elastic) IP addresses require manual configuration on
the host as described in https://help.packet.net/article/54-elastic-ips.
Skip those so that only the automatically configured management
addresses are used. Otherwise, a non-routable address may be returned in
the inventory.
  • Loading branch information
dbnicholson authored and kbreit committed Jan 11, 2019
1 parent dd324db commit 6526517
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions contrib/inventory/packet_net.py
Expand Up @@ -298,10 +298,15 @@ def add_device(self, device, project):
if device.state not in self.packet_device_states:
return

# Select the best destination address
# Select the best destination address. Only include management
# addresses as non-management (elastic) addresses need manual
# host configuration to be routable.
# See https://help.packet.net/article/54-elastic-ips.
dest = None
for ip_address in device.ip_addresses:
if ip_address['public'] is True and ip_address['address_family'] == 4:
if ip_address['public'] is True and \
ip_address['address_family'] == 4 and \
ip_address['management'] is True:
dest = ip_address['address']

if not dest:
Expand Down

0 comments on commit 6526517

Please sign in to comment.