zuul-jobs/roles/prepare-workspace-git/tasks/main.yaml
Paul Belanger 1e92a67db6 Revert "Ensure git is installed in prepare-workspace-git role"
This is breaking jobs in zuul.ansible.com, as there is an issue with
order with DNS.  In our base jobs, we first configure ensure git repos
are installed on the node, then configure the node for infra things
like dns, package mirrors, etc.  In our case, dns hasn't been fully
configured, which makes the package install fail.

I would propose we revert this change and re-release diskimage-builder. Or
have git considered an image based dependency.

A workaround for now has been to revert DIB, to rebuild images adding
back git.  However, this was exposed due to us missing one image.

This reverts commit 5d09503c88.

Change-Id: I533cbec83f7525175b9a94d70a61ba7424154aa6
2020-08-20 16:13:35 +00:00

65 lines
2.2 KiB
YAML

- name: Find locally cached git repos
stat:
path: "{{ cached_repos_root }}/{{ zj_project.canonical_name }}"
with_items: "{{ zuul.projects.values() | list }}"
loop_control:
loop_var: zj_project
register: cached_repos
# We do a bare clone here first so that we skip creating a working copy that
# will be overwritten later anyway.
- name: Clone cached repo to workspace
shell: |
set -e
git clone --bare {{ cached_repos_root }}/{{ zj_project.0.canonical_name }} {{ ansible_user_dir }}/{{ zj_project.0.src_dir }}/.git
cd {{ ansible_user_dir }}/{{ zj_project.0.src_dir }}
git config --local --bool core.bare false
args:
creates: "{{ ansible_user_dir }}/{{ zj_project.0.src_dir }}"
when: zj_project.1.stat.exists
with_together:
- "{{ zuul.projects.values() | list }}"
- "{{ cached_repos.results }}"
loop_control:
loop_var: zj_project
# ANSIBLE0006: If we use the git module, we get warning
# ANSIBLE0004 since we do not give an explicit version
tags:
- skip_ansible_lint
- name: Initialize non-cached repos
command: "git init {{ ansible_user_dir }}/{{ zj_project.0.src_dir }}"
args:
creates: "{{ ansible_user_dir }}/{{ zj_project.0.src_dir }}"
when: not zj_project.1.stat.exists
with_together:
- "{{ zuul.projects.values() | list }}"
- "{{ cached_repos.results }}"
loop_control:
loop_var: zj_project
# ANSIBLE0006: If we use the git module, we get warning
# ANSIBLE0004 since we do not give an explicit version
tags:
- skip_ansible_lint
- name: Remove origin from local git repos and replace it by the zuul fake origin
# To be idempotent, remove origin only if it's found in the local list.
shell: |
set -e
git remote -v | grep origin && git remote rm origin || true
git remote add origin file:///dev/null
args:
chdir: "{{ ansible_user_dir }}/{{ zj_project.src_dir }}"
with_items: "{{ zuul.projects.values() | list }}"
loop_control:
loop_var: zj_project
# ANSIBLE0006: git remote is not supported by ansible module
tags:
- skip_ansible_lint
# TODO(tobiash): we might want to deprecate the role mirror-workspace-git-repos
# and move it here.
- name: Synchronize repos
import_role:
name: mirror-workspace-git-repos