proximacentauri
proximacentauri

Reputation: 1879

ansible git clone times out

On a server I can run the following successfully:

ssh-agent bash -c 'ssh-add /path/key; git clone https://repo_path/repo_name.git'

The repo is cloned into 'repo_name'

However when I run the following ansible (2.2) script on a local machine, the clone task stalls indefinitely

- name: clone or pull latest web app code
  git: repo=https://repo_path/repo_name.git dest=/home/user/repo_name
     key_file=/path/key
     accept_hostkey=yes
     force=yes

Other tasks prior to the clone taks work ok (apt update, library installs etc)

I am using the following to check the paths are correct, and they seem OK:

- debug:
    msg: "about to clone code {{ code_repository }} to {{ base_dir }}"

Any ideas?

Upvotes: 1

Views: 1412

Answers (1)

VonC
VonC

Reputation: 1326636

Note: ssh-add /path/key and git clone https://repo_path/repo_name.git have nothing to do one with another.
ssh-add /path/key is for adding a passphrase-protected private SSH key to the ssh-agent, in order to cache said passphrase when it will be needed by an SSH URL.
And https://repo_path/... is an HTTPS URL, meaning it does not require the SSH key. At all.

The ansible git module does mention:

accept_hostkey

if yes, ensure that "-o StrictHostKeyChecking=no" is present as an ssh option.

Again, the URL is HTTPS, so it is not needed.

Try and remove key-file and accept_hostkey, to see if the HTTPS clone can proceed.


For an SSH URL, you need to make sure that:

Upvotes: 4

Related Questions