1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

xattr - invoke run_command passing list (#3806) (#3820)

* xattr - invoke run_command passing list

* added changelog fragment

* Update plugins/modules/files/xattr.py

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 2edbabd30f)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2021-12-01 06:58:39 +01:00 committed by GitHub
parent 90de95c7b2
commit 6e0e17a7e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 14 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- xattr - calling ``run_command`` with arguments as ``list`` instead of ``str`` (https://github.com/ansible-collections/community.general/pull/3806).

View file

@ -12,9 +12,9 @@ DOCUMENTATION = '''
module: xattr
short_description: Manage user defined extended attributes
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.
- Manages filesystem user defined extended attributes.
- Requires that extended attributes are enabled on the target filesystem
and that the setfattr/getfattr utilities are present.
options:
path:
description:
@ -34,13 +34,13 @@ options:
type: str
value:
description:
- The value to set the named name/key to, it automatically sets the C(state) to 'set'.
- The value to set the named name/key to, it automatically sets the I(state) to C(present).
type: str
state:
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(read) retrieves the current value for a I(key) (default)
C(present) sets I(path) to C(value), default if value is set
C(all) dumps all data
C(keys) retrieves all keys
C(absent) deletes the key
@ -49,14 +49,14 @@ options:
default: read
follow:
description:
- If C(yes), dereferences symlinks and sets/gets attributes on symlink target,
- If C(true), dereferences symlinks and sets/gets attributes on symlink target,
otherwise acts on symlink itself.
type: bool
default: yes
default: true
notes:
- As of Ansible 2.3, the I(name) option has been changed to I(path) as default, but I(name) still works as well.
author:
- Brian Coca (@bcoca)
- Brian Coca (@bcoca)
'''
EXAMPLES = '''
@ -116,7 +116,8 @@ def get_xattr(module, path, key, follow):
if key is None:
cmd.append('-d')
else:
cmd.append('-n %s' % key)
cmd.append('-n')
cmd.append(key)
cmd.append(path)
return _run_xattr(module, cmd, False)
@ -127,8 +128,10 @@ def set_xattr(module, path, key, value, follow):
cmd = [module.get_bin_path('setfattr', True)]
if not follow:
cmd.append('-h')
cmd.append('-n %s' % key)
cmd.append('-v %s' % value)
cmd.append('-n')
cmd.append(key)
cmd.append('-v')
cmd.append(value)
cmd.append(path)
return _run_xattr(module, cmd)
@ -139,7 +142,8 @@ def rm_xattr(module, path, key, follow):
cmd = [module.get_bin_path('setfattr', True)]
if not follow:
cmd.append('-h')
cmd.append('-x %s' % key)
cmd.append('-x')
cmd.append(key)
cmd.append(path)
return _run_xattr(module, cmd, False)
@ -148,7 +152,7 @@ def rm_xattr(module, path, key, follow):
def _run_xattr(module, cmd, check_rc=True):
try:
(rc, out, err) = module.run_command(' '.join(cmd), check_rc=check_rc)
(rc, out, err) = module.run_command(cmd, check_rc=check_rc)
except Exception as e:
module.fail_json(msg="%s!" % to_native(e))