Git module problem ? or maybe not...

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.

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.

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

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

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.

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

– Michael

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
       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

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.