trouble creating symbolic link

hi! I’m trying to create a symbol link using the file module example:

file src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link

Unfortunately, ansible-playbook gives me the following error:
failed: [127.0.0.1] => {“failed”: true, “msg”: “”, “parsed”: false}

Is there a way to dig deeper? Does parsed = false mean that the line could not be parsed? I tried the --debug option but there was no extra output. Let me know if I can provide more info.

Thanks!

This worked for me on version 0.4:

  • hosts: all
    tasks:
  • name: link the stuff
    action: file src=/etc/passwd dest=/tmp/passwd state=link

What version are you using?

I’m using the latest on the devel branch. I switched to master and now I’m getting verbose output. The error I see is the following:

File “//home/suraj/.ansible/tmp/ansible.If0wX3/file”, line 337, in
os.symlink(src, dest)
OSError: [Errno 2] No such file or directory

My src and dest are paths do not point to the path above, which seems like a temp path where files are copied (as part of the ansible-playbook process?). I’m configuring the local machine. I’m assuming src and dest point to location on the target machine?

anyone? I’m still stuck.

you may wish to debug this with the hacking/test-module script in the checkout.

good suggestion - I went ahead and used test-module and everything worked fine. The link was created as expected and src/dest pointed to the right files. So somehow the task is failing when its run with ansible-playbook. I reduced my playbook so that the only task is the task in question (just to eliminate any issues related to system state with prior tasks). I still get the error below.

I think the next logical question is what’s up with the .ansible/tmp/ file path in the error message?

ok, thanks…that seems indicate there is something up in the handoff to the file module in runner/init.py

If you can paste the most minimal playbook that can repro this with the exact command line used in a github ticket I can take a look.

done!

So the thing I found here was that the code to print error messages in
the file module was not quoting strings with spaces in them, leading
to parse errors.

This was done such that the file module could be used without
requiring Python, which allows very basic ansible things
(copy/template) to be run without having python-simplejson installed,
such that you can boostrap ansible to install python-simplejson even
if it means installing a yum config file. (Yeah, corner case, I
know...but useful).

Anyway, I have fixed this such that if you try to run this again, you
should now get proper output.

The test-module script in the "hacking" directory is VERY useful for
testing modules outside of playbooks and the rest of the framework, if
folks are interested in ansible I recommend trying it.

Hi Michael,

Unfortunately this still doesn’t work. I’m cloning the devel branch. With test-module it works fine, but when I try to create the link via ansible-playbook, I get a failure message. With --debug there is no verbose output as there is with the master branch version. Maybe the first step here is to get --debug to generate more info? Is that something you can fix on devel?

-Suraj

– Michael

Hi Michael,

Unfortunately this still doesn’t work. I’m cloning the devel branch. With test-module it works fine, but when I try to create the link via ansible-playbook, I get a failure message. With --debug there is no verbose output as there is with the master branch version. Maybe the first step here is to get --debug to generate more info? Is that something you can fix on devel?

–debug is going away. --verbose will show returns even on success.

What error are you getting now?

Without debug/verbose the error is:
failed: [127.0.0.1] => {“failed”: true, “msg”, “”, “parsed”: false}

with --verbose:
error: no such option: --verbose
=)

Latest devel or not?

– Michael

latest devel

Ok, failed to parse should always show the trace, no flags required. Make sure there is a open ticket.

– Michael

created issue 449

Thanks, should be fixed by early next week. Meanwhile I recommend using hacking/test-module to find your symlink error, so we can resolve that also. This way you can find the actual TB we are currently not presenting.

– Michael

Hi Michael - There is no error when using test-module. The link is created properly. That’s what’s strange.

so I think we should reopen issue 439. I tried but I don’t have permission

There was no error for me so I am afraid you will need to patch it yourself…

– Michael