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

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7ba61192d6bb5712f80354d9e6949825%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to