From 8e94bde3b911b95fb82eb04e6334fd1340f2c8b1 Mon Sep 17 00:00:00 2001 From: Paradox <159635503+i-am-paradox@users.noreply.github.com> Date: Fri, 2 Oct 2026 16:55:29 +0530 Subject: [PATCH] Add api_root option to all glue modules fixes #145 --- plugins/doc_fragments/pulp.py | 7 +++++++ plugins/module_utils/pulp_glue.py | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/doc_fragments/pulp.py b/plugins/doc_fragments/pulp.py index 6c5d25cb..362ea8fe 100644 --- a/plugins/doc_fragments/pulp.py +++ b/plugins/doc_fragments/pulp.py @@ -46,6 +46,13 @@ class ModuleDocFragment(object): - If no value is specified, the value of the environment variable C(SQUEEZER_VALIDATE_CERTS) will be used as a fallback. type: bool default: true + api_root: + description: + - The path to the API root of the Pulp server. + - The value must begin and end with C(/). + - If no value is specified, the value of the environment variable C(SQUEEZER_API_ROOT) will be used as a fallback. + type: str + default: "/pulp/" refresh_api_cache: description: - Whether the cached API specification should be invalidated. diff --git a/plugins/module_utils/pulp_glue.py b/plugins/module_utils/pulp_glue.py index e1de90ee..62132b6d 100644 --- a/plugins/module_utils/pulp_glue.py +++ b/plugins/module_utils/pulp_glue.py @@ -59,6 +59,11 @@ def __init__(self, **kwargs): "default": True, "fallback": (env_fallback, ["SQUEEZER_VALIDATE_CERTS"]), }, + "api_root": { + "type": "str", + "default": "/pulp/", + "fallback": (env_fallback, ["SQUEEZER_API_ROOT"]), + }, "refresh_api_cache": {"type": "bool", "default": False}, "timeout": {"type": "int", "default": 3600}, } @@ -86,6 +91,9 @@ def __init__(self, **kwargs): if import_error[1] is not None: self.fail_json(msg=missing_required_lib(import_error[0]), exception=import_error[1]) + if not self.params["api_root"].startswith("/") or not self.params["api_root"].endswith("/"): + self.fail_json(msg="'api_root' must begin and end with '/'") + auth_args = {} if self.params["username"]: auth_args["auth_provider"] = BasicAuthProvider( @@ -94,7 +102,7 @@ def __init__(self, **kwargs): ) self.pulp_ctx = PulpContext( - api_root="/pulp/", + api_root=self.params["api_root"], api_kwargs=dict( base_url=self.params["pulp_url"], cert=self.params["user_cert"],