I am trying to figure out how to use Ansible to set permissions on a directory tree so that the default will be 644 as default (755 for directories, of course), except for a directory that needs 664/775 permissions.
The naive implementation would be this:
file: path: "mypath" mode: "u+rwX,go+rX,go-w" recurse: True file: path: "mypath/exception" mode: "g+w" recurse: True
However, this is obviously not idempotent. With every run, mypath/exception will have the group-write permissions removed, and then immediately re-added.
The alternative is to enumerate each individual subdirectory in mypath/*, which I hope to avoid.
Is there another way to accomplish this in an idempotent way?