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 <andrii.ostapenko@att.com>
This commit is contained in:
Andrii Ostapenko 2021-05-10 18:23:08 -05:00
parent a2b70338c0
commit 6e5bef457a
No known key found for this signature in database
GPG Key ID: F3E83668DBB223B3

View File

@ -10,14 +10,21 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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 }}" - name: "Run script {{ gate_script_path }}"
environment: "{{ local_environment | combine(job_environment) }}"
shell: | shell: |
set -xe; set -xe;
{{ gate_script_path }} {{ gate_script_path }}
args: args:
chdir: "{{ zuul.project.src_dir }}" 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') }}"