trouble creating symbolic link

2,472 views
Skip to first unread message

Suraj Gupta

unread,
May 28, 2012, 1:10:21 AM5/28/12
to ansible...@googlegroups.com
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!

Cosmin Luță

unread,
May 28, 2012, 2:56:51 AM5/28/12
to ansible...@googlegroups.com

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?
 

Suraj Gupta

unread,
May 28, 2012, 9:51:04 AM5/28/12
to ansible...@googlegroups.com
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 <module>
    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?

Suraj Gupta

unread,
May 31, 2012, 1:55:09 PM5/31/12
to ansible...@googlegroups.com
anyone?  I'm still stuck.

Michael DeHaan

unread,
May 31, 2012, 2:03:44 PM5/31/12
to ansible...@googlegroups.com
you may wish to debug this with the hacking/test-module script in the checkout.

Suraj Gupta

unread,
May 31, 2012, 2:34:28 PM5/31/12
to ansible...@googlegroups.com
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?

Michael DeHaan

unread,
May 31, 2012, 2:36:31 PM5/31/12
to ansible...@googlegroups.com
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.

Suraj Gupta

unread,
May 31, 2012, 3:31:57 PM5/31/12
to ansible...@googlegroups.com
done!

Michael DeHaan

unread,
May 31, 2012, 10:28:21 PM5/31/12
to ansible...@googlegroups.com
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.

Suraj Gupta

unread,
Jun 3, 2012, 10:52:37 AM6/3/12
to ansible...@googlegroups.com
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


On Thursday, May 31, 2012 10:28:21 PM UTC-4, Michael DeHaan wrote:
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.


Michael DeHaan

unread,
Jun 3, 2012, 10:54:42 PM6/3/12
to ansible...@googlegroups.com, ansible...@googlegroups.com


-- Michael

On Jun 3, 2012, at 10:52 AM, Suraj Gupta <sur...@gmail.com> wrote:

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?

Suraj Gupta

unread,
Jun 4, 2012, 2:22:41 PM6/4/12
to ansible...@googlegroups.com
Without debug/verbose the error is:
failed: [127.0.0.1] => {"failed": true, "msg", "", "parsed": false}

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


On Sunday, June 3, 2012 10:54:42 PM UTC-4, Michael DeHaan wrote:


-- Michael

Michael DeHaan

unread,
Jun 4, 2012, 6:33:27 PM6/4/12
to ansible...@googlegroups.com
Latest devel or not?

-- Michael

Suraj Gupta

unread,
Jun 4, 2012, 10:04:33 PM6/4/12
to ansible...@googlegroups.com
latest devel


On Monday, June 4, 2012 6:33:27 PM UTC-4, Michael DeHaan wrote:
Latest devel or not?

-- Michael

Michael DeHaan

unread,
Jun 4, 2012, 10:09:20 PM6/4/12
to ansible...@googlegroups.com, ansible...@googlegroups.com
Ok, failed to parse should always show the trace, no flags required.  Make sure there is a open ticket.


-- Michael

Suraj Gupta

unread,
Jun 4, 2012, 10:13:18 PM6/4/12
to ansible...@googlegroups.com
created issue 449


On Monday, June 4, 2012 10:09:20 PM UTC-4, Michael DeHaan wrote:
Ok, failed to parse should always show the trace, no flags required.  Make sure there is a open ticket.


-- Michael

Michael DeHaan

unread,
Jun 4, 2012, 10:56:31 PM6/4/12
to ansible...@googlegroups.com, ansible...@googlegroups.com
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

Suraj Gupta

unread,
Jun 5, 2012, 1:20:05 PM6/5/12
to ansible...@googlegroups.com
Hi Michael - There is no error when using test-module.  The link is created properly.  That's what's strange.


On Monday, June 4, 2012 10:56:31 PM UTC-4, Michael DeHaan wrote:
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

Suraj Gupta

unread,
Jun 5, 2012, 1:40:58 PM6/5/12
to ansible...@googlegroups.com
so I think we should reopen issue 439.  I tried but I don't have permission

Michael DeHaan

unread,
Jun 5, 2012, 5:05:52 PM6/5/12
to ansible...@googlegroups.com, ansible...@googlegroups.com
There was no error for me so I am afraid you will need to patch it yourself...

-- Michael

Suraj Gupta

unread,
Jun 6, 2012, 2:10:56 PM6/6/12
to ansible...@googlegroups.com
I'll try after issue 449 is fixed.


On Tuesday, June 5, 2012 5:05:52 PM UTC-4, Michael DeHaan wrote:
There was no error for me so I am afraid you will need to patch it yourself...

-- Michael

Lylian meye-mezu

unread,
Jan 6, 2016, 8:46:58 AM1/6/16
to Ansible Project
Has this issue been corrected ?
I'm using Ansible 1.9.4 et still cannot create a symlink.

Lylian meye-mezu

unread,
Jan 6, 2016, 8:46:58 AM1/6/16
to Ansible Project
Oups..
It works fine.
Sorry for annoyance.
Regards


Le mercredi 6 juin 2012 20:10:56 UTC+2, Suraj Gupta a écrit :
Reply all
Reply to author
Forward
0 new messages