Merge "Add prepare-workspace-openshift role"

This commit is contained in:
Zuul 2020-01-23 16:19:37 +00:00 committed by Gerrit Code Review
commit 5ea9bac2df
5 changed files with 38 additions and 0 deletions

View File

@ -25,6 +25,7 @@ General Purpose Roles
.. zuul:autorole:: persistent-firewall .. zuul:autorole:: persistent-firewall
.. zuul:autorole:: prepare-workspace .. zuul:autorole:: prepare-workspace
.. zuul:autorole:: prepare-workspace-git .. zuul:autorole:: prepare-workspace-git
.. zuul:autorole:: prepare-workspace-openshift
.. zuul:autorole:: remove-build-sshkey .. zuul:autorole:: remove-build-sshkey
.. zuul:autorole:: remove-gpgkey .. zuul:autorole:: remove-gpgkey
.. zuul:autorole:: remove-sshkey .. 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