Parameter | Default | Configuration | Comments |
---|---|---|---|
attributes (list) |
Droplet attributes to include as host variables. Consult the API documentation https://docs.digitalocean.com/reference/api/api-reference/#operation/droplets_create for attribute examples. | ||
cache (bool) |
False | ini entries:
env variables: ANSIBLE_INVENTORY_CACHE |
Toggle to enable/disable the caching of the inventory's source data, requires a cache plugin setup to work. |
cache_connection (str) |
ini entries:
env variables: ANSIBLE_CACHE_PLUGIN_CONNECTION ANSIBLE_INVENTORY_CACHE_CONNECTION |
Cache connection data or path, read cache plugin documentation for specifics. | |
cache_plugin (str) |
memory | ini entries:
env variables: ANSIBLE_CACHE_PLUGIN ANSIBLE_INVENTORY_CACHE_PLUGIN |
Cache plugin to use for the inventory's source data. |
cache_prefix () |
ansible_inventory_ | ini entries:
env variables: ANSIBLE_CACHE_PLUGIN_PREFIX ANSIBLE_INVENTORY_CACHE_PLUGIN_PREFIX |
Prefix to use for cache plugin files/tables |
cache_timeout (int) |
3600 | ini entries:
env variables: ANSIBLE_CACHE_PLUGIN_TIMEOUT ANSIBLE_INVENTORY_CACHE_TIMEOUT |
Cache duration in seconds |
client_override_options (dict) |
Client override options (developer use). For example, can be used to override the DigitalOcean API endpoint for an internal test suite. If provided, these options will knock out existing options. | ||
compose (dict) |
{} | Create vars from jinja2 expressions. | |
groups (dict) |
{} | Add hosts to group based on Jinja2 conditionals. | |
keyed_groups (list) |
[] | Add hosts to group based on the values of a variable. | |
default_value (str) |
The default value when the host variable's value is an empty string. This option is mutually exclusive with keyed_groups[].trailing_separator . |
||
key (str) |
The key from input dictionary used to generate groups | ||
parent_group (str) |
parent group for keyed group | ||
prefix (str) |
A keyed group name will start with this prefix | ||
separator (str) |
_ | separator used to build the keyed group name | |
trailing_separator (bool) |
True | Set this option to False to omit the keyed_groups[].separator after the host variable when the value is an empty string. This option is mutually exclusive with keyed_groups[].default_value . |
|
leading_separator (boolean) |
True | Use in conjunction with keyed_groups. By default, a keyed group that does not have a prefix or a separator provided will have a name that starts with an underscore. This is because the default prefix is "" and the default separator is "_". Set this option to False to omit the leading underscore (or other separator) if no prefix is given. If the group name is derived from a mapping the separator is still used to concatenate the items. To not use a separator in the group name at all, set the separator for the keyed group to an empty string instead. | |
plugin () |
Choices:
|
The name of the this inventory plugin digitalocean.cloud.droplets . |
|
strict (bool) |
False | If yes make invalid entries a fatal error, otherwise skip and continue. Since it is possible to use facts in the expressions they might not always be available and we ignore those errors by default. |
|
token (str) |
DigitalOcean API token. There are several environment variables which can be used to provide this value. DIGITALOCEAN_ACCESS_TOKEN , DIGITALOCEAN_TOKEN , DO_API_TOKEN , DO_API_KEY , DO_OAUTH_TOKEN and OAUTH_TOKEN |
||
use_extra_vars (bool) |
False | ini entries:
env variables: ANSIBLE_INVENTORY_USE_EXTRA_VARS |
Merge extra vars into the available variables for composition (highest precedence). |
plugin: digitalocean.cloud.droplets
cache: true
cache_plugin: ansible.builtin.jsonfile
cache_connection: /tmp/digitalocean_droplets_inventory
cache_timeout: 300
#
# By default, this plugin will consult the following environment variables for the API token:
# DIGITALOCEAN_ACCESS_TOKEN, DIGITALOCEAN_TOKEN, DO_API_TOKEN, DO_API_KEY, DO_OAUTH_TOKEN, OAUTH_TOKEN
#
# The API token can also be set statically (but please, avoid committing secrets):
# token: hunter2
#
# Or, lookup plugins can be used:
# token: "{{ lookup('ansible.builtin.pipe', '/script/which/echoes/token.sh') }}"
# token: "{{ lookup('ansible.builtin.env', 'MY_DO_TOKEN') }}"
#
attributes:
- id
- memory
- vcpus
- disk
- locked
- status
- kernel
- created_at
- features
- backup_ids
- next_backup_window
- snapshot_ids
- image
- volume_ids
- size
- size_slug
- networks
- region
- tags
- vpc_uuid
compose:
ansible_host: networks.v4 | selectattr("type", "eq", "public") | map(attribute="ip_address") | first
class: size.description | lower
distribution: image.distribution | lower
keyed_groups:
- key: image.slug | default("null", true)
prefix: image
separator: "_"
- key: tags
prefix: tag
separator: "_"
- key: region.slug
prefix: region
separator: "_"
- key: status
prefix: status
separator: "_"
- key: vpc_uuid
prefix: vpc
groups:
basic: "'basic' in class"
ubuntu: "'ubuntu' in distribution"