diff --git a/roles/mirror-workspace-git-repos/README.rst b/roles/mirror-workspace-git-repos/README.rst new file mode 100644 index 000000000..b6e4ed940 --- /dev/null +++ b/roles/mirror-workspace-git-repos/README.rst @@ -0,0 +1,6 @@ +Mirror the local git repos to remote nodes + +This role uses git operations (unlike :zuul:role:`prepare-workspace` +which uses rsync) to mirror the local prepared git repos to the remote +nodes. This may be useful if the remote node already has a copy of +some or all of the git repos. diff --git a/roles/mirror-workspace-git-repos/tasks/main.yaml b/roles/mirror-workspace-git-repos/tasks/main.yaml new file mode 100644 index 000000000..20410dbc1 --- /dev/null +++ b/roles/mirror-workspace-git-repos/tasks/main.yaml @@ -0,0 +1,19 @@ +- name: Synchronize src repos to workspace directory + command: "git push --mirror git+ssh://{{ ansible_user }}@{{ ansible_host }}/{{ ansible_user_dir }}/{{ item.src_dir}}" + chdir: "{{ zuul.executor.src_root }}/{{ item.src_dir }}" + with_items: "{{ zuul.projects }}" + delegate_to: localhost + +- name: Determine local HEAD + shell: "git status |head -1 |awk '{ print $NF }'" + chdir: "{{ zuul.executor.src_root }}/{{ item.src_dir }}" + with_items: "{{ zuul.projects }}" + delegate_to: localhost + register: statuses + +- name: Checkout local HEAD on remote + command: "git checkout {{ item.1 }}" + chdir: "{{ zuul.executor.src_root }}/{{ item.0.src_dir }}" + with_together: + - "{{ zuul.projects }}" + - "{{ statuses }}"