From 4094ba768237fb87c21f9f0db21379e23d9f59c4 Mon Sep 17 00:00:00 2001 From: Rob Nieuwenhuizen Date: Sat, 3 Feb 2018 23:15:16 +0100 Subject: [PATCH] Digitalocean public private ip (#27269) * When using private networking the ip_address key contains the private ip. Add the following info to module output when available: - private_ipv4_address - public_ipv4_address - private_ipv6_address - public_ipv6_address --- lib/ansible/modules/cloud/digital_ocean/digital_ocean.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/cloud/digital_ocean/digital_ocean.py b/lib/ansible/modules/cloud/digital_ocean/digital_ocean.py index 6936aaaeff6..d2946fb8457 100644 --- a/lib/ansible/modules/cloud/digital_ocean/digital_ocean.py +++ b/lib/ansible/modules/cloud/digital_ocean/digital_ocean.py @@ -232,6 +232,12 @@ class Droplet(JsonfyMixIn): if attrs: for k, v in attrs.items(): setattr(self, k, v) + networks = attrs.get('networks', {}) + for network in networks.get('v6', []): + if network['type'] == 'public': + setattr(self, 'public_ipv6_address', network['ip_address']) + else: + setattr(self, 'private_ipv6_address', network['ip_address']) else: json = self.manager.show_droplet(self.id) if json['ip_address']: