3 Commits

Author SHA1 Message Date
alexander
18b044c7bb Merge d8393d0624 into 5321a9ecb5 2024-09-27 07:12:25 +00:00
Александр Бакановский
d8393d0624 Fix import 2024-09-27 10:12:15 +03:00
Александр Бакановский
424f1b4092 Allow remote path for authorized_key 2024-09-27 09:55:31 +03:00

View File

@@ -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 ansible.module_utils.six.moves.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):