vultr.cloud.vultr inventory – Retrieves list of instances via Vultr v2 API
Note
This inventory plugin is part of the vultr.cloud 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 vultr.cloud
.
To use it in a playbook, specify: vultr.cloud.vultr
.
New in vultr.cloud 1.4.0
Synopsis
Vultr inventory plugin.
Retrieves list of instances via Vultr v2 API.
Configuration of this plugin is done with files ending with ‘(vultr|vultr_hosts|vultr_instances).(yaml|yml)’
Parameters
Parameter |
Comments |
---|---|
URL to API endpint (without trailing slash). Fallback environment variable Default: Configuration:
|
|
API key of the Vultr API. Fallback environment variable Configuration:
|
|
When receiving large numbers of instances, specify how many instances should be returned per call to API. This does not determine how many results are returned; all instances are returned according to other filters. Vultr API maximum is 500. Fallback environment variable Default: Configuration:
|
|
HTTP timeout to Vultr API. Fallback environment variable Default: Configuration:
|
|
Instance attributes to add as host variables to each host added to inventory. See https://www.vultr.com/api/#operation/list-instances for valid values. The internal_ip attribute was added in version 1.10.0. Default: |
|
Toggle to enable/disable the caching of the inventory’s source data, requires a cache plugin setup to work. Choices:
Configuration:
|
|
Cache connection data or path, read cache plugin documentation for specifics. Configuration:
|
|
Cache plugin to use for the inventory’s source data. Default: Configuration:
|
|
Prefix to use for cache plugin files/tables Default: Configuration:
|
|
Cache duration in seconds Default: Configuration:
|
|
Create vars from jinja2 expressions. Default: |
|
Filter hosts with Jinja2 templates. If not provided, all hosts are added to inventory. Default: |
|
Add hosts to group based on Jinja2 conditionals. Default: |
|
Type of instance. Choices:
|
|
Add hosts to group based on the values of a variable. Default: |
|
The default value when the host variable’s value is an empty string. This option is mutually exclusive with |
|
The key from input dictionary used to generate groups |
|
parent group for keyed group |
|
A keyed group name will start with this prefix Default: |
|
separator used to build the keyed group name Default: |
|
Set this option to False to omit the This option is mutually exclusive with Choices:
|
|
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. Choices:
|
|
Name of Vultr inventory plugin. This should always be Choices:
|
|
If Since it is possible to use facts in the expressions they might not always be available and we ignore those errors by default. Choices:
|
|
Merge extra vars into the available variables for composition (highest precedence). Choices:
Configuration:
|
|
Validate SSL certs of the Vultr API. Choices:
|
|
Prefix of generated variables (e.g. Default: |
Notes
Note
Also see the API documentation on https://www.vultr.com/api/.
Examples
---
# File endings vultr{,_{hosts,instances}}.y{,a}ml
# All configuration done via environment variables:
plugin: vultr.cloud.vultr
# Grouping and filtering configuration in inventory file
plugin: vultr.cloud.vultr
api_key: '{{ lookup("pipe"), "./get_vultr_api_key.sh" }}'
keyed_groups:
- key: vultr_tags | lower
prefix: ''
separator: ''
filters:
- '"vpc" in vultr_tags'
- 'vultr_plan == "vc2-2c-4gb"'
# Unless you can connect to your servers via it's vultr label,
# we suggest setting ansible_host with compose:
plugin: vultr.cloud.vultr
compose:
ansible_host: vultr_main_ip
# Respectively for IPv6:
plugin: vultr.cloud.vultr
compose:
ansible_host: vultr_v6_main_ip
# Prioritize IPv6 over IPv4 if available.
plugin: vultr.cloud.vultr
compose:
ansible_host: vultr_v6_main_ip or vultr_main_ip
# Use the internal IP
plugin: vultr.cloud.vultr
compose:
ansible_host: vultr_internal_ip
# Querying the bare metal instances
plugin: vultr.cloud.vultr
instance_type: bare_metal