Skip to content

Latest commit

 

History

History
186 lines (154 loc) · 6.79 KB

cloud.terraform.plan_stash_module.rst

File metadata and controls

186 lines (154 loc) · 6.79 KB

cloud.terraform.plan_stash

Handle the base64 encoding or decoding of a terraform plan file

Version added: 2.1.0

  • This module performs base64-encoding of a terraform plan file and saves it into playbook execution stats similar to :ref:`ansible.builtin.set_stats <ansible.builtin.set_stats_module>` module.
  • The module also performs base64-decoding of a terraform plan file from a variable defined into ansible facts and writes them into a file specified by the user.
Parameter Choices/Defaults Comments
binary_data
raw
When O(state=load), this parameter defines the base64-encoded data of the terraform plan file.
Mutually exclusive with V(var_name).
Ignored when O(state=stash).
path
path / required
The path to the terraform plan file.
per_host
boolean
    Choices:
  • no ←
  • yes
Whether the stats are per host or for all hosts in the run.
Ignored when O(state=load).
state
string
    Choices:
  • stash ←
  • load
O(state=stash): base64-encodes the terraform plan file and saves it into ansible stats like using the ansible.builtin.set_stats module.
O(state=load): base64-decodes data from variable specified in O(var_name) and writes them into terraform plan file.
var_name
string
When O(state=stash), this parameter defines the variable name to be set into stats.
When O(state=load), this parameter defines the variable from ansible facts containing the base64-encoded data of the terraform plan file.
Variables must start with a letter or underscore character, and contain only letters, numbers and underscores.
The module will use V(terraform_plan) as default variable name if not specified.

Note

  • For security reasons, this module should be used with no_log=true and register functionalities as the plan file can contain unencrypted secrets.
# Encode terraform plan file into default variable 'terraform_plan'
- name: Encode a terraform plan file into terraform_plan variable
  cloud.terraform.plan_stash:
    path: /path/to/terraform_plan_file
    state: stash
  no_log: true

# Encode terraform plan file into variable 'stashed_plan'
- name: Encode a terraform plan file into terraform_plan variable
  cloud.terraform.plan_stash:
    path: /path/to/terraform_plan_file
    var_name: stashed_plan
    state: stash
  no_log: true

# Load terraform plan file from variable 'stashed_plan'
- name: Load a terraform plan file data from variable 'stashed_plan' into file 'tfplan'
  cloud.terraform.plan_stash:
    path: tfplan
    var_name: stashed_plan
    state: load
  no_log: true

# Load terraform plan file from binary data
- name: Load a terraform plan file data from binary data
  cloud.terraform.plan_stash:
    path: tfplan
    binary_data: "{{ terraform_binary_data }}"
    state: load
  no_log: true

Authors

  • Aubin Bikouo (@abikouo)