community.general.cloud_init_data_facts module – Retrieve facts of cloud-init

Note

This module is part of the community.general collection (version 9.4.0).

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 community.general.

To use it in a playbook, specify: community.general.cloud_init_data_facts.

Synopsis

  • Gathers facts by reading the status.json and result.json of cloud-init.

Parameters

Parameter

Comments

filter

string

Filter facts

Choices:

  • "status"

  • "result"

Attributes

Attribute

Support

Description

check_mode

Support: full

This action does not modify state.

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: N/A

This action does not modify state.

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

facts

Support: full

Action returns an ansible_facts dictionary that will update existing host facts.

Notes

Note

Examples

- name: Gather all facts of cloud init
  community.general.cloud_init_data_facts:
  register: result

- ansible.builtin.debug:
    var: result

- name: Wait for cloud init to finish
  community.general.cloud_init_data_facts:
    filter: status
  register: res
  until: "res.cloud_init_data_facts.status.v1.stage is defined and not res.cloud_init_data_facts.status.v1.stage"
  retries: 50
  delay: 5

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

cloud_init_data_facts

dictionary

Facts of result and status.

Returned: success

Sample: "{ \"status\": { \"v1\": { \"datasource\": \"DataSourceCloudStack\", \"errors\": [] }, \"result\": { \"v1\": { \"datasource\": \"DataSourceCloudStack\", \"init\": { \"errors\": [], \"finished\": 1522066377.0185432, \"start\": 1522066375.2648022 }, \"init-local\": { \"errors\": [], \"finished\": 1522066373.70919, \"start\": 1522066373.4726632 }, \"modules-config\": { \"errors\": [], \"finished\": 1522066380.9097016, \"start\": 1522066379.0011985 }, \"modules-final\": { \"errors\": [], \"finished\": 1522066383.56594, \"start\": 1522066382.3449218 }, \"stage\": null } }"

Authors

  • René Moser (@resmo)