Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pkg_firewall_hyperscalepolicy.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_pkg_firewall_hyperscalepolicy
15 short_description: Configure IPv4/IPv6 policies.
16 version_added: "2.2.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 pkg:
29 description: The parameter (pkg) in requested url.
30 type: str
31 required: true
32 pkg_firewall_hyperscalepolicy:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 action:
38 type: str
39 description: Policy action
40 choices: ['deny', 'accept']
41 auto_asic_offload:
42 aliases: ['auto-asic-offload']
43 type: str
44 description: Enable/disable policy traffic ASIC offloading.
45 choices: ['disable', 'enable']
46 cgn_eif:
47 aliases: ['cgn-eif']
48 type: str
49 description: Enable/Disable CGN endpoint independent filtering.
50 choices: ['disable', 'enable']
51 cgn_eim:
52 aliases: ['cgn-eim']
53 type: str
54 description: Enable/Disable CGN endpoint independent mapping
55 choices: ['disable', 'enable']
56 cgn_log_server_grp:
57 aliases: ['cgn-log-server-grp']
58 type: str
59 description: NP log server group name
60 cgn_resource_quota:
61 aliases: ['cgn-resource-quota']
62 type: int
63 description: Resource quota
64 cgn_session_quota:
65 aliases: ['cgn-session-quota']
66 type: int
67 description: Session quota
68 comments:
69 type: str
70 description: Comment.
71 delay_tcp_npu_session:
72 aliases: ['delay-tcp-npu-session']
73 type: str
74 description: Enable TCP NPU session delay to guarantee packet order of 3-way handshake.
75 choices: ['disable', 'enable']
76 dstaddr:
77 type: raw
78 description: (list or str) Destination IPv4 address and address group names.
79 dstaddr_negate:
80 aliases: ['dstaddr-negate']
81 type: str
82 description: When enabled dstaddr/dstaddr6 specifies what the destination address must NOT be.
83 choices: ['disable', 'enable']
84 dstaddr6:
85 type: raw
86 description: (list or str) Destination IPv6 address name and address group names.
87 dstintf:
88 type: raw
89 description: (list or str) Outgoing
90 firewall_session_dirty:
91 aliases: ['firewall-session-dirty']
92 type: str
93 description: How to handle sessions if the configuration of this firewall policy changes.
94 choices: ['check-all', 'check-new']
95 global_label:
96 aliases: ['global-label']
97 type: str
98 description: Label for the policy that appears when the GUI is in Global View mode.
99 ippool:
100 type: str
101 description: Enable to use IP Pools for source NAT.
102 choices: ['disable', 'enable']
103 label:
104 type: str
105 description: Label for the policy that appears when the GUI is in Section View mode.
106 name:
107 type: str
108 description: Policy name.
109 nat:
110 type: str
111 description: Enable/disable source NAT.
112 choices: ['disable', 'enable']
113 policy_offload:
114 aliases: ['policy-offload']
115 type: str
116 description: Enable/Disable hardware session setup for CGNAT.
117 choices: ['disable', 'enable']
118 policyid:
119 type: int
120 description: Policy ID
121 required: true
122 poolname:
123 type: raw
124 description: (list or str) IP Pool names.
125 poolname6:
126 type: raw
127 description: (list or str) IPv6 pool names.
128 send_deny_packet:
129 aliases: ['send-deny-packet']
130 type: str
131 description: Enable to send a reply when a session is denied or blocked by a firewall policy.
132 choices: ['disable', 'enable']
133 service:
134 type: raw
135 description: (list or str) Service and service group names.
136 service_negate:
137 aliases: ['service-negate']
138 type: str
139 description: When enabled service specifies what the service must NOT be.
140 choices: ['disable', 'enable']
141 srcaddr:
142 type: raw
143 description: (list or str) Source IPv4 address and address group names.
144 srcaddr_negate:
145 aliases: ['srcaddr-negate']
146 type: str
147 description: When enabled srcaddr/srcaddr6 specifies what the source address must NOT be.
148 choices: ['disable', 'enable']
149 srcaddr6:
150 type: raw
151 description: (list or str) Source IPv6 address name and address group names.
152 srcintf:
153 type: raw
154 description: (list or str) Incoming
155 status:
156 type: str
157 description: Enable or disable this policy.
158 choices: ['disable', 'enable']
159 tcp_timeout_pid:
160 aliases: ['tcp-timeout-pid']
161 type: str
162 description: TCP timeout profile ID
163 traffic_shaper:
164 aliases: ['traffic-shaper']
165 type: str
166 description: Traffic shaper.
167 traffic_shaper_reverse:
168 aliases: ['traffic-shaper-reverse']
169 type: str
170 description: Reverse traffic shaper.
171 udp_timeout_pid:
172 aliases: ['udp-timeout-pid']
173 type: str
174 description: UDP timeout profile ID
175 uuid:
176 type: str
177 description: Universally Unique Identifier
178 '''
179
180 EXAMPLES = '''
181 - name: Example playbook (generated based on argument schema)
182 hosts: fortimanagers
183 connection: httpapi
184 gather_facts: false
185 tasks:
186 - name: Configure IPv4/IPv6 policies.
187 fortinet.fortimanager.fmgr_pkg_firewall_hyperscalepolicy:
188 # workspace_locking_adom: <global or your adom name>
189 adom: <your own value>
190 pkg: <your own value>
191 state: present # <value in [present, absent]>
192 pkg_firewall_hyperscalepolicy:
193 policyid: 0 # Required variable, integer
194 # action: <value in [deny, accept]>
195 # auto_asic_offload: <value in [disable, enable]>
196 # cgn_eif: <value in [disable, enable]>
197 # cgn_eim: <value in [disable, enable]>
198 # cgn_log_server_grp: <string>
199 # cgn_resource_quota: <integer>
200 # cgn_session_quota: <integer>
201 # comments: <string>
202 # delay_tcp_npu_session: <value in [disable, enable]>
203 # dstaddr: <list or string>
204 # dstaddr_negate: <value in [disable, enable]>
205 # dstaddr6: <list or string>
206 # dstintf: <list or string>
207 # firewall_session_dirty: <value in [check-all, check-new]>
208 # global_label: <string>
209 # ippool: <value in [disable, enable]>
210 # label: <string>
211 # name: <string>
212 # nat: <value in [disable, enable]>
213 # policy_offload: <value in [disable, enable]>
214 # poolname: <list or string>
215 # poolname6: <list or string>
216 # send_deny_packet: <value in [disable, enable]>
217 # service: <list or string>
218 # service_negate: <value in [disable, enable]>
219 # srcaddr: <list or string>
220 # srcaddr_negate: <value in [disable, enable]>
221 # srcaddr6: <list or string>
222 # srcintf: <list or string>
223 # status: <value in [disable, enable]>
224 # tcp_timeout_pid: <string>
225 # traffic_shaper: <string>
226 # traffic_shaper_reverse: <string>
227 # udp_timeout_pid: <string>
228 # uuid: <string>
229 '''
230
231 RETURN = '''
232 meta:
233 description: The result of the request.
234 type: dict
235 returned: always
236 contains:
237 request_url:
238 description: The full url requested.
239 returned: always
240 type: str
241 sample: /sys/login/user
242 response_code:
243 description: The status of api request.
244 returned: always
245 type: int
246 sample: 0
247 response_data:
248 description: The api response.
249 type: list
250 returned: always
251 response_message:
252 description: The descriptive message of the api response.
253 type: str
254 returned: always
255 sample: OK.
256 system_information:
257 description: The information of the target system.
258 type: dict
259 returned: always
260 rc:
261 description: The status the request.
262 type: int
263 returned: always
264 sample: 0
265 version_check_warning:
266 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
267 type: list
268 returned: complex
269 '''
270 from ansible.module_utils.basic import AnsibleModule
271 from ansible.module_utils.connection import Connection
272 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
273 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
274
275
276 def main():
277 urls_list = [
278 '/pm/config/adom/{adom}/pkg/{pkg}/firewall/hyperscale-policy'
279 ]
280 module_arg_spec = {
281 'adom': {'required': True, 'type': 'str'},
282 'pkg': {'required': True, 'type': 'str'},
283 'revision_note': {'type': 'str'},
284 'pkg_firewall_hyperscalepolicy': {
285 'type': 'dict', 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
286 'options': {
287 'action': {
288 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
289 'choices': ['deny', 'accept'],
290 'type': 'str'
291 },
292 'auto-asic-offload': {
293 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
294 'choices': ['disable', 'enable'],
295 'type': 'str'
296 },
297 'cgn-eif': {
298 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
299 'choices': ['disable', 'enable'],
300 'type': 'str'
301 },
302 'cgn-eim': {
303 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
304 'choices': ['disable', 'enable'],
305 'type': 'str'
306 },
307 'cgn-log-server-grp': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
308 'cgn-resource-quota': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'int'},
309 'cgn-session-quota': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'int'},
310 'comments': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
311 'delay-tcp-npu-session': {
312 'v_range': [['6.4.7', '6.4.15'], ['7.0.2', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
313 'choices': ['disable', 'enable'],
314 'type': 'str'
315 },
316 'dstaddr': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
317 'dstaddr-negate': {
318 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
319 'choices': ['disable', 'enable'],
320 'type': 'str'
321 },
322 'dstaddr6': {'v_range': [['6.4.7', '6.4.15'], ['7.0.2', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
323 'dstintf': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
324 'firewall-session-dirty': {
325 'v_range': [['6.4.7', '6.4.15'], ['7.0.2', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
326 'choices': ['check-all', 'check-new'],
327 'type': 'str'
328 },
329 'global-label': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
330 'ippool': {
331 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
332 'choices': ['disable', 'enable'],
333 'type': 'str'
334 },
335 'label': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
336 'name': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
337 'nat': {
338 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
339 'choices': ['disable', 'enable'],
340 'type': 'str'
341 },
342 'policy-offload': {
343 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
344 'choices': ['disable', 'enable'],
345 'type': 'str'
346 },
347 'policyid': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'required': True, 'type': 'int'},
348 'poolname': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
349 'poolname6': {'v_range': [['6.4.7', '6.4.15'], ['7.0.2', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
350 'send-deny-packet': {
351 'v_range': [['6.4.7', '6.4.15'], ['7.0.2', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
352 'choices': ['disable', 'enable'],
353 'type': 'str'
354 },
355 'service': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
356 'service-negate': {
357 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
358 'choices': ['disable', 'enable'],
359 'type': 'str'
360 },
361 'srcaddr': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
362 'srcaddr-negate': {
363 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
364 'choices': ['disable', 'enable'],
365 'type': 'str'
366 },
367 'srcaddr6': {'v_range': [['6.4.7', '6.4.15'], ['7.0.2', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
368 'srcintf': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
369 'status': {
370 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
371 'choices': ['disable', 'enable'],
372 'type': 'str'
373 },
374 'tcp-timeout-pid': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
375 'traffic-shaper': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
376 'traffic-shaper-reverse': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
377 'udp-timeout-pid': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
378 'uuid': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'}
379 }
380 }
381 }
382
383 module_option_spec = get_module_arg_spec('full crud')
384 module_arg_spec.update(module_option_spec)
385 check_galaxy_version(module_arg_spec)
386 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_firewall_hyperscalepolicy'),
387 supports_check_mode=True)
388 if not module._socket_path:
389 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
390 connection = Connection(module._socket_path)
391 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
392 'policyid', 'data', module, connection)
393 fmgr.process_crud()
394 module.exit_json(meta=module.params)
395
396
397 if __name__ == '__main__':
398 main()