Skip to content
Merged
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
18 changes: 17 additions & 1 deletion plugins/modules/file_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
- Href of the publication to be served
type: str
required: false
repository:
description:
- Name of the repository to be served
type: str
required: false
content_guard:
description:
- Name of the content guard for the served content
Expand Down Expand Up @@ -87,7 +92,7 @@

try:
from pulp_glue.core.context import PulpContentGuardContext
from pulp_glue.file.context import PulpFileDistributionContext
from pulp_glue.file.context import PulpFileDistributionContext, PulpFileRepositoryContext

PULP_GLUE_IMPORT_ERR = None
except ImportError:
Expand All @@ -105,6 +110,7 @@ def main():
"name": {},
"base_path": {},
"publication": {},
"repository": {},
"content_guard": {},
},
required_if=[
Expand All @@ -113,6 +119,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 @@ -121,6 +128,15 @@ def main():
if module.params[key] is not None
}

if repository_name is not None:
if repository_name:
repository_ctx = PulpFileRepositoryContext(
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
16 changes: 13 additions & 3 deletions plugins/modules/file_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
description:
- Description of the repository
type: str
autopublish:
description:
- Whether to automatically create publications for new repository versions
type: bool
extends_documentation_fragment:
- pulp.squeezer.pulp.entity_state
- pulp.squeezer.pulp
Expand Down Expand Up @@ -79,6 +83,11 @@
PULP_GLUE_IMPORT_ERR = traceback.format_exc()
PulpFileRepositoryContext = None

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


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

module.process(natural_key, desired_attributes)

Expand Down
109,500 changes: 76,573 additions & 32,927 deletions tests/fixtures/file_distribution-0.yml

Large diffs are not rendered by default.

Loading