From 6e5bef457a5800bb7f282a2bd7817f1e1fdf9946 Mon Sep 17 00:00:00 2001 From: Andrii Ostapenko Date: Mon, 10 May 2021 18:23:08 -0500 Subject: [PATCH] Add ability to pass environment to gate runner from job Introduces an ability to pass custom environment that has the highest precedence from job definition for airshipctl-gate-runner playbook, e.g.: job: name: test-job playbook: run: playbooks/airshipctl-gate-runner.yaml vars: job_environment: FOO: BAR Defined environment variables complete/replace default playbook variables. Change-Id: Ib11480068141315126a80f3952b6882cdb7439ae Signed-off-by: Andrii Ostapenko --- roles/airshipctl-run-script/tasks/main.yaml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/roles/airshipctl-run-script/tasks/main.yaml b/roles/airshipctl-run-script/tasks/main.yaml index ff46adb14..e13b03d3d 100644 --- a/roles/airshipctl-run-script/tasks/main.yaml +++ b/roles/airshipctl-run-script/tasks/main.yaml @@ -10,14 +10,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Set default_zuul_dir + set_fact: + default_zuul_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" + +- name: Set env facts + set_fact: + local_environment: + AIRSHIP_CONFIG_PHASE_REPO_URL: "{{ remote_work_dir | default(local_src_dir) | default(default_zuul_dir) }}" + SITE: "{{ site | default('test-site') }}" + job_environment: "{{ job_environment | default({}) }}" + - name: "Run script {{ gate_script_path }}" + environment: "{{ local_environment | combine(job_environment) }}" shell: | set -xe; {{ gate_script_path }} args: chdir: "{{ zuul.project.src_dir }}" - vars: - default_zuul_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" - environment: - AIRSHIP_CONFIG_PHASE_REPO_URL: "{{ remote_work_dir | default(local_src_dir) | default(default_zuul_dir) }}" - SITE: "{{ site | default('test-site') }}"