GIT over SSH in Ansible hangs, eventhough ssh-agent forwarding is set up
Just to expand on tillda's answer, that config can be placed in an ansible.cfg file alongside your playbook. e.g.:
ansible.cfg
[defaults]transport = ssh[ssh_connection]ssh_args = -o ForwardAgent=yes
I'd say it's better to do that than setting as an env variable, as placing it in a conf file is both more declarative and also will minimise the steps needed for other people you may be working with to going with a project.
Conf docs:http://docs.ansible.com/intro_configuration.html#the-ansible-configuration-file
Example config file:https://raw.github.com/ansible/ansible/devel/examples/ansible.cfg
I want to share the answer that worked for me:
https://groups.google.com/forum/#!msg/ansible-project/u6o-sWynMjo/69UwJfJPq7cJ - From Ansible Google Group
For ansible, ssh-add to load ssh keys in your host machine first.Then use "ssh" as connection type with forwarding enabled.
Such as:
$ ssh-add $ export ANSIBLE_TRANSPORT="ssh" $ export ANSIBLE_SSH_ARGS="-o ForwardAgent=yes"
See manual for ssh-add for running the agent.
The Ansible docs for ssh-args
are http://docs.ansible.com/intro_configuration.html#ssh-args
this works for me
- 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