git module hangs on clone with ansible-playbook, but works for ansible with same arguments

5,841 views
Skip to first unread message

nflacco

unread,
Nov 17, 2012, 6:42:52 PM11/17/12
to ansible...@googlegroups.com
I'm having trouble with the git module. It works via ansible but not ansible playbook. The arguments are exactly the same. I can ssh into the server and do a git clone from the command line in the target folder as well. Does ansible-playbook require different params for the git module?

Ansible

$ansible prod --user=ec2-user --private-key=key.pem -m git -a 'repo=g...@bitbucket.org:nflacco/myrepo.git dest=/srv/checkout/myrepo'
www.myserver.com | success >> {
    "after": "3c50d2b", 
    "before": null, 
    "changed": true
}

Ansible-playbook (playbook file)

---
- hosts: prod
  sudo: True
  vars:
    node_version: "0.6.13"
  tasks:
  - name: Install Git
    action: yum pkg=git state=latest
  - name: Get myrepo
    action: git repo=g...@bitbucket.org:nflacco/myrepo.git dest=/srv/checkout/myrepo

Here is the command line output (with verbose), after I manually stop it because it hangs ad infinium:

TASK: [Install Git] ********************* 
ok: [www.myserver.com] => {"changed": false, "msg": "", "rc": 0, "results": ["All packages providing git are up to date"]}
TASK: [Get myrepo] ********************* 
^C32
ERROR: interupted

When I use more than the stub playbook above (copy git ssh keys and bunch of other stuff), ansible-playbook creates an empty folder (with .git subfolder) and hangs.
 

Serge van Ginderachter

unread,
Nov 18, 2012, 6:53:04 AM11/18/12
to ansible...@googlegroups.com
+1 for me, I noticed that same behaviour with ansible-playbook. Didn't test with plain ansible though.
 
 

--
 
 

Michael DeHaan

unread,
Nov 18, 2012, 10:17:20 AM11/18/12
to ansible...@googlegroups.com
It's exactly the same module.

You may be seeing issues with repeated executions.

nflacco

unread,
Nov 18, 2012, 2:47:00 PM11/18/12
to ansible...@googlegroups.com
Repeated executions? I can execute the ansible command over and over, but the playbook one doesn't work from the start, apart from a creating the destination folder and .git subfolder.

With a clean destination the ansible command works great. The folder appears in the destination.

$ansible prod --user=ec2-user --private-key=key.pem -m git -a 'repo=g...@bitbucket.org:nflacco/myrepo.git dest=/srv/checkout/myrepo'
www.myserver.com | success >> {
    "after": "3c50d2b", 
    "before": null, 
    "changed": true
}

I executed it 3 more times and observed the destination folder- no changes as there were no new commits, but it worked fine.

$ansible prod --user=ec2-user --private-key=key.pem -m git -a 'repo=g...@bitbucket.org:nflacco/myrepo.git dest=/srv/checkout/myrepo'
www.myserver.com | success >> {
    "after": "3c50d2b", 
    "before": "3c50d2b", 
    "changed": false
}

I then pushed a commit and the change went through on the destination folder, and the ansible output reflected that:

$ansible prod --user=ec2-user --private-key=key.pem -m git -a 'repo=g...@bitbucket.org:nflacco/myrepo.git dest=/srv/checkout/myrepo'
www.myserver.com | success >> {
    "after": "c15c99c", 
    "before": "3c50d2b", 
    "changed": true
}

Serge van Ginderachter

unread,
Nov 19, 2012, 6:34:45 AM11/19/12
to ansible...@googlegroups.com
Some more info from my side:

When using the git module to deploy ansible from github, no problem.
When jusing the git module to deploy/update out ansible data repository, it hangs.

Looking at our internal "git server", I see these processes, all sleeping:

root      4799  0.0  0.7  73496  3764 ?        Ss   12:28   0:00  \_ sshd: root@pts/3    
root      4814  0.0  0.1  12776   756 ?        Ss   12:28   0:00      \_ /usr/lib/openssh/sftp-server
root      4815  0.0  0.1   4400   612 pts/3    Ss+  12:28   0:00      \_ /bin/sh -c /usr/bin/python /root/.ansible/tmp/ansible-1353324504.07-33812526893647/git
root      4816  0.1  1.4  37780  7120 pts/3    S+   12:28   0:00          \_ /usr/bin/python /root/.ansible/tmp/ansible-1353324504.07-33812526893647/git
root      4817  0.0  0.1   4400   612 pts/3    S+   12:28   0:00              \_ /bin/sh -c git clone -o acd ssh://git@svn-pr-1-mgt/~git/ansible-data.git /opt/ansible/data
root      4818  0.0  0.2  15236  1340 pts/3    S+   12:28   0:00                  \_ git clone -o acd ssh://git@svn-pr-1-mgt/~git/ansible-data.git /opt/ansible/data
root      4819  0.0  0.5  43528  2924 pts/3    S+   12:28   0:00                      \_ ssh git@svn-pr-1-mgt git-upload-pack '~git/ansible-data.git'


When I manually issue the git clone command on the ansible deployed host:

   git clone -o acd ssh://git@svn-pr-1-mgt/~git/ansible-data.git /opt/ansible/data

That works without a problem!

Could this be some weird behaviour caused by the ansible python "wrappers"?


   Serge

Serge van Ginderachter

unread,
Nov 19, 2012, 6:37:30 AM11/19/12
to ansible...@googlegroups.com
Initially, the git target directory was empty.
And after this manual clone, re-running the play yields:

root      5409  0.0  0.7  73496  3756 ?        Ss   12:35   0:00  \_ sshd: root@pts/3    
root      5424  0.0  0.1  12776   756 ?        Ss   12:35   0:00      \_ /usr/lib/openssh/sftp-server
root      5425  0.0  0.1   4400   612 pts/3    Ss+  12:35   0:00      \_ /bin/sh -c /usr/bin/python /root/.ansible/tmp/ansible-1353324934.89-62485605234825/git
root      5426  0.4  1.4  37780  7120 pts/3    S+   12:35   0:00          \_ /usr/bin/python /root/.ansible/tmp/ansible-1353324934.89-62485605234825/git
root      5435  0.0  0.1   4400   612 pts/3    S+   12:35   0:00              \_ /bin/sh -c git fetch acd
root      5436  0.0  0.2  15412  1264 pts/3    S+   12:35   0:00                  \_ git fetch acd
root      5437  0.0  0.5  43528  2924 pts/3    S+   12:35   0:00                      \_ ssh git@svn-pr-1-mgt git-upload-pack '~git/ansible-data.git'

on the git 'server', and hangs similarly.


  Serge

Stephen Fromm

unread,
Nov 19, 2012, 5:38:48 PM11/19/12
to ansible...@googlegroups.com
Based on the above, it appears you are using the git module with different users.  Can you confirm?  If so, are both users set up with the same ssh key to access the git repo via ssh?

It appears, based on your ps listing in a subsequent email, that ssh is hanging on something.  Is the ssh key password protected?  Is ssh-agent, or some similar mechanism, already running?  Have you tried strace'ing that process to see what it is waiting on?

sf

Serge van Ginderachter

unread,
Nov 20, 2012, 5:58:47 AM11/20/12
to ansible...@googlegroups.com
Hi Stephen,

On 19 November 2012 23:38, Stephen Fromm <sfr...@gmail.com> wrote:
Based on the above, it appears you are using the git module with different users.  Can you confirm?  If so, are both users set up with the same ssh key to access the git repo via ssh?

I'm not sure based on what you conclude this. Ansible-playbook runs from a local user on my machine and connects with root on the target machine.

It appears, based on your ps listing in a subsequent email, that ssh is hanging on something.  Is the ssh key password protected?  Is ssh-agent, or some similar mechanism, already running?  Have you tried strace'ing that process to see what it is waiting on?

The target machine has a ssh key managed by keychain which permits it to log on the "git ssh server" (with user git).

This must be my issue: the ansible runner isn't aware of the keychain environment as it doesn't load the shell environment, which is a problem on my side of course, not an ansible problem.


   Serge


gewin

unread,
Dec 30, 2012, 5:26:10 PM12/30/12
to ansible...@googlegroups.com
Same issue here.  I messed around with it for a few hours but ultimately chose to put ansible commands into a batch file instead of using a playbook.  Works fine that way.

Michael DeHaan

unread,
Feb 26, 2013, 1:42:35 PM2/26/13
to ansible...@googlegroups.com
output of "ansible --version" please


On Mon, Feb 25, 2013 at 1:31 PM, damon ciarelli <gda...@gmail.com> wrote:
> I seem to be running into the same problem.
>
> running this command works fine:
>
> $ ansible "post:&nginx" -u ubuntu -m git -a
> 'repo=g...@github.com:user/repo.git dest=/home/ubuntu/repo'
> <ipaddress> | success >> { etc.
>
>
> but in a playbook:
>
> action: git repo=g...@github.com:repo.git dest=/home/ubuntu/
>
> just hangs.
>
> while it's hanging, if I log into the server and do a "watch -n 1 "ps ax |
> grep git", I get:
>
> 23967 pts/3 S+ 0:00 /bin/sh -c /usr/bin/python
> /home/ubuntu/.ansible/tmp/ansible-1361816430.12-44660555879891/git; rm -rf
> /home/ubuntu/.ansible/tmp/ansible-1361816430.12-44660555879891/ >/dev/null
> 23968 pts/3 S+ 0:00 /usr/bin/python
> /home/ubuntu/.ansible/tmp/ansible-1361816430.12-44660555879891/git
> 23969 pts/3 S+ 0:00 /bin/sh -c git clone -o origin
> g...@github.com:user/repo.git /home/ubuntu/repo
> 23970 pts/3 S+ 0:00 git clone -o origin g...@github.com:user/repo.git
> /home/ubuntu/repo
> 23971 pts/3 S+ 0:00 ssh g...@github.com git-upload-pack 'repo.git'
>
> And there it hangs.
> I can ssh into the server and run the command in bold:
>
> git clone -o origin g...@github.com:user/repo.git /home/ubuntu/repo
>
> Cloning into '/home/ubuntu/repo'...
> remote: Counting objects: 6065, done.
> remote: Compressing objects: 100% (1737/1737), done.
> remote: Total 6065 (delta 3884), reused 6065 (delta 3884)
> Receiving objects: 100% (6065/6065), 40.68 MiB | 9.97 MiB/s, done.
> Resolving deltas: 100% (3884/3884), done.
>
> It seems like it's something the ssh context when running a playbook as
> opposed to the command line.
> I'm not too familiar with what exactly the ssh-agent is doing but... I'm
> ignorantly pointing my finger there...
>
> people in the know... any clues here?
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

damon ciarelli

unread,
Feb 27, 2013, 1:38:48 PM2/27/13
to ansible...@googlegroups.com
bash-3.2$ ansible --version
ansible 1.0

I got past this yesterday but I was just able to reproduce the problem on a fresh instance.

by killing the "ssh g...@github.com git-upload-pack" process while it was hanging, the problem reveals itself to be that the git server is not a known host...

"RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?"
at which point git ( and everything else) hangs.

I guess the workaround would be to add your git server to .ssh/known_hosts before firing off the git module.

Oh...haha... and now that I was just looking to see if there was an Ansible "known_hosts" module ala the one for authorized_keys, I notice this exact issue is mentioned in the documentation for the HG module.  Perhaps it can be added to the docs for Git.

Just for the record, even with this trouble on my first experience with Ansible, I was so impressed that I didn't abandon it even after hours of dealing with this issue.
Thanks to the makers!

Michael DeHaan

unread,
Feb 27, 2013, 3:40:43 PM2/27/13
to ansible...@googlegroups.com
That needs to be me in the git module docs under 'notes'.

Someone please send me a patch.

If there are git flags to ignore this, it would be very nice to add
them, but it's a little tricky over ssh:// transport

I imagine lots of people will also be doing deployments over git://
and http:// when the goal of the deployment is not to create a
development environment.

donald lee

unread,
Jun 8, 2013, 3:31:21 PM6/8/13
to ansible...@googlegroups.com
Piggybacking off this thread as it seems related.So, I'm new to ansible, and i have been trying to clone a private repo onto my webserver by doing the following task:

"- name: Copy Coursehack from git to webserver
   action: git repo=https://github.com/sherifnosseir/Coursehack.git dest=/var/www/Coursehack
   tags: deploy"

This would run and hang for a bit and return to me with an error. Specifically, 

failed: [coursehack.org] => {"cmd": ["/usr/bin/git", "clone", "-o", "origin", "https://github.com/sherifnosseir/Coursehack.git", "/var/www/Coursehack"], "failed": true, "rc": 128}
stderr: error: Couldn't resolve host 'github.com' while accessing https://github.com/sherifnosseir/Coursehack.git/info/refs
fatal: HTTP request failed

stdout: Cloning into '/var/www/Coursehack'...

msg: error: Couldn't resolve host 'github.com' while accessing https://github.com/sherifnosseir/Coursehack.git/info/refs
fatal: HTTP request failed

FATAL: all hosts have already failed -- aborting

Now, has anybody else ran into this issue and does anyone have a resolution to this matter?

Thank you,
Donald

damon ciarelli

unread,
Jun 8, 2013, 3:49:08 PM6/8/13
to ansible...@googlegroups.com
What happens if you ssh into the machine and "ping github.com". ?
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/q9G9xIdsRxo/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

donald lee

unread,
Jun 11, 2013, 7:09:40 PM6/11/13
to ansible...@googlegroups.com
Hi Damon, 

Thanks for responding.

I get "ping: unknown host github.com" so it seems like i'm getting the same problem that you had.
I'm not super familiar with all this key, known hosts, and authenticating stuff (raises hand when asked for noob)
so if possible can you give me a play by play on how you solved your problem?

I am assuming I would need to copy the id_rsa/id_rsa.pub file from my local machine (which i use to authenticate
with my private repo) to the server, so that i could clone from my server. 

Thanks for all your help! 

Lorin Hochstein

unread,
Jun 11, 2013, 9:45:48 PM6/11/13
to ansible...@googlegroups.com
Donald:

The error messages you are getting suggest that it is a DNS issue, not an SSH authentication issue. Can you show us the contents of the /etc/resolv.conf file on the remote machine?

Lorin




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Lorin Hochstein
Lead Architect - Cloud Services
Nimbis Services, Inc.

donald lee

unread,
Jun 11, 2013, 10:16:17 PM6/11/13
to ansible...@googlegroups.com
Hi Lorin,

The resolve.conf file is empty. I am currently fiddling around with ansible and vagrant. Following this tutorial: https://github.com/leucos/ansible-tuto/tree/master/step-01 I've managed to set up a LAMP server with the host file containing 

"coursehack.org ansible_ssh_host=192.168.33.11 ansible_ssh_user=root"

Thank you very much for your help sir,

Donald

Tanner Semerad

unread,
Jan 22, 2014, 8:02:23 PM1/22/14
to ansible...@googlegroups.com
For anyone still having this issue, I fixed it by listing the repo in HTTP format rather than SSH - http://mysite.com/mygitrepo.git instead of g...@mysite.com:mygitrepo.git
Reply all
Reply to author
Forward
0 new messages