如何使用 Ansible git 模块克隆一个空的裸存储库?

dei*_*iga 5 git ansible

我有一个空的裸存储库,我试图用 Ansible 克隆它,但是 git 模块正在尝试结帐master并因此失败,因为空存储库中没有这样的 refspec。

我让这个工作的唯一方法是一个 shell 命令来克隆 repo。

小智 4

我尝试了各种方法,唯一有效的方法是添加ignore_errors: true并检查导致 Ansible 模块失败的原因。我知道这不是最佳的,但它有效,而且我们不会让所有错误都通过:

- git: repo=<YOUR REPO> dest=<DEST>
  ignore_errors: true
  register: output
- name: check the error that failed the git module
  fail: msg="{{ output.msg }}"
  when: "'Failed to checkout branch master' not in output.msg"
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我过滤了 ,output.msg而不是 ,output.stderr因为由于某种原因,该特定错误它会发送到 ,.msg但不会发送到.stderr