Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vip64.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_vip64
15 short_description: Configure IPv6 to IPv4 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_vip64:
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 extip:
120 type: str
121 description: Start-external-IP [-end-external-IP].
122 extport:
123 type: str
124 description: External service port.
125 id:
126 type: int
127 description: Custom defined id.
128 ldb_method:
129 aliases: ['ldb-method']
130 type: str
131 description: Load balance method.
132 choices: ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt',
133 'first-alive']
134 mappedip:
135 type: str
136 description: Start-mapped-IP [-end-mapped-IP].
137 mappedport:
138 type: str
139 description: Mapped service port.
140 monitor:
141 type: raw
142 description: (list or str) Health monitors.
143 name:
144 type: str
145 description: VIP64 name.
146 required: true
147 portforward:
148 type: str
149 description: Enable port forwarding.
150 choices: ['disable', 'enable']
151 protocol:
152 type: str
153 description: Mapped port protocol.
154 choices: ['tcp', 'udp']
155 realservers:
156 type: list
157 elements: dict
158 description: Realservers.
159 suboptions:
160 client_ip:
161 aliases: ['client-ip']
162 type: str
163 description: Restrict server to a client IP in this range.
164 healthcheck:
165 type: str
166 description: Per server health check.
167 choices: ['disable', 'enable', 'vip']
168 holddown_interval:
169 aliases: ['holddown-interval']
170 type: int
171 description: Hold down interval.
172 id:
173 type: int
174 description: Real server ID.
175 ip:
176 type: str
177 description: Mapped server IP.
178 max_connections:
179 aliases: ['max-connections']
180 type: int
181 description: Maximum number of connections allowed to server.
182 monitor:
183 type: raw
184 description: (list or str) Health monitors.
185 port:
186 type: int
187 description: Mapped server port.
188 status:
189 type: str
190 description: Server administrative status.
191 choices: ['active', 'standby', 'disable']
192 weight:
193 type: int
194 description: Weight.
195 server_type:
196 aliases: ['server-type']
197 type: str
198 description: Server type.
199 choices: ['http', 'tcp', 'udp', 'ip']
200 src_filter:
201 aliases: ['src-filter']
202 type: raw
203 description: (list) Source IP6 filter
204 type:
205 type: str
206 description: VIP type
207 choices: ['static-nat', 'server-load-balance']
208 uuid:
209 type: str
210 description: Universally Unique Identifier
211 '''
212
213 EXAMPLES = '''
214 - name: Example playbook
215 hosts: fortimanagers
216 gather_facts: false
217 connection: httpapi
218 vars:
219 ansible_httpapi_use_ssl: true
220 ansible_httpapi_validate_certs: false
221 ansible_httpapi_port: 443
222 tasks:
223 - name: Configure IPv6 to IPv4 virtual IPs.
224 fortinet.fortimanager.fmgr_firewall_vip64:
225 bypass_validation: false
226 adom: ansible
227 state: present
228 firewall_vip64:
229 arp_reply: enable
230 color: 1
231 comment: "anisble-comment"
232 id: 1
233 name: "ansible-test-vip64"
234
235 - name: Gathering fortimanager facts
236 hosts: fortimanagers
237 gather_facts: false
238 connection: httpapi
239 vars:
240 ansible_httpapi_use_ssl: true
241 ansible_httpapi_validate_certs: false
242 ansible_httpapi_port: 443
243 tasks:
244 - name: Retrieve all the IPv6 to IPv4 virtual IPs
245 fortinet.fortimanager.fmgr_fact:
246 facts:
247 selector: "firewall_vip64"
248 params:
249 adom: "ansible"
250 vip64: "your_value"
251 '''
252
253 RETURN = '''
254 meta:
255 description: The result of the request.
256 type: dict
257 returned: always
258 contains:
259 request_url:
260 description: The full url requested.
261 returned: always
262 type: str
263 sample: /sys/login/user
264 response_code:
265 description: The status of api request.
266 returned: always
267 type: int
268 sample: 0
269 response_data:
270 description: The api response.
271 type: list
272 returned: always
273 response_message:
274 description: The descriptive message of the api response.
275 type: str
276 returned: always
277 sample: OK.
278 system_information:
279 description: The information of the target system.
280 type: dict
281 returned: always
282 rc:
283 description: The status the request.
284 type: int
285 returned: always
286 sample: 0
287 version_check_warning:
288 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
289 type: list
290 returned: complex
291 '''
292 from ansible.module_utils.basic import AnsibleModule
293 from ansible.module_utils.connection import Connection
294 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
295 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
296
297
298 def main():
299 urls_list = [
300 '/pm/config/adom/{adom}/obj/firewall/vip64',
301 '/pm/config/global/obj/firewall/vip64'
302 ]
303 module_arg_spec = {
304 'adom': {'required': True, 'type': 'str'},
305 'revision_note': {'type': 'str'},
306 'firewall_vip64': {
307 'type': 'dict', 'v_range': [['6.0.0', '']],
308 'options': {
309 'arp-reply': {'choices': ['disable', 'enable'], 'type': 'str'},
310 'color': {'type': 'int'},
311 'comment': {'type': 'str'},
312 'dynamic_mapping': {
313 'type': 'list',
314 'options': {
315 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
316 'arp-reply': {'choices': ['disable', 'enable'], 'type': 'str'},
317 'color': {'type': 'int'},
318 'comment': {'type': 'str'},
319 'extip': {'type': 'str'},
320 'extport': {'type': 'str'},
321 'id': {'type': 'int'},
322 'ldb-method': {'choices': ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt', 'first-alive'], 'type': 'str'},
323 'mappedip': {'type': 'str'},
324 'mappedport': {'type': 'str'},
325 'monitor': {'type': 'raw'},
326 'portforward': {'choices': ['disable', 'enable'], 'type': 'str'},
327 'protocol': {'choices': ['tcp', 'udp'], 'type': 'str'},
328 'server-type': {'choices': ['http', 'tcp', 'udp', 'ip'], 'type': 'str'},
329 'src-filter': {'type': 'raw'},
330 'type': {'choices': ['static-nat', 'server-load-balance'], 'type': 'str'},
331 'uuid': {'type': 'str'}
332 },
333 'elements': 'dict'
334 },
335 'extip': {'type': 'str'},
336 'extport': {'type': 'str'},
337 'id': {'type': 'int'},
338 'ldb-method': {'choices': ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt', 'first-alive'], 'type': 'str'},
339 'mappedip': {'type': 'str'},
340 'mappedport': {'type': 'str'},
341 'monitor': {'type': 'raw'},
342 'name': {'required': True, 'type': 'str'},
343 'portforward': {'choices': ['disable', 'enable'], 'type': 'str'},
344 'protocol': {'choices': ['tcp', 'udp'], 'type': 'str'},
345 'realservers': {
346 'type': 'list',
347 'options': {
348 'client-ip': {'type': 'str'},
349 'healthcheck': {'choices': ['disable', 'enable', 'vip'], 'type': 'str'},
350 'holddown-interval': {'type': 'int'},
351 'id': {'type': 'int'},
352 'ip': {'type': 'str'},
353 'max-connections': {'type': 'int'},
354 'monitor': {'type': 'raw'},
355 'port': {'type': 'int'},
356 'status': {'choices': ['active', 'standby', 'disable'], 'type': 'str'},
357 'weight': {'type': 'int'}
358 },
359 'elements': 'dict'
360 },
361 'server-type': {'choices': ['http', 'tcp', 'udp', 'ip'], 'type': 'str'},
362 'src-filter': {'type': 'raw'},
363 'type': {'choices': ['static-nat', 'server-load-balance'], 'type': 'str'},
364 'uuid': {'type': 'str'}
365 }
366 }
367 }
368
369 module_option_spec = get_module_arg_spec('full crud')
370 module_arg_spec.update(module_option_spec)
371 check_galaxy_version(module_arg_spec)
372 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vip64'),
373 supports_check_mode=True)
374 if not module._socket_path:
375 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
376 connection = Connection(module._socket_path)
377 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
378 'name', 'data', module, connection)
379 fmgr.process_crud()
380 module.exit_json(meta=module.params)
381
382
383 if __name__ == '__main__':
384 main()