ngine_io.cloudstack.api lookup – Iteract with the Cloudstack API via lookup

Note

This lookup plugin is part of the ngine_io.cloudstack collection (version 3.0.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install ngine_io.cloudstack. You need further requirements to be able to use this lookup plugin, see Requirements for details.

To use it in a playbook, specify: ngine_io.cloudstack.api.

Synopsis

  • Returns GET requests from the Cloudstack API.

Requirements

The below requirements are needed on the local controller node that executes this lookup.

  • None

  • cs >= 0.9.0

  • python >= 2.6

Terms

Parameter

Comments

Terms

string / required

The endpoint to query, i.e. listUserData, listVirtualMachines, etc.

Keyword parameters

This describes keyword parameters of the lookup. These are the values key1=value1, key2=value2 and so on in the following examples: lookup('ngine_io.cloudstack.api', key1=value1, key2=value2, ...) and query('ngine_io.cloudstack.api', key1=value1, key2=value2, ...)

Parameter

Comments

api_http_method

string

HTTP method used to query the API endpoint.

If not given, the CLOUDSTACK_METHOD env variable is considered.

Choices:

  • "get" ← (default)

  • "post"

api_key

string / required

API key of the CloudStack API.

If not given, the CLOUDSTACK_KEY env variable is considered.

api_secret

string / required

Secret key of the CloudStack API.

If not set, the CLOUDSTACK_SECRET env variable is considered.

api_timeout

integer

HTTP timeout in seconds.

If not given, the CLOUDSTACK_TIMEOUT env variable is considered.

Default: 10

api_url

string / required

URL of the CloudStack API e.g. https://cloud.example.com/client/api.

If not given, the CLOUDSTACK_ENDPOINT env variable is considered.

api_verify_ssl_cert

string

Verify CA authority cert file.

If not given, the CLOUDSTACK_VERIFY env variable is considered.

query_params

dictionary

The query parameters to search for in the form of key/value pairs.

validate_certs

boolean

added in ngine_io.cloudstack 2.4.0

If false, SSL certificates will not be validated.

If not given, the CLOUDSTACK_DANGEROUS_NO_TLS_VERIFY env variable is considered.

This should only be used on personally controlled sites using self-signed certificates.

Choices:

  • false

  • true ← (default)

Notes

Note

  • When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters: lookup('ngine_io.cloudstack.api', term1, term2, key1=value1, key2=value2) and query('ngine_io.cloudstack.api', term1, term2, key1=value1, key2=value2)

  • If the query is not filtered properly this can cause a performance impact.

  • A detailed guide about cloudstack modules can be found in the CloudStack Cloud Guide.

  • This module supports check mode.

Examples

- name: List all UserData from the API
  set_fact:
    controller_settings: "{{ lookup('ngine_io.cloudstack.api', 'listUserData', query_params={ 'listall': true }) }}"

- name: List all Virtual Machines from the API
  set_fact:
    virtual_machines: "{{ lookup('ngine_io.cloudstack.api', 'listVirtualMachines') }}"

- name: List specific Virtual Machines from the API
  set_fact:
    virtual_machines: "{{ lookup('ngine_io.cloudstack.api', 'listVirtualMachines', query_params={ 'name': 'myvmname' }) }}"

Return Value

Key

Description

Return value

dictionary

Response from the API

Returned: on successful request

Authors

  • Lorenzo Tanganelli (@tanganellilore)