|
| 1 | +.. _cloud.terraform.plan_stash_module: |
| 2 | + |
| 3 | + |
| 4 | +************************** |
| 5 | +cloud.terraform.plan_stash |
| 6 | +************************** |
| 7 | + |
| 8 | +**Handle the base64 encoding or decoding of a terraform plan file** |
| 9 | + |
| 10 | + |
| 11 | +Version added: 2.1.0 |
| 12 | + |
| 13 | +.. contents:: |
| 14 | + :local: |
| 15 | + :depth: 1 |
| 16 | + |
| 17 | + |
| 18 | +Synopsis |
| 19 | +-------- |
| 20 | +- 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. |
| 21 | +- 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. |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +Parameters |
| 27 | +---------- |
| 28 | + |
| 29 | +.. raw:: html |
| 30 | + |
| 31 | + <table border=0 cellpadding=0 class="documentation-table"> |
| 32 | + <tr> |
| 33 | + <th colspan="1">Parameter</th> |
| 34 | + <th>Choices/<font color="blue">Defaults</font></th> |
| 35 | + <th width="100%">Comments</th> |
| 36 | + </tr> |
| 37 | + <tr> |
| 38 | + <td colspan="1"> |
| 39 | + <div class="ansibleOptionAnchor" id="parameter-"></div> |
| 40 | + <b>binary_data</b> |
| 41 | + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 42 | + <div style="font-size: small"> |
| 43 | + <span style="color: purple">raw</span> |
| 44 | + </div> |
| 45 | + </td> |
| 46 | + <td> |
| 47 | + </td> |
| 48 | + <td> |
| 49 | + <div>When O(state=load), this parameter defines the base64-encoded data of the terraform plan file.</div> |
| 50 | + <div>Mutually exclusive with V(var_name).</div> |
| 51 | + <div>Ignored when O(state=stash).</div> |
| 52 | + </td> |
| 53 | + </tr> |
| 54 | + <tr> |
| 55 | + <td colspan="1"> |
| 56 | + <div class="ansibleOptionAnchor" id="parameter-"></div> |
| 57 | + <b>path</b> |
| 58 | + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 59 | + <div style="font-size: small"> |
| 60 | + <span style="color: purple">path</span> |
| 61 | + / <span style="color: red">required</span> |
| 62 | + </div> |
| 63 | + </td> |
| 64 | + <td> |
| 65 | + </td> |
| 66 | + <td> |
| 67 | + <div>The path to the terraform plan file.</div> |
| 68 | + </td> |
| 69 | + </tr> |
| 70 | + <tr> |
| 71 | + <td colspan="1"> |
| 72 | + <div class="ansibleOptionAnchor" id="parameter-"></div> |
| 73 | + <b>per_host</b> |
| 74 | + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 75 | + <div style="font-size: small"> |
| 76 | + <span style="color: purple">boolean</span> |
| 77 | + </div> |
| 78 | + </td> |
| 79 | + <td> |
| 80 | + <ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 81 | + <li><div style="color: blue"><b>no</b> ←</div></li> |
| 82 | + <li>yes</li> |
| 83 | + </ul> |
| 84 | + </td> |
| 85 | + <td> |
| 86 | + <div>Whether the stats are per host or for all hosts in the run.</div> |
| 87 | + <div>Ignored when O(state=load).</div> |
| 88 | + </td> |
| 89 | + </tr> |
| 90 | + <tr> |
| 91 | + <td colspan="1"> |
| 92 | + <div class="ansibleOptionAnchor" id="parameter-"></div> |
| 93 | + <b>state</b> |
| 94 | + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 95 | + <div style="font-size: small"> |
| 96 | + <span style="color: purple">string</span> |
| 97 | + </div> |
| 98 | + </td> |
| 99 | + <td> |
| 100 | + <ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 101 | + <li><div style="color: blue"><b>stash</b> ←</div></li> |
| 102 | + <li>load</li> |
| 103 | + </ul> |
| 104 | + </td> |
| 105 | + <td> |
| 106 | + <div>O(state=stash): base64-encodes the terraform plan file and saves it into ansible stats like using the <span class='module'>ansible.builtin.set_stats</span> module.</div> |
| 107 | + <div>O(state=load): base64-decodes data from variable specified in O(var_name) and writes them into terraform plan file.</div> |
| 108 | + </td> |
| 109 | + </tr> |
| 110 | + <tr> |
| 111 | + <td colspan="1"> |
| 112 | + <div class="ansibleOptionAnchor" id="parameter-"></div> |
| 113 | + <b>var_name</b> |
| 114 | + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 115 | + <div style="font-size: small"> |
| 116 | + <span style="color: purple">string</span> |
| 117 | + </div> |
| 118 | + </td> |
| 119 | + <td> |
| 120 | + </td> |
| 121 | + <td> |
| 122 | + <div>When O(state=stash), this parameter defines the variable name to be set into stats.</div> |
| 123 | + <div>When O(state=load), this parameter defines the variable from ansible facts containing the base64-encoded data of the terraform plan file.</div> |
| 124 | + <div>Variables must start with a letter or underscore character, and contain only letters, numbers and underscores.</div> |
| 125 | + <div>The module will use V(terraform_plan) as default variable name if not specified.</div> |
| 126 | + </td> |
| 127 | + </tr> |
| 128 | + </table> |
| 129 | + <br/> |
| 130 | + |
| 131 | + |
| 132 | +Notes |
| 133 | +----- |
| 134 | + |
| 135 | +.. note:: |
| 136 | + - For security reasons, this module should be used with *no_log=true* and *register* functionalities as the plan file can contain unencrypted secrets. |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | +Examples |
| 141 | +-------- |
| 142 | + |
| 143 | +.. code-block:: yaml |
| 144 | +
|
| 145 | + # Encode terraform plan file into default variable 'terraform_plan' |
| 146 | + - name: Encode a terraform plan file into terraform_plan variable |
| 147 | + cloud.terraform.plan_stash: |
| 148 | + path: /path/to/terraform_plan_file |
| 149 | + state: stash |
| 150 | + no_log: true |
| 151 | +
|
| 152 | + # Encode terraform plan file into variable 'stashed_plan' |
| 153 | + - name: Encode a terraform plan file into terraform_plan variable |
| 154 | + cloud.terraform.plan_stash: |
| 155 | + path: /path/to/terraform_plan_file |
| 156 | + var_name: stashed_plan |
| 157 | + state: stash |
| 158 | + no_log: true |
| 159 | +
|
| 160 | + # Load terraform plan file from variable 'stashed_plan' |
| 161 | + - name: Load a terraform plan file data from variable 'stashed_plan' into file 'tfplan' |
| 162 | + cloud.terraform.plan_stash: |
| 163 | + path: tfplan |
| 164 | + var_name: stashed_plan |
| 165 | + state: load |
| 166 | + no_log: true |
| 167 | +
|
| 168 | + # Load terraform plan file from binary data |
| 169 | + - name: Load a terraform plan file data from binary data |
| 170 | + cloud.terraform.plan_stash: |
| 171 | + path: tfplan |
| 172 | + binary_data: "{{ terraform_binary_data }}" |
| 173 | + state: load |
| 174 | + no_log: true |
| 175 | +
|
| 176 | +
|
| 177 | +
|
| 178 | +
|
| 179 | +Status |
| 180 | +------ |
| 181 | + |
| 182 | + |
| 183 | +Authors |
| 184 | +~~~~~~~ |
| 185 | + |
| 186 | +- Aubin Bikouo (@abikouo) |
0 commit comments