-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathostree_remote.py
More file actions
121 lines (103 loc) · 3.19 KB
/
Copy pathostree_remote.py
File metadata and controls
121 lines (103 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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()