mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-02 20:24:23 -07:00
sysrc: Detect permission denied when using sysrc
This commit is contained in:
parent
880a64087d
commit
3d79d948ec
1 changed files with 7 additions and 2 deletions
|
@ -193,6 +193,8 @@ class Sysrc(object):
|
||||||
cmd.extend(args)
|
cmd.extend(args)
|
||||||
|
|
||||||
(rc, out, err) = self.module.run_command(cmd)
|
(rc, out, err) = self.module.run_command(cmd)
|
||||||
|
if err.find("Permission denied"):
|
||||||
|
raise PermissionError("Permission denied for %s" % self.path)
|
||||||
|
|
||||||
return (rc, out, err)
|
return (rc, out, err)
|
||||||
|
|
||||||
|
@ -226,8 +228,11 @@ def main():
|
||||||
jail=module.params.pop('jail')
|
jail=module.params.pop('jail')
|
||||||
)
|
)
|
||||||
|
|
||||||
sysrc = Sysrc(module, name, result['value'], result['path'], result['delim'], result['jail'])
|
try:
|
||||||
result['changed'] = getattr(sysrc, result['state'])()
|
sysrc = Sysrc(module, name, result['value'], result['path'], result['delim'], result['jail'])
|
||||||
|
result['changed'] = getattr(sysrc, result['state'])()
|
||||||
|
except PermissionError as err:
|
||||||
|
module.fail_json(msg=str(err))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue