Equinix Metal Device inventory source
Version added: 1.0.0
- Get inventory hosts from the Equinix Metal Device API.
- Uses a YAML configuration file that ends with equinix_metal.(yml|yaml).
The below requirements are needed on the local Ansible controller node that executes this inventory.
Parameter |
Choices/Defaults |
Configuration |
Comments |
api_token
string
/ required
|
|
env:METAL_API_TOKEN
env:PACKET_API_TOKEN
env:PACKET_TOKEN
|
The Equinix Metal API token to use
aliases: auth_token
|
cache
boolean
|
|
ini entries:
[inventory] cache = no
env:ANSIBLE_INVENTORY_CACHE
|
Toggle to enable/disable the caching of the inventory's source data, requires a cache plugin setup to work.
|
cache_connection
string
|
|
ini entries:
[defaults] fact_caching_connection = VALUE
[inventory] cache_connection = VALUE
env:ANSIBLE_CACHE_PLUGIN_CONNECTION
env:ANSIBLE_INVENTORY_CACHE_CONNECTION
|
Cache connection data or path, read cache plugin documentation for specifics.
|
cache_plugin
string
|
Default:
"memory"
|
ini entries:
[defaults] fact_caching = memory
[inventory] cache_plugin = memory
env:ANSIBLE_CACHE_PLUGIN
env:ANSIBLE_INVENTORY_CACHE_PLUGIN
|
Cache plugin to use for the inventory's source data.
|
cache_prefix
-
|
Default:
"ansible_inventory_"
|
ini entries:
[default] fact_caching_prefix = ansible_inventory_
[inventory] cache_prefix = ansible_inventory_
env:ANSIBLE_CACHE_PLUGIN_PREFIX
env:ANSIBLE_INVENTORY_CACHE_PLUGIN_PREFIX
|
Prefix to use for cache plugin files/tables
|
cache_timeout
integer
|
Default:
3600
|
ini entries:
[defaults] fact_caching_timeout = 3600
[inventory] cache_timeout = 3600
env:ANSIBLE_CACHE_PLUGIN_TIMEOUT
env:ANSIBLE_INVENTORY_CACHE_TIMEOUT
|
Cache duration in seconds
|
compose
dictionary
|
Default:
{}
|
|
Create vars from jinja2 expressions.
|
groups
dictionary
|
Default:
{}
|
|
Add hosts to group based on Jinja2 conditionals.
|
keyed_groups
list
|
Default:
[]
|
|
Add hosts to group based on the values of a variable.
|
plugin
-
/ required
|
Choices:
- equinix_metal
- equinix.metal.device
|
|
Token that ensures this is a source file for the plugin.
|
projects
list
|
Default:
[]
|
|
A list of projects in which to describe Equinix Metal devices.
If empty (the default) default this will include all projects.
|
strict
boolean
|
|
|
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.
|
# Minimal example using environment var credentials
plugin: equinix.metal.device
# Example using constructed features to create groups and set ansible_host
plugin: equinix.metal.device
# keyed_groups may be used to create custom groups
strict: False
keyed_groups:
# Add hosts to tag_Name groups for each tag
- prefix: tag
key: tags
# Add hosts to e.g. equinix_metal_plan_c3_small_x86
- prefix: equinix_metal_plan
key: plan
# Create a group per region e.g. equinix_metal_facility_am6
- key: facility
prefix: equinix_metal_facility
# Create a group per device state e.g. equinix_metal_state_active
- key: state
prefix: equinix_metal_state
# Set individual variables with compose
compose:
# Use the private IP address to connect to the host
# (note: this does not modify inventory_hostname, which is set via I(hostnames))
ansible_host: (ip_addresses | selectattr('address_family', 'equalto', 4) | selectattr('public', 'equalto', false) | first).address
- Peter Sankauskas
- Tomas Karasek
- Jason DeTiberus
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.