Skip to main content

Lookup lookup

Get inventory hosts from Infrahub

Parameters

ParameterTypeRequiredDefaultDescription
api_endpoint``YesEndpoint of the Infrahub API
token``YesInfrahub API token to be able to read against Infrahub.
timeoutintNo10Timeout for Infrahub requests in seconds
querystrYesGraphQL query to send to Infrahub to obtain desired data
graph_variablesdictNodictionary of keys/values to pass into the GraphQL query
branchstrNomainBranch in which the request is made
validate_certs``NoTrueWhether or not to validate SSL of the Infrahub instance

Examples

- name: Infrahub lookup
gather_facts: false
hosts: localhost

tasks:
- name: SET FACT OF STRING
ansible.builtin.set_fact:
query_string: |
query {
BuiltinLocation {
edges {
node {
name {
value
}
}
}
}
}

- name: Obtain list of sites from Infrahub
ansible.builtin.set_fact:
query_response: "{{ query('opsmill.infrahub.lookup', query=query_string) }}"

- name: Print result
ansible.builtin.debug:
msg: "{{ query_response }}"

Return values

KeyTypeDescription
datadictData result from the Infrahub GraphQL endpoint