tseeker / tseeker.reconstructed / 1.0.0 / inventory / reconstructed A plugin that allows the dynamic construction of groups Authors: Emmanuel BENOÎTtseeker.reconstructed.reconstructed (1.0.0) — inventory
Install with ansible-galaxy collection install tseeker.reconstructed:==1.0.0
collections: - name: tseeker.reconstructed version: 1.0.0
This inventory plugin allows the construction of groups, the optional assignment of hosts to these groups and the computation of arbitrary facts.
plugin: choices: - tseeker.reconstructed.reconstructed - reconstructed description: - Token that ensures this is a source file for the C(group_creator) plugin. required: true strictness: choices: - host - full default: host description: - The C(host) setting will cause an error to skip the host being processed, and the C(full) setting will abort the execution altogether. required: false instructions: description: - The list of instructions to be executed in order to generate the inventory parts. Each instruction is represented as a dictionnary with at least an C(action) field which determines which instruction must be executed. The instructions will be executed once for each inventory host. - Instructions may include various fields that act as control flow. - If the C(loop) field is present, it must contain a list (or a Jinja template that will return a list). The instruction will be repeated for each value in the list. The C(loop_var) field may be added to specify the name of the variable into which the current value will be written; by default the C(item) variable will be used. Once the loop execution ends, the loop variable's previous state is restored. - The C(when) field, if present, must contain a Jinja expression representing a condition which will be checked before the instruction is executed. - The C(run_once) field will ensure that the instuction it is attached to will only run one time at most. - The C(action) field must be set to one of the following values. - The C(block) action is another form of flow control, which can be used to repeat multiple instructions or make them obey a single conditional. The instruction must include a C(block) field, containing the list of instructions which are part of the block. In addition, it may have a C(rescue) field, containing a list of instructions which will be executed on error, and C(always), which may contain a list of instructions to execute in all cases. If the C(locals) field is defined, it must contain a table of local variables to define. Any local variable defined by the instructions under C(block), C(rescue) or C(always) will go out of scope once the block finishes executing, and the previous values, if any, will be restored. - C(create_group) creates a group. The name of the group must be provided using the C(group) field, which must be a valid name or a Jinja template that evaluates to a valid name. In addition, a C(parent) field containting the name of a single, existing parent group (or a Jinja template generating the name) may be provided. Finally, the C(add_host) field may be set to a truthy value if the current host must be added to the new group. - C(add_child) adds a child group to another group. The name of the group being added must be provided in the C(child) entry, while the name of the parent must be provided in the C(group) entry. Both groups must exist. In addition, the names may be specified using Jinja templates. - C(add_host) adds the current inventory host to a group. The name of the group must be provided in the C(group) entry. The group must exist. - C(fail) causes the computations for the current host to stop with an error. The error message may be specified in the C(message) entry; if present, it will be evaluated using Jinja. - C(set_fact) and C(set_var) create a fact and a local variable, respectively. Local variables will only be kept during the execution of the script for the current host, while facts will be added to the host's data. The C(name) entry specifies the name of the fact or variable while the C(value) entry specifies its value. Both may be Jinja templates. - C(stop) stops processing the list of instructions for the current host. - C(rename_host) changes a host's name. It can only be executed once per host. elements: dict required: true type: list