From d8393d06249ba313741e9b4a2f55da4fe607536b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=91=D0=B0=D0=BA=D0=B0=D0=BD=D0=BE=D0=B2=D1=81=D0=BA=D0=B8?= =?UTF-8?q?=D0=B9?= Date: Fri, 27 Sep 2024 10:12:15 +0300 Subject: [PATCH] Fix import --- plugins/modules/authorized_key.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/modules/authorized_key.py b/plugins/modules/authorized_key.py index ba83c1f..12cc1f0 100644 --- a/plugins/modules/authorized_key.py +++ b/plugins/modules/authorized_key.py @@ -230,7 +230,6 @@ from operator import itemgetter from ansible.module_utils._text import to_native from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.urls import fetch_url -from urllib.parse import urlparse class keydict(dict): @@ -578,9 +577,10 @@ def enforce_state(module, params): # resp.read gives bytes on python3, convert to native string type key = to_native(key, errors='surrogate_or_strict') - if key.startswith("file"): + file_prefix = "file://" + if key.startswith(file_prefix): # if the key is an absolute path, check for existense and use it as a key source - key_path = urlparse(key).path + key_path = key[len(file_prefix):] if not os.path.exists(key_path): module.fail_json(msg="Path to a key file not found: %s" % key_path) if not os.path.isfile(key_path):