[英]How do I clone an empty bare repository with Ansible git module?
I have an empty and bare repository which I'm trying to clone with Ansible, but the git module is trying to checkout master
and thus fails, since there is no such refspec in an empty repo. 我有一个空的裸存储库,我正在尝试使用Ansible克隆,但git模块正在尝试检出master
并因此失败,因为在空的repo中没有这样的refspec。
My only way to get this working has been a shell command to just clone the repo. 我唯一的方法是使用shell命令来克隆repo。
I tried in every way and the only way that worked was to add ignore_errors: true
and than check what made the Ansible module to fail. 我尝试过各种方式,唯一有效的方法是添加ignore_errors: true
然后检查是什么让Ansible模块失败。 I know it is not optimal but it works and we are not letting all the errors to pass thru: 我知道它不是最佳的,但它有效,我们不会让所有的错误通过:
- 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"
BTW I filter the output.msg
and not the output.stderr
because for some reason on that specific error it goes out to the .msg
but not to the .stderr
. 顺便说一句,我过滤了output.msg
而不是output.stderr
因为出于某种原因,它出现在.msg
而不是.stderr
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.