Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pkg_firewall_interfacepolicy6.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_interfacepolicy6
15 short_description: Configure IPv6 interface policies.
16 version_added: "2.0.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_interfacepolicy6:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 address_type:
38 aliases: ['address-type']
39 type: str
40 description: Address type.
41 choices: ['ipv4', 'ipv6']
42 application_list:
43 aliases: ['application-list']
44 type: str
45 description: Application list name.
46 application_list_status:
47 aliases: ['application-list-status']
48 type: str
49 description: Enable/disable application control.
50 choices: ['disable', 'enable']
51 av_profile:
52 aliases: ['av-profile']
53 type: str
54 description: Antivirus profile.
55 av_profile_status:
56 aliases: ['av-profile-status']
57 type: str
58 description: Enable/disable antivirus.
59 choices: ['disable', 'enable']
60 comments:
61 type: str
62 description: Comments.
63 dlp_sensor:
64 aliases: ['dlp-sensor']
65 type: str
66 description: DLP sensor name.
67 dlp_sensor_status:
68 aliases: ['dlp-sensor-status']
69 type: str
70 description: Enable/disable DLP.
71 choices: ['disable', 'enable']
72 dsri:
73 type: str
74 description: Enable/disable DSRI.
75 choices: ['disable', 'enable']
76 dstaddr6:
77 type: raw
78 description: (list or str) IPv6 address object to limit traffic monitoring to network traffic sent to the specified address or range.
79 interface:
80 type: str
81 description: Monitored interface name from available interfaces.
82 ips_sensor:
83 aliases: ['ips-sensor']
84 type: str
85 description: IPS sensor name.
86 ips_sensor_status:
87 aliases: ['ips-sensor-status']
88 type: str
89 description: Enable/disable IPS.
90 choices: ['disable', 'enable']
91 label:
92 type: str
93 description: Label.
94 logtraffic:
95 type: str
96 description: Logging type to be used in this policy
97 choices: ['disable', 'all', 'utm']
98 policyid:
99 type: int
100 description: Policy ID.
101 required: true
102 scan_botnet_connections:
103 aliases: ['scan-botnet-connections']
104 type: str
105 description: Enable/disable scanning for connections to Botnet servers.
106 choices: ['disable', 'block', 'monitor']
107 service6:
108 type: raw
109 description: (list or str) Service name.
110 spamfilter_profile:
111 aliases: ['spamfilter-profile']
112 type: str
113 description: Antispam profile.
114 spamfilter_profile_status:
115 aliases: ['spamfilter-profile-status']
116 type: str
117 description: Enable/disable antispam.
118 choices: ['disable', 'enable']
119 srcaddr6:
120 type: raw
121 description: (list or str) IPv6 address object to limit traffic monitoring to network traffic sent from the specified address or range.
122 status:
123 type: str
124 description: Enable/disable this policy.
125 choices: ['disable', 'enable']
126 webfilter_profile:
127 aliases: ['webfilter-profile']
128 type: str
129 description: Web filter profile.
130 webfilter_profile_status:
131 aliases: ['webfilter-profile-status']
132 type: str
133 description: Enable/disable web filtering.
134 choices: ['disable', 'enable']
135 emailfilter_profile:
136 aliases: ['emailfilter-profile']
137 type: str
138 description: Email filter profile.
139 emailfilter_profile_status:
140 aliases: ['emailfilter-profile-status']
141 type: str
142 description: Enable/disable email filter.
143 choices: ['disable', 'enable']
144 uuid:
145 type: str
146 description: Universally Unique Identifier
147 casi_profile:
148 aliases: ['casi-profile']
149 type: str
150 description: CASI profile name.
151 casi_profile_status:
152 aliases: ['casi-profile-status']
153 type: str
154 description: Enable/disable CASI.
155 choices: ['disable', 'enable']
156 dlp_profile:
157 aliases: ['dlp-profile']
158 type: str
159 description: DLP profile name.
160 dlp_profile_status:
161 aliases: ['dlp-profile-status']
162 type: str
163 description: Enable/disable DLP.
164 choices: ['disable', 'enable']
165 casb_profile:
166 aliases: ['casb-profile']
167 type: raw
168 description: (list) CASB profile.
169 casb_profile_status:
170 aliases: ['casb-profile-status']
171 type: str
172 description: Enable/disable CASB.
173 choices: ['disable', 'enable']
174 '''
175
176 EXAMPLES = '''
177 - name: Example playbook
178 hosts: fortimanagers
179 gather_facts: false
180 connection: httpapi
181 vars:
182 ansible_httpapi_use_ssl: true
183 ansible_httpapi_validate_certs: false
184 ansible_httpapi_port: 443
185 tasks:
186 - name: Configure IPv6 interface policies.
187 fortinet.fortimanager.fmgr_pkg_firewall_interfacepolicy6:
188 bypass_validation: false
189 adom: ansible
190 pkg: ansible # package name
191 state: present
192 pkg_firewall_interfacepolicy6:
193 address_type: ipv6 # <value in [ipv4, ipv6]>
194 comments: ansible-comment
195 interface: sslvpn_tun_intf
196 policyid: 1
197 status: enable
198
199 - name: Gathering fortimanager facts
200 hosts: fortimanagers
201 gather_facts: false
202 connection: httpapi
203 vars:
204 ansible_httpapi_use_ssl: true
205 ansible_httpapi_validate_certs: false
206 ansible_httpapi_port: 443
207 tasks:
208 - name: Retrieve all the IPv6 interface policies
209 fortinet.fortimanager.fmgr_fact:
210 facts:
211 selector: "pkg_firewall_interfacepolicy6"
212 params:
213 adom: "ansible"
214 pkg: "ansible" # package name
215 interface_policy6: "your_value"
216 '''
217
218 RETURN = '''
219 meta:
220 description: The result of the request.
221 type: dict
222 returned: always
223 contains:
224 request_url:
225 description: The full url requested.
226 returned: always
227 type: str
228 sample: /sys/login/user
229 response_code:
230 description: The status of api request.
231 returned: always
232 type: int
233 sample: 0
234 response_data:
235 description: The api response.
236 type: list
237 returned: always
238 response_message:
239 description: The descriptive message of the api response.
240 type: str
241 returned: always
242 sample: OK.
243 system_information:
244 description: The information of the target system.
245 type: dict
246 returned: always
247 rc:
248 description: The status the request.
249 type: int
250 returned: always
251 sample: 0
252 version_check_warning:
253 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
254 type: list
255 returned: complex
256 '''
257 from ansible.module_utils.basic import AnsibleModule
258 from ansible.module_utils.connection import Connection
259 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
260 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
261
262
263 def main():
264 urls_list = [
265 '/pm/config/adom/{adom}/pkg/{pkg}/firewall/interface-policy6'
266 ]
267 module_arg_spec = {
268 'adom': {'required': True, 'type': 'str'},
269 'pkg': {'required': True, 'type': 'str'},
270 'revision_note': {'type': 'str'},
271 'pkg_firewall_interfacepolicy6': {
272 'type': 'dict', 'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
273 'options': {
274 'address-type': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'choices': ['ipv4', 'ipv6'], 'type': 'str'},
275 'application-list': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
276 'application-list-status': {
277 'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
278 'choices': ['disable', 'enable'],
279 'type': 'str'
280 },
281 'av-profile': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
282 'av-profile-status': {
283 'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
284 'choices': ['disable', 'enable'],
285 'type': 'str'
286 },
287 'comments': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
288 'dlp-sensor': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
289 'dlp-sensor-status': {
290 'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
291 'choices': ['disable', 'enable'],
292 'type': 'str'
293 },
294 'dsri': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
295 'dstaddr6': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
296 'interface': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
297 'ips-sensor': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
298 'ips-sensor-status': {
299 'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
300 'choices': ['disable', 'enable'],
301 'type': 'str'
302 },
303 'label': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
304 'logtraffic': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'choices': ['disable', 'all', 'utm'], 'type': 'str'},
305 'policyid': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'required': True, 'type': 'int'},
306 'scan-botnet-connections': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['disable', 'block', 'monitor'], 'type': 'str'},
307 'service6': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
308 'spamfilter-profile': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
309 'spamfilter-profile-status': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['disable', 'enable'], 'type': 'str'},
310 'srcaddr6': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
311 'status': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
312 'webfilter-profile': {'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
313 'webfilter-profile-status': {
314 'v_range': [['6.0.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
315 'choices': ['disable', 'enable'],
316 'type': 'str'
317 },
318 'emailfilter-profile': {'v_range': [['6.2.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
319 'emailfilter-profile-status': {
320 'v_range': [['6.2.0', '7.2.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
321 'choices': ['disable', 'enable'],
322 'type': 'str'
323 },
324 'uuid': {'v_range': [['6.2.1', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
325 'casi-profile': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'},
326 'casi-profile-status': {'v_range': [['6.2.0', '6.2.13']], 'choices': ['disable', 'enable'], 'type': 'str'},
327 'dlp-profile': {'v_range': [['7.2.0', '7.2.1'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
328 'dlp-profile-status': {
329 'v_range': [['7.2.0', '7.2.1'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
330 'choices': ['disable', 'enable'],
331 'type': 'str'
332 },
333 'casb-profile': {'v_range': [['7.4.3', '']], 'type': 'raw'},
334 'casb-profile-status': {'v_range': [['7.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
335 }
336 }
337 }
338
339 module_option_spec = get_module_arg_spec('full crud')
340 module_arg_spec.update(module_option_spec)
341 check_galaxy_version(module_arg_spec)
342 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_firewall_interfacepolicy6'),
343 supports_check_mode=True)
344 if not module._socket_path:
345 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
346 connection = Connection(module._socket_path)
347 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
348 'policyid', 'data', module, connection)
349 fmgr.process_crud()
350 module.exit_json(meta=module.params)
351
352
353 if __name__ == '__main__':
354 main()