community.general.incus inventory – Incus inventory source

Note

This inventory plugin is part of the community.general collection (version 12.0.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.general. You need further requirements to be able to use this inventory plugin, see Requirements for details.

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

New in community.general 12.0.0

Synopsis

  • Get inventory hosts from the Incus container and virtual-machine manager.

Requirements

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

  • Incus CLI (incus)

Parameters

Parameter

Comments

compose

dictionary

Create vars from jinja2 expressions.

Default: {}

default_groups

boolean

Whether to generate default groups based on remote and project.

Choices:

  • false

  • true ← (default)

filters

list / elements=string

Filter expression as supported by incus list.

Default: []

groups

dictionary

Add hosts to group based on Jinja2 conditionals.

Default: {}

host_domain

string

Domain to append to the host FQDN.

host_fqdn

boolean

Whether to generate a FQDN for the host name.

This will use the INSTANCE.PROJECT.REMOTE syntax.

Choices:

  • false

  • true ← (default)

keyed_groups

list / elements=dictionary

Add hosts to group based on the values of a variable.

Default: []

default_value

string

added in ansible-core 2.12

The default value when the host variable’s value is None or an empty string.

This option is mutually exclusive with keyed_groups[].trailing_separator.

key

string

The key from input dictionary used to generate groups.

parent_group

string

parent group for keyed group.

prefix

string

A keyed group name will start with this prefix.

Default: ""

separator

string

separator used to build the keyed group name.

Default: "_"

trailing_separator

boolean

added in ansible-core 2.12

Set this option to false to omit the keyed_groups[].separator after the host variable when the value is None or an empty string.

This option is mutually exclusive with keyed_groups[].default_value.

Choices:

  • false

  • true ← (default)

leading_separator

boolean

added in ansible-core 2.11

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:

  • false

  • true ← (default)

plugin

string / required

The name of this plugin, it should always be set to community.general.incus for this plugin to work.

Choices:

  • "community.general.incus"

remotes

list / elements=string

The names of the Incus remotes to use (per incus remote list).

Remotes are used to access multiple servers from a single client.

By default the inventory will go over all projects for each remote.

It is possible to specify a specific project using remote:project.

Default: ["local"]

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.

Choices:

  • false ← (default)

  • true

use_extra_vars

boolean

added in ansible-core 2.11

Merge extra vars into the available variables for composition (highest precedence).

Choices:

  • false ← (default)

  • true

Configuration:

Note

Configuration entries listed above for each entry type (Ansible variable, environment variable, and so on) 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. The entry types are also ordered by precedence from low to high priority order. For example, an ansible.cfg entry (further up in the list) is overwritten by an Ansible variable (further down in the list).

Notes

Note

  • Inventories are not finalized at this stage, so the auto populated all and ungrouped groups will only reflect what previous inventory sources explicitly added to them.

  • Runtime ‘magic variables’ are not available during inventory construction. For example, groups and hostvars do not exist yet.

Examples

---
# Pull instances from all projects on the local remote.
plugin: community.general.incus

---
# Pull running VMs from all projects on the local remote.
plugin: community.general.incus
filters:
  - type=virtual-machine
  - status=running

---
# Pull instances from two different remotes
plugin: community.general.incus
remotes:
  - remote-1
  - remote-2

---
# Pull instances from two different remotes
# Limiting the second to the default project
plugin: community.general.incus
remotes:
  - remote-1
  - remote-2:default

Authors

  • Stéphane Graber (@stgraber)