Files
project-config/roles/use-cached-repos/tasks/main.yaml
James E. Blair 64da87d225 Zuulv3: fix reference to stat results in use-cached-repos
Change-Id: I2fda509eda5012075e2092ab8511625741f604ed
2017-08-30 13:07:57 -07:00

30 lines
968 B
YAML

- name: Find locally cached git repos
stat:
path: "/opt/git/{{ item.name }}"
with_items: "{{ zuul.projects }}"
register: cached_repos
- name: Clone cached repo to workspace
command: "git clone /opt/git/{{ item.0.name }} {{ ansible_user_dir }}/{{ item.0.src_dir}}"
args:
creates: "{{ ansible_user_dir }}/{{ item.0.src_dir}}"
when: item.1.stat.exists
with_together:
- "{{ zuul.projects }}"
- "{{ cached_repos.results }}"
- name: Clone upstream repo to workspace
command: "git clone https://{{ item.0.canonical_hostname }}/{{ item.0.name}} {{ ansible_user_dir }}/{{ item.0.src_dir}}"
args:
creates: "{{ ansible_user_dir }}/{{ item.0.src_dir}}"
when: not item.1.stat.exists
with_together:
- "{{ zuul.projects }}"
- "{{ cached_repos.results }}"
- name: Remove origin from local git repos
command: "git remote rm origin"
args:
chdir: "{{ ansible_user_dir }}/{{ item.src_dir}}"
with_items: "{{ zuul.projects }}"