Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion plugins/modules/python_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@
repository:
description:
- Name of the repository of which the latest RepositoryVersion will be served
- Can be combined with the O(version) option to serve a specific version
type: str
required: false
version:
description:
- Version number of the repository to be served
- Requires the O(repository) option to be set
- If omitted, the latest RepositoryVersion of the repository is served
type: int
required: false
version_added: "0.5.0"
extends_documentation_fragment:
- pulp.squeezer.pulp.entity_state
- pulp.squeezer.pulp
Expand Down Expand Up @@ -82,6 +91,17 @@
repository: my_python_repository
state: present

- name: Create a python distribution that serves a specific repository version
pulp.squeezer.python_distribution:
pulp_url: https://pulp.example.org
username: admin
password: password
name: new_python_distribution
base_path: new/python/dist
repository: my_python_repository
version: 3
state: present

- name: Create a python destribution with remote for pull-through caching
pulp.squeezer.python_distribution:
pulp_url: https://pulp.example.org
Expand Down Expand Up @@ -150,15 +170,20 @@ def main():
"content_guard": {},
"remote": {},
"repository": {},
"version": {"type": "int"},
},
required_if=[
("state", "present", ["name", "base_path"]),
("state", "absent", ["name"]),
],
required_by={
"version": ["repository"],
},
) as module:
content_guard_name = module.params["content_guard"]
remote_name = module.params["remote"]
repository_name = module.params["repository"]
version = module.params["version"]

natural_key = {
"name": module.params["name"],
Expand Down Expand Up @@ -190,8 +215,17 @@ def main():
repository_ctx = PulpPythonRepositoryContext(
module.pulp_ctx, entity={"name": repository_name}
)
desired_attributes["repository"] = repository_ctx.pulp_href
if version is not None:
desired_attributes["repository_version"] = (
repository_ctx.entity["versions_href"] + f"{version}/"
)
else:
desired_attributes["repository"] = repository_ctx.pulp_href
else:
if version is not None:
module.fail_json(
msg="'version' option requires 'repository' option."
)
desired_attributes["repository"] = ""

module.process(natural_key, desired_attributes)
Expand Down