Skip to content

Commit

Permalink
Resolve conflicts in terraform.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciechpietruszewski-tomtom committed Jun 21, 2019
1 parent 655ad74 commit 2bcee5f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/ansible/modules/cloud/misc/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
version_added: "2.5"
options:
state:
choices: ['planned', 'present', 'absent']
choices: ['planned', 'present', 'absent', 'output']
description:
- Goal state of given stage/project
required: false
Expand Down Expand Up @@ -275,7 +275,7 @@ def main():
binary_path=dict(type='path'),
workspace=dict(required=False, type='str', default='default'),
purge_workspace=dict(type='bool', default=False),
state=dict(default='present', choices=['present', 'absent', 'planned']),
state=dict(default='present', choices=['present', 'absent', 'planned', 'output']),
variables=dict(type='dict'),
variables_file=dict(type='path'),
plan_file=dict(type='path'),
Expand Down Expand Up @@ -354,13 +354,13 @@ def main():
command.append(plan_file)
else:
module.fail_json(msg='Could not find plan_file "{0}", check the path and try again.'.format(plan_file))
else:
elif state == 'planned':
plan_file, needs_application, out, err, command = build_plan(command, project_path, variables_args, state_file,
module.params.get('targets'), state, plan_file)
command.append(plan_file)

out, err = '', ''
if needs_application and not module.check_mode and not state == 'planned':
if needs_application and not module.check_mode and state not in ['planned', 'output']:
rc, out, err = module.run_command(command, cwd=project_path)
# checks out to decide if changes were made during execution
if '0 added, 0 changed' not in out and not state == "absent" or '0 destroyed' not in out:
Expand All @@ -384,6 +384,10 @@ def main():
else:
outputs = json.loads(outputs_text)

if state == 'output':
out = outputs_text
err = outputs_err

# Restore the Terraform workspace found when running the module
if workspace_ctx["current"] != workspace:
select_workspace(command[0], project_path, workspace_ctx["current"])
Expand Down

0 comments on commit 2bcee5f

Please sign in to comment.