W3cubDocs

/Ansible

community.digitalocean.digital_ocean_domain_record – Manage DigitalOcean domain records

Note

This plugin is part of the community.digitalocean collection (version 1.11.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_domain_record.

New in version 1.1.0: of community.digitalocean

Synopsis

  • Create/delete a domain record in DigitalOcean.

Parameters

Parameter Choices/Defaults Comments
data
string
Default:
""
This is the value of the record, depending on the record type.
domain
string / required
Name of the domain.
flags
integer
An unsignedinteger between 0-255 used for CAA records.
force_update
boolean
    Choices:
  • no
  • yes
If there is already a record with the same name and type force update it.
name
string
Default:
"@"
Required for A, AAAA, CNAME, TXT, SRV records. The host name, alias, or service being defined by the record.
oauth_token
string
DigitalOcean OAuth token. Can be specified in DO_API_KEY, DO_API_TOKEN, or DO_OAUTH_TOKEN environment variables

aliases: API_TOKEN
port
integer
The port that the service is accessible on for SRV records only.
priority
integer
The priority of the host for SRV, MX records).
record_id
integer
Used with force_update=yes and state='absent' to update or delete a specific record.
state
string
    Choices:
  • present
  • absent
Indicate desired state of the target.
tag
string
    Choices:
  • issue
  • wildissue
  • iodef
The parameter tag for CAA records.
ttl
integer
Default:
1800
Time to live for the record, in seconds.
type
string
    Choices:
  • A
  • AAAA
  • CNAME
  • MX
  • TXT
  • SRV
  • NS
  • CAA
The type of record you would like to create.
weight
integer
The weight of records with the same priority for SRV records only.

Notes

Note

  • Version 2 of DigitalOcean API is used.
  • The number of requests that can be made through the API is currently limited to 5,000 per hour per OAuth token.

Examples

- name: Create default A record for example.com
  community.digitalocean.digital_ocean_domain_record:
    oauth_token: xxxx
    state: present
    domain: example.com
    type: A
    name: "@"
    data: 127.0.0.1

- name: Create A record for www
  community.digitalocean.digital_ocean_domain_record:
    oauth_token: xxxx
    state: present
    domain: example.com
    type: A
    name: www
    data: 127.0.0.1

- name: Update A record for www based on name/type/data
  community.digitalocean.digital_ocean_domain_record:
    oauth_token: xxxx
    state: present
    domain: example.com
    type: A
    name: www
    data: 127.0.0.2
    force_update: yes

- name: Update A record for www based on record_id
  community.digitalocean.digital_ocean_domain_record:
    oauth_token: xxxx
    state: present
    domain: example.com
    record_id: 123456
    type: A
    name: www
    data: 127.0.0.2
    force_update: yes

- name: Remove www record based on name/type/data
  community.digitalocean.digital_ocean_domain_record:
    oauth_token: xxxx
    state: absent
    domain: example.com
    type: A
    name: www
    data: 127.0.0.1

- name: Remove www record based on record_id
  community.digitalocean.digital_ocean_domain_record:
    oauth_token: xxxx
    state: absent
    domain: example.com
    record_id: 1234567

- name: Create MX record with priority 10 for example.com
  community.digitalocean.digital_ocean_domain_record:
    oauth_token: xxxx
    state: present
    domain: example.com
    type: MX
    data: mail1.example.com
    priority: 10

Return Values

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

Key Returned Description
data
dictionary
success
a DigitalOcean Domain Record

Sample:
{'data': '192.168.0.1', 'flags': 16, 'id': 3352896, 'name': 'www', 'port': 5556, 'priority': 10, 'tag': 'issue', 'ttl': 3600, 'type': 'CNAME', 'weight': 10}


Authors

  • Adam Papai (@woohgit)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/digitalocean/digital_ocean_domain_record_module.html