Question

ansible-droplet returns wrong droplet IP address since 2020-10-01 VCP changes

Posted October 13, 2020 66 views
API

I’ve successfully automated droplet creation and destruction with ansible-droplet for since 2017. However, since 2020-10-01, ansible-droplet registers and returns the internal VPC address from the API’s droplet creation response, not the desired external IP address.

It’s easy to see the problem. When ansible creates the droplet, it uses:
- name: “Create Droplet: "{{ dropletname }}"”
digital
ocean:
apitoken: “{{ dotoken }}”
command: droplet
sshkeyids: “{{ sshkeyondo.sshkey.id }}”
uniquename: yes
state: present
name: “{{ droplet
name }}”
sizeid: “{{ dropletspecs.size }}”
regionid: “{{ dropletspecs.region }}”
imageid: “{{ dropletspecs.image }}”
register: created

And it parses that ‘created’ value for 'ipaddress’ to get the external (eth0) ip address. However, since the VPC change, the ipaddress value has been reassigned to the droplet’s VPC private address. There is no distinct key that can be used to call for the droplet’s external IP address.

You can see the issue in this somewhat redacted 'created’ content:

{u'kernel’: None, u'features’: [u'privatenetworking’], u'vpcuuid’: u'bec324ec-dc82-11e8-83ec-3cfdfea9f3f0’, u'image’: {u'status’: u'available’, u'mindisksize’: 15, u'sizegigabytes’: 2.36, u'name’: u'16.04 (LTS) x64’, u'tags’: [], u'createdat’: u'2020-09-02T23:19:07Z’, u'id’: 69451585, u'regions’: [u'nyc3’, u'nyc1’, u'sfo1’, u'nyc2’, u'ams2’, u'sgp1’, u'lon1’, u'ams3’, u'fra1’, u'tor1’, u'sfo2’, u'blr1’, u'sfo3’], u'public’: True, u'distribution’: u'Ubuntu’, u'type’: u'base’, u'slug’: u'ubuntu-16-04-x64’, u'description’: u'Ubuntu 16.04 x86 image’}, u'disk’: 25, u'networks’: {u'v4’: [{u'type’: u'private’, u'netmask’: u'255.255.0.0’, u'ipaddress’: u'10.131.0.2’, u'gateway’: u’<nil>’}, {u'type’: u'public’, u'netmask’: u'255.255.240.0’, u'ipaddress’: u'167.99.81.201’, u'gateway’: u'167.99.80.1’}], u'v6’: []}, u'size’: {u'pricemonthly’: 5.0, u'available’: True, u'transfer’: 1.0, u'pricehourly’: 0.00744, u'regions’: [u'ams2’, u'ams3’, u'blr1’, u'fra1’, u'lon1’, u'nyc1’, u'nyc2’, u'nyc3’, u'sfo1’, u'sfo2’, u'sfo3’, u'sgp1’, u'tor1’], u'vcpus’: 1, u'memory’: 1024, u'disk’: 25, u'slug’: u’s-1vcpu-1gb’}, u'backupids’: [], u'snapshotids’: [], u'id’: 211955088, u'nextbackupwindow’: None, u'memory’: 1024, u'status’: u'active’, u'tags’: [], u'ipaddress’: u'10.131.0.2’, u'volumeids’: [], u'locked’: False, u'name’: u'laptop’, u'region’: {u'available’: True, u'slug’: u'lon1’, u'features’: [u'privatenetworking’, u'backups’, u'ipv6’, u'metadata’, u'installagent’, u'storage’, u'imagetransfer’], u'name’: u'London 1’,}, u'sizeslug’: u’s-1vcpu-1gb’, u'vcpus’: 1, u'created_at’: u'2020-10-13T17:04:48Z’}

Would it be possible to modify the API response so that it has a unique key for the external IP address?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer
Show answer This answer has been marked as resolved by digitalocean371.
Submit an Answer