From ae7e391dab35d07e9ff151490783ee7807265bc7 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Mon, 16 Apr 2018 18:13:13 +0530 Subject: [PATCH] Minor fixes in terraform module (#38438) This fix adds following - * Check for None or blank value in project_path * Make terraform binary path as required Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/cloud/misc/terraform.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/misc/terraform.py b/lib/ansible/modules/cloud/misc/terraform.py index 8f9efb97e43..18045c709a2 100644 --- a/lib/ansible/modules/cloud/misc/terraform.py +++ b/lib/ansible/modules/cloud/misc/terraform.py @@ -138,6 +138,8 @@ module = None def preflight_validation(bin_path, project_path, variables_args=None, plan_file=None): + if project_path in [None, ''] or '/' not in project_path: + module.fail_json(msg="Path for Terraform project can not be None or ''.") if not os.path.exists(bin_path): module.fail_json(msg="Path for Terraform binary '{0}' doesn't exist on this host - check the path and try again please.".format(bin_path)) if not os.path.isdir(project_path): @@ -217,7 +219,7 @@ def main(): if bin_path is not None: command = [bin_path] else: - command = [module.get_bin_path('terraform')] + command = [module.get_bin_path('terraform', required=True)] if force_init: init_plugins(command[0], project_path)