Git clone hangs in Ansible

What I’ve tried:

1) Copy private key from local machine to server and clone with it:

  • Ansible and Git Permission denied (publickey) at Git Clone
  • How to forward ssh key in ansible to checkout git repository on target machine from origin?
  • Ansible with Github: Permission denied (Publickey)
  • Ansible 1.6 + Vagrant 1.6 ssh forwarding doesn't look like it's working
  • Ansible Repo - structure
  • private repo is getting cloned via ansible playbook but private gem are not getting installed
  • - name: clone repo
      sudo: yes
      git: repo={{ app_repo }} dest={{ app_repo_dir }} accept_hostkey=true key_file={{ssh_key}} version=master force=yes
    

    But it hangs. As I understand this issue occurs ’cause key has passphrase.

    2) Use ForwardAgent in ansible.cfg:

    [ssh_connection]
    ssh_args = -o ForwardAgent=yes
    

    But for connection to server I use not standard ssh 22 port.

    How can I setup passphrase for key for git clone task in Ansible? Or any other ways to clone remote repository using Ansible?

    P.S. Yes, I can try to remove passphrase from key. But security aspects…

  • How to merge a branch into another with override option in git
  • Interactive rebase for only my commits
  • How to install portia, a python application from Github (Mac)
  • Can a “git rm -r -f <directory>” command be reverted?
  • Checking out a branch that manages a path with a submodule when the original branch does not
  • Git directory vs SVN directory
  • One Solution collect form web for “Git clone hangs in Ansible”

    1. ~/.ssh/config :

      Host canada.host.xxxx

      HostName canada.host.xxxx

      Port 2233

      User guest

      IdentityFile ~/.ssh/id_rsa.special

    2. 2.

    Copy private key from local machine to server and clone with it:

    • name: clone repo sudo: yes git: repo={{ app_repo }} dest={{ app_repo_dir }} accept_hostkey=true key_file={{ssh_key}}

    This is Copy private key from local machine to server and clone with it:

    - name: Put artifact to target
      sudo: yes
      copy: src="{{ app_repo_dir }}" dest="{{ app_repo_dir }}"
    
    - name: clone repo
      sudo: yes
      git: repo={{ app_repo }} dest={{ app_repo_dir }} accept_hostkey=true key_file={{ssh_key}} version=master force=yes
    

    PS:
    Maybe you should use local_action?

    ansible-playbook -vvv will show you the problem

    Git Baby is a git and github fan, let's start git clone.