Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_interface.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_system_interface
15 short_description: Interface configuration.
16 version_added: "1.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_interface:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 alias:
27 type: str
28 description: Alias.
29 allowaccess:
30 type: list
31 elements: str
32 description:
33 - Allow management access to interface.
34 - ping - PING access.
35 - https - HTTPS access.
36 - ssh - SSH access.
37 - snmp - SNMP access.
38 - http - HTTP access.
39 - webservice - Web service access.
40 - https-logging - Logging over HTTPS access.
41 choices: ['ping', 'https', 'ssh', 'snmp', 'http', 'webservice', 'https-logging',
42 'soc-fabric', 'fabric']
43 description:
44 type: str
45 description: Description.
46 ip:
47 type: str
48 description: IP address of interface.
49 ipv6:
50 type: dict
51 description: Ipv6.
52 suboptions:
53 ip6_address:
54 aliases: ['ip6-address']
55 type: str
56 description: IPv6 address/prefix of interface.
57 ip6_allowaccess:
58 aliases: ['ip6-allowaccess']
59 type: list
60 elements: str
61 description:
62 - Allow management access to interface.
63 - ping - PING access.
64 - https - HTTPS access.
65 - ssh - SSH access.
66 - snmp - SNMP access.
67 - http - HTTP access.
68 - webservice - Web service access.
69 - https-logging - Logging over HTTPS access.
70 choices: ['ping', 'https', 'ssh', 'snmp', 'http', 'webservice',
71 'https-logging', 'fabric']
72 ip6_autoconf:
73 aliases: ['ip6-autoconf']
74 type: str
75 description:
76 - Enable/disable address auto config
77 - disable - Disable setting.
78 - enable - Enable setting.
79 choices: ['disable', 'enable']
80 mtu:
81 type: int
82 description: Maximum transportation unit
83 name:
84 type: str
85 description: Interface name.
86 required: true
87 serviceaccess:
88 type: list
89 elements: str
90 description:
91 - Allow service access to interface.
92 - fgtupdates - FortiGate updates access.
93 - fclupdates - FortiClient updates access.
94 - webfilter-antispam - Web filtering and antispam access.
95 choices: ['fgtupdates', 'fclupdates', 'webfilter-antispam']
96 speed:
97 type: str
98 description:
99 - Speed.
100 - auto - Auto adjust speed.
101 - 10full - 10M full-duplex.
102 - 10half - 10M half-duplex.
103 - 100full - 100M full-duplex.
104 - 100half - 100M half-duplex.
105 - 1000full - 1000M full-duplex.
106 - 10000full - 10000M full-duplex.
107 choices: ['auto', '10full', '10half', '100full', '100half', '1000full',
108 '10000full', '1g/full', '2.5g/full', '5g/full', '10g/full', '14g/full',
109 '20g/full', '25g/full', '40g/full', '50g/full', '56g/full', '100g/full',
110 '1g/half', '200g/full', '400g/full']
111 status:
112 type: str
113 description:
114 - Interface status.
115 - down - Interface down.
116 - up - Interface up.
117 choices: ['down', 'up', 'disable', 'enable']
118 rating_service_ip:
119 aliases: ['rating-service-ip']
120 type: str
121 description: IP address for fgt rating service, must be same subnet with interface ip.
122 update_service_ip:
123 aliases: ['update-service-ip']
124 type: str
125 description: IP address for fgt/fct update service, must be same subnet with interface ip.
126 aggregate:
127 type: str
128 description: Aggregate interface.
129 interface:
130 type: str
131 description: Underlying interface name.
132 lacp_mode:
133 aliases: ['lacp-mode']
134 type: str
135 description:
136 - LACP mode.
137 - active - Actively use LACP to negotiate 802.
138 choices: ['active']
139 lacp_speed:
140 aliases: ['lacp-speed']
141 type: str
142 description:
143 - How often the interface sends LACP messages.
144 - slow - Send LACP message every 30 seconds.
145 - fast - Send LACP message every second.
146 choices: ['slow', 'fast']
147 link_up_delay:
148 aliases: ['link-up-delay']
149 type: int
150 description: Number of milliseconds to wait before considering a link is up.
151 member:
152 type: list
153 elements: dict
154 description: Member.
155 suboptions:
156 interface_name:
157 aliases: ['interface-name']
158 type: str
159 description: Physical interface name.
160 min_links:
161 aliases: ['min-links']
162 type: int
163 description: Minimum number of aggregated ports that must be up.
164 min_links_down:
165 aliases: ['min-links-down']
166 type: str
167 description:
168 - Action to take when less than the configured minimum number of links are active.
169 - operational - Set the aggregate operationally down.
170 - administrative - Set the aggregate administratively down.
171 choices: ['operational', 'administrative']
172 type:
173 type: str
174 description:
175 - Interface type.
176 - vlan - VLAN interface.
177 - physical - Physical interface.
178 - aggregate - Aggregate interface.
179 choices: ['vlan', 'physical', 'aggregate']
180 vlan_protocol:
181 aliases: ['vlan-protocol']
182 type: str
183 description:
184 - Ethernet protocol of VLAN.
185 - 8021q - IEEE 802.
186 - 8021ad - IEEE 802.
187 choices: ['8021q', '8021ad']
188 vlanid:
189 type: int
190 description: VLAN ID
191 lldp:
192 type: str
193 description:
194 - Enable/disable LLDP
195 - disable - Disable setting.
196 - enable - Enable setting.
197 choices: ['disable', 'enable']
198 defaultgw:
199 type: str
200 description:
201 - Enable/disable default gateway.
202 - disable - Disable setting.
203 - enable - Enable setting.
204 choices: ['disable', 'enable']
205 dhcp_client_identifier:
206 aliases: ['dhcp-client-identifier']
207 type: str
208 description: DHCP client identifier.
209 dns_server_override:
210 aliases: ['dns-server-override']
211 type: str
212 description:
213 - Enable/disable use DNS acquired by DHCP or PPPoE.
214 - disable - Disable setting.
215 - enable - Enable setting.
216 choices: ['disable', 'enable']
217 mode:
218 type: str
219 description:
220 - Addressing mode
221 - static - Static setting.
222 - dhcp - External DHCP client mode.
223 choices: ['static', 'dhcp']
224 mtu_override:
225 aliases: ['mtu-override']
226 type: str
227 description:
228 - Enable/disable use MTU acquired by DHCP or PPPoE.
229 - disable - Disable setting.
230 - enable - Enable setting.
231 choices: ['disable', 'enable']
232 '''
233
234 EXAMPLES = '''
235 - name: Example playbook
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: Interface configuration.
245 fortinet.fortimanager.fmgr_system_interface:
246 bypass_validation: false
247 state: present
248 system_interface:
249 allowaccess:
250 - ping
251 ip: "222.222.22.2/24"
252 mtu: 1500
253 name: port4
254 serviceaccess:
255 - fgtupdates
256 speed: auto # <value in [auto, 10full, 10half, ...]>
257 status: up
258
259 - name: Gathering fortimanager facts
260 hosts: fortimanagers
261 gather_facts: false
262 connection: httpapi
263 vars:
264 ansible_httpapi_use_ssl: true
265 ansible_httpapi_validate_certs: false
266 ansible_httpapi_port: 443
267 tasks:
268 - name: Retrieve all the interfaces
269 fortinet.fortimanager.fmgr_fact:
270 facts:
271 selector: "system_interface"
272 params:
273 interface: "your_value"
274 '''
275
276 RETURN = '''
277 meta:
278 description: The result of the request.
279 type: dict
280 returned: always
281 contains:
282 request_url:
283 description: The full url requested.
284 returned: always
285 type: str
286 sample: /sys/login/user
287 response_code:
288 description: The status of api request.
289 returned: always
290 type: int
291 sample: 0
292 response_data:
293 description: The api response.
294 type: list
295 returned: always
296 response_message:
297 description: The descriptive message of the api response.
298 type: str
299 returned: always
300 sample: OK.
301 system_information:
302 description: The information of the target system.
303 type: dict
304 returned: always
305 rc:
306 description: The status the request.
307 type: int
308 returned: always
309 sample: 0
310 version_check_warning:
311 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
312 type: list
313 returned: complex
314 '''
315 from ansible.module_utils.basic import AnsibleModule
316 from ansible.module_utils.connection import Connection
317 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
318 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
319
320
321 def main():
322 urls_list = [
323 '/cli/global/system/interface'
324 ]
325 module_arg_spec = {
326 'system_interface': {
327 'type': 'dict', 'v_range': [['6.0.0', '']],
328 'options': {
329 'alias': {'type': 'str'},
330 'allowaccess': {
331 'type': 'list',
332 'choices': ['ping', 'https', 'ssh', 'snmp', 'http', 'webservice', 'https-logging', 'soc-fabric', 'fabric'],
333 'elements': 'str'
334 },
335 'description': {'type': 'str'},
336 'ip': {'type': 'str'},
337 'ipv6': {
338 'type': 'dict',
339 'options': {
340 'ip6-address': {'type': 'str'},
341 'ip6-allowaccess': {
342 'type': 'list',
343 'choices': ['ping', 'https', 'ssh', 'snmp', 'http', 'webservice', 'https-logging', 'fabric'],
344 'elements': 'str'
345 },
346 'ip6-autoconf': {'choices': ['disable', 'enable'], 'type': 'str'}
347 }
348 },
349 'mtu': {'type': 'int'},
350 'name': {'required': True, 'type': 'str'},
351 'serviceaccess': {'type': 'list', 'choices': ['fgtupdates', 'fclupdates', 'webfilter-antispam'], 'elements': 'str'},
352 'speed': {
353 'choices': [
354 'auto', '10full', '10half', '100full', '100half', '1000full', '10000full', '1g/full', '2.5g/full', '5g/full', '10g/full',
355 '14g/full', '20g/full', '25g/full', '40g/full', '50g/full', '56g/full', '100g/full', '1g/half', '200g/full', '400g/full'
356 ],
357 'type': 'str'
358 },
359 'status': {'choices': ['down', 'up', 'disable', 'enable'], 'type': 'str'},
360 'rating-service-ip': {'v_range': [['6.2.2', '']], 'type': 'str'},
361 'update-service-ip': {'v_range': [['6.2.2', '']], 'type': 'str'},
362 'aggregate': {'v_range': [['7.2.0', '']], 'type': 'str'},
363 'interface': {'v_range': [['7.2.0', '']], 'type': 'str'},
364 'lacp-mode': {'v_range': [['7.2.0', '']], 'choices': ['active'], 'type': 'str'},
365 'lacp-speed': {'v_range': [['7.2.0', '']], 'choices': ['slow', 'fast'], 'type': 'str'},
366 'link-up-delay': {'v_range': [['7.2.0', '']], 'type': 'int'},
367 'member': {
368 'v_range': [['7.2.0', '']],
369 'type': 'list',
370 'options': {'interface-name': {'v_range': [['7.2.0', '']], 'type': 'str'}},
371 'elements': 'dict'
372 },
373 'min-links': {'v_range': [['7.2.0', '']], 'type': 'int'},
374 'min-links-down': {'v_range': [['7.2.0', '']], 'choices': ['operational', 'administrative'], 'type': 'str'},
375 'type': {'v_range': [['7.2.0', '']], 'choices': ['vlan', 'physical', 'aggregate'], 'type': 'str'},
376 'vlan-protocol': {'v_range': [['7.2.0', '']], 'choices': ['8021q', '8021ad'], 'type': 'str'},
377 'vlanid': {'v_range': [['7.2.0', '']], 'type': 'int'},
378 'lldp': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
379 'defaultgw': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
380 'dhcp-client-identifier': {'v_range': [['7.4.2', '']], 'type': 'str'},
381 'dns-server-override': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
382 'mode': {'v_range': [['7.4.2', '']], 'choices': ['static', 'dhcp'], 'type': 'str'},
383 'mtu-override': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
384 }
385 }
386 }
387
388 module_option_spec = get_module_arg_spec('full crud')
389 module_arg_spec.update(module_option_spec)
390 check_galaxy_version(module_arg_spec)
391 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_interface'),
392 supports_check_mode=True)
393 if not module._socket_path:
394 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
395 connection = Connection(module._socket_path)
396 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
397 'name', 'data', module, connection)
398 fmgr.process_crud()
399 module.exit_json(meta=module.params)
400
401
402 if __name__ == '__main__':
403 main()