On 21.07.2017 17:34, Dan Linder wrote:
> I setup a playbook with this play:
>
> - name: "Remove immutable flag"
> file:
> path: /etc/security/access.conf
> attributes: "-i"
>
> The documentation isn't clear on what "attributes" can be but the file
> module call chattr with the "=" precursor before the attributes. For
> my
> case, I can just send "e" as the attribute (which effectively removes
> "i",
> the only attribute on this file usually), but it doesn't make it easy
> to
> enforce a single change without knowing and setting all attributes.
> (Admittedly that would be more idempotent.)
It only require an additional task to only remove the attribute without
touching the other ones.
- stat:
path: /etc/security/access.conf
register: result
- file:
path: /etc/security/access.conf
attr: '{{ result.stat.attr_flags | regex_replace('i', '') }}
> Can someone update the the documentation, to add this note on the
> usage?
>
> Or, can the command line fed to chattr be updated to remove the "="
> before
> the attributes when a +/- is present in the attributes line? That
> makes it
> easy to use "-i" to remove immutable, or "+i" to add immutable flag,
> though
> I haven't thought through the ramifications and idempotent features...
You can always make a feature request on Github
https://github.com/ansible/ansible/issues
--
Kai Stian Olstad