You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using terraform module with state=present with defined state_file, the resource are created and terraform state is written to specified state_file.
ok: [localhost] => {
"terraform_output": {
"changed": true,
"command": "/usr/bin/terraform apply -no-color -input=false -auto-approve -lock=true /tmp/tmp5q4lttoj.tfplan",
When using terraform module with state=absent with defined state_file, no resource are destroyed as terraform state file is ignored.
ok: [localhost] => {
"terraform_output": {
"changed": false,
"command": "/usr/bin/terraform destroy -no-color -auto-approve -lock=true -var-file /opt/terraform/vm_opvm/vm_destroy.tfvars.json",
"failed": false,
"stdout": "\nNo changes. No objects need to be destroyed.\n\nEither you have not created any objects yet or the existing objects were\nalready deleted outside of Terraform.\n\nDestroy complete! Resources: 0 destroyed.\n",
Solution proposal:
In a file terraform.py add "command.extend(_state_args(state_file))" to the line 610:
*** 607,613 ****
if state == 'absent':
command.extend(variables_args)
command.extend(_state_args(state_file))
elif state == 'present' and plan_file:
if any([os.path.isfile(project_path + "/" + plan_file), os.path.isfile(plan_file)]):
command.append(plan_file)
Summary
When using terraform module with state=present with defined state_file, the resource are created and terraform state is written to specified state_file.
ok: [localhost] => {
"terraform_output": {
"changed": true,
"command": "/usr/bin/terraform apply -no-color -input=false -auto-approve -lock=true /tmp/tmp5q4lttoj.tfplan",
When using terraform module with state=absent with defined state_file, no resource are destroyed as terraform state file is ignored.
ok: [localhost] => {
"terraform_output": {
"changed": false,
"command": "/usr/bin/terraform destroy -no-color -auto-approve -lock=true -var-file /opt/terraform/vm_opvm/vm_destroy.tfvars.json",
"failed": false,
"stdout": "\nNo changes. No objects need to be destroyed.\n\nEither you have not created any objects yet or the existing objects were\nalready deleted outside of Terraform.\n\nDestroy complete! Resources: 0 destroyed.\n",
Solution proposal:
In a file terraform.py add "command.extend(_state_args(state_file))" to the line 610:
*** 607,613 ****
--- 607,612 ----
Issue Type
Bug Report
Component Name
terraform
Ansible Version
Community.general Version
Configuration
OS / Environment
Ubuntu22.04
Steps to Reproduce
Expected Results
The resource will be destroyed when running terraform module with state=absent
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: