【问题标题】:Ansible hangs when pulling from vsts git repo从 vsts git repo 拉取时 Ansible 挂起
【发布时间】:2017-05-09 16:20:36
【问题描述】:

您好,我正在尝试从 vsts git 存储库 (ssh://********/_git/ClouderaAutomation) 克隆,但是当我尝试时,ansible 似乎只是挂起。下面是正在使用的 git 模块的 sn-p。

name: Clone git repo.
  git:
   repo: "{{ repoToClone }}"
   dest: "/home/vagrant/ClouderaAutomation"
   accept_hostkey: yes
   clone: yes
  become: yes

repoToClone 是 ssh://********/_git/ClouderaAutomation。当我直接在远程服务器上执行 'git clone' cmd 时,它会毫无问题地克隆存储库。但是,当我尝试通过 ansible 进行克隆时,它只是挂起而没有错误,这是 -vvv 日志的最后一行:

SSH:EXEC sshpass -d15 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/9a3517bddd -tt 192.168 .33.30 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo 成为-成功-lugffujkolhidvafudbyhootlistpyyf; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1494346256.28-165153189526831/git.py; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1494346256.28-165153189526831/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''

【问题讨论】:

  • 这是 ansible 的唯一问题吗?您可以使用哪个用户在远程机器上手动克隆?
  • 是的,这是我目前在使用 Ansible 时面临的唯一问题。例如,如果我尝试使用相同的 ansible 模块克隆“github.com/Microsoft/PowerBI-JavaScript.git”,它会成功完成。我手动使用 vagrant 用户。

标签: git ansible azure-pipelines azure-pipelines-release-pipeline


【解决方案1】:

我设法通过在我的 Ansible git 模块 -key_file 中添加一个附加参数来解决我的问题。

Ansible Docs:指定用于结帐的可选私钥文件。

完整模块示例:

name: Clone git repo.
  git:
   repo: "{{ repoToClone }}"
   dest: "/home/vagrant/ClouderaAutomation"
   accept_hostkey: yes
   key_file: /home/vagrant/.ssh/id_rsa
  become: yes

附加要求:

  • 确保您已经生成了一个 ssh 密钥对 (ssh-keygen),由于 OP 给出了 here 的答案,我制作了一个没有密码的密钥对。
  • 将公钥添加到 vsts 服务器

希望这可以帮助遇到同样问题的其他人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多