GIT over SSH in Ansible hangs, eventhough ssh-agent forwarding is set up

tillda picture tillda · Jan 29, 2014 · Viewed 18.5k times · Source

I have set up everyhing I could find, but still cloning a repo from GitHub hangs the provisioning process.

I have:

  • server in known_hosts
  • .ssh/config

    Host github.com
      ForwardAgent yes
      StrictHostKeyChecking no
    
  • copied private key

  • public key is in authorized_keys
  • the command runs as vagrant user
  • the play is:

    - name: Checkout from git
      git: [email protected]:username/repositoryname.git dest=/srv/website
    

Answer

Tom Seldon picture Tom Seldon · Mar 31, 2014

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