Add prepare-workspace-openshift role

Change-Id: I41ce5a1ec5ca8b1b101af77169e31fc4a9131ae9
This commit is contained in:
Tristan de Cacqueray 2019-09-06 14:32:34 +00:00 committed by Tristan Cacqueray
parent 2b670759ed
commit 517bc81404
5 changed files with 38 additions and 0 deletions

View File

@ -24,6 +24,7 @@ General Purpose Roles
.. zuul:autorole:: persistent-firewall
.. zuul:autorole:: prepare-workspace
.. zuul:autorole:: prepare-workspace-git
.. zuul:autorole:: prepare-workspace-openshift
.. zuul:autorole:: remove-build-sshkey
.. zuul:autorole:: remove-gpgkey
.. zuul:autorole:: remove-sshkey

View File

@ -0,0 +1,15 @@
Prepare remote workspaces
This role can be used instead of the `prepare-workspace` role when the
synchronize module doesn't work with kubectl connection. It copies the
prepared source repos to the pods' cwd using the `oc rsync` command.
This role is intended to run once before any other role in a Zuul job.
This role requires the origin-clients to be installed.
**Role Variables**
.. zuul:rolevar:: openshift_pods
:default: {{ zuul.resources }}
The dictionary of pod name, pod information to copy the sources to.

View File

@ -0,0 +1 @@
openshift_pods: "{{ zuul.resources }}"

View File

@ -0,0 +1,4 @@
---
- include_tasks: rsync.yaml
when: item.1.pod is defined
loop: "{{ openshift_pods.items()|list }}"

View File

@ -0,0 +1,17 @@
---
- name: Create src directory
command: >
oc --context "{{ item.1.context }}"
--namespace "{{ item.1.namespace }}"
exec {{ item.1.pod }} mkdir src
delegate_to: localhost
- name: Copy src repos to the pod
command: >
oc --context "{{ item.1.context }}"
--namespace "{{ item.1.namespace }}"
rsync -q --progress=false
{{ zuul.executor.src_root }}/
{{ item.1.pod }}:src/
no_log: true
delegate_to: localhost