On Mon, Sep 17, 2012 at 7:22 PM, Michael DeHaan
<
michael...@gmail.com> wrote:
> Yeah, we fixed the glitch.
>
> I'd accept a patch for a recurse option that ads the '-R' ... I almost
> thought we already had that but it looks like no.
>
> The hard part is computing 'changed' in that instance, to which point
> I'd probably say returning 'True' all the time is plenty sufficient
> when recurse is set.
I've got a commit that attempts this at
https://github.com/mcodd/ansible/commit/2ec3db0643d52859f45c6c8a846fc8864c77e956.
Apparently Python doesn't have built-in recursion for chmod/chown so
you have to use os.walk, but when you do that you actually get
computing "changed" for free because you can just use the existing
functions in the file module while looping over the files and
directories (I'm a pretty novice Python programmer, but this bears
itself out based on a few basic tests I've run since that commit in my
local environment).
Didn't submit a pull request yet because I'm on the fence about
whether and/or how to recurse for chmod'ing. Per the commit above, it
does just what you tell it to do; e.g. if I say recurse=yes and tell
it mode=0644 then all my files and directories will become 0644. Even
thought that's what I asked for, I probably didn't mean it (I probably
meant I wanted all the files to be 644 but that I still wanted the
execute bit set on my directories). os.walk makes it easy to just
chmod the files instead of the directories, but that's also probably
not what everyone wants (and certainly not what everyone would
expect). Should we just not allow recurse for mode, leave it as-is,
or... ?
thanks,
matt