1
votes

Hi I'm attmepting to clone from a vsts git repository (ssh://********/_git/ClouderaAutomation) but ansible seems to just hang when I try. Below is a snippet of the git module being used.

name: Clone git repo.
  git:
   repo: "{{ repoToClone }}"
   dest: "/home/vagrant/ClouderaAutomation"
   accept_hostkey: yes
   clone: yes
  become: yes

repoToClone is ssh://********/_git/ClouderaAutomation. When i execute 'git clone' cmd directly on the remote servers it clones the repository without issue. However when I attempt to clone via ansible it just hangs with no error, here is the last line of the -vvv logs:

<192.168.33.30> SSH: EXEC sshpass -d15 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/9a3517bddd -tt 192.168.33.30 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-lugffujkolhidvafudbyhootlistpyyf; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1494346256.28-165153189526831/git.py; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1494346256.28-165153189526831/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''

1
is it the only issue with ansible ? and with which user are you able to clone manually on the remote machine ?Berlin
yes its the only issue I'm currently facing with Ansible. For example if I attempt to clone 'github.com/Microsoft/PowerBI-JavaScript.git' with the same ansible module it completes successfully. I was using the vagrant user manually.raah

1 Answers

1
votes

I managed to resolve my issue by including an additional parameter to my Ansible git module, -key_file.

Ansible Docs: Specify an optional private key file to use for the checkout.

Full module sample:

name: Clone git repo.
  git:
   repo: "{{ repoToClone }}"
   dest: "/home/vagrant/ClouderaAutomation"
   accept_hostkey: yes
   key_file: /home/vagrant/.ssh/id_rsa
  become: yes

Additional requirements:

  • Make sure you have generated an ssh keypair (ssh-keygen), I made one without a passphrase due to the answer given here by the OP.
  • Add the public key to the vsts server

Hopefully this helps anyone else who has the same issue.