Skip to main content

Modules modules

Triggers the regeneration of an artifact for a specified target node in Infrahub. The module looks up the artifact associated with the target node and triggers regeneration.

Parameters

ParameterTypeRequiredDefaultDescription
api_endpointstrNoEndpoint of the Infrahub API, optional env=INFRAHUB_ADDRESS
tokenstrNoThe API token created through Infrahub, optional env=INFRAHUB_API_TOKEN
timeoutintNo10Timeout for Infrahub requests in seconds
artifact_namestrNoName of the artifact (mutually exclusive with artifact_id)
artifact_idstrNoUUID of the artifact (mutually exclusive with artifact_name)
target_idstrYesUUID of the target node (e.g., device ID) that the artifact is associated with
branchstrNomainBranch in which the request is made
validate_certsboolNoTrueWhether to validate SSL of the Infrahub instance
statestrNopresentUse C(present) or C(absent) for adding or removing.

Examples

---
# Example 1: Regenerate artifact by name for a device
- name: Regenerate artifact by name
gather_facts: false
hosts: localhost
connection: local

tasks:
- name: Regenerate Startup Config for a device
opsmill.infrahub.artifact_generate:
artifact_name: "Startup Config"
target_id: "{{ device_id }}"
register: result

- name: Display regeneration result
ansible.builtin.debug:
var: result

---
# Example 2: Regenerate artifact by UUID
- name: Regenerate artifact by ID
gather_facts: false
hosts: localhost

tasks:
- name: Regenerate specific artifact by ID
opsmill.infrahub.artifact_generate:
artifact_id: "12345678-1234-1234-1234-123456789abc"
target_id: "{{ device_id }}"

---
# Example 3: Using with Infrahub inventory plugin
# Run with: ansible-playbook playbook.yml -i inventory.infrahub.yml -l "*edge*"
- name: Regenerate artifacts using inventory host IDs
gather_facts: false
hosts: all
connection: local

tasks:
- name: Regenerate Startup Config for each device
opsmill.infrahub.artifact_generate:
artifact_name: "Startup Config"
target_id: "{{ id }}"
register: result

Return values

KeyTypeDescription
artifact_idstrUUID of the artifact that was regenerated
artifact_namestrName of the artifact that was regenerated
definition_idstrUUID of the artifact definition
target_idstrUUID of the target node that the artifact is associated with
changedboolWhether the artifact regeneration was triggered
msgstrMessage indicating the result of the operation