【问题标题】:Cloning git project with submodules using ansible使用 ansible 克隆带有子模块的 git 项目
【发布时间】:2017-09-11 11:33:22
【问题描述】:

虽然看起来很简单,但我的 ansible 设置在尝试克隆具有子模块的 git 存储库时会挂起。 'parent' repo 被克隆没有问题,但是 ansible 任务无法克隆子模块并且实际上在此之后挂起,几乎就像它期待一些响应一样......

这是我克隆 repo 的 ansible 任务:

- name: Clone/Pull the {{ certificate_authority.repo.name }} repository
  become: yes
  git: repo="{{ ca.repo.url }}" force=yes accept_hostkey=yes clone=yes version="{{ git_branch | default(git_tag) }}"
       dest="{{ ca.repo.dest }}" key_file={{ ca.repo.key.location }}/{{ ca.repo.key.name }} recursive=yes track_submodules=yes

知道为什么 ansible 会挂起克隆这个 repo 吗?

【问题讨论】:

  • 使用-vvv 运行您的剧本是否会产生任何有用的细节?如果您在挂起时运行ps,它正在运行的git 命令行是什么?你能在同一系统上从命令行成功克隆它吗?
  • Running with -vvvv 包括以下有趣的 sn-p ...Looking up /var/folders/z9/v1czs6dd7vb5jtq_0fr8f5y80000gp/T/tmp_lrYWR\r\ndebug3: Sent message fd 8 T:17 I:2\r\ndebug3: Received stat reply T:101 I:2\r\ndebug1: Couldn\'t stat remote file: No such file or directory\r\ndebug3: Sent message SSH2_FXP_OPEN I:3 ... SSH2_FXP_STATUS 0\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')。运行ps aux|grep git 显示以下正在运行`
  • 并运行 ps aux | grep git 显示正在运行的命令是 /usr/bin/python /tmp/ansible_6X_csE/ansible_module_git.py/usr/bin/git submodule update --init --recursive --force/bin/sh /usr/lib/git-core/git-submodule update --init --recursive --force(对于 3 个子模块中的每一个)、git submodule--helper update-clone/usr/lib/git-core/git submodule--helper clone --path lib/first-subproject --name lib/first-subproject --url https://reayn@bitbucket.org/reayn/first-subproject.git。所以看起来 ansible 正在尝试克隆 repos

标签: git ansible


【解决方案1】:

对于遇到此问题的其他人,解决方法是确保您在.gitmodules 文件中的子模块使用git 协议,即ssh://git@....

【讨论】:

  • +100 我不明白为什么 ansible git 模块在手动执行 git pull 时提示我输入密码工作正常。显然,事实证明我在手动拉动时并没有拉动子模块,因此在手动操作时是误报。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-06
相关资源
最近更新 更多