Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vip46.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_firewall_vip46
15 short_description: Configure IPv4 to IPv6 virtual IPs.
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 firewall_vip46:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 arp_reply:
34 aliases: ['arp-reply']
35 type: str
36 description: Enable ARP reply.
37 choices: ['disable', 'enable']
38 color:
39 type: int
40 description: Color of icon on the GUI.
41 comment:
42 type: str
43 description: Comment.
44 dynamic_mapping:
45 type: list
46 elements: dict
47 description: Dynamic mapping.
48 suboptions:
49 _scope:
50 type: list
51 elements: dict
52 description: Scope.
53 suboptions:
54 name:
55 type: str
56 description: Name.
57 vdom:
58 type: str
59 description: Vdom.
60 arp_reply:
61 aliases: ['arp-reply']
62 type: str
63 description: Arp reply.
64 choices: ['disable', 'enable']
65 color:
66 type: int
67 description: Color.
68 comment:
69 type: str
70 description: Comment.
71 extip:
72 type: str
73 description: Extip.
74 extport:
75 type: str
76 description: Extport.
77 id:
78 type: int
79 description: Id.
80 ldb_method:
81 aliases: ['ldb-method']
82 type: str
83 description: Ldb method.
84 choices: ['static', 'round-robin', 'weighted', 'least-session',
85 'least-rtt', 'first-alive']
86 mappedip:
87 type: str
88 description: Mappedip.
89 mappedport:
90 type: str
91 description: Mappedport.
92 monitor:
93 type: raw
94 description: (list or str) Monitor.
95 portforward:
96 type: str
97 description: Portforward.
98 choices: ['disable', 'enable']
99 protocol:
100 type: str
101 description: Protocol.
102 choices: ['tcp', 'udp']
103 server_type:
104 aliases: ['server-type']
105 type: str
106 description: Server type.
107 choices: ['http', 'tcp', 'udp', 'ip']
108 src_filter:
109 aliases: ['src-filter']
110 type: raw
111 description: (list) Src filter.
112 type:
113 type: str
114 description: Type.
115 choices: ['static-nat', 'server-load-balance']
116 uuid:
117 type: str
118 description: Uuid.
119 srcintf_filter:
120 aliases: ['srcintf-filter']
121 type: raw
122 description: (list or str) Interfaces to which the VIP46 applies.
123 extip:
124 type: str
125 description: Start-external-IP [-end-external-IP].
126 extport:
127 type: str
128 description: External service port.
129 id:
130 type: int
131 description: Custom defined id.
132 ldb_method:
133 aliases: ['ldb-method']
134 type: str
135 description: Load balance method.
136 choices: ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt',
137 'first-alive']
138 mappedip:
139 type: str
140 description: Start-mapped-IP [-end mapped-IP].
141 mappedport:
142 type: str
143 description: Mapped service port.
144 monitor:
145 type: raw
146 description: (list or str) Health monitors.
147 name:
148 type: str
149 description: VIP46 name.
150 required: true
151 portforward:
152 type: str
153 description: Enable port forwarding.
154 choices: ['disable', 'enable']
155 protocol:
156 type: str
157 description: Mapped port protocol.
158 choices: ['tcp', 'udp']
159 realservers:
160 type: list
161 elements: dict
162 description: Realservers.
163 suboptions:
164 client_ip:
165 aliases: ['client-ip']
166 type: str
167 description: Restrict server to a client IP in this range.
168 healthcheck:
169 type: str
170 description: Per server health check.
171 choices: ['disable', 'enable', 'vip']
172 holddown_interval:
173 aliases: ['holddown-interval']
174 type: int
175 description: Hold down interval.
176 id:
177 type: int
178 description: Real server ID.
179 ip:
180 type: str
181 description: Mapped server IPv6.
182 max_connections:
183 aliases: ['max-connections']
184 type: int
185 description: Maximum number of connections allowed to server.
186 monitor:
187 type: raw
188 description: (list or str) Health monitors.
189 port:
190 type: int
191 description: Mapped server port.
192 status:
193 type: str
194 description: Server administrative status.
195 choices: ['active', 'standby', 'disable']
196 weight:
197 type: int
198 description: Weight.
199 server_type:
200 aliases: ['server-type']
201 type: str
202 description: Server type.
203 choices: ['http', 'tcp', 'udp', 'ip']
204 src_filter:
205 aliases: ['src-filter']
206 type: raw
207 description: (list) Source IP filter
208 type:
209 type: str
210 description: VIP type
211 choices: ['static-nat', 'server-load-balance']
212 uuid:
213 type: str
214 description: Universally Unique Identifier
215 srcintf_filter:
216 aliases: ['srcintf-filter']
217 type: raw
218 description: (list or str) Interfaces to which the VIP46 applies.
219 '''
220
221 EXAMPLES = '''
222 - name: Example playbook
223 hosts: fortimanagers
224 gather_facts: false
225 connection: httpapi
226 vars:
227 ansible_httpapi_use_ssl: true
228 ansible_httpapi_validate_certs: false
229 ansible_httpapi_port: 443
230 tasks:
231 - name: Configure IPv4 to IPv6 virtual IPs.
232 fortinet.fortimanager.fmgr_firewall_vip46:
233 bypass_validation: false
234 adom: ansible
235 state: present
236 firewall_vip46:
237 arp_reply: enable
238 color: 1
239 comment: "ansible-comment"
240 id: 1
241 ldb_method: static # <value in [static, round-robin, weighted, ...]>
242 name: "ansible-test-vip46"
243 protocol: tcp # <value in [tcp, udp]>
244
245 - name: Gathering fortimanager facts
246 hosts: fortimanagers
247 gather_facts: false
248 connection: httpapi
249 vars:
250 ansible_httpapi_use_ssl: true
251 ansible_httpapi_validate_certs: false
252 ansible_httpapi_port: 443
253 tasks:
254 - name: Retrieve all the IPv4 to IPv6 virtual IPs
255 fortinet.fortimanager.fmgr_fact:
256 facts:
257 selector: "firewall_vip46"
258 params:
259 adom: "ansible"
260 vip46: "your_value"
261 '''
262
263 RETURN = '''
264 meta:
265 description: The result of the request.
266 type: dict
267 returned: always
268 contains:
269 request_url:
270 description: The full url requested.
271 returned: always
272 type: str
273 sample: /sys/login/user
274 response_code:
275 description: The status of api request.
276 returned: always
277 type: int
278 sample: 0
279 response_data:
280 description: The api response.
281 type: list
282 returned: always
283 response_message:
284 description: The descriptive message of the api response.
285 type: str
286 returned: always
287 sample: OK.
288 system_information:
289 description: The information of the target system.
290 type: dict
291 returned: always
292 rc:
293 description: The status the request.
294 type: int
295 returned: always
296 sample: 0
297 version_check_warning:
298 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
299 type: list
300 returned: complex
301 '''
302 from ansible.module_utils.basic import AnsibleModule
303 from ansible.module_utils.connection import Connection
304 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
305 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
306
307
308 def main():
309 urls_list = [
310 '/pm/config/adom/{adom}/obj/firewall/vip46',
311 '/pm/config/global/obj/firewall/vip46'
312 ]
313 module_arg_spec = {
314 'adom': {'required': True, 'type': 'str'},
315 'revision_note': {'type': 'str'},
316 'firewall_vip46': {
317 'type': 'dict', 'v_range': [['6.0.0', '']],
318 'options': {
319 'arp-reply': {'choices': ['disable', 'enable'], 'type': 'str'},
320 'color': {'type': 'int'},
321 'comment': {'type': 'str'},
322 'dynamic_mapping': {
323 'type': 'list',
324 'options': {
325 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
326 'arp-reply': {'choices': ['disable', 'enable'], 'type': 'str'},
327 'color': {'type': 'int'},
328 'comment': {'type': 'str'},
329 'extip': {'type': 'str'},
330 'extport': {'type': 'str'},
331 'id': {'type': 'int'},
332 'ldb-method': {'choices': ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt', 'first-alive'], 'type': 'str'},
333 'mappedip': {'type': 'str'},
334 'mappedport': {'type': 'str'},
335 'monitor': {'type': 'raw'},
336 'portforward': {'choices': ['disable', 'enable'], 'type': 'str'},
337 'protocol': {'choices': ['tcp', 'udp'], 'type': 'str'},
338 'server-type': {'choices': ['http', 'tcp', 'udp', 'ip'], 'type': 'str'},
339 'src-filter': {'type': 'raw'},
340 'type': {'choices': ['static-nat', 'server-load-balance'], 'type': 'str'},
341 'uuid': {'type': 'str'},
342 'srcintf-filter': {'v_range': [['6.2.7', '6.2.13'], ['6.4.4', '']], 'type': 'raw'}
343 },
344 'elements': 'dict'
345 },
346 'extip': {'type': 'str'},
347 'extport': {'type': 'str'},
348 'id': {'type': 'int'},
349 'ldb-method': {'choices': ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt', 'first-alive'], 'type': 'str'},
350 'mappedip': {'type': 'str'},
351 'mappedport': {'type': 'str'},
352 'monitor': {'type': 'raw'},
353 'name': {'required': True, 'type': 'str'},
354 'portforward': {'choices': ['disable', 'enable'], 'type': 'str'},
355 'protocol': {'choices': ['tcp', 'udp'], 'type': 'str'},
356 'realservers': {
357 'type': 'list',
358 'options': {
359 'client-ip': {'type': 'str'},
360 'healthcheck': {'choices': ['disable', 'enable', 'vip'], 'type': 'str'},
361 'holddown-interval': {'type': 'int'},
362 'id': {'type': 'int'},
363 'ip': {'type': 'str'},
364 'max-connections': {'type': 'int'},
365 'monitor': {'type': 'raw'},
366 'port': {'type': 'int'},
367 'status': {'choices': ['active', 'standby', 'disable'], 'type': 'str'},
368 'weight': {'type': 'int'}
369 },
370 'elements': 'dict'
371 },
372 'server-type': {'choices': ['http', 'tcp', 'udp', 'ip'], 'type': 'str'},
373 'src-filter': {'type': 'raw'},
374 'type': {'choices': ['static-nat', 'server-load-balance'], 'type': 'str'},
375 'uuid': {'type': 'str'},
376 'srcintf-filter': {'v_range': [['6.2.7', '6.2.13'], ['6.4.4', '']], 'type': 'raw'}
377 }
378 }
379 }
380
381 module_option_spec = get_module_arg_spec('full crud')
382 module_arg_spec.update(module_option_spec)
383 check_galaxy_version(module_arg_spec)
384 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vip46'),
385 supports_check_mode=True)
386 if not module._socket_path:
387 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
388 connection = Connection(module._socket_path)
389 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
390 'name', 'data', module, connection)
391 fmgr.process_crud()
392 module.exit_json(meta=module.params)
393
394
395 if __name__ == '__main__':
396 main()