community.digitalocean.digital_ocean_database module – Create and delete a DigitalOcean database
Note
This module is part of the community.digitalocean collection (version 1.23.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_database
.
New in community.digitalocean 1.3.0
Synopsis
Create and delete a database in DigitalOcean and optionally wait for it to be online.
DigitalOcean’s managed database service simplifies the creation and management of highly available database clusters.
Currently, it offers support for PostgreSQL, Redis, MySQL, and MongoDB.
Parameters
Parameter |
Comments |
---|---|
DigitalOcean API base url. Default: |
|
A slug representing the database engine used for the cluster. The possible values are Choices:
|
|
A unique ID that can be used to identify and reference a database cluster. |
|
A unique, human-readable name for the database cluster. |
|
The number of nodes in the database cluster. Valid choices are 1, 2 or 3. Choices:
|
|
DigitalOcean OAuth token. There are several other environment variables which can be used to provide this value. i.e., - ‘DO_API_TOKEN’, ‘DO_API_KEY’, ‘DO_OAUTH_TOKEN’ and ‘OAUTH_TOKEN’ |
|
A string specifying the UUID of the VPC to which the database cluster is assigned. |
|
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 databases. Default: |
|
The slug identifier for the region where the database cluster is located. |
|
The slug identifier representing the size of the nodes in the database cluster. See https://docs.digitalocean.com/reference/api/api-reference/#operation/create_database_cluster for supported sizes. |
|
Indicates the desired state of the target. Choices:
|
|
An array of tags that have been applied to the database cluster. |
|
The timeout in seconds used for polling DigitalOcean’s API. Default: |
|
If set to This should only set to Choices:
|
|
A string representing the version of the database engine in use for the cluster. For For For For |
|
Wait for the database to be online before returning. Choices:
|
|
How long before wait gives up, in seconds, when creating a database. Default: |
Examples
- name: Create a Redis database
community.digitalocean.digital_ocean_database:
oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_KEY') }}"
state: present
name: testdatabase1
engine: redis
size: db-s-1vcpu-1gb
region: nyc1
num_nodes: 1
register: my_database
- name: Create a Redis database (and assign to Project "test")
community.digitalocean.digital_ocean_database:
oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_KEY') }}"
state: present
name: testdatabase1
engine: redis
size: db-s-1vcpu-1gb
region: nyc1
num_nodes: 1
project_name: test
register: my_database
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Assignment status (ok, not_found, assigned, already_assigned, service_down) Returned: changed Sample: |
|
A DigitalOcean database Returned: success Sample: |
|
Informational or error message encountered during execution Returned: changed Sample: |
|
Resource assignment involved in project assignment Returned: changed Sample: |