Git clone hangs in Ansible

What I tried:

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

- 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 he is hanging. As I understand it, this problem occurs because the key has a passphrase.

2) Use ForwardAgent in ansible.cfg :

 [ssh_connection] ssh_args = -o ForwardAgent=yes 

But to connect to the server, I use a non-standard ssh 22 port.

How to set passphrase for key for git clone task in Ansible? Or any other ways to clone a remote repository using Ansible?

PS Yes, I can try to remove the passphrase from the key. But security aspects ...

+6
source share
1 answer
  • ~ / .ssh / config:

    Host canada.host.xxxx

    HostName canada.host.xxxx

    Port 2233

    User guest

    IdentityFile ~ / .ssh / id_rsa.special

    2.

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

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

This Copy the private key from the local computer to the 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

+1
source

All Articles