Skip to content
New issue

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

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

Already on GitHub? # to your account

Change order of name and state_file in command #19

Merged
merged 1 commit into from
Dec 12, 2022
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
bugfixes:
- terraform_output module - when providing name and state_file parameters, the value of the requested output wasn't returned.
This issue was solved by changing the order of the name and state parameters in the invoked Terraform command (https://github.com/ansible-collections/cloud.terraform/pull/19).
2 changes: 1 addition & 1 deletion plugins/modules/terraform_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_outputs(terraform_binary, project_path, state_file, output_format, name=
"-no-color",
"-{0}".format(output_format)
]
outputs_command += ([name] if name else []) + _state_args(state_file)
outputs_command += _state_args(state_file) + ([name] if name else [])
rc, outputs_text, outputs_err = module.run_command(
outputs_command, cwd=project_path
)
Expand Down
15 changes: 8 additions & 7 deletions tests/integration/targets/terraform_output/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@
- terraform_output.outputs.my_output.value == "file generated"
- terraform_output.value is not defined

- name: Delete results
cloud.terraform.terraform:
project_path: "{{ test_basedir }}"
state: absent
register: terraform_result
check_mode: false
- name: Terraform checkout - specified state file and specified output
cloud.terraform.terraform_output:
state_file: "{{ test_basedir }}/mycustomstate.tfstate"
name: my_output
register: terraform_output
- assert:
that:
- terraform_result is changed
- terraform_output is not changed
- terraform_output.outputs is not defined
- terraform_output.value == "file generated"