Skip to content
Draft
Show file tree
Hide file tree
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
Binary file added plugins/modules/.rpm_repository.py.swp
Binary file not shown.
19 changes: 18 additions & 1 deletion plugins/modules/deb_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
- Href of the publication to be served
type: str
required: false
repository:
description:
- Name of the repository to be served
type: str
required: false
version_added: "0.2.4"
content_guard:
description:
- Name of the content guard for the served content
Expand Down Expand Up @@ -98,7 +104,7 @@

try:
from pulp_glue.deb import __version__ as pulp_glue_deb_version
from pulp_glue.deb.context import PulpAptDistributionContext
from pulp_glue.deb.context import PulpAptDistributionContext, PulpAptRepositoryContext

assert_version(GLUE_DEB_VERSION_SPEC, pulp_glue_deb_version, "pulp-glue-deb")
PULP_GLUE_DEB_IMPORT_ERR = None
Expand All @@ -120,6 +126,7 @@ def main():
"name": {},
"base_path": {},
"publication": {},
"repository": {},
"content_guard": {},
},
required_if=[
Expand All @@ -128,6 +135,7 @@ def main():
],
) as module:
content_guard_name = module.params["content_guard"]
repository_name = module.params["repository"]

natural_key = {"name": module.params["name"]}
desired_attributes = {
Expand All @@ -136,6 +144,15 @@ def main():
if module.params[key] is not None
}

if repository_name is not None:
if repository_name:
repository_ctx = PulpAptRepositoryContext(
module.pulp_ctx, entity={"name": repository_name}
)
desired_attributes["repository"] = repository_ctx.pulp_href
else:
desired_attributes["repository"] = ""

if content_guard_name is not None:
if content_guard_name:
content_guard_ctx = PulpContentGuardContext(
Expand Down
26 changes: 22 additions & 4 deletions plugins/modules/deb_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@
description:
- Description of the repository
type: str
autopublish:
description:
- Whether to automatically create publications for new repository versions
type: bool
version_added: "0.2.4"
remote:
description:
- An optional remote to use by default when syncing
type: str
retain_repo_versions:
description:
- Max number of repository versions to keep
type: int
version_added: "0.2.4"
extends_documentation_fragment:
- pulp.squeezer.pulp.entity_state
- pulp.squeezer.pulp
Expand Down Expand Up @@ -102,6 +112,13 @@
PULP_GLUE_DEB_IMPORT_ERR = traceback.format_exc()
PulpAptRepositoryContext = None

DESIRED_KEYS = {
"autopublish",
"description",
"remote",
"retain_repo_versions",
}


def main():
with PulpEntityAnsibleModule(
Expand All @@ -112,13 +129,17 @@ def main():
argument_spec={
"name": {},
"description": {},
"autopublish": {"type": "bool"},
"retain_repo_versions": {"type": "int"},
"remote": {},
},
required_if=[("state", "present", ["name"]), ("state", "absent", ["name"])],
) as module:
remote_name = module.params["remote"]
natural_key = {"name": module.params["name"]}
desired_attributes = {}
desired_attributes = {
key: module.params[key] for key in DESIRED_KEYS if module.params[key] is not None
}

if remote_name is not None:
if remote_name:
Expand All @@ -127,9 +148,6 @@ def main():
else:
desired_attributes["remote"] = ""

if module.params["description"] is not None:
desired_attributes["description"] = module.params["description"]

module.process(natural_key, desired_attributes)


Expand Down