diff --git a/templates/full-pipeline.yml b/templates/full-pipeline.yml index 15835df32c5ea0390277ce08f8fd69c8aee2f88d..7c73b416d0f400c3056a465f9a8b83d7b77a76c2 100644 --- a/templates/full-pipeline.yml +++ b/templates/full-pipeline.yml @@ -102,6 +102,21 @@ include: root_dir: $[[ inputs.root_dir ]] state_name: $[[ inputs.state_name ]] auto_apply: $[[ inputs.auto_apply ]] + - local: '/templates/plan.yml' + inputs: + as: 'destroy:plan' + stage: $[[ inputs.stage_cleanup ]] + version: $[[ inputs.version ]] + opentofu_version: $[[ inputs.opentofu_version ]] + image_registry_base: $[[ inputs.image_registry_base ]] + root_dir: $[[ inputs.root_dir ]] + state_name: $[[ inputs.state_name ]] + plan: destroy-plan.cache + destroy_plan: true + rules: + - if: '"$[[ inputs.create_destroy_job ]]" == "true"' + when: always + - when: never - local: '/templates/destroy.yml' inputs: as: 'destroy' @@ -112,6 +127,7 @@ include: root_dir: $[[ inputs.root_dir ]] state_name: $[[ inputs.state_name ]] auto_destroy: $[[ inputs.auto_apply ]] + plan: $[[ inputs.root_dir ]]/destroy-plan.cache rules: - if: '"$[[ inputs.create_destroy_job ]]" == "true"' when: always diff --git a/templates/plan.yml b/templates/plan.yml index 04e0b3acc08c50bf1f0f66f495075dd0851212ca..d47c4df1e174e52f45d4b9e14ce535f7dd059c75 100644 --- a/templates/plan.yml +++ b/templates/plan.yml @@ -42,6 +42,9 @@ spec: state_name: default: default description: 'Remote OpenTofu state name.' + plan: + default: 'plan.cache' + description: 'Path for the generated plan relative to the root directory' destroy_plan: default: false type: boolean @@ -64,7 +67,7 @@ spec: # See: https://docs.gitlab.com/ee/ci/yaml/#artifactspublic public: false paths: - - $[[ inputs.root_dir ]]/plan.cache + - $[[ inputs.root_dir ]]/$[[ inputs.plan ]] reports: terraform: $[[ inputs.root_dir ]]/plan.json rules: @@ -79,6 +82,7 @@ spec: variables: TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] + TF_PLAN_CACHE: $[[ inputs.root_dir ]]/$[[ inputs.plan ]] image: name: '$[[ inputs.image_registry_base ]]/gitlab-opentofu:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]' script: