File module - would be great to be able to apply attribs to just files or dirs

23 views
Skip to first unread message

edu...@pobox.com

unread,
May 7, 2014, 8:45:15 PM5/7/14
to ansible...@googlegroups.com
Hello,

I haven't found a way to recursively apply attributes (user/group/mode) to just
files or just directories in a  recursive way. A common use case is wanting a
directory structure to be 0755 and files 0644 - there appears to way to do that
currently using a module. Only command or shell chmod -R would work in this 
case it seems.

Regards,
--Ed

Michael DeHaan

unread,
May 9, 2014, 7:57:33 PM5/9/14
to ansible...@googlegroups.com
The pattern is to just shell out to chmod/chown since the changed detection and reporting of changes would be squirrely.

People think you can just chmod every directory along the line but you can't, the rules along the way might need to be different at different levels, which is why this is not recursive.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ddcb4353-61be-4ae8-8585-a44b2f85578f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
May 9, 2014, 11:08:49 PM5/9/14
to ansible...@googlegroups.com
If you REAAAAAAALLLLY need it, I suggest 2 tasks, the first finds the directories you want to change:

- shell: find /path -type d -owner -etc
  register: dirs_to_change

- file: path={{item}} owner="correct one" ...
  with_items: dirs_to_change.stdout_lines

or something similar.
Reply all
Reply to author
Forward
0 new messages