summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/network/fortios/fortios_system_interface.py
blob: 5a1da7590b5fae55b9a77cfe402e97aedd9ab875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
#!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
# Copyright 2019 Fortinet, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
# the lib use python logging can get it if the following is set in your
# Ansible config.

__metaclass__ = type

ANSIBLE_METADATA = {'status': ['preview'],
                    'supported_by': 'community',
                    'metadata_version': '1.1'}

DOCUMENTATION = '''
---
module: fortios_system_interface
short_description: Configure interfaces in Fortinet's FortiOS and FortiGate.
description:
    - This module is able to configure a FortiGate or FortiOS by allowing the
      user to set and modify system feature and interface category.
      Examples include all parameters and values need to be adjusted to datasources before usage.
      Tested with FOS v6.0.2
version_added: "2.8"
author:
    - Miguel Angel Munoz (@mamunozgonzalez)
    - Nicolas Thomas (@thomnico)
notes:
    - Requires fortiosapi library developed by Fortinet
    - Run as a local_action in your playbook
requirements:
    - fortiosapi>=0.9.8
options:
    host:
       description:
            - FortiOS or FortiGate ip address.
       required: true
    username:
        description:
            - FortiOS or FortiGate username.
        required: true
    password:
        description:
            - FortiOS or FortiGate password.
        default: ""
    vdom:
        description:
            - Virtual domain, among those defined previously. A vdom is a
              virtual instance of the FortiGate that can be configured and
              used as a different unit.
        default: root
    https:
        description:
            - Indicates if the requests towards FortiGate must use HTTPS
              protocol
        type: bool
        default: true
    system_interface:
        description:
            - Configure interfaces.
        default: null
        suboptions:
            state:
                description:
                    - Indicates whether to create or remove the object
                choices:
                    - present
                    - absent
            ac-name:
                description:
                    - PPPoE server name.
            aggregate:
                description:
                    - Aggregate interface.
            algorithm:
                description:
                    - Frame distribution algorithm.
                choices:
                    - L2
                    - L3
                    - L4
            alias:
                description:
                    - Alias will be displayed with the interface name to make it easier to distinguish.
            allowaccess:
                description:
                    - Permitted types of management access to this interface.
                choices:
                    - ping
                    - https
                    - ssh
                    - snmp
                    - http
                    - telnet
                    - fgfm
                    - radius-acct
                    - probe-response
                    - capwap
                    - ftm
            ap-discover:
                description:
                    - Enable/disable automatic registration of unknown FortiAP devices.
                choices:
                    - enable
                    - disable
            arpforward:
                description:
                    - Enable/disable ARP forwarding.
                choices:
                    - enable
                    - disable
            auth-type:
                description:
                    - PPP authentication type to use.
                choices:
                    - auto
                    - pap
                    - chap
                    - mschapv1
                    - mschapv2
            auto-auth-extension-device:
                description:
                    - Enable/disable automatic authorization of dedicated Fortinet extension device on this interface.
                choices:
                    - enable
                    - disable
            bfd:
                description:
                    - Bidirectional Forwarding Detection (BFD) settings.
                choices:
                    - global
                    - enable
                    - disable
            bfd-desired-min-tx:
                description:
                    - BFD desired minimal transmit interval.
            bfd-detect-mult:
                description:
                    - BFD detection multiplier.
            bfd-required-min-rx:
                description:
                    - BFD required minimal receive interval.
            broadcast-forticlient-discovery:
                description:
                    - Enable/disable broadcasting FortiClient discovery messages.
                choices:
                    - enable
                    - disable
            broadcast-forward:
                description:
                    - Enable/disable broadcast forwarding.
                choices:
                    - enable
                    - disable
            captive-portal:
                description:
                    - Enable/disable captive portal.
            cli-conn-status:
                description:
                    - CLI connection status.
            color:
                description:
                    - Color of icon on the GUI.
            dedicated-to:
                description:
                    - Configure interface for single purpose.
                choices:
                    - none
                    - management
            defaultgw:
                description:
                    - Enable to get the gateway IP from the DHCP or PPPoE server.
                choices:
                    - enable
                    - disable
            description:
                description:
                    - Description.
            detected-peer-mtu:
                description:
                    - MTU of detected peer (0 - 4294967295).
            detectprotocol:
                description:
                    - Protocols used to detect the server.
                choices:
                    - ping
                    - tcp-echo
                    - udp-echo
            detectserver:
                description:
                    - Gateway's ping server for this IP.
            device-access-list:
                description:
                    - Device access list.
            device-identification:
                description:
                    - Enable/disable passively gathering of device identity information about the devices on the network connected to this interface.
                choices:
                    - enable
                    - disable
            device-identification-active-scan:
                description:
                    - Enable/disable active gathering of device identity information about the devices on the network connected to this interface.
                choices:
                    - enable
                    - disable
            device-netscan:
                description:
                    - Enable/disable inclusion of devices detected on this interface in network vulnerability scans.
                choices:
                    - disable
                    - enable
            device-user-identification:
                description:
                    - Enable/disable passive gathering of user identity information about users on this interface.
                choices:
                    - enable
                    - disable
            devindex:
                description:
                    - Device Index.
            dhcp-client-identifier:
                description:
                    - DHCP client identifier.
            dhcp-relay-agent-option:
                description:
                    - Enable/disable DHCP relay agent option.
                choices:
                    - enable
                    - disable
            dhcp-relay-ip:
                description:
                    - DHCP relay IP address.
            dhcp-relay-service:
                description:
                    - Enable/disable allowing this interface to act as a DHCP relay.
                choices:
                    - disable
                    - enable
            dhcp-relay-type:
                description:
                    - DHCP relay type (regular or IPsec).
                choices:
                    - regular
                    - ipsec
            dhcp-renew-time:
                description:
                    - DHCP renew time in seconds (300-604800), 0 means use the renew time provided by the server.
            disc-retry-timeout:
                description:
                    - Time in seconds to wait before retrying to start a PPPoE discovery, 0 means no timeout.
            disconnect-threshold:
                description:
                    - Time in milliseconds to wait before sending a notification that this interface is down or disconnected.
            distance:
                description:
                    - Distance for routes learned through PPPoE or DHCP, lower distance indicates preferred route.
            dns-server-override:
                description:
                    - Enable/disable use DNS acquired by DHCP or PPPoE.
                choices:
                    - enable
                    - disable
            drop-fragment:
                description:
                    - Enable/disable drop fragment packets.
                choices:
                    - enable
                    - disable
            drop-overlapped-fragment:
                description:
                    - Enable/disable drop overlapped fragment packets.
                choices:
                    - enable
                    - disable
            egress-shaping-profile:
                description:
                    - Outgoing traffic shaping profile.
            endpoint-compliance:
                description:
                    - Enable/disable endpoint compliance enforcement.
                choices:
                    - enable
                    - disable
            estimated-downstream-bandwidth:
                description:
                    - Estimated maximum downstream bandwidth (kbps). Used to estimate link utilization.
            estimated-upstream-bandwidth:
                description:
                    - Estimated maximum upstream bandwidth (kbps). Used to estimate link utilization.
            explicit-ftp-proxy:
                description:
                    - Enable/disable the explicit FTP proxy on this interface.
                choices:
                    - enable
                    - disable
            explicit-web-proxy:
                description:
                    - Enable/disable the explicit web proxy on this interface.
                choices:
                    - enable
                    - disable
            external:
                description:
                    - Enable/disable identifying the interface as an external interface (which usually means it's connected to the Internet).
                choices:
                    - enable
                    - disable
            fail-action-on-extender:
                description:
                    - Action on extender when interface fail .
                choices:
                    - soft-restart
                    - hard-restart
                    - reboot
            fail-alert-interfaces:
                description:
                    - Names of the FortiGate interfaces from which the link failure alert is sent for this interface.
                suboptions:
                    name:
                        description:
                            - Names of the physical interfaces belonging to the aggregate or redundant interface. Source system.interface.name.
                        required: true
            fail-alert-method:
                description:
                    - Select link-failed-signal or link-down method to alert about a failed link.
                choices:
                    - link-failed-signal
                    - link-down
            fail-detect:
                description:
                    - Enable/disable fail detection features for this interface.
                choices:
                    - enable
                    - disable
            fail-detect-option:
                description:
                    - Options for detecting that this interface has failed.
                choices:
                    - detectserver
                    - link-down
            fortiheartbeat:
                description:
                    - Enable/disable FortiHeartBeat (FortiTelemetry on GUI).
                choices:
                    - enable
                    - disable
            fortilink:
                description:
                    - Enable FortiLink to dedicate this interface to manage other Fortinet devices.
                choices:
                    - enable
                    - disable
            fortilink-backup-link:
                description:
                    - fortilink split interface backup link.
            fortilink-split-interface:
                description:
                    - Enable/disable FortiLink split interface to connect member link to different FortiSwitch in stack for uplink redundancy (maximum 2
                       interfaces in the "members" command).
                choices:
                    - enable
                    - disable
            fortilink-stacking:
                description:
                    - Enable/disable FortiLink switch-stacking on this interface.
                choices:
                    - enable
                    - disable
            forward-domain:
                description:
                    - Transparent mode forward domain.
            gwdetect:
                description:
                    - Enable/disable detect gateway alive for first.
                choices:
                    - enable
                    - disable
            ha-priority:
                description:
                    - HA election priority for the PING server.
            icmp-accept-redirect:
                description:
                    - Enable/disable ICMP accept redirect.
                choices:
                    - enable
                    - disable
            icmp-send-redirect:
                description:
                    - Enable/disable ICMP send redirect.
                choices:
                    - enable
                    - disable
            ident-accept:
                description:
                    - Enable/disable authentication for this interface.
                choices:
                    - enable
                    - disable
            idle-timeout:
                description:
                    - PPPoE auto disconnect after idle timeout seconds, 0 means no timeout.
            inbandwidth:
                description:
                    - Bandwidth limit for incoming traffic (0 - 16776000 kbps), 0 means unlimited.
            ingress-spillover-threshold:
                description:
                    - Ingress Spillover threshold (0 - 16776000 kbps).
            interface:
                description:
                    - Interface name. Source system.interface.name.
            internal:
                description:
                    - Implicitly created.
            ip:
                description:
                    - "Interface IPv4 address and subnet mask, syntax: X.X.X.X/24."
            ipmac:
                description:
                    - Enable/disable IP/MAC binding.
                choices:
                    - enable
                    - disable
            ips-sniffer-mode:
                description:
                    - Enable/disable the use of this interface as a one-armed sniffer.
                choices:
                    - enable
                    - disable
            ipunnumbered:
                description:
                    - Unnumbered IP used for PPPoE interfaces for which no unique local address is provided.
            ipv6:
                description:
                    - IPv6 of interface.
                suboptions:
                    autoconf:
                        description:
                            - Enable/disable address auto config.
                        choices:
                            - enable
                            - disable
                    dhcp6-client-options:
                        description:
                            - DHCPv6 client options.
                        choices:
                            - rapid
                            - iapd
                            - iana
                    dhcp6-information-request:
                        description:
                            - Enable/disable DHCPv6 information request.
                        choices:
                            - enable
                            - disable
                    dhcp6-prefix-delegation:
                        description:
                            - Enable/disable DHCPv6 prefix delegation.
                        choices:
                            - enable
                            - disable
                    dhcp6-prefix-hint:
                        description:
                            - DHCPv6 prefix that will be used as a hint to the upstream DHCPv6 server.
                    dhcp6-prefix-hint-plt:
                        description:
                            - DHCPv6 prefix hint preferred life time (sec), 0 means unlimited lease time.
                    dhcp6-prefix-hint-vlt:
                        description:
                            - DHCPv6 prefix hint valid life time (sec).
                    dhcp6-relay-ip:
                        description:
                            - DHCPv6 relay IP address.
                    dhcp6-relay-service:
                        description:
                            - Enable/disable DHCPv6 relay.
                        choices:
                            - disable
                            - enable
                    dhcp6-relay-type:
                        description:
                            - DHCPv6 relay type.
                        choices:
                            - regular
                    ip6-address:
                        description:
                            - "Primary IPv6 address prefix, syntax: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/xxx"
                    ip6-allowaccess:
                        description:
                            - Allow management access to the interface.
                        choices:
                            - ping
                            - https
                            - ssh
                            - snmp
                            - http
                            - telnet
                            - fgfm
                            - capwap
                    ip6-default-life:
                        description:
                            - Default life (sec).
                    ip6-delegated-prefix-list:
                        description:
                            - Advertised IPv6 delegated prefix list.
                        suboptions:
                            autonomous-flag:
                                description:
                                    - Enable/disable the autonomous flag.
                                choices:
                                    - enable
                                    - disable
                            onlink-flag:
                                description:
                                    - Enable/disable the onlink flag.
                                choices:
                                    - enable
                                    - disable
                            prefix-id:
                                description:
                                    - Prefix ID.
                                required: true
                            rdnss:
                                description:
                                    - Recursive DNS server option.
                            rdnss-service:
                                description:
                                    - Recursive DNS service option.
                                choices:
                                    - delegated
                                    - default
                                    - specify
                            subnet:
                                description:
                                    -  Add subnet ID to routing prefix.
                            upstream-interface:
                                description:
                                    - Name of the interface that provides delegated information. Source system.interface.name.
                    ip6-dns-server-override:
                        description:
                            - Enable/disable using the DNS server acquired by DHCP.
                        choices:
                            - enable
                            - disable
                    ip6-extra-addr:
                        description:
                            - Extra IPv6 address prefixes of interface.
                        suboptions:
                            prefix:
                                description:
                                    - IPv6 address prefix.
                                required: true
                    ip6-hop-limit:
                        description:
                            - Hop limit (0 means unspecified).
                    ip6-link-mtu:
                        description:
                            - IPv6 link MTU.
                    ip6-manage-flag:
                        description:
                            - Enable/disable the managed flag.
                        choices:
                            - enable
                            - disable
                    ip6-max-interval:
                        description:
                            - IPv6 maximum interval (4 to 1800 sec).
                    ip6-min-interval:
                        description:
                            - IPv6 minimum interval (3 to 1350 sec).
                    ip6-mode:
                        description:
                            - Addressing mode (static, DHCP, delegated).
                        choices:
                            - static
                            - dhcp
                            - pppoe
                            - delegated
                    ip6-other-flag:
                        description:
                            - Enable/disable the other IPv6 flag.
                        choices:
                            - enable
                            - disable
                    ip6-prefix-list:
                        description:
                            - Advertised prefix list.
                        suboptions:
                            autonomous-flag:
                                description:
                                    - Enable/disable the autonomous flag.
                                choices:
                                    - enable
                                    - disable
                            dnssl:
                                description:
                                    - DNS search list option.
                                suboptions:
                                    domain:
                                        description:
                                            - Domain name.
                                        required: true
                            onlink-flag:
                                description:
                                    - Enable/disable the onlink flag.
                                choices:
                                    - enable
                                    - disable
                            preferred-life-time:
                                description:
                                    - Preferred life time (sec).
                            prefix:
                                description:
                                    - IPv6 prefix.
                                required: true
                            rdnss:
                                description:
                                    - Recursive DNS server option.
                            valid-life-time:
                                description:
                                    - Valid life time (sec).
                    ip6-reachable-time:
                        description:
                            - IPv6 reachable time (milliseconds; 0 means unspecified).
                    ip6-retrans-time:
                        description:
                            - IPv6 retransmit time (milliseconds; 0 means unspecified).
                    ip6-send-adv:
                        description:
                            - Enable/disable sending advertisements about the interface.
                        choices:
                            - enable
                            - disable
                    ip6-subnet:
                        description:
                            - " Subnet to routing prefix, syntax: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/xxx"
                    ip6-upstream-interface:
                        description:
                            - Interface name providing delegated information. Source system.interface.name.
                    nd-cert:
                        description:
                            - Neighbor discovery certificate. Source certificate.local.name.
                    nd-cga-modifier:
                        description:
                            - Neighbor discovery CGA modifier.
                    nd-mode:
                        description:
                            - Neighbor discovery mode.
                        choices:
                            - basic
                            - SEND-compatible
                    nd-security-level:
                        description:
                            - Neighbor discovery security level (0 - 7; 0 = least secure, default = 0).
                    nd-timestamp-delta:
                        description:
                            - Neighbor discovery timestamp delta value (1 - 3600 sec; default = 300).
                    nd-timestamp-fuzz:
                        description:
                            - Neighbor discovery timestamp fuzz factor (1 - 60 sec; default = 1).
                    vrip6_link_local:
                        description:
                            - Link-local IPv6 address of virtual router.
                    vrrp-virtual-mac6:
                        description:
                            - Enable/disable virtual MAC for VRRP.
                        choices:
                            - enable
                            - disable
                    vrrp6:
                        description:
                            - IPv6 VRRP configuration.
                        suboptions:
                            accept-mode:
                                description:
                                    - Enable/disable accept mode.
                                choices:
                                    - enable
                                    - disable
                            adv-interval:
                                description:
                                    - Advertisement interval (1 - 255 seconds).
                            preempt:
                                description:
                                    - Enable/disable preempt mode.
                                choices:
                                    - enable
                                    - disable
                            priority:
                                description:
                                    - Priority of the virtual router (1 - 255).
                            start-time:
                                description:
                                    - Startup time (1 - 255 seconds).
                            status:
                                description:
                                    - Enable/disable VRRP.
                                choices:
                                    - enable
                                    - disable
                            vrdst6:
                                description:
                                    - Monitor the route to this destination.
                            vrgrp:
                                description:
                                    - VRRP group ID (1 - 65535).
                            vrid:
                                description:
                                    - Virtual router identifier (1 - 255).
                                required: true
                            vrip6:
                                description:
                                    - IPv6 address of the virtual router.
            l2forward:
                description:
                    - Enable/disable l2 forwarding.
                choices:
                    - enable
                    - disable
            lacp-ha-slave:
                description:
                    - LACP HA slave.
                choices:
                    - enable
                    - disable
            lacp-mode:
                description:
                    - LACP mode.
                choices:
                    - static
                    - passive
                    - active
            lacp-speed:
                description:
                    - How often the interface sends LACP messages.
                choices:
                    - slow
                    - fast
            lcp-echo-interval:
                description:
                    - Time in seconds between PPPoE Link Control Protocol (LCP) echo requests.
            lcp-max-echo-fails:
                description:
                    - Maximum missed LCP echo messages before disconnect.
            link-up-delay:
                description:
                    - Number of milliseconds to wait before considering a link is up.
            lldp-transmission:
                description:
                    - Enable/disable Link Layer Discovery Protocol (LLDP) transmission.
                choices:
                    - enable
                    - disable
                    - vdom
            macaddr:
                description:
                    - Change the interface's MAC address.
            managed-device:
                description:
                    - Available when FortiLink is enabled, used for managed devices through FortiLink interface.
                suboptions:
                    name:
                        description:
                            - Managed dev identifier.
                        required: true
            management-ip:
                description:
                    - High Availability in-band management IP address of this interface.
            member:
                description:
                    - Physical interfaces that belong to the aggregate or redundant interface.
                suboptions:
                    interface-name:
                        description:
                            - Physical interface name. Source system.interface.name.
                        required: true
            min-links:
                description:
                    - Minimum number of aggregated ports that must be up.
            min-links-down:
                description:
                    - Action to take when less than the configured minimum number of links are active.
                choices:
                    - operational
                    - administrative
            mode:
                description:
                    - Addressing mode (static, DHCP, PPPoE).
                choices:
                    - static
                    - dhcp
                    - pppoe
            mtu:
                description:
                    - MTU value for this interface.
            mtu-override:
                description:
                    - Enable to set a custom MTU for this interface.
                choices:
                    - enable
                    - disable
            name:
                description:
                    - Name.
                required: true
            ndiscforward:
                description:
                    - Enable/disable NDISC forwarding.
                choices:
                    - enable
                    - disable
            netbios-forward:
                description:
                    - Enable/disable NETBIOS forwarding.
                choices:
                    - disable
                    - enable
            netflow-sampler:
                description:
                    - Enable/disable NetFlow on this interface and set the data that NetFlow collects (rx, tx, or both).
                choices:
                    - disable
                    - tx
                    - rx
                    - both
            outbandwidth:
                description:
                    - Bandwidth limit for outgoing traffic (0 - 16776000 kbps).
            padt-retry-timeout:
                description:
                    - PPPoE Active Discovery Terminate (PADT) used to terminate sessions after an idle time.
            password:
                description:
                    - PPPoE account's password.
            ping-serv-status:
                description:
                    - PING server status.
            polling-interval:
                description:
                    - sFlow polling interval (1 - 255 sec).
            pppoe-unnumbered-negotiate:
                description:
                    - Enable/disable PPPoE unnumbered negotiation.
                choices:
                    - enable
                    - disable
            pptp-auth-type:
                description:
                    - PPTP authentication type.
                choices:
                    - auto
                    - pap
                    - chap
                    - mschapv1
                    - mschapv2
            pptp-client:
                description:
                    - Enable/disable PPTP client.
                choices:
                    - enable
                    - disable
            pptp-password:
                description:
                    - PPTP password.
            pptp-server-ip:
                description:
                    - PPTP server IP address.
            pptp-timeout:
                description:
                    - Idle timer in minutes (0 for disabled).
            pptp-user:
                description:
                    - PPTP user name.
            preserve-session-route:
                description:
                    - Enable/disable preservation of session route when dirty.
                choices:
                    - enable
                    - disable
            priority:
                description:
                    - Priority of learned routes.
            priority-override:
                description:
                    - Enable/disable fail back to higher priority port once recovered.
                choices:
                    - enable
                    - disable
            proxy-captive-portal:
                description:
                    - Enable/disable proxy captive portal on this interface.
                choices:
                    - enable
                    - disable
            redundant-interface:
                description:
                    - Redundant interface.
            remote-ip:
                description:
                    - Remote IP address of tunnel.
            replacemsg-override-group:
                description:
                    - Replacement message override group.
            role:
                description:
                    - Interface role.
                choices:
                    - lan
                    - wan
                    - dmz
                    - undefined
            sample-direction:
                description:
                    - Data that NetFlow collects (rx, tx, or both).
                choices:
                    - tx
                    - rx
                    - both
            sample-rate:
                description:
                    - sFlow sample rate (10 - 99999).
            scan-botnet-connections:
                description:
                    - Enable monitoring or blocking connections to Botnet servers through this interface.
                choices:
                    - disable
                    - block
                    - monitor
            secondary-IP:
                description:
                    - Enable/disable adding a secondary IP to this interface.
                choices:
                    - enable
                    - disable
            secondaryip:
                description:
                    - Second IP address of interface.
                suboptions:
                    allowaccess:
                        description:
                            - Management access settings for the secondary IP address.
                        choices:
                            - ping
                            - https
                            - ssh
                            - snmp
                            - http
                            - telnet
                            - fgfm
                            - radius-acct
                            - probe-response
                            - capwap
                            - ftm
                    detectprotocol:
                        description:
                            - Protocols used to detect the server.
                        choices:
                            - ping
                            - tcp-echo
                            - udp-echo
                    detectserver:
                        description:
                            - Gateway's ping server for this IP.
                    gwdetect:
                        description:
                            - Enable/disable detect gateway alive for first.
                        choices:
                            - enable
                            - disable
                    ha-priority:
                        description:
                            - HA election priority for the PING server.
                    id:
                        description:
                            - ID.
                        required: true
                    ip:
                        description:
                            - Secondary IP address of the interface.
                    ping-serv-status:
                        description:
                            - PING server status.
            security-exempt-list:
                description:
                    - Name of security-exempt-list.
            security-external-logout:
                description:
                    - URL of external authentication logout server.
            security-external-web:
                description:
                    - URL of external authentication web server.
            security-groups:
                description:
                    - User groups that can authenticate with the captive portal.
                suboptions:
                    name:
                        description:
                            - Names of user groups that can authenticate with the captive portal.
                        required: true
            security-mac-auth-bypass:
                description:
                    - Enable/disable MAC authentication bypass.
                choices:
                    - enable
                    - disable
            security-mode:
                description:
                    - Turn on captive portal authentication for this interface.
                choices:
                    - none
                    - captive-portal
                    - 802.1X
            security-redirect-url:
                description:
                    - URL redirection after disclaimer/authentication.
            service-name:
                description:
                    - PPPoE service name.
            sflow-sampler:
                description:
                    - Enable/disable sFlow on this interface.
                choices:
                    - enable
                    - disable
            snmp-index:
                description:
                    - Permanent SNMP Index of the interface.
            speed:
                description:
                    - Interface speed. The default setting and the options available depend on the interface hardware.
                choices:
                    - auto
                    - 10full
                    - 10half
                    - 100full
                    - 100half
                    - 1000full
                    - 1000half
                    - 1000auto
            spillover-threshold:
                description:
                    - Egress Spillover threshold (0 - 16776000 kbps), 0 means unlimited.
            src-check:
                description:
                    - Enable/disable source IP check.
                choices:
                    - enable
                    - disable
            status:
                description:
                    - Bring the interface up or shut the interface down.
                choices:
                    - up
                    - down
            stpforward:
                description:
                    - Enable/disable STP forwarding.
                choices:
                    - enable
                    - disable
            stpforward-mode:
                description:
                    - Configure STP forwarding mode.
                choices:
                    - rpl-all-ext-id
                    - rpl-bridge-ext-id
                    - rpl-nothing
            subst:
                description:
                    - Enable to always send packets from this interface to a destination MAC address.
                choices:
                    - enable
                    - disable
            substitute-dst-mac:
                description:
                    - Destination MAC address that all packets are sent to from this interface.
            switch:
                description:
                    - Contained in switch.
            switch-controller-access-vlan:
                description:
                    - Block FortiSwitch port-to-port traffic.
                choices:
                    - enable
                    - disable
            switch-controller-arp-inspection:
                description:
                    - Enable/disable FortiSwitch ARP inspection.
                choices:
                    - enable
                    - disable
            switch-controller-dhcp-snooping:
                description:
                    - Switch controller DHCP snooping.
                choices:
                    - enable
                    - disable
            switch-controller-dhcp-snooping-option82:
                description:
                    - Switch controller DHCP snooping option82.
                choices:
                    - enable
                    - disable
            switch-controller-dhcp-snooping-verify-mac:
                description:
                    - Switch controller DHCP snooping verify MAC.
                choices:
                    - enable
                    - disable
            switch-controller-igmp-snooping:
                description:
                    - Switch controller IGMP snooping.
                choices:
                    - enable
                    - disable
            switch-controller-learning-limit:
                description:
                    - Limit the number of dynamic MAC addresses on this VLAN (1 - 128, 0 = no limit, default).
            tagging:
                description:
                    - Config object tagging.
                suboptions:
                    category:
                        description:
                            - Tag category. Source system.object-tagging.category.
                    name:
                        description:
                            - Tagging entry name.
                        required: true
                    tags:
                        description:
                            - Tags.
                        suboptions:
                            name:
                                description:
                                    - Tag name. Source system.object-tagging.tags.name.
                                required: true
            tcp-mss:
                description:
                    - TCP maximum segment size. 0 means do not change segment size.
            trust-ip-1:
                description:
                    - Trusted host for dedicated management traffic (0.0.0.0/24 for all hosts).
            trust-ip-2:
                description:
                    - Trusted host for dedicated management traffic (0.0.0.0/24 for all hosts).
            trust-ip-3:
                description:
                    - Trusted host for dedicated management traffic (0.0.0.0/24 for all hosts).
            trust-ip6-1:
                description:
                    - "Trusted IPv6 host for dedicated management traffic (::/0 for all hosts)."
            trust-ip6-2:
                description:
                    - "Trusted IPv6 host for dedicated management traffic (::/0 for all hosts)."
            trust-ip6-3:
                description:
                    - "Trusted IPv6 host for dedicated management traffic (::/0 for all hosts)."
            type:
                description:
                    - Interface type.
                choices:
                    - physical
                    - vlan
                    - aggregate
                    - redundant
                    - tunnel
                    - vdom-link
                    - loopback
                    - switch
                    - hard-switch
                    - vap-switch
                    - wl-mesh
                    - fext-wan
                    - vxlan
                    - hdlc
                    - switch-vlan
            username:
                description:
                    - Username of the PPPoE account, provided by your ISP.
            vdom:
                description:
                    - Interface is in this virtual domain (VDOM). Source system.vdom.name.
            vindex:
                description:
                    - Switch control interface VLAN ID.
            vlanforward:
                description:
                    - Enable/disable traffic forwarding between VLANs on this interface.
                choices:
                    - enable
                    - disable
            vlanid:
                description:
                    - VLAN ID (1 - 4094).
            vrf:
                description:
                    - Virtual Routing Forwarding ID.
            vrrp:
                description:
                    - VRRP configuration.
                suboptions:
                    accept-mode:
                        description:
                            - Enable/disable accept mode.
                        choices:
                            - enable
                            - disable
                    adv-interval:
                        description:
                            - Advertisement interval (1 - 255 seconds).
                    preempt:
                        description:
                            - Enable/disable preempt mode.
                        choices:
                            - enable
                            - disable
                    priority:
                        description:
                            - Priority of the virtual router (1 - 255).
                    proxy-arp:
                        description:
                            - VRRP Proxy ARP configuration.
                        suboptions:
                            id:
                                description:
                                    - ID.
                                required: true
                            ip:
                                description:
                                    - Set IP addresses of proxy ARP.
                    start-time:
                        description:
                            - Startup time (1 - 255 seconds).
                    status:
                        description:
                            - Enable/disable this VRRP configuration.
                        choices:
                            - enable
                            - disable
                    version:
                        description:
                            - VRRP version.
                        choices:
                            - 2
                            - 3
                    vrdst:
                        description:
                            - Monitor the route to this destination.
                    vrdst-priority:
                        description:
                            - Priority of the virtual router when the virtual router destination becomes unreachable (0 - 254).
                    vrgrp:
                        description:
                            - VRRP group ID (1 - 65535).
                    vrid:
                        description:
                            - Virtual router identifier (1 - 255).
                        required: true
                    vrip:
                        description:
                            - IP address of the virtual router.
            vrrp-virtual-mac:
                description:
                    - Enable/disable use of virtual MAC for VRRP.
                choices:
                    - enable
                    - disable
            wccp:
                description:
                    - Enable/disable WCCP on this interface. Used for encapsulated WCCP communication between WCCP clients and servers.
                choices:
                    - enable
                    - disable
            weight:
                description:
                    - Default weight for static routes (if route has no weight configured).
            wins-ip:
                description:
                    - WINS server IP.
'''

EXAMPLES = '''
- hosts: localhost
  vars:
   host: "192.168.122.40"
   username: "admin"
   password: ""
   vdom: "root"
  tasks:
  - name: Configure interfaces.
    fortios_system_interface:
      host:  "{{ host }}"
      username: "{{ username }}"
      password: "{{ password }}"
      vdom:  "{{ vdom }}"
      https: "False"
      system_interface:
        state: "present"
        ac-name: "<your_own_value>"
        aggregate: "<your_own_value>"
        algorithm: "L2"
        alias: "<your_own_value>"
        allowaccess: "ping"
        ap-discover: "enable"
        arpforward: "enable"
        auth-type: "auto"
        auto-auth-extension-device: "enable"
        bfd: "global"
        bfd-desired-min-tx: "13"
        bfd-detect-mult: "14"
        bfd-required-min-rx: "15"
        broadcast-forticlient-discovery: "enable"
        broadcast-forward: "enable"
        captive-portal: "18"
        cli-conn-status: "19"
        color: "20"
        dedicated-to: "none"
        defaultgw: "enable"
        description: "<your_own_value>"
        detected-peer-mtu: "24"
        detectprotocol: "ping"
        detectserver: "<your_own_value>"
        device-access-list: "<your_own_value>"
        device-identification: "enable"
        device-identification-active-scan: "enable"
        device-netscan: "disable"
        device-user-identification: "enable"
        devindex: "32"
        dhcp-client-identifier:  "myId_33"
        dhcp-relay-agent-option: "enable"
        dhcp-relay-ip: "<your_own_value>"
        dhcp-relay-service: "disable"
        dhcp-relay-type: "regular"
        dhcp-renew-time: "38"
        disc-retry-timeout: "39"
        disconnect-threshold: "40"
        distance: "41"
        dns-server-override: "enable"
        drop-fragment: "enable"
        drop-overlapped-fragment: "enable"
        egress-shaping-profile: "<your_own_value>"
        endpoint-compliance: "enable"
        estimated-downstream-bandwidth: "47"
        estimated-upstream-bandwidth: "48"
        explicit-ftp-proxy: "enable"
        explicit-web-proxy: "enable"
        external: "enable"
        fail-action-on-extender: "soft-restart"
        fail-alert-interfaces:
         -
            name: "default_name_54 (source system.interface.name)"
        fail-alert-method: "link-failed-signal"
        fail-detect: "enable"
        fail-detect-option: "detectserver"
        fortiheartbeat: "enable"
        fortilink: "enable"
        fortilink-backup-link: "60"
        fortilink-split-interface: "enable"
        fortilink-stacking: "enable"
        forward-domain: "63"
        gwdetect: "enable"
        ha-priority: "65"
        icmp-accept-redirect: "enable"
        icmp-send-redirect: "enable"
        ident-accept: "enable"
        idle-timeout: "69"
        inbandwidth: "70"
        ingress-spillover-threshold: "71"
        interface: "<your_own_value> (source system.interface.name)"
        internal: "73"
        ip: "<your_own_value>"
        ipmac: "enable"
        ips-sniffer-mode: "enable"
        ipunnumbered: "<your_own_value>"
        ipv6:
            autoconf: "enable"
            dhcp6-client-options: "rapid"
            dhcp6-information-request: "enable"
            dhcp6-prefix-delegation: "enable"
            dhcp6-prefix-hint: "<your_own_value>"
            dhcp6-prefix-hint-plt: "84"
            dhcp6-prefix-hint-vlt: "85"
            dhcp6-relay-ip: "<your_own_value>"
            dhcp6-relay-service: "disable"
            dhcp6-relay-type: "regular"
            ip6-address: "<your_own_value>"
            ip6-allowaccess: "ping"
            ip6-default-life: "91"
            ip6-delegated-prefix-list:
             -
                autonomous-flag: "enable"
                onlink-flag: "enable"
                prefix-id: "95"
                rdnss: "<your_own_value>"
                rdnss-service: "delegated"
                subnet: "<your_own_value>"
                upstream-interface: "<your_own_value> (source system.interface.name)"
            ip6-dns-server-override: "enable"
            ip6-extra-addr:
             -
                prefix: "<your_own_value>"
            ip6-hop-limit: "103"
            ip6-link-mtu: "104"
            ip6-manage-flag: "enable"
            ip6-max-interval: "106"
            ip6-min-interval: "107"
            ip6-mode: "static"
            ip6-other-flag: "enable"
            ip6-prefix-list:
             -
                autonomous-flag: "enable"
                dnssl:
                 -
                    domain: "<your_own_value>"
                onlink-flag: "enable"
                preferred-life-time: "115"
                prefix: "<your_own_value>"
                rdnss: "<your_own_value>"
                valid-life-time: "118"
            ip6-reachable-time: "119"
            ip6-retrans-time: "120"
            ip6-send-adv: "enable"
            ip6-subnet: "<your_own_value>"
            ip6-upstream-interface: "<your_own_value> (source system.interface.name)"
            nd-cert: "<your_own_value> (source certificate.local.name)"
            nd-cga-modifier: "<your_own_value>"
            nd-mode: "basic"
            nd-security-level: "127"
            nd-timestamp-delta: "128"
            nd-timestamp-fuzz: "129"
            vrip6_link_local: "<your_own_value>"
            vrrp-virtual-mac6: "enable"
            vrrp6:
             -
                accept-mode: "enable"
                adv-interval: "134"
                preempt: "enable"
                priority: "136"
                start-time: "137"
                status: "enable"
                vrdst6: "<your_own_value>"
                vrgrp: "140"
                vrid: "141"
                vrip6: "<your_own_value>"
        l2forward: "enable"
        lacp-ha-slave: "enable"
        lacp-mode: "static"
        lacp-speed: "slow"
        lcp-echo-interval: "147"
        lcp-max-echo-fails: "148"
        link-up-delay: "149"
        lldp-transmission: "enable"
        macaddr: "<your_own_value>"
        managed-device:
         -
            name: "default_name_153"
        management-ip: "<your_own_value>"
        member:
         -
            interface-name: "<your_own_value> (source system.interface.name)"
        min-links: "157"
        min-links-down: "operational"
        mode: "static"
        mtu: "160"
        mtu-override: "enable"
        name: "default_name_162"
        ndiscforward: "enable"
        netbios-forward: "disable"
        netflow-sampler: "disable"
        outbandwidth: "166"
        padt-retry-timeout: "167"
        password: "<your_own_value>"
        ping-serv-status: "169"
        polling-interval: "170"
        pppoe-unnumbered-negotiate: "enable"
        pptp-auth-type: "auto"
        pptp-client: "enable"
        pptp-password: "<your_own_value>"
        pptp-server-ip: "<your_own_value>"
        pptp-timeout: "176"
        pptp-user: "<your_own_value>"
        preserve-session-route: "enable"
        priority: "179"
        priority-override: "enable"
        proxy-captive-portal: "enable"
        redundant-interface: "<your_own_value>"
        remote-ip: "<your_own_value>"
        replacemsg-override-group: "<your_own_value>"
        role: "lan"
        sample-direction: "tx"
        sample-rate: "187"
        scan-botnet-connections: "disable"
        secondary-IP: "enable"
        secondaryip:
         -
            allowaccess: "ping"
            detectprotocol: "ping"
            detectserver: "<your_own_value>"
            gwdetect: "enable"
            ha-priority: "195"
            id:  "196"
            ip: "<your_own_value>"
            ping-serv-status: "198"
        security-exempt-list: "<your_own_value>"
        security-external-logout: "<your_own_value>"
        security-external-web: "<your_own_value>"
        security-groups:
         -
            name: "default_name_203"
        security-mac-auth-bypass: "enable"
        security-mode: "none"
        security-redirect-url: "<your_own_value>"
        service-name: "<your_own_value>"
        sflow-sampler: "enable"
        snmp-index: "209"
        speed: "auto"
        spillover-threshold: "211"
        src-check: "enable"
        status: "up"
        stpforward: "enable"
        stpforward-mode: "rpl-all-ext-id"
        subst: "enable"
        substitute-dst-mac: "<your_own_value>"
        switch: "<your_own_value>"
        switch-controller-access-vlan: "enable"
        switch-controller-arp-inspection: "enable"
        switch-controller-dhcp-snooping: "enable"
        switch-controller-dhcp-snooping-option82: "enable"
        switch-controller-dhcp-snooping-verify-mac: "enable"
        switch-controller-igmp-snooping: "enable"
        switch-controller-learning-limit: "225"
        tagging:
         -
            category: "<your_own_value> (source system.object-tagging.category)"
            name: "default_name_228"
            tags:
             -
                name: "default_name_230 (source system.object-tagging.tags.name)"
        tcp-mss: "231"
        trust-ip-1: "<your_own_value>"
        trust-ip-2: "<your_own_value>"
        trust-ip-3: "<your_own_value>"
        trust-ip6-1: "<your_own_value>"
        trust-ip6-2: "<your_own_value>"
        trust-ip6-3: "<your_own_value>"
        type: "physical"
        username: "<your_own_value>"
        vdom: "<your_own_value> (source system.vdom.name)"
        vindex: "241"
        vlanforward: "enable"
        vlanid: "243"
        vrf: "244"
        vrrp:
         -
            accept-mode: "enable"
            adv-interval: "247"
            preempt: "enable"
            priority: "249"
            proxy-arp:
             -
                id:  "251"
                ip: "<your_own_value>"
            start-time: "253"
            status: "enable"
            version: "2"
            vrdst: "<your_own_value>"
            vrdst-priority: "257"
            vrgrp: "258"
            vrid: "259"
            vrip: "<your_own_value>"
        vrrp-virtual-mac: "enable"
        wccp: "enable"
        weight: "263"
        wins-ip: "<your_own_value>"
'''

RETURN = '''
build:
  description: Build number of the fortigate image
  returned: always
  type: str
  sample: '1547'
http_method:
  description: Last method used to provision the content into FortiGate
  returned: always
  type: str
  sample: 'PUT'
http_status:
  description: Last result given by FortiGate on last operation applied
  returned: always
  type: str
  sample: "200"
mkey:
  description: Master key (id) used in the last call to FortiGate
  returned: success
  type: str
  sample: "id"
name:
  description: Name of the table used to fulfill the request
  returned: always
  type: str
  sample: "urlfilter"
path:
  description: Path of the table used to fulfill the request
  returned: always
  type: str
  sample: "webfilter"
revision:
  description: Internal revision number
  returned: always
  type: str
  sample: "17.0.2.10658"
serial:
  description: Serial number of the unit
  returned: always
  type: str
  sample: "FGVMEVYYQT3AB5352"
status:
  description: Indication of the operation's result
  returned: always
  type: str
  sample: "success"
vdom:
  description: Virtual domain used
  returned: always
  type: str
  sample: "root"
version:
  description: Version of the FortiGate
  returned: always
  type: str
  sample: "v5.6.3"

'''

from ansible.module_utils.basic import AnsibleModule

fos = None


def login(data):
    host = data['host']
    username = data['username']
    password = data['password']

    fos.debug('on')
    if 'https' in data and not data['https']:
        fos.https('off')
    else:
        fos.https('on')

    fos.login(host, username, password)


def filter_system_interface_data(json):
    option_list = ['ac-name', 'aggregate', 'algorithm',
                   'alias', 'allowaccess', 'ap-discover',
                   'arpforward', 'auth-type', 'auto-auth-extension-device',
                   'bfd', 'bfd-desired-min-tx', 'bfd-detect-mult',
                   'bfd-required-min-rx', 'broadcast-forticlient-discovery', 'broadcast-forward',
                   'captive-portal', 'cli-conn-status', 'color',
                   'dedicated-to', 'defaultgw', 'description',
                   'detected-peer-mtu', 'detectprotocol', 'detectserver',
                   'device-access-list', 'device-identification', 'device-identification-active-scan',
                   'device-netscan', 'device-user-identification', 'devindex',
                   'dhcp-client-identifier', 'dhcp-relay-agent-option', 'dhcp-relay-ip',
                   'dhcp-relay-service', 'dhcp-relay-type', 'dhcp-renew-time',
                   'disc-retry-timeout', 'disconnect-threshold', 'distance',
                   'dns-server-override', 'drop-fragment', 'drop-overlapped-fragment',
                   'egress-shaping-profile', 'endpoint-compliance', 'estimated-downstream-bandwidth',
                   'estimated-upstream-bandwidth', 'explicit-ftp-proxy', 'explicit-web-proxy',
                   'external', 'fail-action-on-extender', 'fail-alert-interfaces',
                   'fail-alert-method', 'fail-detect', 'fail-detect-option',
                   'fortiheartbeat', 'fortilink', 'fortilink-backup-link',
                   'fortilink-split-interface', 'fortilink-stacking', 'forward-domain',
                   'gwdetect', 'ha-priority', 'icmp-accept-redirect',
                   'icmp-send-redirect', 'ident-accept', 'idle-timeout',
                   'inbandwidth', 'ingress-spillover-threshold', 'interface',
                   'internal', 'ip', 'ipmac',
                   'ips-sniffer-mode', 'ipunnumbered', 'ipv6',
                   'l2forward', 'lacp-ha-slave', 'lacp-mode',
                   'lacp-speed', 'lcp-echo-interval', 'lcp-max-echo-fails',
                   'link-up-delay', 'lldp-transmission', 'macaddr',
                   'managed-device', 'management-ip', 'member',
                   'min-links', 'min-links-down', 'mode',
                   'mtu', 'mtu-override', 'name',
                   'ndiscforward', 'netbios-forward', 'netflow-sampler',
                   'outbandwidth', 'padt-retry-timeout', 'password',
                   'ping-serv-status', 'polling-interval', 'pppoe-unnumbered-negotiate',
                   'pptp-auth-type', 'pptp-client', 'pptp-password',
                   'pptp-server-ip', 'pptp-timeout', 'pptp-user',
                   'preserve-session-route', 'priority', 'priority-override',
                   'proxy-captive-portal', 'redundant-interface', 'remote-ip',
                   'replacemsg-override-group', 'role', 'sample-direction',
                   'sample-rate', 'scan-botnet-connections', 'secondary-IP',
                   'secondaryip', 'security-exempt-list', 'security-external-logout',
                   'security-external-web', 'security-groups', 'security-mac-auth-bypass',
                   'security-mode', 'security-redirect-url', 'service-name',
                   'sflow-sampler', 'snmp-index', 'speed',
                   'spillover-threshold', 'src-check', 'status',
                   'stpforward', 'stpforward-mode', 'subst',
                   'substitute-dst-mac', 'switch', 'switch-controller-access-vlan',
                   'switch-controller-arp-inspection', 'switch-controller-dhcp-snooping', 'switch-controller-dhcp-snooping-option82',
                   'switch-controller-dhcp-snooping-verify-mac', 'switch-controller-igmp-snooping', 'switch-controller-learning-limit',
                   'tagging', 'tcp-mss', 'trust-ip-1',
                   'trust-ip-2', 'trust-ip-3', 'trust-ip6-1',
                   'trust-ip6-2', 'trust-ip6-3', 'type',
                   'username', 'vdom', 'vindex',
                   'vlanforward', 'vlanid', 'vrf',
                   'vrrp', 'vrrp-virtual-mac', 'wccp',
                   'weight', 'wins-ip']
    dictionary = {}

    for attribute in option_list:
        if attribute in json and json[attribute] is not None:
            dictionary[attribute] = json[attribute]

    return dictionary


def flatten_multilists_attributes(data):
    multilist_attrs = [[u'allowaccess'], [u'ipv6', u'ip6-allowaccess']]

    for attr in multilist_attrs:
        try:
            path = "data['" + "']['".join(elem for elem in attr) + "']"
            current_val = eval(path)
            flattened_val = ' '.join(elem for elem in current_val)
            exec(path + '= flattened_val')
        except BaseException:
            pass

    return data


def system_interface(data, fos):
    vdom = data['vdom']
    system_interface_data = data['system_interface']
    flattened_data = flatten_multilists_attributes(system_interface_data)
    filtered_data = filter_system_interface_data(flattened_data)
    if system_interface_data['state'] == "present":
        return fos.set('system',
                       'interface',
                       data=filtered_data,
                       vdom=vdom)

    elif system_interface_data['state'] == "absent":
        return fos.delete('system',
                          'interface',
                          mkey=filtered_data['name'],
                          vdom=vdom)


def fortios_system(data, fos):
    login(data)

    if data['system_interface']:
        resp = system_interface(data, fos)

    fos.logout()
    return not resp['status'] == "success", resp['status'] == "success", resp


def main():
    fields = {
        "host": {"required": True, "type": "str"},
        "username": {"required": True, "type": "str"},
        "password": {"required": False, "type": "str", "no_log": True},
        "vdom": {"required": False, "type": "str", "default": "root"},
        "https": {"required": False, "type": "bool", "default": True},
        "system_interface": {
            "required": False, "type": "dict",
            "options": {
                "state": {"required": True, "type": "str",
                          "choices": ["present", "absent"]},
                "ac-name": {"required": False, "type": "str"},
                "aggregate": {"required": False, "type": "str"},
                "algorithm": {"required": False, "type": "str",
                              "choices": ["L2", "L3", "L4"]},
                "alias": {"required": False, "type": "str"},
                "allowaccess": {"required": False, "type": "list",
                                "choices": ["ping", "https", "ssh",
                                            "snmp", "http", "telnet",
                                            "fgfm", "radius-acct", "probe-response",
                                            "capwap", "ftm"]},
                "ap-discover": {"required": False, "type": "str",
                                "choices": ["enable", "disable"]},
                "arpforward": {"required": False, "type": "str",
                               "choices": ["enable", "disable"]},
                "auth-type": {"required": False, "type": "str",
                              "choices": ["auto", "pap", "chap",
                                          "mschapv1", "mschapv2"]},
                "auto-auth-extension-device": {"required": False, "type": "str",
                                               "choices": ["enable", "disable"]},
                "bfd": {"required": False, "type": "str",
                        "choices": ["global", "enable", "disable"]},
                "bfd-desired-min-tx": {"required": False, "type": "int"},
                "bfd-detect-mult": {"required": False, "type": "int"},
                "bfd-required-min-rx": {"required": False, "type": "int"},
                "broadcast-forticlient-discovery": {"required": False, "type": "str",
                                                    "choices": ["enable", "disable"]},
                "broadcast-forward": {"required": False, "type": "str",
                                      "choices": ["enable", "disable"]},
                "captive-portal": {"required": False, "type": "int"},
                "cli-conn-status": {"required": False, "type": "int"},
                "color": {"required": False, "type": "int"},
                "dedicated-to": {"required": False, "type": "str",
                                 "choices": ["none", "management"]},
                "defaultgw": {"required": False, "type": "str",
                              "choices": ["enable", "disable"]},
                "description": {"required": False, "type": "str"},
                "detected-peer-mtu": {"required": False, "type": "int"},
                "detectprotocol": {"required": False, "type": "str",
                                   "choices": ["ping", "tcp-echo", "udp-echo"]},
                "detectserver": {"required": False, "type": "str"},
                "device-access-list": {"required": False, "type": "str"},
                "device-identification": {"required": False, "type": "str",
                                          "choices": ["enable", "disable"]},
                "device-identification-active-scan": {"required": False, "type": "str",
                                                      "choices": ["enable", "disable"]},
                "device-netscan": {"required": False, "type": "str",
                                   "choices": ["disable", "enable"]},
                "device-user-identification": {"required": False, "type": "str",
                                               "choices": ["enable", "disable"]},
                "devindex": {"required": False, "type": "int"},
                "dhcp-client-identifier": {"required": False, "type": "str"},
                "dhcp-relay-agent-option": {"required": False, "type": "str",
                                            "choices": ["enable", "disable"]},
                "dhcp-relay-ip": {"required": False, "type": "str"},
                "dhcp-relay-service": {"required": False, "type": "str",
                                       "choices": ["disable", "enable"]},
                "dhcp-relay-type": {"required": False, "type": "str",
                                    "choices": ["regular", "ipsec"]},
                "dhcp-renew-time": {"required": False, "type": "int"},
                "disc-retry-timeout": {"required": False, "type": "int"},
                "disconnect-threshold": {"required": False, "type": "int"},
                "distance": {"required": False, "type": "int"},
                "dns-server-override": {"required": False, "type": "str",
                                        "choices": ["enable", "disable"]},
                "drop-fragment": {"required": False, "type": "str",
                                  "choices": ["enable", "disable"]},
                "drop-overlapped-fragment": {"required": False, "type": "str",
                                             "choices": ["enable", "disable"]},
                "egress-shaping-profile": {"required": False, "type": "str"},
                "endpoint-compliance": {"required": False, "type": "str",
                                        "choices": ["enable", "disable"]},
                "estimated-downstream-bandwidth": {"required": False, "type": "int"},
                "estimated-upstream-bandwidth": {"required": False, "type": "int"},
                "explicit-ftp-proxy": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "explicit-web-proxy": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "external": {"required": False, "type": "str",
                             "choices": ["enable", "disable"]},
                "fail-action-on-extender": {"required": False, "type": "str",
                                            "choices": ["soft-restart", "hard-restart", "reboot"]},
                "fail-alert-interfaces": {"required": False, "type": "list",
                                          "options": {
                                              "name": {"required": True, "type": "str"}
                                          }},
                "fail-alert-method": {"required": False, "type": "str",
                                      "choices": ["link-failed-signal", "link-down"]},
                "fail-detect": {"required": False, "type": "str",
                                "choices": ["enable", "disable"]},
                "fail-detect-option": {"required": False, "type": "str",
                                       "choices": ["detectserver", "link-down"]},
                "fortiheartbeat": {"required": False, "type": "str",
                                   "choices": ["enable", "disable"]},
                "fortilink": {"required": False, "type": "str",
                              "choices": ["enable", "disable"]},
                "fortilink-backup-link": {"required": False, "type": "int"},
                "fortilink-split-interface": {"required": False, "type": "str",
                                              "choices": ["enable", "disable"]},
                "fortilink-stacking": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "forward-domain": {"required": False, "type": "int"},
                "gwdetect": {"required": False, "type": "str",
                             "choices": ["enable", "disable"]},
                "ha-priority": {"required": False, "type": "int"},
                "icmp-accept-redirect": {"required": False, "type": "str",
                                         "choices": ["enable", "disable"]},
                "icmp-send-redirect": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "ident-accept": {"required": False, "type": "str",
                                 "choices": ["enable", "disable"]},
                "idle-timeout": {"required": False, "type": "int"},
                "inbandwidth": {"required": False, "type": "int"},
                "ingress-spillover-threshold": {"required": False, "type": "int"},
                "interface": {"required": False, "type": "str"},
                "internal": {"required": False, "type": "int"},
                "ip": {"required": False, "type": "str"},
                "ipmac": {"required": False, "type": "str",
                          "choices": ["enable", "disable"]},
                "ips-sniffer-mode": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "ipunnumbered": {"required": False, "type": "str"},
                "ipv6": {"required": False, "type": "dict",
                         "options": {
                             "autoconf": {"required": False, "type": "str",
                                          "choices": ["enable", "disable"]},
                             "dhcp6-client-options": {"required": False, "type": "str",
                                                      "choices": ["rapid", "iapd", "iana"]},
                             "dhcp6-information-request": {"required": False, "type": "str",
                                                           "choices": ["enable", "disable"]},
                             "dhcp6-prefix-delegation": {"required": False, "type": "str",
                                                         "choices": ["enable", "disable"]},
                             "dhcp6-prefix-hint": {"required": False, "type": "str"},
                             "dhcp6-prefix-hint-plt": {"required": False, "type": "int"},
                             "dhcp6-prefix-hint-vlt": {"required": False, "type": "int"},
                             "dhcp6-relay-ip": {"required": False, "type": "str"},
                             "dhcp6-relay-service": {"required": False, "type": "str",
                                                     "choices": ["disable", "enable"]},
                             "dhcp6-relay-type": {"required": False, "type": "str",
                                                  "choices": ["regular"]},
                             "ip6-address": {"required": False, "type": "str"},
                             "ip6-allowaccess": {"required": False, "type": "list",
                                                 "choices": ["ping", "https", "ssh",
                                                             "snmp", "http", "telnet",
                                                             "fgfm", "capwap"]},
                             "ip6-default-life": {"required": False, "type": "int"},
                             "ip6-delegated-prefix-list": {"required": False, "type": "list",
                                                           "options": {
                                                               "autonomous-flag": {"required": False, "type": "str",
                                                                                   "choices": ["enable", "disable"]},
                                                               "onlink-flag": {"required": False, "type": "str",
                                                                               "choices": ["enable", "disable"]},
                                                               "prefix-id": {"required": True, "type": "int"},
                                                               "rdnss": {"required": False, "type": "str"},
                                                               "rdnss-service": {"required": False, "type": "str",
                                                                                 "choices": ["delegated", "default", "specify"]},
                                                               "subnet": {"required": False, "type": "str"},
                                                               "upstream-interface": {"required": False, "type": "str"}
                                                           }},
                             "ip6-dns-server-override": {"required": False, "type": "str",
                                                         "choices": ["enable", "disable"]},
                             "ip6-extra-addr": {"required": False, "type": "list",
                                                "options": {
                                                    "prefix": {"required": True, "type": "str"}
                                                }},
                             "ip6-hop-limit": {"required": False, "type": "int"},
                             "ip6-link-mtu": {"required": False, "type": "int"},
                             "ip6-manage-flag": {"required": False, "type": "str",
                                                 "choices": ["enable", "disable"]},
                             "ip6-max-interval": {"required": False, "type": "int"},
                             "ip6-min-interval": {"required": False, "type": "int"},
                             "ip6-mode": {"required": False, "type": "str",
                                          "choices": ["static", "dhcp", "pppoe",
                                                      "delegated"]},
                             "ip6-other-flag": {"required": False, "type": "str",
                                                "choices": ["enable", "disable"]},
                             "ip6-prefix-list": {"required": False, "type": "list",
                                                 "options": {
                                                     "autonomous-flag": {"required": False, "type": "str",
                                                                         "choices": ["enable", "disable"]},
                                                     "dnssl": {"required": False, "type": "list",
                                                               "options": {
                                                                   "domain": {"required": True, "type": "str"}
                                                               }},
                                                     "onlink-flag": {"required": False, "type": "str",
                                                                     "choices": ["enable", "disable"]},
                                                     "preferred-life-time": {"required": False, "type": "int"},
                                                     "prefix": {"required": True, "type": "str"},
                                                     "rdnss": {"required": False, "type": "str"},
                                                     "valid-life-time": {"required": False, "type": "int"}
                                                 }},
                             "ip6-reachable-time": {"required": False, "type": "int"},
                             "ip6-retrans-time": {"required": False, "type": "int"},
                             "ip6-send-adv": {"required": False, "type": "str",
                                              "choices": ["enable", "disable"]},
                             "ip6-subnet": {"required": False, "type": "str"},
                             "ip6-upstream-interface": {"required": False, "type": "str"},
                             "nd-cert": {"required": False, "type": "str"},
                             "nd-cga-modifier": {"required": False, "type": "str"},
                             "nd-mode": {"required": False, "type": "str",
                                         "choices": ["basic", "SEND-compatible"]},
                             "nd-security-level": {"required": False, "type": "int"},
                             "nd-timestamp-delta": {"required": False, "type": "int"},
                             "nd-timestamp-fuzz": {"required": False, "type": "int"},
                             "vrip6_link_local": {"required": False, "type": "str"},
                             "vrrp-virtual-mac6": {"required": False, "type": "str",
                                                   "choices": ["enable", "disable"]},
                             "vrrp6": {"required": False, "type": "list",
                                       "options": {
                                           "accept-mode": {"required": False, "type": "str",
                                                           "choices": ["enable", "disable"]},
                                           "adv-interval": {"required": False, "type": "int"},
                                           "preempt": {"required": False, "type": "str",
                                                       "choices": ["enable", "disable"]},
                                           "priority": {"required": False, "type": "int"},
                                           "start-time": {"required": False, "type": "int"},
                                           "status": {"required": False, "type": "str",
                                                      "choices": ["enable", "disable"]},
                                           "vrdst6": {"required": False, "type": "str"},
                                           "vrgrp": {"required": False, "type": "int"},
                                           "vrid": {"required": True, "type": "int"},
                                           "vrip6": {"required": False, "type": "str"}
                                       }}
                         }},
                "l2forward": {"required": False, "type": "str",
                              "choices": ["enable", "disable"]},
                "lacp-ha-slave": {"required": False, "type": "str",
                                  "choices": ["enable", "disable"]},
                "lacp-mode": {"required": False, "type": "str",
                              "choices": ["static", "passive", "active"]},
                "lacp-speed": {"required": False, "type": "str",
                               "choices": ["slow", "fast"]},
                "lcp-echo-interval": {"required": False, "type": "int"},
                "lcp-max-echo-fails": {"required": False, "type": "int"},
                "link-up-delay": {"required": False, "type": "int"},
                "lldp-transmission": {"required": False, "type": "str",
                                      "choices": ["enable", "disable", "vdom"]},
                "macaddr": {"required": False, "type": "str"},
                "managed-device": {"required": False, "type": "list",
                                   "options": {
                                       "name": {"required": True, "type": "str"}
                                   }},
                "management-ip": {"required": False, "type": "str"},
                "member": {"required": False, "type": "list",
                           "options": {
                               "interface-name": {"required": True, "type": "str"}
                           }},
                "min-links": {"required": False, "type": "int"},
                "min-links-down": {"required": False, "type": "str",
                                   "choices": ["operational", "administrative"]},
                "mode": {"required": False, "type": "str",
                         "choices": ["static", "dhcp", "pppoe"]},
                "mtu": {"required": False, "type": "int"},
                "mtu-override": {"required": False, "type": "str",
                                 "choices": ["enable", "disable"]},
                "name": {"required": True, "type": "str"},
                "ndiscforward": {"required": False, "type": "str",
                                 "choices": ["enable", "disable"]},
                "netbios-forward": {"required": False, "type": "str",
                                    "choices": ["disable", "enable"]},
                "netflow-sampler": {"required": False, "type": "str",
                                    "choices": ["disable", "tx", "rx",
                                                "both"]},
                "outbandwidth": {"required": False, "type": "int"},
                "padt-retry-timeout": {"required": False, "type": "int"},
                "password": {"required": False, "type": "str"},
                "ping-serv-status": {"required": False, "type": "int"},
                "polling-interval": {"required": False, "type": "int"},
                "pppoe-unnumbered-negotiate": {"required": False, "type": "str",
                                               "choices": ["enable", "disable"]},
                "pptp-auth-type": {"required": False, "type": "str",
                                   "choices": ["auto", "pap", "chap",
                                               "mschapv1", "mschapv2"]},
                "pptp-client": {"required": False, "type": "str",
                                "choices": ["enable", "disable"]},
                "pptp-password": {"required": False, "type": "str"},
                "pptp-server-ip": {"required": False, "type": "str"},
                "pptp-timeout": {"required": False, "type": "int"},
                "pptp-user": {"required": False, "type": "str"},
                "preserve-session-route": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                "priority": {"required": False, "type": "int"},
                "priority-override": {"required": False, "type": "str",
                                      "choices": ["enable", "disable"]},
                "proxy-captive-portal": {"required": False, "type": "str",
                                         "choices": ["enable", "disable"]},
                "redundant-interface": {"required": False, "type": "str"},
                "remote-ip": {"required": False, "type": "str"},
                "replacemsg-override-group": {"required": False, "type": "str"},
                "role": {"required": False, "type": "str",
                         "choices": ["lan", "wan", "dmz",
                                     "undefined"]},
                "sample-direction": {"required": False, "type": "str",
                                     "choices": ["tx", "rx", "both"]},
                "sample-rate": {"required": False, "type": "int"},
                "scan-botnet-connections": {"required": False, "type": "str",
                                            "choices": ["disable", "block", "monitor"]},
                "secondary-IP": {"required": False, "type": "str",
                                 "choices": ["enable", "disable"]},
                "secondaryip": {"required": False, "type": "list",
                                "options": {
                                    "allowaccess": {"required": False, "type": "str",
                                                    "choices": ["ping", "https", "ssh",
                                                                "snmp", "http", "telnet",
                                                                "fgfm", "radius-acct", "probe-response",
                                                                "capwap", "ftm"]},
                                    "detectprotocol": {"required": False, "type": "str",
                                                       "choices": ["ping", "tcp-echo", "udp-echo"]},
                                    "detectserver": {"required": False, "type": "str"},
                                    "gwdetect": {"required": False, "type": "str",
                                                 "choices": ["enable", "disable"]},
                                    "ha-priority": {"required": False, "type": "int"},
                                    "id": {"required": True, "type": "int"},
                                    "ip": {"required": False, "type": "str"},
                                    "ping-serv-status": {"required": False, "type": "int"}
                                }},
                "security-exempt-list": {"required": False, "type": "str"},
                "security-external-logout": {"required": False, "type": "str"},
                "security-external-web": {"required": False, "type": "str"},
                "security-groups": {"required": False, "type": "list",
                                    "options": {
                                        "name": {"required": True, "type": "str"}
                                    }},
                "security-mac-auth-bypass": {"required": False, "type": "str",
                                             "choices": ["enable", "disable"]},
                "security-mode": {"required": False, "type": "str",
                                  "choices": ["none", "captive-portal", "802.1X"]},
                "security-redirect-url": {"required": False, "type": "str"},
                "service-name": {"required": False, "type": "str"},
                "sflow-sampler": {"required": False, "type": "str",
                                  "choices": ["enable", "disable"]},
                "snmp-index": {"required": False, "type": "int"},
                "speed": {"required": False, "type": "str",
                          "choices": ["auto", "10full", "10half",
                                      "100full", "100half", "1000full",
                                      "1000half", "1000auto"]},
                "spillover-threshold": {"required": False, "type": "int"},
                "src-check": {"required": False, "type": "str",
                              "choices": ["enable", "disable"]},
                "status": {"required": False, "type": "str",
                           "choices": ["up", "down"]},
                "stpforward": {"required": False, "type": "str",
                               "choices": ["enable", "disable"]},
                "stpforward-mode": {"required": False, "type": "str",
                                    "choices": ["rpl-all-ext-id", "rpl-bridge-ext-id", "rpl-nothing"]},
                "subst": {"required": False, "type": "str",
                          "choices": ["enable", "disable"]},
                "substitute-dst-mac": {"required": False, "type": "str"},
                "switch": {"required": False, "type": "str"},
                "switch-controller-access-vlan": {"required": False, "type": "str",
                                                  "choices": ["enable", "disable"]},
                "switch-controller-arp-inspection": {"required": False, "type": "str",
                                                     "choices": ["enable", "disable"]},
                "switch-controller-dhcp-snooping": {"required": False, "type": "str",
                                                    "choices": ["enable", "disable"]},
                "switch-controller-dhcp-snooping-option82": {"required": False, "type": "str",
                                                             "choices": ["enable", "disable"]},
                "switch-controller-dhcp-snooping-verify-mac": {"required": False, "type": "str",
                                                               "choices": ["enable", "disable"]},
                "switch-controller-igmp-snooping": {"required": False, "type": "str",
                                                    "choices": ["enable", "disable"]},
                "switch-controller-learning-limit": {"required": False, "type": "int"},
                "tagging": {"required": False, "type": "list",
                            "options": {
                                "category": {"required": False, "type": "str"},
                                "name": {"required": True, "type": "str"},
                                "tags": {"required": False, "type": "list",
                                         "options": {
                                             "name": {"required": True, "type": "str"}
                                         }}
                            }},
                "tcp-mss": {"required": False, "type": "int"},
                "trust-ip-1": {"required": False, "type": "str"},
                "trust-ip-2": {"required": False, "type": "str"},
                "trust-ip-3": {"required": False, "type": "str"},
                "trust-ip6-1": {"required": False, "type": "str"},
                "trust-ip6-2": {"required": False, "type": "str"},
                "trust-ip6-3": {"required": False, "type": "str"},
                "type": {"required": False, "type": "str",
                         "choices": ["physical", "vlan", "aggregate",
                                     "redundant", "tunnel", "vdom-link",
                                     "loopback", "switch", "hard-switch",
                                     "vap-switch", "wl-mesh", "fext-wan",
                                     "vxlan", "hdlc", "switch-vlan"]},
                "username": {"required": False, "type": "str"},
                "vdom": {"required": False, "type": "str"},
                "vindex": {"required": False, "type": "int"},
                "vlanforward": {"required": False, "type": "str",
                                "choices": ["enable", "disable"]},
                "vlanid": {"required": False, "type": "int"},
                "vrf": {"required": False, "type": "int"},
                "vrrp": {"required": False, "type": "list",
                         "options": {
                             "accept-mode": {"required": False, "type": "str",
                                             "choices": ["enable", "disable"]},
                             "adv-interval": {"required": False, "type": "int"},
                             "preempt": {"required": False, "type": "str",
                                         "choices": ["enable", "disable"]},
                             "priority": {"required": False, "type": "int"},
                             "proxy-arp": {"required": False, "type": "list",
                                           "options": {
                                               "id": {"required": True, "type": "int"},
                                               "ip": {"required": False, "type": "str"}
                                           }},
                             "start-time": {"required": False, "type": "int"},
                             "status": {"required": False, "type": "str",
                                        "choices": ["enable", "disable"]},
                             "version": {"required": False, "type": "str",
                                         "choices": ["2", "3"]},
                             "vrdst": {"required": False, "type": "str"},
                             "vrdst-priority": {"required": False, "type": "int"},
                             "vrgrp": {"required": False, "type": "int"},
                             "vrid": {"required": True, "type": "int"},
                             "vrip": {"required": False, "type": "str"}
                         }},
                "vrrp-virtual-mac": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "wccp": {"required": False, "type": "str",
                         "choices": ["enable", "disable"]},
                "weight": {"required": False, "type": "int"},
                "wins-ip": {"required": False, "type": "str"}

            }
        }
    }

    module = AnsibleModule(argument_spec=fields,
                           supports_check_mode=False)
    try:
        from fortiosapi import FortiOSAPI
    except ImportError:
        module.fail_json(msg="fortiosapi module is required")

    global fos
    fos = FortiOSAPI()

    is_error, has_changed, result = fortios_system(module.params, fos)

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)


if __name__ == '__main__':
    main()