ripclawffb.helix_core.helix_core inventory – Perforce Helix Core dynamic inventory plugin

Note

This inventory plugin is part of the ripclawffb.helix_core collection (version 1.3.0).

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 ripclawffb.helix_core. You need further requirements to be able to use this inventory plugin, see Requirements for details.

To use it in a playbook, specify: ripclawffb.helix_core.helix_core.

New in ripclawffb.helix_core 1.3.0

Synopsis

  • Discovers Perforce server topology by querying p4 servers.

  • Each registered server becomes an Ansible host, keyed by its ServerID.

  • Hosts are automatically grouped by server type (commit, edge, replica, etc.).

  • Supports Constructable features like compose, keyed_groups, and groups.

  • Ideal for federated Perforce environments with commit + edge/replica servers.

Requirements

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

  • P4Python pip module is required

Parameters

Parameter

Comments

charset

string

Character set used for translation of unicode files.

Can also use P4CHARSET environment variable.

Default: "none"

Configuration:

compose

dictionary

Create vars from jinja2 expressions.

Default: {}

groups

dictionary

Add hosts to group based on Jinja2 conditionals.

Default: {}

include_commit

boolean

Whether to include the commit server itself in the inventory.

Only relevant when the commit server has a registered server spec.

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 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 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)

password

string / required

The login password for the Perforce user.

Can also use P4PASSWD environment variable.

Configuration:

plugin

string / required

Token to ensure this is an inventory plugin file.

Choices:

  • "ripclawffb.helix_core.helix_core"

server

string / required

The hostname/ip and port of the Perforce server (e.g. ssl:perforce:1666).

Can also use P4PORT environment variable.

Configuration:

  • Environment variable: P4PORT

server_types

list / elements=string

Optional list of server types to include in the inventory.

Valid types include commit-server, edge-server, replica, forwarding-replica, build-server, depot-master, etc.

If omitted, all server types are included.

Default: []

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:

user

string / required

A Perforce user with permission to run p4 servers.

Can also use P4USER environment variable.

Configuration:

  • Environment variable: P4USER

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).

Examples

# Minimal inventory file — discover all servers
# inventory.helix_core.yml
plugin: ripclawffb.helix_core.helix_core
server: ssl:commit-server:1666
user: admin
password: "{{ vault_p4_password }}"

# Filter to only edge servers and group by type
plugin: ripclawffb.helix_core.helix_core
server: ssl:commit-server:1666
user: admin
password: "{{ vault_p4_password }}"
server_types:
  - edge-server
  - commit-server
keyed_groups:
  - key: server_type
    prefix: p4
    separator: "_"

# Use compose to set ansible_host from the server address
plugin: ripclawffb.helix_core.helix_core
server: ssl:commit-server:1666
user: admin
password: "{{ vault_p4_password }}"
compose:
  ansible_port: 22