From 517bc81404b45baaa5c1a7ebcee2c16f0440ae3e Mon Sep 17 00:00:00 2001 From: Tristan de Cacqueray Date: Fri, 6 Sep 2019 14:32:34 +0000 Subject: [PATCH] Add prepare-workspace-openshift role Change-Id: I41ce5a1ec5ca8b1b101af77169e31fc4a9131ae9 --- doc/source/general-roles.rst | 1 + roles/prepare-workspace-openshift/README.rst | 15 +++++++++++++++ .../defaults/main.yaml | 1 + .../prepare-workspace-openshift/tasks/main.yaml | 4 ++++ .../tasks/rsync.yaml | 17 +++++++++++++++++ 5 files changed, 38 insertions(+) create mode 100644 roles/prepare-workspace-openshift/README.rst create mode 100644 roles/prepare-workspace-openshift/defaults/main.yaml create mode 100644 roles/prepare-workspace-openshift/tasks/main.yaml create mode 100644 roles/prepare-workspace-openshift/tasks/rsync.yaml diff --git a/doc/source/general-roles.rst b/doc/source/general-roles.rst index ba1dff296..b14e925a4 100644 --- a/doc/source/general-roles.rst +++ b/doc/source/general-roles.rst @@ -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 diff --git a/roles/prepare-workspace-openshift/README.rst b/roles/prepare-workspace-openshift/README.rst new file mode 100644 index 000000000..caa516316 --- /dev/null +++ b/roles/prepare-workspace-openshift/README.rst @@ -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. diff --git a/roles/prepare-workspace-openshift/defaults/main.yaml b/roles/prepare-workspace-openshift/defaults/main.yaml new file mode 100644 index 000000000..fa948958d --- /dev/null +++ b/roles/prepare-workspace-openshift/defaults/main.yaml @@ -0,0 +1 @@ +openshift_pods: "{{ zuul.resources }}" diff --git a/roles/prepare-workspace-openshift/tasks/main.yaml b/roles/prepare-workspace-openshift/tasks/main.yaml new file mode 100644 index 000000000..0d6d50ba3 --- /dev/null +++ b/roles/prepare-workspace-openshift/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include_tasks: rsync.yaml + when: item.1.pod is defined + loop: "{{ openshift_pods.items()|list }}" diff --git a/roles/prepare-workspace-openshift/tasks/rsync.yaml b/roles/prepare-workspace-openshift/tasks/rsync.yaml new file mode 100644 index 000000000..c90c4ed5c --- /dev/null +++ b/roles/prepare-workspace-openshift/tasks/rsync.yaml @@ -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