artifact_generate¶
Collection Note
This module is part of the opsmill.infrahub collection. To install the collection, use:
Added in version1.7.0.
You need further requirements to be able to use this module, see the Requirements section for details.
Synopsis¶
- 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.
Requirements¶
The following Python packages are needed on the host that executes this module:
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| api_endpoint str |
Endpoint of the Infrahub API, optional env=INFRAHUB_ADDRESS | |
| artifact_id str |
UUID of the artifact (mutually exclusive with artifact_name) | |
| artifact_name str |
Name of the artifact (mutually exclusive with artifact_id) | |
| branch str |
Default: main |
Branch in which the request is made |
| target_id str required |
UUID of the target node (e.g., device ID) that the artifact is associated with | |
| timeout int |
Default: 10 |
Timeout for Infrahub requests in seconds |
| token str |
The API token created through Infrahub, optional env=INFRAHUB_API_TOKEN | |
| validate_certs bool |
Default: True |
Whether or not to validate SSL of the Infrahub instance |
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 | Data Type | Description | Returned |
|---|---|---|---|
| artifact_id | str | UUID of the artifact that was regenerated | success |
| artifact_name | str | Name of the artifact that was regenerated | success |
| changed | bool | Whether the artifact regeneration was triggered | success |
| definition_id | str | UUID of the artifact definition | success |
| msg | str | Message indicating the result of the operation | always |
| target_id | str | UUID of the target node that the artifact is associated with | success |
Authors¶
- Opsmill (@opsmill)