From d02b8507d1e265a5413b8ffe80bf9ebf031f94ad Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 11 Mar 2022 06:56:07 +0100 Subject: [PATCH] Allow complex values in variables parameter of terraform module (#4281) (#4341) * Allow complex values in variables parameter Signed-off-by: Webster Mudge * Add changelog fragment Signed-off-by: Webster Mudge * Update changelogs fragments formatting Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit 4cc7f413953606cda79596c7682eac0319936199) Co-authored-by: Webster Mudge --- changelogs/fragments/4281-terraform-complex-variables.yml | 2 ++ plugins/modules/cloud/misc/terraform.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/4281-terraform-complex-variables.yml diff --git a/changelogs/fragments/4281-terraform-complex-variables.yml b/changelogs/fragments/4281-terraform-complex-variables.yml new file mode 100644 index 0000000000..92538791f0 --- /dev/null +++ b/changelogs/fragments/4281-terraform-complex-variables.yml @@ -0,0 +1,2 @@ +bugfixes: + - terraform - fix ``variable`` handling to allow complex values (https://github.com/ansible-collections/community.general/pull/4281). \ No newline at end of file diff --git a/plugins/modules/cloud/misc/terraform.py b/plugins/modules/cloud/misc/terraform.py index 8eca14e712..310dd77c8e 100644 --- a/plugins/modules/cloud/misc/terraform.py +++ b/plugins/modules/cloud/misc/terraform.py @@ -443,7 +443,7 @@ def main(): for k, v in variables.items(): variables_args.extend([ '-var', - '{0}={1}'.format(k, v) + '{0}={1}'.format(k, json.dumps(v)) ]) if variables_files: for f in variables_files: