-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ostree support #100
base: develop
Are you sure you want to change the base?
ostree support #100
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think, you should put my copyright there... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy/paste error |
||
# 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." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really true? |
||
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() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# copyright (c) 2022, Andrew Block | ||
# 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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to make this really idempotent? Maybe by checking if commits are part of the latest version? (Not so much of an ostree expert here.)