mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-01 11:44:24 -07:00
sysrc: Fixed the permission check and 2.7 compatibility
This commit is contained in:
parent
3d79d948ec
commit
78e2c1698b
1 changed files with 3 additions and 2 deletions
|
@ -103,6 +103,7 @@ changed:
|
|||
"""
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
improt errno
|
||||
import os
|
||||
import re
|
||||
|
||||
|
@ -194,7 +195,7 @@ class Sysrc(object):
|
|||
|
||||
(rc, out, err) = self.module.run_command(cmd)
|
||||
if err.find("Permission denied"):
|
||||
raise PermissionError("Permission denied for %s" % self.path)
|
||||
raise OSError(errno.EACCES, "Permission denied for %s" % self.path)
|
||||
|
||||
return (rc, out, err)
|
||||
|
||||
|
@ -231,7 +232,7 @@ def main():
|
|||
try:
|
||||
sysrc = Sysrc(module, name, result['value'], result['path'], result['delim'], result['jail'])
|
||||
result['changed'] = getattr(sysrc, result['state'])()
|
||||
except PermissionError as err:
|
||||
except OSError as err:
|
||||
module.fail_json(msg=str(err))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue