diff --git a/plugins/modules/python_repository.py b/plugins/modules/python_repository.py index d78e532..6450710 100644 --- a/plugins/modules/python_repository.py +++ b/plugins/modules/python_repository.py @@ -19,6 +19,12 @@ description: - Description of the repository type: str + autopublish: + description: + - Publish new versions automatically. + required: false + type: bool + default: false extends_documentation_fragment: - pulp.squeezer.pulp.entity_state - pulp.squeezer.pulp @@ -89,13 +95,16 @@ 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 = { + k: module.params[k] + for k in ("description", "autopublish") + if module.params.get(k) is not None + } module.process(natural_key, desired_attributes) diff --git a/tests/playbooks/python_repository.yaml b/tests/playbooks/python_repository.yaml index ea42f30..49855cc 100644 --- a/tests/playbooks/python_repository.yaml +++ b/tests/playbooks/python_repository.yaml @@ -31,12 +31,15 @@ name: test_python_repository description: "" state: present + autopublish: false register: result - name: Verify create repository assert: that: - result.changed == true - result.repository.name == 'test_python_repository' + - result.repository.description == '' + - result.repository.autopublish == false - name: Create repository (2nd try) pulp.squeezer.python_repository: @@ -71,6 +74,41 @@ that: - result.changed == false + - name: Enable autopublish + pulp.squeezer.python_repository: + name: test_python_repository + state: present + autopublish: true + register: result + - name: Verify enabled autopublish flag + assert: + that: + - result.changed == true + - result.repository.autopublish == true + + - name: Enable autopublish (2nd try) + pulp.squeezer.python_repository: + name: test_python_repository + state: present + autopublish: true + register: result + - name: Verify enabled autopublish flag + assert: + that: + - result.changed == false + + - name: Disable autopublish + pulp.squeezer.python_repository: + name: test_python_repository + state: present + autopublish: false + register: result + - name: Verify cleared autopublish flag + assert: + that: + - result.changed == true + - result.repository.autopublish == false + - name: Fake modify repository pulp.squeezer.python_repository: name: test_python_repository