Ansible git模块没有检出分支

gth*_*eys 9 git ansible

我正在使用ansible来检查EC2 Web实例上的web应用程序.我的代码如下:

- name: Checkout the source code
  git:
    accept_hostkey=yes
    depth=5
    dest={{ webapp_dir }}
    force=yes
    key_file=/var/tmp/webapp_deploy_key
    repo=git@github.com:MyRepo/web-app.git
    update=yes
    version={{ webapp_version }}
  register: git_output
Run Code Online (Sandbox Code Playgroud)

只要webapp_version = master它完美无缺.但是只要我输入SHA1或分支名称就会失败.

TASK: [webapp | Checkout the source code]
************************************* 
failed: [52.17.69.83] => {"failed": true}
msg: Failed to checkout some-branch
Run Code Online (Sandbox Code Playgroud)

这很奇怪.

我用:

› ansible --version
ansible 1.9.1
  configured module search path = None
Run Code Online (Sandbox Code Playgroud)

gth*_*eys 7

我将再次回答我自己的一个问题.这depth=5是杀手.如果你想访问所有不同的版本,请不要使用它;)

  • 对于其他任何人来到这里,我必须删除`depth`属性然后`rm -rf`我的整个git目录才能工作. (4认同)