在Ansible中通过SSH进行GIT挂起,即使设置了ssh-agent转发也是如此

til*_*lda 31 git ssh timeout ssh-agent ansible

我已经设置了我能找到的每一个,但仍然从GitHub克隆一个repo挂起了配置过程.

我有:

Tom*_*don 61

只是为了扩展到fifda的答案,该配置可以放在你的剧本旁边的ansible.cfg文件中.例如:

ansible.cfg

[defaults]
transport = ssh

[ssh_connection]
ssh_args = -o ForwardAgent=yes
Run Code Online (Sandbox Code Playgroud)

我认为这样做比设置为env变量更好,因为将它放在conf文件中既更具声明性,也可以最大限度地减少您与项目合作的其他人所需的步骤.

Conf docs:http: //docs.ansible.com/intro_configuration.html#the-ansible-configuration-file

配置文件示例:https: //raw.github.com/ansible/ansible/devel/examples/ansible.cfg


til*_*lda 14

我想分享对我有用的答案:

https://groups.google.com/forum/#!msg/ansible-project/u6o-sWynMjo/69UwJfJPq7cJ - 来自Ansible Google Group

对于ansible,ssh-add首先在主机中加载ssh密钥.然后使用"ssh"作为连接类型并启用转发.

如:

$ ssh-add  
$ export ANSIBLE_TRANSPORT="ssh"  
$ export  ANSIBLE_SSH_ARGS="-o ForwardAgent=yes"
Run Code Online (Sandbox Code Playgroud)

有关运行代理的信息,请参阅ssh-add手册.

Ansible文档ssh-argshttp://docs.ansible.com/intro_configuration.html#ssh-args


loc*_*jay 7

这对我有用

- name: ensure known hosts
  shell: touch ~/.ssh/known_hosts
- name: remove github.com from known host
  shell: ssh-keygen -R github.com
  # >> instead of > to keep existing known_hosts file
- name: ensure github.com in known host
  shell: ssh-keyscan -H github.com >> ~/.ssh/known_hosts
Run Code Online (Sandbox Code Playgroud)

  • 没有必要因为git ansible模块有一个标志accept_hostkey来确保它.只需打开它. (14认同)