community.general.proxmox – Proxmox inventory source

Note

This plugin is part of the community.general collection (version 3.7.0).

To install it use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.proxmox.

New in version 1.2.0: of community.general

Synopsis

  • Get inventory hosts from a Proxmox PVE cluster.

  • Uses a configuration file as an inventory source, it must end in .proxmox.yml or .proxmox.yaml

  • Will retrieve the first network interface with an IP for Proxmox nodes.

  • Can retrieve LXC/QEMU configuration as facts.

Requirements

The below requirements are needed on the local controller node that executes this inventory.

  • requests >= 1.1

Parameters

Parameter Choices/Defaults Configuration Comments
cache
boolean
    Choices:
  • no ←
  • yes
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 = None

[inventory]
cache_connection = None

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
string
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
added in 2.5.0 of community.general
Default:
{}
Create vars from jinja2 expressions.
facts_prefix
string
Default:
"proxmox_"
Prefix to apply to LXC/QEMU config facts.
group_prefix
string
Default:
"proxmox_"
Prefix to apply to Proxmox groups.
groups
dictionary
added in 2.5.0 of community.general
Default:
{}
Add hosts to group based on Jinja2 conditionals.
keyed_groups
list / elements=string
added in 2.5.0 of community.general
Default:
[]
Add hosts to group based on the values of a variable.
leading_separator
boolean
added in 2.11 of ansible.builtin
    Choices:
  • no
  • yes ←
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.
password
string / required
env:PROXMOX_PASSWORD
added in 2.0.0 of community.general
Proxmox authentication password.
If the value is not specified in the inventory configuration, the value of environment variable PROXMOX_PASSWORD will be used instead.
plugin
string / required
    Choices:
  • community.general.proxmox
The name of this plugin, it should always be set to community.general.proxmox for this plugin to recognize it as it's own.
strict
boolean
added in 2.5.0 of community.general
    Choices:
  • no ←
  • yes
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.
url
string
Default:
"http://localhost:8006"
env:PROXMOX_URL
added in 2.0.0 of community.general
URL to Proxmox cluster.
If the value is not specified in the inventory configuration, the value of environment variable PROXMOX_URL will be used instead.
use_extra_vars
boolean
added in 2.11 of ansible.builtin
    Choices:
  • no ←
  • yes
ini entries:

[inventory_plugins]
use_extra_vars = no

env:ANSIBLE_INVENTORY_USE_EXTRA_VARS
Merge extra vars into the available variables for composition (highest precedence).
user
string / required
env:PROXMOX_USER
added in 2.0.0 of community.general
Proxmox authentication user.
If the value is not specified in the inventory configuration, the value of environment variable PROXMOX_USER will be used instead.
validate_certs
boolean
    Choices:
  • no
  • yes ←
Verify SSL certificate if using HTTPS.
want_facts
boolean
    Choices:
  • no ←
  • yes
Gather LXC/QEMU configuration facts.
want_proxmox_nodes_ansible_host
boolean
added in 3.0.0 of community.general
    Choices:
  • no
  • yes ←
Whether to set ansbile_host for proxmox nodes.
When set to true (default), will use the first available interface. This can be different from what you expect.

Examples

# Minimal example which will not gather additional facts for QEMU/LXC guests
# By not specifying a URL the plugin will attempt to connect to the controller host on port 8006
# my.proxmox.yml
plugin: community.general.proxmox
user: [email protected]
password: secure

# More complete example demonstrating the use of 'want_facts' and the constructed options
# Note that using facts returned by 'want_facts' in constructed options requires 'want_facts=true'
# my.proxmox.yml
plugin: community.general.proxmox
url: http://pve.domain.com:8006
user: [email protected]
password: secure
validate_certs: false
want_facts: true
keyed_groups:
    # proxmox_tags_parsed is an example of a fact only returned when 'want_facts=true'
  - key: proxmox_tags_parsed
    separator: ""
    prefix: group
groups:
  webservers: "'web' in (proxmox_tags_parsed|list)"
  mailservers: "'mail' in (proxmox_tags_parsed|list)"
compose:
  ansible_port: 2222

Authors