ansible.builtin.xattr (v2.9.27) — module

Manage user defined extended attributes

| "added in version" 1.3 of ansible.builtin"

Authors: Brian Coca (@bcoca)

stableinterface | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

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
  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'
  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'
  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'
  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'
  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.
    - Before 2.3 this option was only usable as I(name).
    required: true
    type: path

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

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

follow:
    default: true
    description:
    - If C(yes), 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
    version_added: '2.7'
    version_added_collection: ansible.builtin