community.general.xattr module – Manage user defined extended attributes

Note

This module is part of the community.general collection (version 10.0.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.xattr.

Synopsis

  • Manages filesystem user defined extended attributes.

  • Requires that extended attributes are enabled on the target filesystem and that the setfattr/getfattr utilities are present.

Parameters

Parameter

Comments

follow

boolean

If true, dereferences symlinks and sets/gets attributes on symlink target, otherwise acts on symlink itself.

Choices:

  • false

  • true ← (default)

key

string

The name of a specific Extended attribute key to set/retrieve.

namespace

string

Namespace of the named name/key.

Default: "user"

path

aliases: name

path / required

The full path of the file/object to get the facts of.

state

string

defines which state you want to do. read retrieves the current value for a key (default) present sets path to value, default if value is set all dumps all data keys retrieves all keys absent deletes the key

Choices:

  • "absent"

  • "all"

  • "keys"

  • "present"

  • "read" ← (default)

value

string

The value to set the named name/key to, it automatically sets the state to present.

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Obtain the extended attributes  of /etc/foo.conf
  community.general.xattr:
    path: /etc/foo.conf

- name: Set the key 'user.foo' to value 'bar'
  community.general.xattr:
    path: /etc/foo.conf
    key: foo
    value: bar

- name: Set the key 'trusted.glusterfs.volume-id' to value '0x817b94343f164f199e5b573b4ea1f914'
  community.general.xattr:
    path: /mnt/bricks/brick1
    namespace: trusted
    key: glusterfs.volume-id
    value: "0x817b94343f164f199e5b573b4ea1f914"

- name: Remove the key 'user.foo'
  community.general.xattr:
    path: /etc/foo.conf
    key: foo
    state: absent

- name: Remove the key 'trusted.glusterfs.volume-id'
  community.general.xattr:
    path: /mnt/bricks/brick1
    namespace: trusted
    key: glusterfs.volume-id
    state: absent

Authors

  • Brian Coca (@bcoca)