Skip to content
Open
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
15 changes: 12 additions & 3 deletions plugins/modules/python_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
38 changes: 38 additions & 0 deletions tests/playbooks/python_repository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading