1#!/usr/bin/python 2from __future__ import (absolute_import, division, print_function) 3# Copyright 2019 Fortinet, Inc. 4# 5# This program is free software: you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation, either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <https://www.gnu.org/licenses/>. 17 18__metaclass__ = type 19 20ANSIBLE_METADATA = {'status': ['preview'], 21 'supported_by': 'community', 22 'metadata_version': '1.1'} 23 24DOCUMENTATION = ''' 25--- 26module: fortios_router_bgp 27short_description: Configure BGP in Fortinet's FortiOS and FortiGate. 28description: 29 - This module is able to configure a FortiGate or FortiOS (FOS) device by allowing the 30 user to set and modify router feature and bgp category. 31 Examples include all parameters and values need to be adjusted to datasources before usage. 32 Tested with FOS v6.0.5 33version_added: "2.8" 34author: 35 - Miguel Angel Munoz (@mamunozgonzalez) 36 - Nicolas Thomas (@thomnico) 37notes: 38 - Requires fortiosapi library developed by Fortinet 39 - Run as a local_action in your playbook 40requirements: 41 - fortiosapi>=0.9.8 42options: 43 host: 44 description: 45 - FortiOS or FortiGate IP address. 46 type: str 47 required: false 48 username: 49 description: 50 - FortiOS or FortiGate username. 51 type: str 52 required: false 53 password: 54 description: 55 - FortiOS or FortiGate password. 56 type: str 57 default: "" 58 vdom: 59 description: 60 - Virtual domain, among those defined previously. A vdom is a 61 virtual instance of the FortiGate that can be configured and 62 used as a different unit. 63 type: str 64 default: root 65 https: 66 description: 67 - Indicates if the requests towards FortiGate must use HTTPS protocol. 68 type: bool 69 default: true 70 ssl_verify: 71 description: 72 - Ensures FortiGate certificate must be verified by a proper CA. 73 type: bool 74 default: true 75 version_added: 2.9 76 router_bgp: 77 description: 78 - Configure BGP. 79 default: null 80 type: dict 81 suboptions: 82 admin_distance: 83 description: 84 - Administrative distance modifications. 85 type: list 86 suboptions: 87 distance: 88 description: 89 - Administrative distance to apply (1 - 255). 90 type: int 91 id: 92 description: 93 - ID. 94 required: true 95 type: int 96 neighbour_prefix: 97 description: 98 - Neighbor address prefix. 99 type: str 100 route_list: 101 description: 102 - Access list of routes to apply new distance to. Source router.access-list.name. 103 type: str 104 aggregate_address: 105 description: 106 - BGP aggregate address table. 107 type: list 108 suboptions: 109 as_set: 110 description: 111 - Enable/disable generate AS set path information. 112 type: str 113 choices: 114 - enable 115 - disable 116 id: 117 description: 118 - ID. 119 required: true 120 type: int 121 prefix: 122 description: 123 - Aggregate prefix. 124 type: str 125 summary_only: 126 description: 127 - Enable/disable filter more specific routes from updates. 128 type: str 129 choices: 130 - enable 131 - disable 132 aggregate_address6: 133 description: 134 - BGP IPv6 aggregate address table. 135 type: list 136 suboptions: 137 as_set: 138 description: 139 - Enable/disable generate AS set path information. 140 type: str 141 choices: 142 - enable 143 - disable 144 id: 145 description: 146 - ID. 147 required: true 148 type: int 149 prefix6: 150 description: 151 - Aggregate IPv6 prefix. 152 type: str 153 summary_only: 154 description: 155 - Enable/disable filter more specific routes from updates. 156 type: str 157 choices: 158 - enable 159 - disable 160 always_compare_med: 161 description: 162 - Enable/disable always compare MED. 163 type: str 164 choices: 165 - enable 166 - disable 167 as: 168 description: 169 - Router AS number, valid from 1 to 4294967295, 0 to disable BGP. 170 type: int 171 bestpath_as_path_ignore: 172 description: 173 - Enable/disable ignore AS path. 174 type: str 175 choices: 176 - enable 177 - disable 178 bestpath_cmp_confed_aspath: 179 description: 180 - Enable/disable compare federation AS path length. 181 type: str 182 choices: 183 - enable 184 - disable 185 bestpath_cmp_routerid: 186 description: 187 - Enable/disable compare router ID for identical EBGP paths. 188 type: str 189 choices: 190 - enable 191 - disable 192 bestpath_med_confed: 193 description: 194 - Enable/disable compare MED among confederation paths. 195 type: str 196 choices: 197 - enable 198 - disable 199 bestpath_med_missing_as_worst: 200 description: 201 - Enable/disable treat missing MED as least preferred. 202 type: str 203 choices: 204 - enable 205 - disable 206 client_to_client_reflection: 207 description: 208 - Enable/disable client-to-client route reflection. 209 type: str 210 choices: 211 - enable 212 - disable 213 cluster_id: 214 description: 215 - Route reflector cluster ID. 216 type: str 217 confederation_identifier: 218 description: 219 - Confederation identifier. 220 type: int 221 confederation_peers: 222 description: 223 - Confederation peers. 224 type: list 225 suboptions: 226 peer: 227 description: 228 - Peer ID. 229 required: true 230 type: str 231 dampening: 232 description: 233 - Enable/disable route-flap dampening. 234 type: str 235 choices: 236 - enable 237 - disable 238 dampening_max_suppress_time: 239 description: 240 - Maximum minutes a route can be suppressed. 241 type: int 242 dampening_reachability_half_life: 243 description: 244 - Reachability half-life time for penalty (min). 245 type: int 246 dampening_reuse: 247 description: 248 - Threshold to reuse routes. 249 type: int 250 dampening_route_map: 251 description: 252 - Criteria for dampening. Source router.route-map.name. 253 type: str 254 dampening_suppress: 255 description: 256 - Threshold to suppress routes. 257 type: int 258 dampening_unreachability_half_life: 259 description: 260 - Unreachability half-life time for penalty (min). 261 type: int 262 default_local_preference: 263 description: 264 - Default local preference. 265 type: int 266 deterministic_med: 267 description: 268 - Enable/disable enforce deterministic comparison of MED. 269 type: str 270 choices: 271 - enable 272 - disable 273 distance_external: 274 description: 275 - Distance for routes external to the AS. 276 type: int 277 distance_internal: 278 description: 279 - Distance for routes internal to the AS. 280 type: int 281 distance_local: 282 description: 283 - Distance for routes local to the AS. 284 type: int 285 ebgp_multipath: 286 description: 287 - Enable/disable EBGP multi-path. 288 type: str 289 choices: 290 - enable 291 - disable 292 enforce_first_as: 293 description: 294 - Enable/disable enforce first AS for EBGP routes. 295 type: str 296 choices: 297 - enable 298 - disable 299 fast_external_failover: 300 description: 301 - Enable/disable reset peer BGP session if link goes down. 302 type: str 303 choices: 304 - enable 305 - disable 306 graceful_end_on_timer: 307 description: 308 - Enable/disable to exit graceful restart on timer only. 309 type: str 310 choices: 311 - enable 312 - disable 313 graceful_restart: 314 description: 315 - Enable/disable BGP graceful restart capabilities. 316 type: str 317 choices: 318 - enable 319 - disable 320 graceful_restart_time: 321 description: 322 - Time needed for neighbors to restart (sec). 323 type: int 324 graceful_stalepath_time: 325 description: 326 - Time to hold stale paths of restarting neighbor (sec). 327 type: int 328 graceful_update_delay: 329 description: 330 - Route advertisement/selection delay after restart (sec). 331 type: int 332 holdtime_timer: 333 description: 334 - Number of seconds to mark peer as dead. 335 type: int 336 ibgp_multipath: 337 description: 338 - Enable/disable IBGP multi-path. 339 type: str 340 choices: 341 - enable 342 - disable 343 ignore_optional_capability: 344 description: 345 - Don't send unknown optional capability notification message 346 type: str 347 choices: 348 - enable 349 - disable 350 keepalive_timer: 351 description: 352 - Frequency to send keep alive requests. 353 type: int 354 log_neighbour_changes: 355 description: 356 - Enable logging of BGP neighbour's changes 357 type: str 358 choices: 359 - enable 360 - disable 361 neighbor: 362 description: 363 - BGP neighbor table. 364 type: list 365 suboptions: 366 activate: 367 description: 368 - Enable/disable address family IPv4 for this neighbor. 369 type: str 370 choices: 371 - enable 372 - disable 373 activate6: 374 description: 375 - Enable/disable address family IPv6 for this neighbor. 376 type: str 377 choices: 378 - enable 379 - disable 380 advertisement_interval: 381 description: 382 - Minimum interval (sec) between sending updates. 383 type: int 384 allowas_in: 385 description: 386 - IPv4 The maximum number of occurrence of my AS number allowed. 387 type: int 388 allowas_in_enable: 389 description: 390 - Enable/disable IPv4 Enable to allow my AS in AS path. 391 type: str 392 choices: 393 - enable 394 - disable 395 allowas_in_enable6: 396 description: 397 - Enable/disable IPv6 Enable to allow my AS in AS path. 398 type: str 399 choices: 400 - enable 401 - disable 402 allowas_in6: 403 description: 404 - IPv6 The maximum number of occurrence of my AS number allowed. 405 type: int 406 as_override: 407 description: 408 - Enable/disable replace peer AS with own AS for IPv4. 409 type: str 410 choices: 411 - enable 412 - disable 413 as_override6: 414 description: 415 - Enable/disable replace peer AS with own AS for IPv6. 416 type: str 417 choices: 418 - enable 419 - disable 420 attribute_unchanged: 421 description: 422 - IPv4 List of attributes that should be unchanged. 423 type: str 424 choices: 425 - as-path 426 - med 427 - next-hop 428 attribute_unchanged6: 429 description: 430 - IPv6 List of attributes that should be unchanged. 431 type: str 432 choices: 433 - as-path 434 - med 435 - next-hop 436 bfd: 437 description: 438 - Enable/disable BFD for this neighbor. 439 type: str 440 choices: 441 - enable 442 - disable 443 capability_default_originate: 444 description: 445 - Enable/disable advertise default IPv4 route to this neighbor. 446 type: str 447 choices: 448 - enable 449 - disable 450 capability_default_originate6: 451 description: 452 - Enable/disable advertise default IPv6 route to this neighbor. 453 type: str 454 choices: 455 - enable 456 - disable 457 capability_dynamic: 458 description: 459 - Enable/disable advertise dynamic capability to this neighbor. 460 type: str 461 choices: 462 - enable 463 - disable 464 capability_graceful_restart: 465 description: 466 - Enable/disable advertise IPv4 graceful restart capability to this neighbor. 467 type: str 468 choices: 469 - enable 470 - disable 471 capability_graceful_restart6: 472 description: 473 - Enable/disable advertise IPv6 graceful restart capability to this neighbor. 474 type: str 475 choices: 476 - enable 477 - disable 478 capability_orf: 479 description: 480 - Accept/Send IPv4 ORF lists to/from this neighbor. 481 type: str 482 choices: 483 - none 484 - receive 485 - send 486 - both 487 capability_orf6: 488 description: 489 - Accept/Send IPv6 ORF lists to/from this neighbor. 490 type: str 491 choices: 492 - none 493 - receive 494 - send 495 - both 496 capability_route_refresh: 497 description: 498 - Enable/disable advertise route refresh capability to this neighbor. 499 type: str 500 choices: 501 - enable 502 - disable 503 conditional_advertise: 504 description: 505 - Conditional advertisement. 506 type: list 507 suboptions: 508 advertise_routemap: 509 description: 510 - Name of advertising route map. Source router.route-map.name. 511 type: str 512 condition_routemap: 513 description: 514 - Name of condition route map. Source router.route-map.name. 515 type: str 516 condition_type: 517 description: 518 - Type of condition. 519 type: str 520 choices: 521 - exist 522 - non-exist 523 connect_timer: 524 description: 525 - Interval (sec) for connect timer. 526 type: int 527 default_originate_routemap: 528 description: 529 - Route map to specify criteria to originate IPv4 default. Source router.route-map.name. 530 type: str 531 default_originate_routemap6: 532 description: 533 - Route map to specify criteria to originate IPv6 default. Source router.route-map.name. 534 type: str 535 description: 536 description: 537 - Description. 538 type: str 539 distribute_list_in: 540 description: 541 - Filter for IPv4 updates from this neighbor. Source router.access-list.name. 542 type: str 543 distribute_list_in6: 544 description: 545 - Filter for IPv6 updates from this neighbor. Source router.access-list6.name. 546 type: str 547 distribute_list_out: 548 description: 549 - Filter for IPv4 updates to this neighbor. Source router.access-list.name. 550 type: str 551 distribute_list_out6: 552 description: 553 - Filter for IPv6 updates to this neighbor. Source router.access-list6.name. 554 type: str 555 dont_capability_negotiate: 556 description: 557 - Don't negotiate capabilities with this neighbor 558 type: str 559 choices: 560 - enable 561 - disable 562 ebgp_enforce_multihop: 563 description: 564 - Enable/disable allow multi-hop EBGP neighbors. 565 type: str 566 choices: 567 - enable 568 - disable 569 ebgp_multihop_ttl: 570 description: 571 - EBGP multihop TTL for this peer. 572 type: int 573 filter_list_in: 574 description: 575 - BGP filter for IPv4 inbound routes. Source router.aspath-list.name. 576 type: str 577 filter_list_in6: 578 description: 579 - BGP filter for IPv6 inbound routes. Source router.aspath-list.name. 580 type: str 581 filter_list_out: 582 description: 583 - BGP filter for IPv4 outbound routes. Source router.aspath-list.name. 584 type: str 585 filter_list_out6: 586 description: 587 - BGP filter for IPv6 outbound routes. Source router.aspath-list.name. 588 type: str 589 holdtime_timer: 590 description: 591 - Interval (sec) before peer considered dead. 592 type: int 593 interface: 594 description: 595 - Interface Source system.interface.name. 596 type: str 597 ip: 598 description: 599 - IP/IPv6 address of neighbor. 600 required: true 601 type: str 602 keep_alive_timer: 603 description: 604 - Keep alive timer interval (sec). 605 type: int 606 link_down_failover: 607 description: 608 - Enable/disable failover upon link down. 609 type: str 610 choices: 611 - enable 612 - disable 613 local_as: 614 description: 615 - Local AS number of neighbor. 616 type: int 617 local_as_no_prepend: 618 description: 619 - Do not prepend local-as to incoming updates. 620 type: str 621 choices: 622 - enable 623 - disable 624 local_as_replace_as: 625 description: 626 - Replace real AS with local-as in outgoing updates. 627 type: str 628 choices: 629 - enable 630 - disable 631 maximum_prefix: 632 description: 633 - Maximum number of IPv4 prefixes to accept from this peer. 634 type: int 635 maximum_prefix_threshold: 636 description: 637 - Maximum IPv4 prefix threshold value (1 - 100 percent). 638 type: int 639 maximum_prefix_threshold6: 640 description: 641 - Maximum IPv6 prefix threshold value (1 - 100 percent). 642 type: int 643 maximum_prefix_warning_only: 644 description: 645 - Enable/disable IPv4 Only give warning message when limit is exceeded. 646 type: str 647 choices: 648 - enable 649 - disable 650 maximum_prefix_warning_only6: 651 description: 652 - Enable/disable IPv6 Only give warning message when limit is exceeded. 653 type: str 654 choices: 655 - enable 656 - disable 657 maximum_prefix6: 658 description: 659 - Maximum number of IPv6 prefixes to accept from this peer. 660 type: int 661 next_hop_self: 662 description: 663 - Enable/disable IPv4 next-hop calculation for this neighbor. 664 type: str 665 choices: 666 - enable 667 - disable 668 next_hop_self6: 669 description: 670 - Enable/disable IPv6 next-hop calculation for this neighbor. 671 type: str 672 choices: 673 - enable 674 - disable 675 override_capability: 676 description: 677 - Enable/disable override result of capability negotiation. 678 type: str 679 choices: 680 - enable 681 - disable 682 passive: 683 description: 684 - Enable/disable sending of open messages to this neighbor. 685 type: str 686 choices: 687 - enable 688 - disable 689 password: 690 description: 691 - Password used in MD5 authentication. 692 type: str 693 prefix_list_in: 694 description: 695 - IPv4 Inbound filter for updates from this neighbor. Source router.prefix-list.name. 696 type: str 697 prefix_list_in6: 698 description: 699 - IPv6 Inbound filter for updates from this neighbor. Source router.prefix-list6.name. 700 type: str 701 prefix_list_out: 702 description: 703 - IPv4 Outbound filter for updates to this neighbor. Source router.prefix-list.name. 704 type: str 705 prefix_list_out6: 706 description: 707 - IPv6 Outbound filter for updates to this neighbor. Source router.prefix-list6.name. 708 type: str 709 remote_as: 710 description: 711 - AS number of neighbor. 712 type: int 713 remove_private_as: 714 description: 715 - Enable/disable remove private AS number from IPv4 outbound updates. 716 type: str 717 choices: 718 - enable 719 - disable 720 remove_private_as6: 721 description: 722 - Enable/disable remove private AS number from IPv6 outbound updates. 723 type: str 724 choices: 725 - enable 726 - disable 727 restart_time: 728 description: 729 - Graceful restart delay time (sec, 0 = global default). 730 type: int 731 retain_stale_time: 732 description: 733 - Time to retain stale routes. 734 type: int 735 route_map_in: 736 description: 737 - IPv4 Inbound route map filter. Source router.route-map.name. 738 type: str 739 route_map_in6: 740 description: 741 - IPv6 Inbound route map filter. Source router.route-map.name. 742 type: str 743 route_map_out: 744 description: 745 - IPv4 Outbound route map filter. Source router.route-map.name. 746 type: str 747 route_map_out6: 748 description: 749 - IPv6 Outbound route map filter. Source router.route-map.name. 750 type: str 751 route_reflector_client: 752 description: 753 - Enable/disable IPv4 AS route reflector client. 754 type: str 755 choices: 756 - enable 757 - disable 758 route_reflector_client6: 759 description: 760 - Enable/disable IPv6 AS route reflector client. 761 type: str 762 choices: 763 - enable 764 - disable 765 route_server_client: 766 description: 767 - Enable/disable IPv4 AS route server client. 768 type: str 769 choices: 770 - enable 771 - disable 772 route_server_client6: 773 description: 774 - Enable/disable IPv6 AS route server client. 775 type: str 776 choices: 777 - enable 778 - disable 779 send_community: 780 description: 781 - IPv4 Send community attribute to neighbor. 782 type: str 783 choices: 784 - standard 785 - extended 786 - both 787 - disable 788 send_community6: 789 description: 790 - IPv6 Send community attribute to neighbor. 791 type: str 792 choices: 793 - standard 794 - extended 795 - both 796 - disable 797 shutdown: 798 description: 799 - Enable/disable shutdown this neighbor. 800 type: str 801 choices: 802 - enable 803 - disable 804 soft_reconfiguration: 805 description: 806 - Enable/disable allow IPv4 inbound soft reconfiguration. 807 type: str 808 choices: 809 - enable 810 - disable 811 soft_reconfiguration6: 812 description: 813 - Enable/disable allow IPv6 inbound soft reconfiguration. 814 type: str 815 choices: 816 - enable 817 - disable 818 stale_route: 819 description: 820 - Enable/disable stale route after neighbor down. 821 type: str 822 choices: 823 - enable 824 - disable 825 strict_capability_match: 826 description: 827 - Enable/disable strict capability matching. 828 type: str 829 choices: 830 - enable 831 - disable 832 unsuppress_map: 833 description: 834 - IPv4 Route map to selectively unsuppress suppressed routes. Source router.route-map.name. 835 type: str 836 unsuppress_map6: 837 description: 838 - IPv6 Route map to selectively unsuppress suppressed routes. Source router.route-map.name. 839 type: str 840 update_source: 841 description: 842 - Interface to use as source IP/IPv6 address of TCP connections. Source system.interface.name. 843 type: str 844 weight: 845 description: 846 - Neighbor weight. 847 type: int 848 neighbor_group: 849 description: 850 - BGP neighbor group table. 851 type: list 852 suboptions: 853 activate: 854 description: 855 - Enable/disable address family IPv4 for this neighbor. 856 type: str 857 choices: 858 - enable 859 - disable 860 activate6: 861 description: 862 - Enable/disable address family IPv6 for this neighbor. 863 type: str 864 choices: 865 - enable 866 - disable 867 advertisement_interval: 868 description: 869 - Minimum interval (sec) between sending updates. 870 type: int 871 allowas_in: 872 description: 873 - IPv4 The maximum number of occurrence of my AS number allowed. 874 type: int 875 allowas_in_enable: 876 description: 877 - Enable/disable IPv4 Enable to allow my AS in AS path. 878 type: str 879 choices: 880 - enable 881 - disable 882 allowas_in_enable6: 883 description: 884 - Enable/disable IPv6 Enable to allow my AS in AS path. 885 type: str 886 choices: 887 - enable 888 - disable 889 allowas_in6: 890 description: 891 - IPv6 The maximum number of occurrence of my AS number allowed. 892 type: int 893 as_override: 894 description: 895 - Enable/disable replace peer AS with own AS for IPv4. 896 type: str 897 choices: 898 - enable 899 - disable 900 as_override6: 901 description: 902 - Enable/disable replace peer AS with own AS for IPv6. 903 type: str 904 choices: 905 - enable 906 - disable 907 attribute_unchanged: 908 description: 909 - IPv4 List of attributes that should be unchanged. 910 type: str 911 choices: 912 - as-path 913 - med 914 - next-hop 915 attribute_unchanged6: 916 description: 917 - IPv6 List of attributes that should be unchanged. 918 type: str 919 choices: 920 - as-path 921 - med 922 - next-hop 923 bfd: 924 description: 925 - Enable/disable BFD for this neighbor. 926 type: str 927 choices: 928 - enable 929 - disable 930 capability_default_originate: 931 description: 932 - Enable/disable advertise default IPv4 route to this neighbor. 933 type: str 934 choices: 935 - enable 936 - disable 937 capability_default_originate6: 938 description: 939 - Enable/disable advertise default IPv6 route to this neighbor. 940 type: str 941 choices: 942 - enable 943 - disable 944 capability_dynamic: 945 description: 946 - Enable/disable advertise dynamic capability to this neighbor. 947 type: str 948 choices: 949 - enable 950 - disable 951 capability_graceful_restart: 952 description: 953 - Enable/disable advertise IPv4 graceful restart capability to this neighbor. 954 type: str 955 choices: 956 - enable 957 - disable 958 capability_graceful_restart6: 959 description: 960 - Enable/disable advertise IPv6 graceful restart capability to this neighbor. 961 type: str 962 choices: 963 - enable 964 - disable 965 capability_orf: 966 description: 967 - Accept/Send IPv4 ORF lists to/from this neighbor. 968 type: str 969 choices: 970 - none 971 - receive 972 - send 973 - both 974 capability_orf6: 975 description: 976 - Accept/Send IPv6 ORF lists to/from this neighbor. 977 type: str 978 choices: 979 - none 980 - receive 981 - send 982 - both 983 capability_route_refresh: 984 description: 985 - Enable/disable advertise route refresh capability to this neighbor. 986 type: str 987 choices: 988 - enable 989 - disable 990 connect_timer: 991 description: 992 - Interval (sec) for connect timer. 993 type: int 994 default_originate_routemap: 995 description: 996 - Route map to specify criteria to originate IPv4 default. Source router.route-map.name. 997 type: str 998 default_originate_routemap6: 999 description: 1000 - Route map to specify criteria to originate IPv6 default. Source router.route-map.name. 1001 type: str 1002 description: 1003 description: 1004 - Description. 1005 type: str 1006 distribute_list_in: 1007 description: 1008 - Filter for IPv4 updates from this neighbor. Source router.access-list.name. 1009 type: str 1010 distribute_list_in6: 1011 description: 1012 - Filter for IPv6 updates from this neighbor. Source router.access-list6.name. 1013 type: str 1014 distribute_list_out: 1015 description: 1016 - Filter for IPv4 updates to this neighbor. Source router.access-list.name. 1017 type: str 1018 distribute_list_out6: 1019 description: 1020 - Filter for IPv6 updates to this neighbor. Source router.access-list6.name. 1021 type: str 1022 dont_capability_negotiate: 1023 description: 1024 - Don't negotiate capabilities with this neighbor 1025 type: str 1026 choices: 1027 - enable 1028 - disable 1029 ebgp_enforce_multihop: 1030 description: 1031 - Enable/disable allow multi-hop EBGP neighbors. 1032 type: str 1033 choices: 1034 - enable 1035 - disable 1036 ebgp_multihop_ttl: 1037 description: 1038 - EBGP multihop TTL for this peer. 1039 type: int 1040 filter_list_in: 1041 description: 1042 - BGP filter for IPv4 inbound routes. Source router.aspath-list.name. 1043 type: str 1044 filter_list_in6: 1045 description: 1046 - BGP filter for IPv6 inbound routes. Source router.aspath-list.name. 1047 type: str 1048 filter_list_out: 1049 description: 1050 - BGP filter for IPv4 outbound routes. Source router.aspath-list.name. 1051 type: str 1052 filter_list_out6: 1053 description: 1054 - BGP filter for IPv6 outbound routes. Source router.aspath-list.name. 1055 type: str 1056 holdtime_timer: 1057 description: 1058 - Interval (sec) before peer considered dead. 1059 type: int 1060 interface: 1061 description: 1062 - Interface Source system.interface.name. 1063 type: str 1064 keep_alive_timer: 1065 description: 1066 - Keep alive timer interval (sec). 1067 type: int 1068 link_down_failover: 1069 description: 1070 - Enable/disable failover upon link down. 1071 type: str 1072 choices: 1073 - enable 1074 - disable 1075 local_as: 1076 description: 1077 - Local AS number of neighbor. 1078 type: int 1079 local_as_no_prepend: 1080 description: 1081 - Do not prepend local-as to incoming updates. 1082 type: str 1083 choices: 1084 - enable 1085 - disable 1086 local_as_replace_as: 1087 description: 1088 - Replace real AS with local-as in outgoing updates. 1089 type: str 1090 choices: 1091 - enable 1092 - disable 1093 maximum_prefix: 1094 description: 1095 - Maximum number of IPv4 prefixes to accept from this peer. 1096 type: int 1097 maximum_prefix_threshold: 1098 description: 1099 - Maximum IPv4 prefix threshold value (1 - 100 percent). 1100 type: int 1101 maximum_prefix_threshold6: 1102 description: 1103 - Maximum IPv6 prefix threshold value (1 - 100 percent). 1104 type: int 1105 maximum_prefix_warning_only: 1106 description: 1107 - Enable/disable IPv4 Only give warning message when limit is exceeded. 1108 type: str 1109 choices: 1110 - enable 1111 - disable 1112 maximum_prefix_warning_only6: 1113 description: 1114 - Enable/disable IPv6 Only give warning message when limit is exceeded. 1115 type: str 1116 choices: 1117 - enable 1118 - disable 1119 maximum_prefix6: 1120 description: 1121 - Maximum number of IPv6 prefixes to accept from this peer. 1122 type: int 1123 name: 1124 description: 1125 - Neighbor group name. 1126 required: true 1127 type: str 1128 next_hop_self: 1129 description: 1130 - Enable/disable IPv4 next-hop calculation for this neighbor. 1131 type: str 1132 choices: 1133 - enable 1134 - disable 1135 next_hop_self6: 1136 description: 1137 - Enable/disable IPv6 next-hop calculation for this neighbor. 1138 type: str 1139 choices: 1140 - enable 1141 - disable 1142 override_capability: 1143 description: 1144 - Enable/disable override result of capability negotiation. 1145 type: str 1146 choices: 1147 - enable 1148 - disable 1149 passive: 1150 description: 1151 - Enable/disable sending of open messages to this neighbor. 1152 type: str 1153 choices: 1154 - enable 1155 - disable 1156 prefix_list_in: 1157 description: 1158 - IPv4 Inbound filter for updates from this neighbor. Source router.prefix-list.name. 1159 type: str 1160 prefix_list_in6: 1161 description: 1162 - IPv6 Inbound filter for updates from this neighbor. Source router.prefix-list6.name. 1163 type: str 1164 prefix_list_out: 1165 description: 1166 - IPv4 Outbound filter for updates to this neighbor. Source router.prefix-list.name. 1167 type: str 1168 prefix_list_out6: 1169 description: 1170 - IPv6 Outbound filter for updates to this neighbor. Source router.prefix-list6.name. 1171 type: str 1172 remote_as: 1173 description: 1174 - AS number of neighbor. 1175 type: int 1176 remove_private_as: 1177 description: 1178 - Enable/disable remove private AS number from IPv4 outbound updates. 1179 type: str 1180 choices: 1181 - enable 1182 - disable 1183 remove_private_as6: 1184 description: 1185 - Enable/disable remove private AS number from IPv6 outbound updates. 1186 type: str 1187 choices: 1188 - enable 1189 - disable 1190 restart_time: 1191 description: 1192 - Graceful restart delay time (sec, 0 = global default). 1193 type: int 1194 retain_stale_time: 1195 description: 1196 - Time to retain stale routes. 1197 type: int 1198 route_map_in: 1199 description: 1200 - IPv4 Inbound route map filter. Source router.route-map.name. 1201 type: str 1202 route_map_in6: 1203 description: 1204 - IPv6 Inbound route map filter. Source router.route-map.name. 1205 type: str 1206 route_map_out: 1207 description: 1208 - IPv4 Outbound route map filter. Source router.route-map.name. 1209 type: str 1210 route_map_out6: 1211 description: 1212 - IPv6 Outbound route map filter. Source router.route-map.name. 1213 type: str 1214 route_reflector_client: 1215 description: 1216 - Enable/disable IPv4 AS route reflector client. 1217 type: str 1218 choices: 1219 - enable 1220 - disable 1221 route_reflector_client6: 1222 description: 1223 - Enable/disable IPv6 AS route reflector client. 1224 type: str 1225 choices: 1226 - enable 1227 - disable 1228 route_server_client: 1229 description: 1230 - Enable/disable IPv4 AS route server client. 1231 type: str 1232 choices: 1233 - enable 1234 - disable 1235 route_server_client6: 1236 description: 1237 - Enable/disable IPv6 AS route server client. 1238 type: str 1239 choices: 1240 - enable 1241 - disable 1242 send_community: 1243 description: 1244 - IPv4 Send community attribute to neighbor. 1245 type: str 1246 choices: 1247 - standard 1248 - extended 1249 - both 1250 - disable 1251 send_community6: 1252 description: 1253 - IPv6 Send community attribute to neighbor. 1254 type: str 1255 choices: 1256 - standard 1257 - extended 1258 - both 1259 - disable 1260 shutdown: 1261 description: 1262 - Enable/disable shutdown this neighbor. 1263 type: str 1264 choices: 1265 - enable 1266 - disable 1267 soft_reconfiguration: 1268 description: 1269 - Enable/disable allow IPv4 inbound soft reconfiguration. 1270 type: str 1271 choices: 1272 - enable 1273 - disable 1274 soft_reconfiguration6: 1275 description: 1276 - Enable/disable allow IPv6 inbound soft reconfiguration. 1277 type: str 1278 choices: 1279 - enable 1280 - disable 1281 stale_route: 1282 description: 1283 - Enable/disable stale route after neighbor down. 1284 type: str 1285 choices: 1286 - enable 1287 - disable 1288 strict_capability_match: 1289 description: 1290 - Enable/disable strict capability matching. 1291 type: str 1292 choices: 1293 - enable 1294 - disable 1295 unsuppress_map: 1296 description: 1297 - IPv4 Route map to selectively unsuppress suppressed routes. Source router.route-map.name. 1298 type: str 1299 unsuppress_map6: 1300 description: 1301 - IPv6 Route map to selectively unsuppress suppressed routes. Source router.route-map.name. 1302 type: str 1303 update_source: 1304 description: 1305 - Interface to use as source IP/IPv6 address of TCP connections. Source system.interface.name. 1306 type: str 1307 weight: 1308 description: 1309 - Neighbor weight. 1310 type: int 1311 neighbor_range: 1312 description: 1313 - BGP neighbor range table. 1314 type: list 1315 suboptions: 1316 id: 1317 description: 1318 - Neighbor range ID. 1319 required: true 1320 type: int 1321 max_neighbor_num: 1322 description: 1323 - Maximum number of neighbors. 1324 type: int 1325 neighbor_group: 1326 description: 1327 - Neighbor group name. Source router.bgp.neighbor-group.name. 1328 type: str 1329 prefix: 1330 description: 1331 - Neighbor range prefix. 1332 type: str 1333 neighbor_range6: 1334 description: 1335 - BGP IPv6 neighbor range table. 1336 type: list 1337 suboptions: 1338 id: 1339 description: 1340 - IPv6 neighbor range ID. 1341 required: true 1342 type: int 1343 max_neighbor_num: 1344 description: 1345 - Maximum number of neighbors. 1346 type: int 1347 neighbor_group: 1348 description: 1349 - Neighbor group name. Source router.bgp.neighbor-group.name. 1350 type: str 1351 prefix6: 1352 description: 1353 - IPv6 prefix. 1354 type: str 1355 network: 1356 description: 1357 - BGP network table. 1358 type: list 1359 suboptions: 1360 backdoor: 1361 description: 1362 - Enable/disable route as backdoor. 1363 type: str 1364 choices: 1365 - enable 1366 - disable 1367 id: 1368 description: 1369 - ID. 1370 required: true 1371 type: int 1372 prefix: 1373 description: 1374 - Network prefix. 1375 type: str 1376 route_map: 1377 description: 1378 - Route map to modify generated route. Source router.route-map.name. 1379 type: str 1380 network_import_check: 1381 description: 1382 - Enable/disable ensure BGP network route exists in IGP. 1383 type: str 1384 choices: 1385 - enable 1386 - disable 1387 network6: 1388 description: 1389 - BGP IPv6 network table. 1390 type: list 1391 suboptions: 1392 backdoor: 1393 description: 1394 - Enable/disable route as backdoor. 1395 type: str 1396 choices: 1397 - enable 1398 - disable 1399 id: 1400 description: 1401 - ID. 1402 required: true 1403 type: int 1404 prefix6: 1405 description: 1406 - Network IPv6 prefix. 1407 type: str 1408 route_map: 1409 description: 1410 - Route map to modify generated route. Source router.route-map.name. 1411 type: str 1412 redistribute: 1413 description: 1414 - BGP IPv4 redistribute table. 1415 type: list 1416 suboptions: 1417 name: 1418 description: 1419 - Distribute list entry name. 1420 required: true 1421 type: str 1422 route_map: 1423 description: 1424 - Route map name. Source router.route-map.name. 1425 type: str 1426 status: 1427 description: 1428 - Status 1429 type: str 1430 choices: 1431 - enable 1432 - disable 1433 redistribute6: 1434 description: 1435 - BGP IPv6 redistribute table. 1436 type: list 1437 suboptions: 1438 name: 1439 description: 1440 - Distribute list entry name. 1441 required: true 1442 type: str 1443 route_map: 1444 description: 1445 - Route map name. Source router.route-map.name. 1446 type: str 1447 status: 1448 description: 1449 - Status 1450 type: str 1451 choices: 1452 - enable 1453 - disable 1454 router_id: 1455 description: 1456 - Router ID. 1457 type: str 1458 scan_time: 1459 description: 1460 - Background scanner interval (sec), 0 to disable it. 1461 type: int 1462 synchronization: 1463 description: 1464 - Enable/disable only advertise routes from iBGP if routes present in an IGP. 1465 type: str 1466 choices: 1467 - enable 1468 - disable 1469''' 1470 1471EXAMPLES = ''' 1472- hosts: localhost 1473 vars: 1474 host: "192.168.122.40" 1475 username: "admin" 1476 password: "" 1477 vdom: "root" 1478 ssl_verify: "False" 1479 tasks: 1480 - name: Configure BGP. 1481 fortios_router_bgp: 1482 host: "{{ host }}" 1483 username: "{{ username }}" 1484 password: "{{ password }}" 1485 vdom: "{{ vdom }}" 1486 https: "False" 1487 router_bgp: 1488 admin_distance: 1489 - 1490 distance: "4" 1491 id: "5" 1492 neighbour_prefix: "<your_own_value>" 1493 route_list: "<your_own_value> (source router.access-list.name)" 1494 aggregate_address: 1495 - 1496 as_set: "enable" 1497 id: "10" 1498 prefix: "<your_own_value>" 1499 summary_only: "enable" 1500 aggregate_address6: 1501 - 1502 as_set: "enable" 1503 id: "15" 1504 prefix6: "<your_own_value>" 1505 summary_only: "enable" 1506 always_compare_med: "enable" 1507 as: "19" 1508 bestpath_as_path_ignore: "enable" 1509 bestpath_cmp_confed_aspath: "enable" 1510 bestpath_cmp_routerid: "enable" 1511 bestpath_med_confed: "enable" 1512 bestpath_med_missing_as_worst: "enable" 1513 client_to_client_reflection: "enable" 1514 cluster_id: "<your_own_value>" 1515 confederation_identifier: "27" 1516 confederation_peers: 1517 - 1518 peer: "<your_own_value>" 1519 dampening: "enable" 1520 dampening_max_suppress_time: "31" 1521 dampening_reachability_half_life: "32" 1522 dampening_reuse: "33" 1523 dampening_route_map: "<your_own_value> (source router.route-map.name)" 1524 dampening_suppress: "35" 1525 dampening_unreachability_half_life: "36" 1526 default_local_preference: "37" 1527 deterministic_med: "enable" 1528 distance_external: "39" 1529 distance_internal: "40" 1530 distance_local: "41" 1531 ebgp_multipath: "enable" 1532 enforce_first_as: "enable" 1533 fast_external_failover: "enable" 1534 graceful_end_on_timer: "enable" 1535 graceful_restart: "enable" 1536 graceful_restart_time: "47" 1537 graceful_stalepath_time: "48" 1538 graceful_update_delay: "49" 1539 holdtime_timer: "50" 1540 ibgp_multipath: "enable" 1541 ignore_optional_capability: "enable" 1542 keepalive_timer: "53" 1543 log_neighbour_changes: "enable" 1544 neighbor: 1545 - 1546 activate: "enable" 1547 activate6: "enable" 1548 advertisement_interval: "58" 1549 allowas_in: "59" 1550 allowas_in_enable: "enable" 1551 allowas_in_enable6: "enable" 1552 allowas_in6: "62" 1553 as_override: "enable" 1554 as_override6: "enable" 1555 attribute_unchanged: "as-path" 1556 attribute_unchanged6: "as-path" 1557 bfd: "enable" 1558 capability_default_originate: "enable" 1559 capability_default_originate6: "enable" 1560 capability_dynamic: "enable" 1561 capability_graceful_restart: "enable" 1562 capability_graceful_restart6: "enable" 1563 capability_orf: "none" 1564 capability_orf6: "none" 1565 capability_route_refresh: "enable" 1566 conditional_advertise: 1567 - 1568 advertise_routemap: "<your_own_value> (source router.route-map.name)" 1569 condition_routemap: "<your_own_value> (source router.route-map.name)" 1570 condition_type: "exist" 1571 connect_timer: "80" 1572 default_originate_routemap: "<your_own_value> (source router.route-map.name)" 1573 default_originate_routemap6: "<your_own_value> (source router.route-map.name)" 1574 description: "<your_own_value>" 1575 distribute_list_in: "<your_own_value> (source router.access-list.name)" 1576 distribute_list_in6: "<your_own_value> (source router.access-list6.name)" 1577 distribute_list_out: "<your_own_value> (source router.access-list.name)" 1578 distribute_list_out6: "<your_own_value> (source router.access-list6.name)" 1579 dont_capability_negotiate: "enable" 1580 ebgp_enforce_multihop: "enable" 1581 ebgp_multihop_ttl: "90" 1582 filter_list_in: "<your_own_value> (source router.aspath-list.name)" 1583 filter_list_in6: "<your_own_value> (source router.aspath-list.name)" 1584 filter_list_out: "<your_own_value> (source router.aspath-list.name)" 1585 filter_list_out6: "<your_own_value> (source router.aspath-list.name)" 1586 holdtime_timer: "95" 1587 interface: "<your_own_value> (source system.interface.name)" 1588 ip: "<your_own_value>" 1589 keep_alive_timer: "98" 1590 link_down_failover: "enable" 1591 local_as: "100" 1592 local_as_no_prepend: "enable" 1593 local_as_replace_as: "enable" 1594 maximum_prefix: "103" 1595 maximum_prefix_threshold: "104" 1596 maximum_prefix_threshold6: "105" 1597 maximum_prefix_warning_only: "enable" 1598 maximum_prefix_warning_only6: "enable" 1599 maximum_prefix6: "108" 1600 next_hop_self: "enable" 1601 next_hop_self6: "enable" 1602 override_capability: "enable" 1603 passive: "enable" 1604 password: "<your_own_value>" 1605 prefix_list_in: "<your_own_value> (source router.prefix-list.name)" 1606 prefix_list_in6: "<your_own_value> (source router.prefix-list6.name)" 1607 prefix_list_out: "<your_own_value> (source router.prefix-list.name)" 1608 prefix_list_out6: "<your_own_value> (source router.prefix-list6.name)" 1609 remote_as: "118" 1610 remove_private_as: "enable" 1611 remove_private_as6: "enable" 1612 restart_time: "121" 1613 retain_stale_time: "122" 1614 route_map_in: "<your_own_value> (source router.route-map.name)" 1615 route_map_in6: "<your_own_value> (source router.route-map.name)" 1616 route_map_out: "<your_own_value> (source router.route-map.name)" 1617 route_map_out6: "<your_own_value> (source router.route-map.name)" 1618 route_reflector_client: "enable" 1619 route_reflector_client6: "enable" 1620 route_server_client: "enable" 1621 route_server_client6: "enable" 1622 send_community: "standard" 1623 send_community6: "standard" 1624 shutdown: "enable" 1625 soft_reconfiguration: "enable" 1626 soft_reconfiguration6: "enable" 1627 stale_route: "enable" 1628 strict_capability_match: "enable" 1629 unsuppress_map: "<your_own_value> (source router.route-map.name)" 1630 unsuppress_map6: "<your_own_value> (source router.route-map.name)" 1631 update_source: "<your_own_value> (source system.interface.name)" 1632 weight: "141" 1633 neighbor_group: 1634 - 1635 activate: "enable" 1636 activate6: "enable" 1637 advertisement_interval: "145" 1638 allowas_in: "146" 1639 allowas_in_enable: "enable" 1640 allowas_in_enable6: "enable" 1641 allowas_in6: "149" 1642 as_override: "enable" 1643 as_override6: "enable" 1644 attribute_unchanged: "as-path" 1645 attribute_unchanged6: "as-path" 1646 bfd: "enable" 1647 capability_default_originate: "enable" 1648 capability_default_originate6: "enable" 1649 capability_dynamic: "enable" 1650 capability_graceful_restart: "enable" 1651 capability_graceful_restart6: "enable" 1652 capability_orf: "none" 1653 capability_orf6: "none" 1654 capability_route_refresh: "enable" 1655 connect_timer: "163" 1656 default_originate_routemap: "<your_own_value> (source router.route-map.name)" 1657 default_originate_routemap6: "<your_own_value> (source router.route-map.name)" 1658 description: "<your_own_value>" 1659 distribute_list_in: "<your_own_value> (source router.access-list.name)" 1660 distribute_list_in6: "<your_own_value> (source router.access-list6.name)" 1661 distribute_list_out: "<your_own_value> (source router.access-list.name)" 1662 distribute_list_out6: "<your_own_value> (source router.access-list6.name)" 1663 dont_capability_negotiate: "enable" 1664 ebgp_enforce_multihop: "enable" 1665 ebgp_multihop_ttl: "173" 1666 filter_list_in: "<your_own_value> (source router.aspath-list.name)" 1667 filter_list_in6: "<your_own_value> (source router.aspath-list.name)" 1668 filter_list_out: "<your_own_value> (source router.aspath-list.name)" 1669 filter_list_out6: "<your_own_value> (source router.aspath-list.name)" 1670 holdtime_timer: "178" 1671 interface: "<your_own_value> (source system.interface.name)" 1672 keep_alive_timer: "180" 1673 link_down_failover: "enable" 1674 local_as: "182" 1675 local_as_no_prepend: "enable" 1676 local_as_replace_as: "enable" 1677 maximum_prefix: "185" 1678 maximum_prefix_threshold: "186" 1679 maximum_prefix_threshold6: "187" 1680 maximum_prefix_warning_only: "enable" 1681 maximum_prefix_warning_only6: "enable" 1682 maximum_prefix6: "190" 1683 name: "default_name_191" 1684 next_hop_self: "enable" 1685 next_hop_self6: "enable" 1686 override_capability: "enable" 1687 passive: "enable" 1688 prefix_list_in: "<your_own_value> (source router.prefix-list.name)" 1689 prefix_list_in6: "<your_own_value> (source router.prefix-list6.name)" 1690 prefix_list_out: "<your_own_value> (source router.prefix-list.name)" 1691 prefix_list_out6: "<your_own_value> (source router.prefix-list6.name)" 1692 remote_as: "200" 1693 remove_private_as: "enable" 1694 remove_private_as6: "enable" 1695 restart_time: "203" 1696 retain_stale_time: "204" 1697 route_map_in: "<your_own_value> (source router.route-map.name)" 1698 route_map_in6: "<your_own_value> (source router.route-map.name)" 1699 route_map_out: "<your_own_value> (source router.route-map.name)" 1700 route_map_out6: "<your_own_value> (source router.route-map.name)" 1701 route_reflector_client: "enable" 1702 route_reflector_client6: "enable" 1703 route_server_client: "enable" 1704 route_server_client6: "enable" 1705 send_community: "standard" 1706 send_community6: "standard" 1707 shutdown: "enable" 1708 soft_reconfiguration: "enable" 1709 soft_reconfiguration6: "enable" 1710 stale_route: "enable" 1711 strict_capability_match: "enable" 1712 unsuppress_map: "<your_own_value> (source router.route-map.name)" 1713 unsuppress_map6: "<your_own_value> (source router.route-map.name)" 1714 update_source: "<your_own_value> (source system.interface.name)" 1715 weight: "223" 1716 neighbor_range: 1717 - 1718 id: "225" 1719 max_neighbor_num: "226" 1720 neighbor_group: "<your_own_value> (source router.bgp.neighbor-group.name)" 1721 prefix: "<your_own_value>" 1722 neighbor_range6: 1723 - 1724 id: "230" 1725 max_neighbor_num: "231" 1726 neighbor_group: "<your_own_value> (source router.bgp.neighbor-group.name)" 1727 prefix6: "<your_own_value>" 1728 network: 1729 - 1730 backdoor: "enable" 1731 id: "236" 1732 prefix: "<your_own_value>" 1733 route_map: "<your_own_value> (source router.route-map.name)" 1734 network_import_check: "enable" 1735 network6: 1736 - 1737 backdoor: "enable" 1738 id: "242" 1739 prefix6: "<your_own_value>" 1740 route_map: "<your_own_value> (source router.route-map.name)" 1741 redistribute: 1742 - 1743 name: "default_name_246" 1744 route_map: "<your_own_value> (source router.route-map.name)" 1745 status: "enable" 1746 redistribute6: 1747 - 1748 name: "default_name_250" 1749 route_map: "<your_own_value> (source router.route-map.name)" 1750 status: "enable" 1751 router_id: "<your_own_value>" 1752 scan_time: "254" 1753 synchronization: "enable" 1754''' 1755 1756RETURN = ''' 1757build: 1758 description: Build number of the fortigate image 1759 returned: always 1760 type: str 1761 sample: '1547' 1762http_method: 1763 description: Last method used to provision the content into FortiGate 1764 returned: always 1765 type: str 1766 sample: 'PUT' 1767http_status: 1768 description: Last result given by FortiGate on last operation applied 1769 returned: always 1770 type: str 1771 sample: "200" 1772mkey: 1773 description: Master key (id) used in the last call to FortiGate 1774 returned: success 1775 type: str 1776 sample: "id" 1777name: 1778 description: Name of the table used to fulfill the request 1779 returned: always 1780 type: str 1781 sample: "urlfilter" 1782path: 1783 description: Path of the table used to fulfill the request 1784 returned: always 1785 type: str 1786 sample: "webfilter" 1787revision: 1788 description: Internal revision number 1789 returned: always 1790 type: str 1791 sample: "17.0.2.10658" 1792serial: 1793 description: Serial number of the unit 1794 returned: always 1795 type: str 1796 sample: "FGVMEVYYQT3AB5352" 1797status: 1798 description: Indication of the operation's result 1799 returned: always 1800 type: str 1801 sample: "success" 1802vdom: 1803 description: Virtual domain used 1804 returned: always 1805 type: str 1806 sample: "root" 1807version: 1808 description: Version of the FortiGate 1809 returned: always 1810 type: str 1811 sample: "v5.6.3" 1812 1813''' 1814 1815from ansible.module_utils.basic import AnsibleModule 1816from ansible.module_utils.connection import Connection 1817from ansible.module_utils.network.fortios.fortios import FortiOSHandler 1818from ansible.module_utils.network.fortimanager.common import FAIL_SOCKET_MSG 1819 1820 1821def login(data, fos): 1822 host = data['host'] 1823 username = data['username'] 1824 password = data['password'] 1825 ssl_verify = data['ssl_verify'] 1826 1827 fos.debug('on') 1828 if 'https' in data and not data['https']: 1829 fos.https('off') 1830 else: 1831 fos.https('on') 1832 1833 fos.login(host, username, password, verify=ssl_verify) 1834 1835 1836def filter_router_bgp_data(json): 1837 option_list = ['admin_distance', 'aggregate_address', 'aggregate_address6', 1838 'always_compare_med', 'as', 'bestpath_as_path_ignore', 1839 'bestpath_cmp_confed_aspath', 'bestpath_cmp_routerid', 'bestpath_med_confed', 1840 'bestpath_med_missing_as_worst', 'client_to_client_reflection', 'cluster_id', 1841 'confederation_identifier', 'confederation_peers', 'dampening', 1842 'dampening_max_suppress_time', 'dampening_reachability_half_life', 'dampening_reuse', 1843 'dampening_route_map', 'dampening_suppress', 'dampening_unreachability_half_life', 1844 'default_local_preference', 'deterministic_med', 'distance_external', 1845 'distance_internal', 'distance_local', 'ebgp_multipath', 1846 'enforce_first_as', 'fast_external_failover', 'graceful_end_on_timer', 1847 'graceful_restart', 'graceful_restart_time', 'graceful_stalepath_time', 1848 'graceful_update_delay', 'holdtime_timer', 'ibgp_multipath', 1849 'ignore_optional_capability', 'keepalive_timer', 'log_neighbour_changes', 1850 'neighbor', 'neighbor_group', 'neighbor_range', 1851 'neighbor_range6', 'network', 'network_import_check', 1852 'network6', 'redistribute', 'redistribute6', 1853 'router_id', 'scan_time', 'synchronization'] 1854 dictionary = {} 1855 1856 for attribute in option_list: 1857 if attribute in json and json[attribute] is not None: 1858 dictionary[attribute] = json[attribute] 1859 1860 return dictionary 1861 1862 1863def underscore_to_hyphen(data): 1864 if isinstance(data, list): 1865 for elem in data: 1866 elem = underscore_to_hyphen(elem) 1867 elif isinstance(data, dict): 1868 new_data = {} 1869 for k, v in data.items(): 1870 new_data[k.replace('_', '-')] = underscore_to_hyphen(v) 1871 data = new_data 1872 1873 return data 1874 1875 1876def router_bgp(data, fos): 1877 vdom = data['vdom'] 1878 router_bgp_data = data['router_bgp'] 1879 filtered_data = underscore_to_hyphen(filter_router_bgp_data(router_bgp_data)) 1880 1881 return fos.set('router', 1882 'bgp', 1883 data=filtered_data, 1884 vdom=vdom) 1885 1886 1887def is_successful_status(status): 1888 return status['status'] == "success" or \ 1889 status['http_method'] == "DELETE" and status['http_status'] == 404 1890 1891 1892def fortios_router(data, fos): 1893 1894 if data['router_bgp']: 1895 resp = router_bgp(data, fos) 1896 1897 return not is_successful_status(resp), \ 1898 resp['status'] == "success", \ 1899 resp 1900 1901 1902def main(): 1903 fields = { 1904 "host": {"required": False, "type": "str"}, 1905 "username": {"required": False, "type": "str"}, 1906 "password": {"required": False, "type": "str", "default": "", "no_log": True}, 1907 "vdom": {"required": False, "type": "str", "default": "root"}, 1908 "https": {"required": False, "type": "bool", "default": True}, 1909 "ssl_verify": {"required": False, "type": "bool", "default": True}, 1910 "router_bgp": { 1911 "required": False, "type": "dict", "default": None, 1912 "options": { 1913 "admin_distance": {"required": False, "type": "list", 1914 "options": { 1915 "distance": {"required": False, "type": "int"}, 1916 "id": {"required": True, "type": "int"}, 1917 "neighbour_prefix": {"required": False, "type": "str"}, 1918 "route_list": {"required": False, "type": "str"} 1919 }}, 1920 "aggregate_address": {"required": False, "type": "list", 1921 "options": { 1922 "as_set": {"required": False, "type": "str", 1923 "choices": ["enable", "disable"]}, 1924 "id": {"required": True, "type": "int"}, 1925 "prefix": {"required": False, "type": "str"}, 1926 "summary_only": {"required": False, "type": "str", 1927 "choices": ["enable", "disable"]} 1928 }}, 1929 "aggregate_address6": {"required": False, "type": "list", 1930 "options": { 1931 "as_set": {"required": False, "type": "str", 1932 "choices": ["enable", "disable"]}, 1933 "id": {"required": True, "type": "int"}, 1934 "prefix6": {"required": False, "type": "str"}, 1935 "summary_only": {"required": False, "type": "str", 1936 "choices": ["enable", "disable"]} 1937 }}, 1938 "always_compare_med": {"required": False, "type": "str", 1939 "choices": ["enable", "disable"]}, 1940 "as": {"required": False, "type": "int"}, 1941 "bestpath_as_path_ignore": {"required": False, "type": "str", 1942 "choices": ["enable", "disable"]}, 1943 "bestpath_cmp_confed_aspath": {"required": False, "type": "str", 1944 "choices": ["enable", "disable"]}, 1945 "bestpath_cmp_routerid": {"required": False, "type": "str", 1946 "choices": ["enable", "disable"]}, 1947 "bestpath_med_confed": {"required": False, "type": "str", 1948 "choices": ["enable", "disable"]}, 1949 "bestpath_med_missing_as_worst": {"required": False, "type": "str", 1950 "choices": ["enable", "disable"]}, 1951 "client_to_client_reflection": {"required": False, "type": "str", 1952 "choices": ["enable", "disable"]}, 1953 "cluster_id": {"required": False, "type": "str"}, 1954 "confederation_identifier": {"required": False, "type": "int"}, 1955 "confederation_peers": {"required": False, "type": "list", 1956 "options": { 1957 "peer": {"required": True, "type": "str"} 1958 }}, 1959 "dampening": {"required": False, "type": "str", 1960 "choices": ["enable", "disable"]}, 1961 "dampening_max_suppress_time": {"required": False, "type": "int"}, 1962 "dampening_reachability_half_life": {"required": False, "type": "int"}, 1963 "dampening_reuse": {"required": False, "type": "int"}, 1964 "dampening_route_map": {"required": False, "type": "str"}, 1965 "dampening_suppress": {"required": False, "type": "int"}, 1966 "dampening_unreachability_half_life": {"required": False, "type": "int"}, 1967 "default_local_preference": {"required": False, "type": "int"}, 1968 "deterministic_med": {"required": False, "type": "str", 1969 "choices": ["enable", "disable"]}, 1970 "distance_external": {"required": False, "type": "int"}, 1971 "distance_internal": {"required": False, "type": "int"}, 1972 "distance_local": {"required": False, "type": "int"}, 1973 "ebgp_multipath": {"required": False, "type": "str", 1974 "choices": ["enable", "disable"]}, 1975 "enforce_first_as": {"required": False, "type": "str", 1976 "choices": ["enable", "disable"]}, 1977 "fast_external_failover": {"required": False, "type": "str", 1978 "choices": ["enable", "disable"]}, 1979 "graceful_end_on_timer": {"required": False, "type": "str", 1980 "choices": ["enable", "disable"]}, 1981 "graceful_restart": {"required": False, "type": "str", 1982 "choices": ["enable", "disable"]}, 1983 "graceful_restart_time": {"required": False, "type": "int"}, 1984 "graceful_stalepath_time": {"required": False, "type": "int"}, 1985 "graceful_update_delay": {"required": False, "type": "int"}, 1986 "holdtime_timer": {"required": False, "type": "int"}, 1987 "ibgp_multipath": {"required": False, "type": "str", 1988 "choices": ["enable", "disable"]}, 1989 "ignore_optional_capability": {"required": False, "type": "str", 1990 "choices": ["enable", "disable"]}, 1991 "keepalive_timer": {"required": False, "type": "int"}, 1992 "log_neighbour_changes": {"required": False, "type": "str", 1993 "choices": ["enable", "disable"]}, 1994 "neighbor": {"required": False, "type": "list", 1995 "options": { 1996 "activate": {"required": False, "type": "str", 1997 "choices": ["enable", "disable"]}, 1998 "activate6": {"required": False, "type": "str", 1999 "choices": ["enable", "disable"]}, 2000 "advertisement_interval": {"required": False, "type": "int"}, 2001 "allowas_in": {"required": False, "type": "int"}, 2002 "allowas_in_enable": {"required": False, "type": "str", 2003 "choices": ["enable", "disable"]}, 2004 "allowas_in_enable6": {"required": False, "type": "str", 2005 "choices": ["enable", "disable"]}, 2006 "allowas_in6": {"required": False, "type": "int"}, 2007 "as_override": {"required": False, "type": "str", 2008 "choices": ["enable", "disable"]}, 2009 "as_override6": {"required": False, "type": "str", 2010 "choices": ["enable", "disable"]}, 2011 "attribute_unchanged": {"required": False, "type": "str", 2012 "choices": ["as-path", "med", "next-hop"]}, 2013 "attribute_unchanged6": {"required": False, "type": "str", 2014 "choices": ["as-path", "med", "next-hop"]}, 2015 "bfd": {"required": False, "type": "str", 2016 "choices": ["enable", "disable"]}, 2017 "capability_default_originate": {"required": False, "type": "str", 2018 "choices": ["enable", "disable"]}, 2019 "capability_default_originate6": {"required": False, "type": "str", 2020 "choices": ["enable", "disable"]}, 2021 "capability_dynamic": {"required": False, "type": "str", 2022 "choices": ["enable", "disable"]}, 2023 "capability_graceful_restart": {"required": False, "type": "str", 2024 "choices": ["enable", "disable"]}, 2025 "capability_graceful_restart6": {"required": False, "type": "str", 2026 "choices": ["enable", "disable"]}, 2027 "capability_orf": {"required": False, "type": "str", 2028 "choices": ["none", "receive", "send", 2029 "both"]}, 2030 "capability_orf6": {"required": False, "type": "str", 2031 "choices": ["none", "receive", "send", 2032 "both"]}, 2033 "capability_route_refresh": {"required": False, "type": "str", 2034 "choices": ["enable", "disable"]}, 2035 "conditional_advertise": {"required": False, "type": "list", 2036 "options": { 2037 "advertise_routemap": {"required": False, "type": "str"}, 2038 "condition_routemap": {"required": False, "type": "str"}, 2039 "condition_type": {"required": False, "type": "str", 2040 "choices": ["exist", "non-exist"]} 2041 }}, 2042 "connect_timer": {"required": False, "type": "int"}, 2043 "default_originate_routemap": {"required": False, "type": "str"}, 2044 "default_originate_routemap6": {"required": False, "type": "str"}, 2045 "description": {"required": False, "type": "str"}, 2046 "distribute_list_in": {"required": False, "type": "str"}, 2047 "distribute_list_in6": {"required": False, "type": "str"}, 2048 "distribute_list_out": {"required": False, "type": "str"}, 2049 "distribute_list_out6": {"required": False, "type": "str"}, 2050 "dont_capability_negotiate": {"required": False, "type": "str", 2051 "choices": ["enable", "disable"]}, 2052 "ebgp_enforce_multihop": {"required": False, "type": "str", 2053 "choices": ["enable", "disable"]}, 2054 "ebgp_multihop_ttl": {"required": False, "type": "int"}, 2055 "filter_list_in": {"required": False, "type": "str"}, 2056 "filter_list_in6": {"required": False, "type": "str"}, 2057 "filter_list_out": {"required": False, "type": "str"}, 2058 "filter_list_out6": {"required": False, "type": "str"}, 2059 "holdtime_timer": {"required": False, "type": "int"}, 2060 "interface": {"required": False, "type": "str"}, 2061 "ip": {"required": True, "type": "str"}, 2062 "keep_alive_timer": {"required": False, "type": "int"}, 2063 "link_down_failover": {"required": False, "type": "str", 2064 "choices": ["enable", "disable"]}, 2065 "local_as": {"required": False, "type": "int"}, 2066 "local_as_no_prepend": {"required": False, "type": "str", 2067 "choices": ["enable", "disable"]}, 2068 "local_as_replace_as": {"required": False, "type": "str", 2069 "choices": ["enable", "disable"]}, 2070 "maximum_prefix": {"required": False, "type": "int"}, 2071 "maximum_prefix_threshold": {"required": False, "type": "int"}, 2072 "maximum_prefix_threshold6": {"required": False, "type": "int"}, 2073 "maximum_prefix_warning_only": {"required": False, "type": "str", 2074 "choices": ["enable", "disable"]}, 2075 "maximum_prefix_warning_only6": {"required": False, "type": "str", 2076 "choices": ["enable", "disable"]}, 2077 "maximum_prefix6": {"required": False, "type": "int"}, 2078 "next_hop_self": {"required": False, "type": "str", 2079 "choices": ["enable", "disable"]}, 2080 "next_hop_self6": {"required": False, "type": "str", 2081 "choices": ["enable", "disable"]}, 2082 "override_capability": {"required": False, "type": "str", 2083 "choices": ["enable", "disable"]}, 2084 "passive": {"required": False, "type": "str", 2085 "choices": ["enable", "disable"]}, 2086 "password": {"required": False, "type": "str", "no_log": True}, 2087 "prefix_list_in": {"required": False, "type": "str"}, 2088 "prefix_list_in6": {"required": False, "type": "str"}, 2089 "prefix_list_out": {"required": False, "type": "str"}, 2090 "prefix_list_out6": {"required": False, "type": "str"}, 2091 "remote_as": {"required": False, "type": "int"}, 2092 "remove_private_as": {"required": False, "type": "str", 2093 "choices": ["enable", "disable"]}, 2094 "remove_private_as6": {"required": False, "type": "str", 2095 "choices": ["enable", "disable"]}, 2096 "restart_time": {"required": False, "type": "int"}, 2097 "retain_stale_time": {"required": False, "type": "int"}, 2098 "route_map_in": {"required": False, "type": "str"}, 2099 "route_map_in6": {"required": False, "type": "str"}, 2100 "route_map_out": {"required": False, "type": "str"}, 2101 "route_map_out6": {"required": False, "type": "str"}, 2102 "route_reflector_client": {"required": False, "type": "str", 2103 "choices": ["enable", "disable"]}, 2104 "route_reflector_client6": {"required": False, "type": "str", 2105 "choices": ["enable", "disable"]}, 2106 "route_server_client": {"required": False, "type": "str", 2107 "choices": ["enable", "disable"]}, 2108 "route_server_client6": {"required": False, "type": "str", 2109 "choices": ["enable", "disable"]}, 2110 "send_community": {"required": False, "type": "str", 2111 "choices": ["standard", "extended", "both", 2112 "disable"]}, 2113 "send_community6": {"required": False, "type": "str", 2114 "choices": ["standard", "extended", "both", 2115 "disable"]}, 2116 "shutdown": {"required": False, "type": "str", 2117 "choices": ["enable", "disable"]}, 2118 "soft_reconfiguration": {"required": False, "type": "str", 2119 "choices": ["enable", "disable"]}, 2120 "soft_reconfiguration6": {"required": False, "type": "str", 2121 "choices": ["enable", "disable"]}, 2122 "stale_route": {"required": False, "type": "str", 2123 "choices": ["enable", "disable"]}, 2124 "strict_capability_match": {"required": False, "type": "str", 2125 "choices": ["enable", "disable"]}, 2126 "unsuppress_map": {"required": False, "type": "str"}, 2127 "unsuppress_map6": {"required": False, "type": "str"}, 2128 "update_source": {"required": False, "type": "str"}, 2129 "weight": {"required": False, "type": "int"} 2130 }}, 2131 "neighbor_group": {"required": False, "type": "list", 2132 "options": { 2133 "activate": {"required": False, "type": "str", 2134 "choices": ["enable", "disable"]}, 2135 "activate6": {"required": False, "type": "str", 2136 "choices": ["enable", "disable"]}, 2137 "advertisement_interval": {"required": False, "type": "int"}, 2138 "allowas_in": {"required": False, "type": "int"}, 2139 "allowas_in_enable": {"required": False, "type": "str", 2140 "choices": ["enable", "disable"]}, 2141 "allowas_in_enable6": {"required": False, "type": "str", 2142 "choices": ["enable", "disable"]}, 2143 "allowas_in6": {"required": False, "type": "int"}, 2144 "as_override": {"required": False, "type": "str", 2145 "choices": ["enable", "disable"]}, 2146 "as_override6": {"required": False, "type": "str", 2147 "choices": ["enable", "disable"]}, 2148 "attribute_unchanged": {"required": False, "type": "str", 2149 "choices": ["as-path", "med", "next-hop"]}, 2150 "attribute_unchanged6": {"required": False, "type": "str", 2151 "choices": ["as-path", "med", "next-hop"]}, 2152 "bfd": {"required": False, "type": "str", 2153 "choices": ["enable", "disable"]}, 2154 "capability_default_originate": {"required": False, "type": "str", 2155 "choices": ["enable", "disable"]}, 2156 "capability_default_originate6": {"required": False, "type": "str", 2157 "choices": ["enable", "disable"]}, 2158 "capability_dynamic": {"required": False, "type": "str", 2159 "choices": ["enable", "disable"]}, 2160 "capability_graceful_restart": {"required": False, "type": "str", 2161 "choices": ["enable", "disable"]}, 2162 "capability_graceful_restart6": {"required": False, "type": "str", 2163 "choices": ["enable", "disable"]}, 2164 "capability_orf": {"required": False, "type": "str", 2165 "choices": ["none", "receive", "send", 2166 "both"]}, 2167 "capability_orf6": {"required": False, "type": "str", 2168 "choices": ["none", "receive", "send", 2169 "both"]}, 2170 "capability_route_refresh": {"required": False, "type": "str", 2171 "choices": ["enable", "disable"]}, 2172 "connect_timer": {"required": False, "type": "int"}, 2173 "default_originate_routemap": {"required": False, "type": "str"}, 2174 "default_originate_routemap6": {"required": False, "type": "str"}, 2175 "description": {"required": False, "type": "str"}, 2176 "distribute_list_in": {"required": False, "type": "str"}, 2177 "distribute_list_in6": {"required": False, "type": "str"}, 2178 "distribute_list_out": {"required": False, "type": "str"}, 2179 "distribute_list_out6": {"required": False, "type": "str"}, 2180 "dont_capability_negotiate": {"required": False, "type": "str", 2181 "choices": ["enable", "disable"]}, 2182 "ebgp_enforce_multihop": {"required": False, "type": "str", 2183 "choices": ["enable", "disable"]}, 2184 "ebgp_multihop_ttl": {"required": False, "type": "int"}, 2185 "filter_list_in": {"required": False, "type": "str"}, 2186 "filter_list_in6": {"required": False, "type": "str"}, 2187 "filter_list_out": {"required": False, "type": "str"}, 2188 "filter_list_out6": {"required": False, "type": "str"}, 2189 "holdtime_timer": {"required": False, "type": "int"}, 2190 "interface": {"required": False, "type": "str"}, 2191 "keep_alive_timer": {"required": False, "type": "int"}, 2192 "link_down_failover": {"required": False, "type": "str", 2193 "choices": ["enable", "disable"]}, 2194 "local_as": {"required": False, "type": "int"}, 2195 "local_as_no_prepend": {"required": False, "type": "str", 2196 "choices": ["enable", "disable"]}, 2197 "local_as_replace_as": {"required": False, "type": "str", 2198 "choices": ["enable", "disable"]}, 2199 "maximum_prefix": {"required": False, "type": "int"}, 2200 "maximum_prefix_threshold": {"required": False, "type": "int"}, 2201 "maximum_prefix_threshold6": {"required": False, "type": "int"}, 2202 "maximum_prefix_warning_only": {"required": False, "type": "str", 2203 "choices": ["enable", "disable"]}, 2204 "maximum_prefix_warning_only6": {"required": False, "type": "str", 2205 "choices": ["enable", "disable"]}, 2206 "maximum_prefix6": {"required": False, "type": "int"}, 2207 "name": {"required": True, "type": "str"}, 2208 "next_hop_self": {"required": False, "type": "str", 2209 "choices": ["enable", "disable"]}, 2210 "next_hop_self6": {"required": False, "type": "str", 2211 "choices": ["enable", "disable"]}, 2212 "override_capability": {"required": False, "type": "str", 2213 "choices": ["enable", "disable"]}, 2214 "passive": {"required": False, "type": "str", 2215 "choices": ["enable", "disable"]}, 2216 "prefix_list_in": {"required": False, "type": "str"}, 2217 "prefix_list_in6": {"required": False, "type": "str"}, 2218 "prefix_list_out": {"required": False, "type": "str"}, 2219 "prefix_list_out6": {"required": False, "type": "str"}, 2220 "remote_as": {"required": False, "type": "int"}, 2221 "remove_private_as": {"required": False, "type": "str", 2222 "choices": ["enable", "disable"]}, 2223 "remove_private_as6": {"required": False, "type": "str", 2224 "choices": ["enable", "disable"]}, 2225 "restart_time": {"required": False, "type": "int"}, 2226 "retain_stale_time": {"required": False, "type": "int"}, 2227 "route_map_in": {"required": False, "type": "str"}, 2228 "route_map_in6": {"required": False, "type": "str"}, 2229 "route_map_out": {"required": False, "type": "str"}, 2230 "route_map_out6": {"required": False, "type": "str"}, 2231 "route_reflector_client": {"required": False, "type": "str", 2232 "choices": ["enable", "disable"]}, 2233 "route_reflector_client6": {"required": False, "type": "str", 2234 "choices": ["enable", "disable"]}, 2235 "route_server_client": {"required": False, "type": "str", 2236 "choices": ["enable", "disable"]}, 2237 "route_server_client6": {"required": False, "type": "str", 2238 "choices": ["enable", "disable"]}, 2239 "send_community": {"required": False, "type": "str", 2240 "choices": ["standard", "extended", "both", 2241 "disable"]}, 2242 "send_community6": {"required": False, "type": "str", 2243 "choices": ["standard", "extended", "both", 2244 "disable"]}, 2245 "shutdown": {"required": False, "type": "str", 2246 "choices": ["enable", "disable"]}, 2247 "soft_reconfiguration": {"required": False, "type": "str", 2248 "choices": ["enable", "disable"]}, 2249 "soft_reconfiguration6": {"required": False, "type": "str", 2250 "choices": ["enable", "disable"]}, 2251 "stale_route": {"required": False, "type": "str", 2252 "choices": ["enable", "disable"]}, 2253 "strict_capability_match": {"required": False, "type": "str", 2254 "choices": ["enable", "disable"]}, 2255 "unsuppress_map": {"required": False, "type": "str"}, 2256 "unsuppress_map6": {"required": False, "type": "str"}, 2257 "update_source": {"required": False, "type": "str"}, 2258 "weight": {"required": False, "type": "int"} 2259 }}, 2260 "neighbor_range": {"required": False, "type": "list", 2261 "options": { 2262 "id": {"required": True, "type": "int"}, 2263 "max_neighbor_num": {"required": False, "type": "int"}, 2264 "neighbor_group": {"required": False, "type": "str"}, 2265 "prefix": {"required": False, "type": "str"} 2266 }}, 2267 "neighbor_range6": {"required": False, "type": "list", 2268 "options": { 2269 "id": {"required": True, "type": "int"}, 2270 "max_neighbor_num": {"required": False, "type": "int"}, 2271 "neighbor_group": {"required": False, "type": "str"}, 2272 "prefix6": {"required": False, "type": "str"} 2273 }}, 2274 "network": {"required": False, "type": "list", 2275 "options": { 2276 "backdoor": {"required": False, "type": "str", 2277 "choices": ["enable", "disable"]}, 2278 "id": {"required": True, "type": "int"}, 2279 "prefix": {"required": False, "type": "str"}, 2280 "route_map": {"required": False, "type": "str"} 2281 }}, 2282 "network_import_check": {"required": False, "type": "str", 2283 "choices": ["enable", "disable"]}, 2284 "network6": {"required": False, "type": "list", 2285 "options": { 2286 "backdoor": {"required": False, "type": "str", 2287 "choices": ["enable", "disable"]}, 2288 "id": {"required": True, "type": "int"}, 2289 "prefix6": {"required": False, "type": "str"}, 2290 "route_map": {"required": False, "type": "str"} 2291 }}, 2292 "redistribute": {"required": False, "type": "list", 2293 "options": { 2294 "name": {"required": True, "type": "str"}, 2295 "route_map": {"required": False, "type": "str"}, 2296 "status": {"required": False, "type": "str", 2297 "choices": ["enable", "disable"]} 2298 }}, 2299 "redistribute6": {"required": False, "type": "list", 2300 "options": { 2301 "name": {"required": True, "type": "str"}, 2302 "route_map": {"required": False, "type": "str"}, 2303 "status": {"required": False, "type": "str", 2304 "choices": ["enable", "disable"]} 2305 }}, 2306 "router_id": {"required": False, "type": "str"}, 2307 "scan_time": {"required": False, "type": "int"}, 2308 "synchronization": {"required": False, "type": "str", 2309 "choices": ["enable", "disable"]} 2310 2311 } 2312 } 2313 } 2314 2315 module = AnsibleModule(argument_spec=fields, 2316 supports_check_mode=False) 2317 2318 # legacy_mode refers to using fortiosapi instead of HTTPAPI 2319 legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 2320 'username' in module.params and module.params['username'] is not None and \ 2321 'password' in module.params and module.params['password'] is not None 2322 2323 if not legacy_mode: 2324 if module._socket_path: 2325 connection = Connection(module._socket_path) 2326 fos = FortiOSHandler(connection) 2327 2328 is_error, has_changed, result = fortios_router(module.params, fos) 2329 else: 2330 module.fail_json(**FAIL_SOCKET_MSG) 2331 else: 2332 try: 2333 from fortiosapi import FortiOSAPI 2334 except ImportError: 2335 module.fail_json(msg="fortiosapi module is required") 2336 2337 fos = FortiOSAPI() 2338 2339 login(module.params, fos) 2340 is_error, has_changed, result = fortios_router(module.params, fos) 2341 fos.logout() 2342 2343 if not is_error: 2344 module.exit_json(changed=has_changed, meta=result) 2345 else: 2346 module.fail_json(msg="Error in repo", meta=result) 2347 2348 2349if __name__ == '__main__': 2350 main() 2351