# Git module problem ? or maybe not...

**URL:** <https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914>\
**Category:** Ansible Project\
**Created:** [September 20, 2012, 7:07pm UTC](https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914 "2012-09-20T19:07:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [September 20, 2012, 7:07pm UTC](https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914/1 "2012-09-20T19:07:52Z")

</div>

Hi.

I’m running a simple playbook with using the git module :

- name: Exporting git ansible-vagrant git repo  
action: git repo=git://github.com/username/ansible-vagrant.git dest=$local\_dir/ansible-vagrant version=dev

and I get this :

TASK: [Exporting git ansible-vagrant git repo] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [127.0.0.1] =\> failed to parse: Traceback (most recent call last):  
File “/Users/jamengual/.ansible/tmp/ansible-1348164119.69-135879337996804/git”, line 497, in   
main()  
File “/Users/jamengual/.ansible/tmp/ansible-1348164119.69-135879337996804/git”, line 187, in main  
(rc, out, err) = switch\_version(module, dest, remote, version)  
File “/Users/jamengual/.ansible/tmp/ansible-1348164119.69-135879337996804/git”, line 126, in switch\_version  
os.chdir(dest)  
OSError: [Errno 2] No such file or directory: ‘~/project/ansible-vagrant’

But the directory gets created anyways and the repo is cloned so my question is :

does the git module create the dst directory if it doesn’t exist like the git command does ? ( or it does it handle that feature ?)

Thanks.

---

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [September 21, 2012, 3:50am UTC](https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914/2 "2012-09-21T03:50:53Z")

</div>

Sorry I was reading my post and I just notice that is totally understandable!!!

So I know that the git module is creating the directory but is but is sending this error and skiping al the rest of the task so I don’t know if the ansible git module is supposed to handle this error or could be another git bug ?

Thanks.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 21, 2012, 12:20pm UTC](https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914/3 "2012-09-21T12:20:48Z")

</div>

On vacation without a computer right now, just the phone… Someone want to take a look at the module src and try to figure it out?

– Michael

---

<div class="post-metadata">

**Author:** ![Daniel\_Hokka\_Zakriss](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@Daniel\_Hokka\_Zakriss](https://forum.ansible.com/u/Daniel_Hokka_Zakriss)\
**Post date:** [September 21, 2012, 5:17pm UTC](https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914/4 "2012-09-21T17:17:38Z")

</div>

PePe Amengual wrote:

> Sorry I was reading my post and I just notice that is  
> totally understandable!!!
> 
> So I know that the git module is creating the directory but is but is  
> sending this error and skiping al the rest of the task so I don't know if  
> the ansible git module is supposed to handle this error or could be  
> another  
> git bug ?

For now, just expanding the path yourself should do the trick, i.e.  
replacing ~ with whatever the home directory of the current user is. I'll  
submit a fix for the module to do this.

Daniel

---

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [September 21, 2012, 6:10pm UTC](https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914/5 "2012-09-21T18:10:23Z")

</div>

ok I changed that and seems to be working ok with the fully qualified path.

could that fix be added to the command module too ?

failed: [127.0.0.1] =\> {“failed”: true, “msg”: “the path for ‘chdir’ argument must be fully qualified”}

after doing :

- name: Starting Vagrant Vm  
action: command chdir=$local\_dir vagrant up

and local\_dir is relative to the home directory too.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 21, 2012, 6:42pm UTC](https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914/6 "2012-09-21T18:42:43Z")

</div>

Yes, the module just needs an os.path.expanduser added.

– Michael

---

<div class="post-metadata">

**Author:** ![Daniel\_Hokka\_Zakriss](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@Daniel\_Hokka\_Zakriss](https://forum.ansible.com/u/Daniel_Hokka_Zakriss)\
**Post date:** [September 21, 2012, 6:52pm UTC](https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914/7 "2012-09-21T18:52:32Z")

</div>

PePe Amengual wrote:

> ok I changed that and seems to be working ok with the fully qualified  
> path.
> 
> could that fix be added to the command module too ?

No, the command module already does this.

> failed: [127.0.0.1] =\> {"failed": true, "msg": "the path for 'chdir'  
> argument must be fully qualified"}
> 
> after doing :
> 
> - name: Starting Vagrant Vm  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action: command chdir=$local\_dir vagrant up
> 
> and local\_dir is relative to the home directory too.

What is the value of $local\_dir?

Daniel

---

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [September 21, 2012, 9:55pm UTC](https://forum.ansible.com/t/git-module-problem-or-maybe-not/11914/8 "2012-09-21T21:55:28Z")

</div>

testproject

just that is relative to the where the playbook is.

this playbook runs a bunch of command to localhost so I’m running ansible from the directory where all the files are and then I do a cleanup.

Thanks Daniel.
