community.digitalocean.digital_ocean_domain module – Create/delete a DNS domain in DigitalOcean
Note
This module is part of the community.digitalocean collection (version 1.27.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.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.digitalocean.digital_ocean_domain.
Synopsis
- Create/delete a DNS domain in DigitalOcean. 
Requirements
The below requirements are needed on the host that executes this module.
- python >= 2.6 
Parameters
| Parameter | Comments | 
|---|---|
| DigitalOcean API base url. Default:  | |
| The droplet id you want to operate on. | |
| An ‘A’ record for ‘@’ ($ORIGIN) will be created with the value ‘ip’. ‘ip’ is an IP version 4 address. | |
| An ‘AAAA’ record for ‘@’ ($ORIGIN) will be created with the value ‘ip6’. ‘ip6’ is an IP version 6 address. | |
| The name of the droplet - must be formatted by hostname rules, or the name of a SSH key, or the name of a domain. | |
| DigitalOcean OAuth token. There are several other environment variables which can be used to provide this value. i.e., -  | |
| 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 domains. Default:  | |
| Indicate desired state of the target. Choices: 
 | |
| The timeout in seconds used for polling DigitalOcean’s API. Default:  | |
| If set to  This should only set to  Choices: 
 | 
Notes
Note
- Environment variables DO_OAUTH_TOKEN can be used for the oauth_token. 
- As of Ansible 1.9.5 and 2.0, Version 2 of the DigitalOcean API is used, this removes - client_idand- api_keyoptions in favor of- oauth_token.
- If you are running Ansible 1.9.4 or earlier you might not be able to use the included version of this module as the API version used has been retired. 
Examples
- name: Create a domain
  community.digitalocean.digital_ocean_domain:
    state: present
    name: my.digitalocean.domain
    ip: 127.0.0.1
- name: Create a domain (and associate to Project "test")
  community.digitalocean.digital_ocean_domain:
    state: present
    name: my.digitalocean.domain
    ip: 127.0.0.1
    project: test
# Create a droplet and corresponding domain
- name: Create a droplet
  community.digitalocean.digital_ocean:
    state: present
    name: test_droplet
    size_id: 1gb
    region_id: sgp1
    image_id: ubuntu-14-04-x64
  register: test_droplet
- name: Create a corresponding domain
  community.digitalocean.digital_ocean_domain:
    state: present
    name: "{{ test_droplet.droplet.name }}.my.domain"
    ip: "{{ test_droplet.droplet.ip_address }}"
