Add mirror-workspace-git-repos role

Change-Id: I6958e95a9ea31ab8ae027a9b33069d74be615d91
This commit is contained in:
James E. Blair 2017-08-29 15:23:02 -07:00
parent ead78fed13
commit 348598e96a
2 changed files with 25 additions and 0 deletions

View File

@ -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.

View File

@ -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 }}"