mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
authorized_key: remove deprecated get_exception API (#33277)
This fix removes deprecated get_exception API. Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
914829f56b
commit
1faa0a7c60
1 changed files with 4 additions and 7 deletions
|
@ -225,7 +225,6 @@ from operator import itemgetter
|
|||
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
|
||||
|
||||
|
@ -312,11 +311,10 @@ def keyfile(module, user, write=False, path=None, manage_dir=True):
|
|||
|
||||
try:
|
||||
user_entry = pwd.getpwnam(user)
|
||||
except KeyError:
|
||||
e = get_exception()
|
||||
except KeyError as e:
|
||||
if module.check_mode and path is None:
|
||||
module.fail_json(msg="Either user must exist or you must provide full path to key file in check mode")
|
||||
module.fail_json(msg="Failed to lookup user %s: %s" % (user, str(e)))
|
||||
module.fail_json(msg="Failed to lookup user %s: %s" % (user, to_native(e)))
|
||||
if path is None:
|
||||
homedir = user_entry.pw_dir
|
||||
sshdir = os.path.join(homedir, ".ssh")
|
||||
|
@ -475,9 +473,8 @@ def writefile(module, filename, content):
|
|||
|
||||
try:
|
||||
f.write(content)
|
||||
except IOError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, str(e)))
|
||||
except IOError as e:
|
||||
module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, to_native(e)))
|
||||
f.close()
|
||||
module.atomic_move(tmp_path, filename)
|
||||
|
||||
|
|
Loading…
Reference in a new issue