Set force option to false by default
Now git-reset does not have force option [1]. So we're setting it
to False by default but enable to distros except Ubuntu Focal since
it has pretty modern git, while others don't
We also add rescue block not to hard fail in case parallel clone
experience issues.
[1] https://git-scm.com/docs/git-reset
Change-Id: I6e7f35b2aedfd5552f1f451a2b18182ae623ec0f
(cherry picked from commit 273d84be94
)
This commit is contained in:
parent
4dd5617acc
commit
f8f4c9b416
@ -60,7 +60,7 @@ options:
|
||||
force:
|
||||
description:
|
||||
Boolean. Apply --force flags to git clones wherever
|
||||
possible. Defaults to True. Not required.
|
||||
possible. Defaults to False. Not required.
|
||||
core_multiplier:
|
||||
description:
|
||||
Integer multiplier on the number of cores
|
||||
@ -258,7 +258,7 @@ def main():
|
||||
"default": 0},
|
||||
"force": {"required": False,
|
||||
"type": "bool",
|
||||
"default": True},
|
||||
"default": False},
|
||||
"core_multiplier": {"required": False,
|
||||
"type": "int",
|
||||
"default": 4},
|
||||
|
@ -116,6 +116,8 @@
|
||||
set_fact:
|
||||
clone_roles: "{{ clone_roles + user_roles }}"
|
||||
|
||||
- name: Clone git repos
|
||||
block:
|
||||
- name: Clone git repos (parallel)
|
||||
git_requirements:
|
||||
default_path: "{{ role_path_default }}"
|
||||
@ -124,8 +126,23 @@
|
||||
repo_info: "{{ clone_roles }}"
|
||||
retries: "{{ git_clone_retries }}"
|
||||
delay: "{{ git_clone_retry_delay }}"
|
||||
force: true
|
||||
force: "{{ not (ansible_distribution | lower == 'ubuntu' and ansible_distribution_version is version('20.04', '>=')) }}"
|
||||
core_multiplier: 4
|
||||
rescue:
|
||||
- name: Clone git repos (with git)
|
||||
git:
|
||||
repo: "{{ item.src }}"
|
||||
dest: "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}"
|
||||
version: "{{ item.version | default('master') }}"
|
||||
refspec: "{{ item.refspec | default(omit) }}"
|
||||
depth: "{{ item.depth | default('10') }}"
|
||||
update: true
|
||||
force: true
|
||||
with_items: "{{ clone_roles }}"
|
||||
register: git_clone
|
||||
until: git_clone is success
|
||||
retries: "{{ git_clone_retries }}"
|
||||
delay: "{{ git_clone_retry_delay }}"
|
||||
|
||||
vars:
|
||||
ansible_python_interpreter: "/opt/ansible-runtime/bin/python"
|
||||
|
Loading…
Reference in New Issue
Block a user