1
0
Fork 0
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:
Abhijeet Kasurde 2017-12-02 18:54:30 +05:30 committed by René Moser
parent 914829f56b
commit 1faa0a7c60

View file

@ -225,7 +225,6 @@ from operator import itemgetter
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.urls import fetch_url from ansible.module_utils.urls import fetch_url
@ -312,11 +311,10 @@ def keyfile(module, user, write=False, path=None, manage_dir=True):
try: try:
user_entry = pwd.getpwnam(user) user_entry = pwd.getpwnam(user)
except KeyError: except KeyError as e:
e = get_exception()
if module.check_mode and path is None: 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="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: if path is None:
homedir = user_entry.pw_dir homedir = user_entry.pw_dir
sshdir = os.path.join(homedir, ".ssh") sshdir = os.path.join(homedir, ".ssh")
@ -475,9 +473,8 @@ def writefile(module, filename, content):
try: try:
f.write(content) f.write(content)
except IOError: except IOError as e:
e = get_exception() module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, to_native(e)))
module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, str(e)))
f.close() f.close()
module.atomic_move(tmp_path, filename) module.atomic_move(tmp_path, filename)