From 4566e65c4542bc7908d5d8899d66b1b93bba5e66 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Thu, 9 Dec 2021 13:11:26 +0000 Subject: [PATCH] Create yaml file of the zuul job vars for embedded ansible Drop copies of the 'zuul' dict from the executor ansible into files which can be read later by the embedded ansible. Change-Id: I756af31f9afeaccb44498c39d0e55200d4844544 --- zuul.d/playbooks/pre-gate-scenario.yml | 11 +++++++++++ zuul.d/playbooks/templates/osa-gate-scenario.yml.j2 | 3 ++- zuul.d/playbooks/templates/osa-job-vars.yml.j2 | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 zuul.d/playbooks/templates/osa-job-vars.yml.j2 diff --git a/zuul.d/playbooks/pre-gate-scenario.yml b/zuul.d/playbooks/pre-gate-scenario.yml index f3ba8901f8..57ee2938a5 100644 --- a/zuul.d/playbooks/pre-gate-scenario.yml +++ b/zuul.d/playbooks/pre-gate-scenario.yml @@ -23,6 +23,7 @@ install_methods: - distro - source + zuul_user_vars_file: "{{ ansible_env.HOME }}/osa-job-vars.yml" tasks: - name: Dynamically create scenario if not set set_fact: @@ -110,3 +111,13 @@ src: osa-gate-scenario.yml.j2 dest: "{{ zuul.executor.work_root }}/osa-gate-scenario.yml" delegate_to: localhost + + # Other playbooks can consume this vars file to access the + # Zuul job variables, see https://zuul-ci.org/docs/zuul/reference/jobs.html#user-jobs-job-variables + - name: Record the zuul user job variables for future use by embedded ansible + vars: + zuul_helper_var: + zuul: "{{ zuul }}" + template: + src: osa-job-vars.yml.j2 + dest: "{{ zuul_user_vars_file }}" diff --git a/zuul.d/playbooks/templates/osa-gate-scenario.yml.j2 b/zuul.d/playbooks/templates/osa-gate-scenario.yml.j2 index cf1ba2c5a6..fddaad258a 100644 --- a/zuul.d/playbooks/templates/osa-gate-scenario.yml.j2 +++ b/zuul.d/playbooks/templates/osa-gate-scenario.yml.j2 @@ -2,4 +2,5 @@ scenario: {{ scenario | to_json }} action: {{ action | to_json }} -install_method: {{ install_method | to_json }} \ No newline at end of file +install_method: {{ install_method | to_json }} +zuul_user_vars_file: {{ zuul_user_vars_file }} diff --git a/zuul.d/playbooks/templates/osa-job-vars.yml.j2 b/zuul.d/playbooks/templates/osa-job-vars.yml.j2 new file mode 100644 index 0000000000..077fdd9f30 --- /dev/null +++ b/zuul.d/playbooks/templates/osa-job-vars.yml.j2 @@ -0,0 +1,2 @@ +--- +{{ zuul_helper_var | to_nice_yaml(indent=2) }}