community.digitalocean.digital_ocean_floating_ip – Manage DigitalOcean Floating IPs

Note

This plugin is part of the community.digitalocean collection (version 1.14.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.digitalocean.

To use it in a playbook, specify: community.digitalocean.digital_ocean_floating_ip.

Synopsis

  • Create/delete/assign a floating IP.

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 2.6

Parameters

Parameter Choices/Defaults Comments
droplet_id
string
The Droplet that the Floating IP has been assigned to.
ip
string
Public IP address of the Floating IP. Used to remove an IP

aliases: id
oauth_token
string / required
DigitalOcean OAuth token.
project_name
string
Default:
""
Project to assign the resource to (project name, not UUID).
Defaults to the default project of the account (empty string).
Currently only supported when creating.

aliases: project
region
string
The region that the Floating IP is reserved to.
state
string
    Choices:
  • present ←
  • absent
  • attached
  • detached
Indicate desired state of the target.
If state=present Create (and optionally attach) floating IP
If state=absent Delete floating IP
If state=attached attach floating IP to a droplet
If state=detached detach floating IP from a droplet
timeout
integer
Default:
30
Floating IP creation timeout.
validate_certs
boolean
    Choices:
  • no
  • yes ←
If set to no, the SSL certificates will not be validated.
This should only set to no used on personally controlled sites using self-signed certificates.

Notes

Note

  • Version 2 of DigitalOcean API is used.

Examples

- name: "Create a Floating IP in region lon1"
  community.digitalocean.digital_ocean_floating_ip:
    state: present
    region: lon1

- name: Create a Floating IP in region lon1 (and assign to Project "test")
  community.digitalocean.digital_ocean_floating_ip:
    state: present
    region: lon1
    project: test

- name: "Create a Floating IP assigned to Droplet ID 123456"
  community.digitalocean.digital_ocean_floating_ip:
    state: present
    droplet_id: 123456

- name: "Attach an existing Floating IP of 1.2.3.4 to Droplet ID 123456"
  community.digitalocean.digital_ocean_floating_ip:
    state: attached
    ip: "1.2.3.4"
    droplet_id: 123456

- name: "Detach an existing Floating IP of 1.2.3.4 from its Droplet"
  community.digitalocean.digital_ocean_floating_ip:
    state: detached
    ip: "1.2.3.4"

- name: "Delete a Floating IP with ip 1.2.3.4"
  community.digitalocean.digital_ocean_floating_ip:
    state: absent
    ip: "1.2.3.4"

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
assign_status
string
changed
Assignment status (ok, not_found, assigned, already_assigned, service_down)

Sample:
assigned
data
dictionary
success and no resource constraint
a DigitalOcean Floating IP resource

Sample:
{'action': {'completed_at': None, 'id': 68212728, 'region': {'available': True, 'features': ['private_networking', 'backups', 'ipv6', 'metadata'], 'name': 'New York 3', 'sizes': ['512mb,', '1gb,', '2gb,', '4gb,', '8gb,', '16gb,', '32gb,', '48gb,', '64gb'], 'slug': 'nyc3'}, 'region_slug': 'nyc3', 'resource_id': 758603823, 'resource_type': 'floating_ip', 'started_at': '2015-10-15T17:45:44Z', 'status': 'in-progress', 'type': 'assign_ip'}}
msg
string
changed
Informational or error message encountered during execution

Sample:
No project named test2 found
resources
dictionary
changed
Resource assignment involved in project assignment

Sample:
{'assigned_at': '2021-10-25T17:39:38Z', 'links': {'self': 'https://api.digitalocean.com/v2/floating_ips/157.230.64.107'}, 'status': 'assigned', 'urn': 'do:floatingip:157.230.64.107'}


Authors

  • Patrick Marques (@pmarques)

  • Daniel George (@danxg87)