From 1a806f04e21a5dc9f161461d11e0bc30c7698d14 Mon Sep 17 00:00:00 2001 From: Denis Fortin Date: Tue, 18 Aug 2020 10:14:17 +0200 Subject: [PATCH] terraform: Add parameter for plan file Add terraform_plan parameter to be defined when using apply command. It allows to specify a plan file to apply. Change-Id: I2858317e4dd560030a367b2cd2ac43db5585152a --- roles/terraform/README.rst | 4 ++++ roles/terraform/defaults/main.yaml | 1 + roles/terraform/tasks/main.yaml | 1 + 3 files changed, 6 insertions(+) diff --git a/roles/terraform/README.rst b/roles/terraform/README.rst index 50a98a1ae..4bd0aaf2e 100644 --- a/roles/terraform/README.rst +++ b/roles/terraform/README.rst @@ -17,6 +17,10 @@ Run terraform command. Assumes the appropriate version of terraform has been ins String of extra command line options to pass to terraform. +.. zuul:rolevar:: terraform_plan + + Optional. Path to the plan file to use when using 'apply' command. + .. zuul:rolevar:: terraform_workspace Name of the workspace to operate against. diff --git a/roles/terraform/defaults/main.yaml b/roles/terraform/defaults/main.yaml index d6caa23bc..e59581a22 100644 --- a/roles/terraform/defaults/main.yaml +++ b/roles/terraform/defaults/main.yaml @@ -1,5 +1,6 @@ terraform_executable: "{{ ansible_user_dir }}/.local/bin/terraform" terraform_extra_args: "" +terraform_plan: "" terraform_create_workspace: false terraform_purge_workspace: false terraform_comment: true diff --git a/roles/terraform/tasks/main.yaml b/roles/terraform/tasks/main.yaml index 6fe8038fc..2bc054d40 100644 --- a/roles/terraform/tasks/main.yaml +++ b/roles/terraform/tasks/main.yaml @@ -59,6 +59,7 @@ -input=false {{ terraform_extra_args }} {% if terraform_command == 'apply' or terraform_command == 'destroy' %}-auto-approve{% endif %} + {{ terraform_plan }} args: chdir: "{{ zuul_work_dir }}" environment: