Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_package.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage Check Point Firewall (c) 2019
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 from __future__ import absolute_import, division, print_function
21
22 __metaclass__ = type
23
24 ANSIBLE_METADATA = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_package
33 short_description: Manages package objects on Check Point over Web Services API
34 description:
35 - Manages package objects on Check Point devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "1.0.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 access:
47 description:
48 - True - enables, False - disables access & NAT policies, empty - nothing is changed.
49 type: bool
50 desktop_security:
51 description:
52 - True - enables, False - disables Desktop security policy, empty - nothing is changed.
53 type: bool
54 installation_targets:
55 description:
56 - Which Gateways identified by the name or UID to install the policy on.
57 type: list
58 elements: str
59 qos:
60 description:
61 - True - enables, False - disables QoS policy, empty - nothing is changed.
62 type: bool
63 qos_policy_type:
64 description:
65 - QoS policy type.
66 type: str
67 choices: ['recommended', 'express']
68 tags:
69 description:
70 - Collection of tag identifiers.
71 type: list
72 elements: str
73 threat_prevention:
74 description:
75 - True - enables, False - disables Threat policy, empty - nothing is changed.
76 type: bool
77 vpn_traditional_mode:
78 description:
79 - True - enables, False - disables VPN traditional mode, empty - nothing is changed.
80 type: bool
81 color:
82 description:
83 - Color of the object. Should be one of existing colors.
84 type: str
85 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
86 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
87 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
88 comments:
89 description:
90 - Comments string.
91 type: str
92 details_level:
93 description:
94 - The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed
95 representation of the object.
96 type: str
97 choices: ['uid', 'standard', 'full']
98 ignore_warnings:
99 description:
100 - Apply changes ignoring warnings.
101 type: bool
102 ignore_errors:
103 description:
104 - Apply changes ignoring errors. You won't be able to publish such a changes. If ignore-warnings flag was omitted - warnings will also be ignored.
105 type: bool
106 access_layers:
107 description:
108 - Access policy layers.
109 type: dict
110 suboptions:
111 add:
112 description:
113 - Collection of Access layer objects to be added identified by the name or UID.
114 type: list
115 elements: dict
116 suboptions:
117 name:
118 description:
119 - Layer name or UID.
120 type: str
121 position:
122 description:
123 - Layer position.
124 type: int
125 remove:
126 description:
127 - Collection of Access layer objects to be removed identified by the name or UID.
128 type: list
129 elements: str
130 value:
131 description:
132 - Collection of Access layer objects to be set identified by the name or UID. Replaces existing Access layers.
133 type: list
134 elements: str
135 threat_layers:
136 description:
137 - Threat policy layers.
138 type: dict
139 suboptions:
140 add:
141 description:
142 - Collection of Threat layer objects to be added identified by the name or UID.
143 type: list
144 elements: dict
145 suboptions:
146 name:
147 description:
148 - Layer name or UID.
149 type: str
150 position:
151 description:
152 - Layer position.
153 type: int
154 remove:
155 description:
156 - Collection of Threat layer objects to be removed identified by the name or UID.
157 type: list
158 elements: str
159 value:
160 description:
161 - Collection of Threat layer objects to be set identified by the name or UID. Replaces existing Threat layers.
162 type: list
163 elements: str
164 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
165 """
166
167 EXAMPLES = """
168 - name: add-package
169 cp_mgmt_package:
170 access: true
171 color: green
172 comments: My Comments
173 name: New_Standard_Package_1
174 state: present
175 threat_prevention: false
176
177 - name: set-package
178 cp_mgmt_package:
179 access_layers:
180 add:
181 - name: New Access Layer 1
182 position: 1
183 name: Standard
184 state: present
185 threat_layers:
186 add:
187 - name: New Layer 1
188 position: 2
189
190 - name: delete-package
191 cp_mgmt_package:
192 name: New Standard Package 1
193 state: absent
194 """
195
196 RETURN = """
197 cp_mgmt_package:
198 description: The checkpoint object created or updated.
199 returned: always, except when deleting the object.
200 type: dict
201 """
202
203 from ansible.module_utils.basic import AnsibleModule
204 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
205 checkpoint_argument_spec_for_objects,
206 api_call,
207 )
208
209
210 def main():
211 argument_spec = dict(
212 name=dict(type="str", required=True),
213 access=dict(type="bool"),
214 desktop_security=dict(type="bool"),
215 installation_targets=dict(type="list", elements="str"),
216 qos=dict(type="bool"),
217 qos_policy_type=dict(type="str", choices=["recommended", "express"]),
218 tags=dict(type="list", elements="str"),
219 threat_prevention=dict(type="bool"),
220 vpn_traditional_mode=dict(type="bool"),
221 color=dict(
222 type="str",
223 choices=[
224 "aquamarine",
225 "black",
226 "blue",
227 "crete blue",
228 "burlywood",
229 "cyan",
230 "dark green",
231 "khaki",
232 "orchid",
233 "dark orange",
234 "dark sea green",
235 "pink",
236 "turquoise",
237 "dark blue",
238 "firebrick",
239 "brown",
240 "forest green",
241 "gold",
242 "dark gold",
243 "gray",
244 "dark gray",
245 "light green",
246 "lemon chiffon",
247 "coral",
248 "sea green",
249 "sky blue",
250 "magenta",
251 "purple",
252 "slate blue",
253 "violet red",
254 "navy blue",
255 "olive",
256 "orange",
257 "red",
258 "sienna",
259 "yellow",
260 ],
261 ),
262 comments=dict(type="str"),
263 details_level=dict(type="str", choices=["uid", "standard", "full"]),
264 ignore_warnings=dict(type="bool"),
265 ignore_errors=dict(type="bool"),
266 access_layers=dict(
267 type="dict",
268 options=dict(
269 add=dict(
270 type="list",
271 elements="dict",
272 options=dict(
273 name=dict(type="str"), position=dict(type="int")
274 ),
275 ),
276 remove=dict(type="list", elements="str"),
277 value=dict(type="list", elements="str"),
278 ),
279 ),
280 threat_layers=dict(
281 type="dict",
282 options=dict(
283 add=dict(
284 type="list",
285 elements="dict",
286 options=dict(
287 name=dict(type="str"), position=dict(type="int")
288 ),
289 ),
290 remove=dict(type="list", elements="str"),
291 value=dict(type="list", elements="str"),
292 ),
293 ),
294 )
295 argument_spec.update(checkpoint_argument_spec_for_objects)
296
297 module = AnsibleModule(
298 argument_spec=argument_spec, supports_check_mode=True
299 )
300 api_call_object = "package"
301
302 result = api_call(module, api_call_object)
303 module.exit_json(**result)
304
305
306 if __name__ == "__main__":
307 main()