Note
This inventory plugin is part of the community.general collection (version 10.7.3).
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.iocage.
New in community.general 10.2.0
host.host is localhost. If host is not localhost it is expected that the user running Ansible on the controller can connect to the host account user with SSH non-interactively and execute the command iocage list..iocage.yml or .iocage.yaml.The below requirements are needed on the local controller node that executes this inventory.
Parameter | Comments |
|---|---|
cache boolean | Toggle to enable/disable the caching of the inventory’s source data, requires a cache plugin setup to work. Choices:
Configuration:
|
cache_connection string | Cache connection data or path, read cache plugin documentation for specifics. Configuration:
|
cache_plugin string | Cache plugin to use for the inventory’s source data. Default: Configuration:
|
cache_prefix string | Prefix to use for cache plugin files/tables. Default: Configuration:
|
cache_timeout integer | Cache duration in seconds. Default: Configuration:
|
compose dictionary | Create vars from jinja2 expressions. Default: |
env dictionary | |
get_properties boolean | Get jails’ properties. Creates dictionary Choices:
|
groups dictionary | Add hosts to group based on Jinja2 conditionals. Default: |
hooks_results list / elements=path added in community.general 10.4.0 | List of paths to the files in a jail. Content of the files is stored in the items of the list If a file is not available the item keeps the dash character The variable |
host string | The IP/hostname of the 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 an empty string. This option is mutually exclusive with |
|
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 This option is mutually exclusive with Choices:
|
leading_separator boolean added in ansible-core 2.11 | Use in conjunction with 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 Set this option to 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:
|
plugin string / required | The name of this plugin, it should always be set to Choices:
|
strict boolean | 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:
|
sudo boolean added in community.general 10.3.0 | Enable execution as root. This requires passwordless sudo of the command Choices:
|
sudo_preserve_env boolean added in community.general 10.3.0 | Preserve environment if This requires Choices:
|
use_extra_vars boolean added in ansible-core 2.11 | Merge extra vars into the available variables for composition (highest precedence). Choices:
Configuration:
|
user string |
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).
Note
ssh user@host iocage list -l on the controller before using this inventory plugin with user specified and with host other than localhost.localhost ssh is not used. In this case, test the command iocage list -l.iocage_* for each added host.iocage list -l.NAME is used to name the added host.hooks_results expects the poolname of a jail is mounted to /poolname. For example, if you activate the pool iocage this plugin expects to find the hooks_results items in the path /iocage/iocage/jails/<name>/root. If you mount the poolname to a different path the easiest remedy is to create a symlink.---
# file name must end with iocage.yaml or iocage.yml
plugin: community.general.iocage
host: 10.1.0.73
user: admin
---
# user is not required if iocage is running on localhost (default)
plugin: community.general.iocage
---
# run cryptography without legacy algorithms
plugin: community.general.iocage
host: 10.1.0.73
user: admin
env:
CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1
---
# execute as root
# sudoers example 'admin ALL=(ALL) NOPASSWD:SETENV: /usr/local/bin/iocage list*'
plugin: community.general.iocage
host: 10.1.0.73
user: admin
sudo: true
sudo_preserve_env: true
env:
CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1
---
# enable cache
plugin: community.general.iocage
host: 10.1.0.73
user: admin
env:
CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1
cache: true
---
# see inventory plugin ansible.builtin.constructed
plugin: community.general.iocage
host: 10.1.0.73
user: admin
env:
CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1
cache: true
strict: false
compose:
ansible_host: iocage_ip4
release: iocage_release | split('-') | first
groups:
test: inventory_hostname.startswith('test')
keyed_groups:
- prefix: distro
key: iocage_release
- prefix: state
key: iocage_state
---
# Read the file /var/db/dhclient-hook.address.epair0b in the jails and use it as ansible_host
plugin: community.general.iocage
host: 10.1.0.73
user: admin
hooks_results:
- /var/db/dhclient-hook.address.epair0b
compose:
ansible_host: iocage_hooks.0
groups:
test: inventory_hostname.startswith('test')
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/iocage_inventory.html