From b580f2929dd9048e0d2752463b62994d1114ae1b Mon Sep 17 00:00:00 2001 From: Christophe Drevet-Droguet Date: Sat, 21 Dec 2019 12:50:31 +0100 Subject: [PATCH] terraform workspace list failure warns instead of fails (#65044) * terraform workspace list failure warns instead of fails Fixes #64788 * add a changelog fragment --- changelogs/fragments/65044-fix-terraform-no-workspace.yaml | 2 ++ lib/ansible/modules/cloud/misc/terraform.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/65044-fix-terraform-no-workspace.yaml diff --git a/changelogs/fragments/65044-fix-terraform-no-workspace.yaml b/changelogs/fragments/65044-fix-terraform-no-workspace.yaml new file mode 100644 index 00000000000..3fc9f5918d0 --- /dev/null +++ b/changelogs/fragments/65044-fix-terraform-no-workspace.yaml @@ -0,0 +1,2 @@ +bugfixes: +- terraform module - fixes usage for providers not supporting workspaces diff --git a/lib/ansible/modules/cloud/misc/terraform.py b/lib/ansible/modules/cloud/misc/terraform.py index 3b7ad647d6e..90b47c5bccf 100644 --- a/lib/ansible/modules/cloud/misc/terraform.py +++ b/lib/ansible/modules/cloud/misc/terraform.py @@ -209,7 +209,7 @@ def get_workspace_context(bin_path, project_path): command = [bin_path, 'workspace', 'list', '-no-color'] rc, out, err = module.run_command(command, cwd=project_path) if rc != 0: - module.fail_json(msg="Failed to list Terraform workspaces:\r\n{0}".format(err)) + module.warn("Failed to list Terraform workspaces:\r\n{0}".format(err)) for item in out.split('\n'): stripped_item = item.strip() if not stripped_item: