From 348598e96aac742954fa326a15a4ef8fd7f71b8b Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 29 Aug 2017 15:23:02 -0700 Subject: [PATCH] Add mirror-workspace-git-repos role Change-Id: I6958e95a9ea31ab8ae027a9b33069d74be615d91 --- roles/mirror-workspace-git-repos/README.rst | 6 ++++++ .../tasks/main.yaml | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 roles/mirror-workspace-git-repos/README.rst create mode 100644 roles/mirror-workspace-git-repos/tasks/main.yaml 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 }}"