Skip to content

artifact_fetch

Collection Note

This module is part of the opsmill.infrahub collection. To install the collection, use:

ansible-galaxy collection install opsmill.infrahub
Added in version 0.0.3.

You need further requirements to be able to use this module, see the Requirements section for details.

Synopsis

  • Fetch the content of an artifact from Infrahub through Infrahub SDK

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
artifact_name
str
Name of the artifact
branch
str
Default: main
Branch in which the request is made
target_id
str
Id of the target for this artifact
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

---
- name: Infrahub action plugin artifact_fetch
  gather_facts: false
  hosts: platform_eos
  vars:
    ansible_become: true

  tasks:
    - name: Query Startup Config for Edge Devices
      opsmill.infrahub.artifact_fetch:
        artifact_name: "Startup Config for Edge devices"
        target_id: "{{ id }}"
      register: startup_artifact

    - name: Save configs to localhost
      ansible.builtin.copy:
        content: "{{ startup_artifact.text }}"
        dest: "/tmp/{{ inventory_hostname }}-startup.conf"
        mode: '644'
      delegate_to: localhost

Return Values

Key Data Type Description Returned
json dict Content of the artifact in JSON format. success
text str Content of the artifact in TEXT format. success

Authors

  • Damien Garros (@dgarros)