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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
api_endpoint | str | No | Endpoint of the Infrahub API, optional env=INFRAHUB_ADDRESS | |
token | str | No | The API token created through Infrahub, optional env=INFRAHUB_API_TOKEN | |
timeout | int | No | 10 | Timeout for Infrahub requests in seconds |
artifact_name | str | No | Name of the artifact (mutually exclusive with artifact_id) | |
artifact_id | str | No | UUID of the artifact (mutually exclusive with artifact_name) | |
target_id | str | Yes | UUID of the target node (e.g., device ID) that the artifact is associated with | |
branch | str | No | main | Branch in which the request is made |
validate_certs | bool | No | True | Whether to validate SSL of the Infrahub instance |
state | str | No | present | Use 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
| Key | Type | Description |
|---|---|---|
artifact_id | str | UUID of the artifact that was regenerated |
artifact_name | str | Name of the artifact that was regenerated |
definition_id | str | UUID of the artifact definition |
target_id | str | UUID of the target node that the artifact is associated with |
changed | bool | Whether the artifact regeneration was triggered |
msg | str | Message indicating the result of the operation |