From 027c46f1195197c30bfcc4373f2c63d0d52d393a Mon Sep 17 00:00:00 2001 From: Pavel Bar Date: Sun, 15 Feb 2026 23:14:59 +0200 Subject: [PATCH] Fix deprecated imports in plugins/modules/authorized_key.py Replace deprecated module_utils imports: - ansible.module_utils._text -> ansible.module_utils.common.text.converters - ansible.module_utils.six.moves.urllib.parse -> urllib.parse Fixes #686 Co-authored-by: Cursor AI Signed-off-by: Pavel Bar --- plugins/modules/authorized_key.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/modules/authorized_key.py b/plugins/modules/authorized_key.py index d712a10..5908610 100644 --- a/plugins/modules/authorized_key.py +++ b/plugins/modules/authorized_key.py @@ -229,10 +229,17 @@ import errno import traceback from operator import itemgetter -from ansible.module_utils._text import to_native +# TODO(Python2): urllib.parse is available in Python 3. This module may run on +# target hosts with Python 2.7 (e.g., older RHEL systems in CI integration tests). +# Remove the try/except fallback to urlparse when Python 2 support is dropped. +try: + from urllib.parse import urlparse +except ImportError: + from urlparse import urlparse + from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.urls import fetch_url -from ansible.module_utils.six.moves.urllib.parse import urlparse class keydict(dict):