【发布时间】:2016-07-03 10:46:47
【问题描述】:
我有一个空的裸仓库,我正在尝试使用 Ansible 克隆它,但 git 模块正在尝试签出 master 并因此失败,因为在空仓库中没有这样的 refspec。
我让这个工作的唯一方法是一个 shell 命令来克隆 repo。
【问题讨论】:
我有一个空的裸仓库,我正在尝试使用 Ansible 克隆它,但 git 模块正在尝试签出 master 并因此失败,因为在空仓库中没有这样的 refspec。
我让这个工作的唯一方法是一个 shell 命令来克隆 repo。
【问题讨论】:
我尝试了各种方法,唯一有效的方法是添加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"
顺便说一句,我过滤了output.msg 而不是output.stderr,因为出于某种原因,该特定错误会发送到.msg,而不是.stderr。
【讨论】: