【问题标题】:How do I clone an empty bare repository with Ansible git module?如何使用 Ansible git 模块克隆一个空的裸存储库?
【发布时间】:2016-07-03 10:46:47
【问题描述】:

我有一个空的裸仓库,我正在尝试使用 Ansible 克隆它,但 git 模块正在尝试签出 master 并因此失败,因为在空仓库中没有这样的 refspec。

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

【问题讨论】:

    标签: git ansible


    【解决方案1】:

    我尝试了各种方法,唯一有效的方法是添加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

    【讨论】:

    • 太棒了!找了很久,谢谢!
    • 我不再从事这个项目,但我会接受。看起来是正确的
    猜你喜欢
    • 1970-01-01
    • 2017-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-04
    • 1970-01-01
    • 2012-09-03
    • 1970-01-01
    相关资源
    最近更新 更多