Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ansible: git module is hanging

Tags:

git

ansible

I am using Ansible and I am having a hard time making the git module works. I have read several posts of people having the same problem, I looked at the ansible doc, well I tried almost everything. I found a clear tutorial that I followed until they use git but again I have a problem when I use my repository... :/ The git task just hangs... no error, it is just stuck!

Here is my host file:

[web] dev1 ansible_ssh_host=10.0.0.101 ansible_ssh_user=root 

This is a vagrant VM running on virtualbox on my computer.

I took the playbook from this tutorial and did all the steps until step 08: https://github.com/leucos/ansible-tuto/tree/master/step-08

I run it on my VM, it works fine, then I add one task "Deploy my code" to use my repository... but this task does not work. It is a private repository on bitbucket. Does it make a difference?

- hosts: web   tasks:      - name: Deploy our awesome application       action: git repo=https://github.com/leucos/ansible-tuto-demosite.git dest=/var/www/awesome-app       tags: deploy      - name: Deploy my code       action: git repo=https://[email protected]/YAmikep/djangotutorial.git dest=/var/www/my-app       tags: deploy 

There might be something with the user, or the user running ansible, or the keys, etc, but I tried back and forth for hours and I am even more confused now... I just do not know what to do to debug that now and find out what is wrong and what I am missing.

Thanks.

like image 231
Michael Avatar asked Nov 22 '13 03:11

Michael


1 Answers

There are a couple of reasons why the git module might be hanging, but the most possible is that the git clone command is waiting for a confirmation if the host key should be added to your server's known hosts. To verify if this is the problem execute ansible with the flag: --verbose, so that it runs in verbose mode, this will give you more information about the error.

If you confirm that the known hosts is the problem, then you have two choices:

Solution 1:

To avoid this problem with the git module use the accept_hostkey parameter.

- name: ensure jquery repo is available   git: [email protected]:jquery/jquery.git version=master accept_hostkey=True 

Solution 2:

Use the ansible-sshknownhosts third-party module before using the core git module:

- name: ensure github is a known host   action: sshknownhosts host=github.com state=present   - name: ensure jquery repo is available   git: [email protected]:jquery/jquery.git version=master accept_hostkey=True 

Since the knownhosts is not a core ansible module, you will need to install it first, please refer to the github repo docs for more information hon how to install it.


another solution would be to disable ssh host key checking, but this has security implications, so unless you really know what you are doing it is best to avoid this.

like image 166
Marcos Abreu Avatar answered Oct 06 '22 19:10

Marcos Abreu