Skip to main content

Modules modules

Creates, Updates or Deletes a node of a given Kind in Infrahub through Infrahub SDK

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
kindstrYesKind of node to create
datarawYesDictionary of node attributes
branchstrNomainBranch in which the request is made
validate_certsboolNoTrueWhether or not to validate SSL of the Infrahub instance
statestrNopresentUse C(present) or C(absent) for adding or removing.
file_pathstrNoNoneLocal filesystem path to the file to upload when creating or updating a CoreFileObject node. Required when the kind inherits from CoreFileObject (unless C(fetch_file) is used instead). Mutually exclusive with C(fetch_file). When provided, the module computes a SHA-1 checksum and skips the upload if it matches the server-side checksum (idempotent). Fails if the kind does not inherit from CoreFileObject. Ignored in check mode (no upload performed).
fetch_fileboolNoFalseWhen C(true), download the file content from the CoreFileObject node and include it in the result as C(binary) (base64-encoded) and C(text) (UTF-8 decoded for text MIME types, null otherwise). Required when the kind inherits from CoreFileObject and C(file_path) is not provided. Mutually exclusive with C(file_path). Ignored in check mode (no download performed). Fails if the kind does not inherit from CoreFileObject.

Examples

---
- name: Infrahub playbook for opsmill.infrahub.node
gather_facts: false
hosts: localhost

tasks:
- name: Create tag1
opsmill.infrahub.node:
kind: "BuiltinTag"
data:
name: "tag1"
state: present

- name: Delete tag1
opsmill.infrahub.node:
kind: "BuiltinTag"
data:
name: "tag1"
state: absent

Return values

KeyTypeDescription
objectdictSerialized object as created or already existent within Infrahub
msgstrMessage indicating failure or info about what has been achieved
binarystrBase64-encoded file content downloaded from the CoreFileObject node. Present only when I(fetch_file=true) and not in check mode.
textstrUTF-8 decoded file content for text MIME types (text/plain, application/json, etc.). null for binary MIME types. Present only when I(fetch_file=true) and not in check mode.