Git clone hangs in Ansible

What I’ve tried:

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

  • Vagrant shell and ansible provisioning fail with bitbucket
  • How to fix Memory error in Ansible?
  • Run a build task only when changes have been pulled from a git repository
  • How to pass the value to Ansible playbook from Jenkins
  • How to link a deployment script/repo from an application repo in Gitlab CD?
  • ansible git clone Permission denied issue
  • - 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 block false user name and email in commits
  • simplest way to download tip/head revision from a sourceforge git repository?
  • BrotherBard's GitX won't load a certain repo
  • git rebase -i with squash cannot detach HEAD
  • Unable to find current origin/master revision in submodule path
  • Splitting one commit into 2 and get the resulting diff
  • 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.