Changing mode/group/owner for symbolic link

1,507 views
Skip to first unread message

Rob Tirrell

unread,
Jul 7, 2012, 8:14:12 PM7/7/12
to ansible-project
I had a use case where I wanted to change the mode/group/owner of the file pointed to by a symbolic link. This link already exists on the system, I know where the link is but don't necessarily know where the pointed-to file is. 

Extending the file module to support this particular use case, something like file state=link dest=/some/link group=mygroup, is on its own simple enough. However, to support these sorts of use-cases more generally, there are a few other issues:
  1. In the case of files, you need an additional argument to the module to specify whether you wish to modify the referer (the real file) or the referent (the link itself).
  2. For directories, the default behavior of chown/chgrp when operating recursively (ansible always passes -R) is not to traverse symbolic links. By providing other switches, you can instruct chown/chgrp to traverse directories either (a) if explicitly targeted on the command line or (b) always. Getting this to work may entail an additional parameter to the module besides the parameter selecting referer or referent.
  3. chmod is unable to change the mode of the referer, it can only change the mode of the referent.

I'd welcome opinions on how to proceed. My vote would be to ignore the issue raised by (2) altogether, and just add a single dereference=yes/no parameter (defaulting, as the CLI interfaces do, to yes).
--
Robert Tirrell | r.ti...@gmail.com | (607) 437-6532
Sent from my mobile device

Rob Tirrell

unread,
Jul 7, 2012, 8:20:02 PM7/7/12
to ansible-project
Link to issue: https://github.com/ansible/ansible/issues/548

--
Robert Tirrell | r.ti...@gmail.com | (607) 437-6532
Sent from my mobile device



Reply all
Reply to author
Forward
0 new messages