community.general.xattr (8.5.0) — module

Manage user defined extended attributes

Authors: Brian Coca (@bcoca)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Manages filesystem user defined extended attributes.

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

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Obtain the extended attributes  of /etc/foo.conf
  community.general.xattr:
    path: /etc/foo.conf
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Set the key 'user.foo' to value 'bar'
  community.general.xattr:
    path: /etc/foo.conf
    key: foo
    value: bar
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove the key 'user.foo'
  community.general.xattr:
    path: /etc/foo.conf
    key: foo
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove the key 'trusted.glusterfs.volume-id'
  community.general.xattr:
    path: /mnt/bricks/brick1
    namespace: trusted
    key: glusterfs.volume-id
    state: absent

Inputs

    
key:
    description:
    - The name of a specific Extended attribute key to set/retrieve.
    type: str

path:
    aliases:
    - name
    description:
    - The full path of the file/object to get the facts of.
    required: true
    type: path

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

value:
    description:
    - The value to set the named name/key to, it automatically sets the O(state) to V(present).
    type: str

follow:
    default: true
    description:
    - If V(true), dereferences symlinks and sets/gets attributes on symlink target, otherwise
      acts on symlink itself.
    type: bool

namespace:
    default: user
    description:
    - Namespace of the named name/key.
    type: str