Skip to content

Improve preflight validation #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/module_utils/terraform_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def show(self, state_or_plan_file_path: str) -> Optional[TerraformShow]:
return TerraformShow.from_json(result)

def validate(self, version: LooseVersion, variables_args: List[str]) -> None:
command = ["validate"]
command = ["validate", "-no-color"]
if version < LooseVersion("0.15.0"):
command += variables_args
self._run(*command, check_rc=True)
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ def main() -> None:
for f in variables_files:
variables_args.extend(["-var-file", f])

preflight_validation(terraform, terraform_binary, project_path, checked_version, variables_args)

# only use an existing plan file if we're not in the deprecated "planned" mode
if plan_file and state != "planned":
if not any([os.path.isfile(project_path + "/" + plan_file), os.path.isfile(plan_file)]):
Expand Down Expand Up @@ -586,8 +588,6 @@ def main() -> None:
out = plan_stdout
err = plan_stderr

preflight_validation(terraform, terraform_binary, project_path, checked_version, variables_args)

try:
planned_state = terraform.show(plan_file_to_apply)
if planned_state is not None:
Expand Down