简体   繁体   中英

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.

My only way to get this working has been a shell command to just clone the 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. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM