openstack-ansible/zuul.d/playbooks/run.yml
Logan V 47eddb946b Use ZUUL_SRC_PATH to pass the path to Zuul git sources
To make get-ansible-role-requirements usable for 3rd party Zuul based
CI, which may have test nodes that do not conform to the previously
hard-coded /home/zuul home path for Zuul workers, we need to make
this Zuul sources path dynamic based on the home directory of the
Zuul worker user.

However, we cannot rely on {{ ansible_user_dir }} inside
get-ansible-role-requirements.yml, since it uses become: yes. This
means ansible_user_dir will be /root, rather than the Zuul user's
home directory.

The solution is to pass the ZUUL_SRC_PATH that Zuul is operating
with into the OSA test job environment, and use this environment var
inside our role cloning playbook to locate the Zuul sources.

Change-Id: Id71c6502741285e7b83d40be8006e82c9960b7ff
2018-08-08 20:41:32 +00:00

30 lines
985 B
YAML

- hosts: all
tasks:
- name: Set the Zuul sources path
set_fact:
zuul_src_path: "{{ ansible_user_dir }}/src"
- name: Set current test repo (cross-repo)
set_fact:
current_test_repo: "git.openstack.org/{{ osa_test_repo }}"
when:
- osa_test_repo is defined
- name: Set current test repo (non-cross-repo)
set_fact:
current_test_repo: "{{ zuul.project.canonical_name }}"
when:
- osa_test_repo is not defined
- name: Run gate-check-commit.sh script
become: yes
become_user: root
command: "scripts/gate-check-commit.sh {{ scenario }} {{ action }} {{ install_method }}"
args:
chdir: "src/{{ current_test_repo }}"
environment:
# ZUUL_SRC_PATH is used by tests/get-ansible-role-requirements to
# where the CI provided git sources were cloned.
ZUUL_SRC_PATH: "{{ zuul_src_path }}"
ANSIBLE_PACKAGE: "{{ ansible_package | default('') }}"