-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andrew Block <[email protected]>
- Loading branch information
Showing
6 changed files
with
669 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# copyright (c) 2019, Matthias Dellweg | ||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
|
||
DOCUMENTATION = r""" | ||
--- | ||
module: ostree_distribution | ||
short_description: Manage ostree distributions of a pulp api server instance | ||
description: | ||
- "This performs CRUD operations on ostree distributions in a pulp api server instance." | ||
options: | ||
name: | ||
description: | ||
- Name of the distribution to query or manipulate | ||
type: str | ||
required: true | ||
base_path: | ||
description: | ||
- Base path to the distribution | ||
type: str | ||
required: true | ||
repository: | ||
description: | ||
- Name of the repository | ||
type: str | ||
required: false | ||
version: | ||
description: | ||
- Repository version number | ||
type: str | ||
required: false | ||
content_guard: | ||
description: | ||
- Name of the content guard for the served content | ||
- "Warning: This feature is not yet supported." | ||
type: str | ||
required: false | ||
extends_documentation_fragment: | ||
- pulp.squeezer.pulp | ||
- pulp.squeezer.pulp.entity_state | ||
author: | ||
- Andrew Block (@sabre1041) | ||
""" | ||
|
||
EXAMPLES = r""" | ||
- name: Read list of ostree distributions from pulp api server | ||
pulp.squeezer.ostree_distribution: | ||
pulp_url: https://pulp.example.org | ||
username: admin | ||
password: password | ||
register: distribution_status | ||
- name: Report pulp ostree distributions | ||
debug: | ||
var: distribution_status | ||
- name: Create a ostree distribution | ||
pulp.squeezer.ostree_distribution: | ||
pulp_url: https://pulp.example.org | ||
username: admin | ||
password: password | ||
name: new_ostree_distribution | ||
base_path: new/ostree/dist | ||
repository: ostree_repository | ||
state: present | ||
- name: Delete a ostree distribution | ||
pulp.squeezer.ostree_distribution: | ||
pulp_url: https://pulp.example.org | ||
username: admin | ||
password: password | ||
name: new_ostree_distribution | ||
state: absent | ||
""" | ||
|
||
RETURN = r""" | ||
distributions: | ||
description: List of ostree distributions | ||
type: list | ||
returned: when no name is given | ||
distribution: | ||
description: Ostree distribution details | ||
type: dict | ||
returned: when name is given | ||
""" | ||
|
||
|
||
from ansible_collections.pulp.squeezer.plugins.module_utils.pulp import ( | ||
PulpEntityAnsibleModule, | ||
PulpOstreeDistribution, | ||
PulpContentGuard, | ||
) | ||
|
||
|
||
def main(): | ||
with PulpEntityAnsibleModule( | ||
argument_spec=dict( | ||
name=dict(required=True), | ||
base_path=dict(required=True), | ||
repository=dict(), | ||
version=dict(), | ||
content_guard=dict(), | ||
), | ||
required_if=[ | ||
("state", "present", ["name", "base_path"]), | ||
("state", "absent", ["name"]), | ||
], | ||
) as module: | ||
|
||
content_guard_name = module.params["content_guard"] | ||
|
||
natural_key = { | ||
"name": module.params["name"], | ||
} | ||
desired_attributes = { | ||
key: module.params[key] | ||
for key in ["base_path", "repository"] | ||
if module.params[key] is not None | ||
} | ||
|
||
if content_guard_name is not None: | ||
if content_guard_name: | ||
content_guard = PulpContentGuard(module, {"name": content_guard_name}) | ||
content_guard.find(failsafe=False) | ||
desired_attributes["content_guard"] = content_guard.href | ||
else: | ||
desired_attributes["content_guard"] = None | ||
|
||
if module.params["version"] is not None: | ||
desired_attributes["version"] = module.params["version"] or None | ||
|
||
PulpOstreeDistribution(module, natural_key, desired_attributes).process() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# copyright (c) 2019, Matthias Dellweg | ||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
|
||
DOCUMENTATION = r""" | ||
--- | ||
module: ostree_remote | ||
short_description: Manage ostree remotes of a pulp api server instance | ||
description: | ||
- "This performs CRUD operations on ostree remotes in a pulp api server instance." | ||
options: | ||
policy: | ||
description: | ||
- Whether downloads should be performed immediately, or lazy. | ||
type: str | ||
choices: | ||
- immediate | ||
- on_demand | ||
- streamed | ||
extends_documentation_fragment: | ||
- pulp.squeezer.pulp | ||
- pulp.squeezer.pulp.entity_state | ||
- pulp.squeezer.pulp.remote | ||
author: | ||
- Andrew Block (@sabre1041) | ||
""" | ||
|
||
EXAMPLES = r""" | ||
- name: Read list of ostree remotes from pulp api server | ||
pulp.squeezer.ostree_remote: | ||
pulp_url: https://pulp.example.org | ||
username: admin | ||
password: password | ||
register: remote_status | ||
- name: Report pulp ostree remotes | ||
debug: | ||
var: remote_status | ||
- name: Create a ostree remote | ||
pulp.squeezer.ostree_remote: | ||
pulp_url: https://pulp.example.org | ||
username: admin | ||
password: password | ||
name: new_ostree_remote | ||
url: http://localhost/pub//pulp_manifest | ||
state: present | ||
- name: Delete a ostree remote | ||
pulp.squeezer.ostree_remote: | ||
pulp_url: https://pulp.example.org | ||
username: admin | ||
password: password | ||
name: new_ostree_remote | ||
state: absent | ||
""" | ||
|
||
RETURN = r""" | ||
remotes: | ||
description: List of ostree remotes | ||
type: list | ||
returned: when no name is given | ||
remote: | ||
description: Ostree remote details | ||
type: dict | ||
returned: when name is given | ||
""" | ||
|
||
|
||
from ansible_collections.pulp.squeezer.plugins.module_utils.pulp import ( | ||
PulpRemoteAnsibleModule, | ||
PulpOstreeRemote, | ||
) | ||
|
||
|
||
def main(): | ||
with PulpRemoteAnsibleModule( | ||
argument_spec=dict( | ||
policy=dict(choices=["immediate", "on_demand", "streamed"]), | ||
), | ||
required_if=[("state", "present", ["name"]), ("state", "absent", ["name"])], | ||
) as module: | ||
|
||
natural_key = {"name": module.params["name"]} | ||
desired_attributes = { | ||
key: module.params[key] | ||
for key in ["url", "download_concurrency", "policy", "tls_validation"] | ||
if module.params[key] is not None | ||
} | ||
|
||
# Nullifiable values | ||
if module.params["remote_username"] is not None: | ||
desired_attributes["username"] = module.params["remote_username"] or None | ||
if module.params["remote_password"] is not None: | ||
desired_attributes["password"] = module.params["remote_password"] or None | ||
desired_attributes.update( | ||
{ | ||
key: module.params[key] or None | ||
for key in [ | ||
"proxy_url", | ||
"proxy_username", | ||
"proxy_password", | ||
"ca_cert", | ||
"client_cert", | ||
"client_key", | ||
] | ||
if module.params[key] is not None | ||
} | ||
) | ||
|
||
PulpOstreeRemote(module, natural_key, desired_attributes).process() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.