diff --git a/plugins/modules/.rpm_repository.py.swp b/plugins/modules/.rpm_repository.py.swp new file mode 100644 index 0000000..4b0fd8d Binary files /dev/null and b/plugins/modules/.rpm_repository.py.swp differ diff --git a/plugins/modules/deb_distribution.py b/plugins/modules/deb_distribution.py index 48644ab..23796a5 100644 --- a/plugins/modules/deb_distribution.py +++ b/plugins/modules/deb_distribution.py @@ -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 @@ -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 @@ -120,6 +126,7 @@ def main(): "name": {}, "base_path": {}, "publication": {}, + "repository": {}, "content_guard": {}, }, required_if=[ @@ -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 = { @@ -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( diff --git a/plugins/modules/deb_repository.py b/plugins/modules/deb_repository.py index 5d84283..7288b33 100644 --- a/plugins/modules/deb_repository.py +++ b/plugins/modules/deb_repository.py @@ -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 @@ -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( @@ -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: @@ -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)