| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
__metaclass__ = type |
| 13 |
|
| 14 |
ANSIBLE_METADATA = { |
| 15 |
"status": ["preview"], |
| 16 |
"supported_by": "community", |
| 17 |
"metadata_version": "1.1", |
| 18 |
} |
| 19 |
|
| 20 |
DOCUMENTATION = """ |
| 21 |
--- |
| 22 |
module: fortios_router_ospf |
| 23 |
short_description: Configure OSPF in Fortinet's FortiOS and FortiGate. |
| 24 |
description: |
| 25 |
- This module is able to configure a FortiGate or FortiOS (FOS) device by allowing the |
| 26 |
user to set and modify router feature and ospf category. |
| 27 |
Examples include all parameters and values need to be adjusted to datasources before usage. |
| 28 |
Tested with FOS v6.0.0 |
| 29 |
version_added: "2.0.0" |
| 30 |
author: |
| 31 |
- Link Zheng (@chillancezen) |
| 32 |
- Jie Xue (@JieX19) |
| 33 |
- Hongbin Lu (@fgtdev-hblu) |
| 34 |
- Frank Shen (@frankshen01) |
| 35 |
- Miguel Angel Munoz (@mamunozgonzalez) |
| 36 |
- Nicolas Thomas (@thomnico) |
| 37 |
notes: |
| 38 |
- Legacy fortiosapi has been deprecated, httpapi is the preferred way to run playbooks |
| 39 |
|
| 40 |
- The module supports check_mode. |
| 41 |
|
| 42 |
requirements: |
| 43 |
- ansible>=2.16 |
| 44 |
options: |
| 45 |
access_token: |
| 46 |
description: |
| 47 |
- Token-based authentication. |
| 48 |
Generated from GUI of Fortigate. |
| 49 |
type: str |
| 50 |
required: false |
| 51 |
enable_log: |
| 52 |
description: |
| 53 |
- Enable/Disable logging for task. |
| 54 |
type: bool |
| 55 |
required: false |
| 56 |
default: false |
| 57 |
vdom: |
| 58 |
description: |
| 59 |
- Virtual domain, among those defined previously. A vdom is a |
| 60 |
virtual instance of the FortiGate that can be configured and |
| 61 |
used as a different unit. |
| 62 |
type: str |
| 63 |
default: root |
| 64 |
member_path: |
| 65 |
type: str |
| 66 |
description: |
| 67 |
- Member attribute path to operate on. |
| 68 |
- Delimited by a slash character if there are more than one attribute. |
| 69 |
- Parameter marked with member_path is legitimate for doing member operation. |
| 70 |
member_state: |
| 71 |
type: str |
| 72 |
description: |
| 73 |
- Add or delete a member under specified attribute path. |
| 74 |
- When member_state is specified, the state option is ignored. |
| 75 |
choices: |
| 76 |
- 'present' |
| 77 |
- 'absent' |
| 78 |
|
| 79 |
router_ospf: |
| 80 |
description: |
| 81 |
- Configure OSPF. |
| 82 |
default: null |
| 83 |
type: dict |
| 84 |
suboptions: |
| 85 |
abr_type: |
| 86 |
description: |
| 87 |
- Area border router type. |
| 88 |
type: str |
| 89 |
choices: |
| 90 |
- 'cisco' |
| 91 |
- 'ibm' |
| 92 |
- 'shortcut' |
| 93 |
- 'standard' |
| 94 |
area: |
| 95 |
description: |
| 96 |
- OSPF area configuration. |
| 97 |
type: list |
| 98 |
elements: dict |
| 99 |
suboptions: |
| 100 |
authentication: |
| 101 |
description: |
| 102 |
- Authentication type. |
| 103 |
type: str |
| 104 |
choices: |
| 105 |
- 'none' |
| 106 |
- 'text' |
| 107 |
- 'message-digest' |
| 108 |
- 'md5' |
| 109 |
comments: |
| 110 |
description: |
| 111 |
- Comment. |
| 112 |
type: str |
| 113 |
default_cost: |
| 114 |
description: |
| 115 |
- Summary default cost of stub or NSSA area. |
| 116 |
type: int |
| 117 |
filter_list: |
| 118 |
description: |
| 119 |
- OSPF area filter-list configuration. |
| 120 |
type: list |
| 121 |
elements: dict |
| 122 |
suboptions: |
| 123 |
direction: |
| 124 |
description: |
| 125 |
- Direction. |
| 126 |
type: str |
| 127 |
choices: |
| 128 |
- 'in' |
| 129 |
- 'out' |
| 130 |
id: |
| 131 |
description: |
| 132 |
- Filter list entry ID. see <a href='#notes'>Notes</a>. |
| 133 |
required: true |
| 134 |
type: int |
| 135 |
list: |
| 136 |
description: |
| 137 |
- Access-list or prefix-list name. Source router.access-list.name router.prefix-list.name. |
| 138 |
type: str |
| 139 |
id: |
| 140 |
description: |
| 141 |
- Area entry IP address. |
| 142 |
required: true |
| 143 |
type: str |
| 144 |
nssa_default_information_originate: |
| 145 |
description: |
| 146 |
- Redistribute, advertise, or do not originate Type-7 default route into NSSA area. |
| 147 |
type: str |
| 148 |
choices: |
| 149 |
- 'enable' |
| 150 |
- 'always' |
| 151 |
- 'disable' |
| 152 |
nssa_default_information_originate_metric: |
| 153 |
description: |
| 154 |
- OSPF default metric. |
| 155 |
type: int |
| 156 |
nssa_default_information_originate_metric_type: |
| 157 |
description: |
| 158 |
- OSPF metric type for default routes. |
| 159 |
type: str |
| 160 |
choices: |
| 161 |
- '1' |
| 162 |
- '2' |
| 163 |
nssa_redistribution: |
| 164 |
description: |
| 165 |
- Enable/disable redistribute into NSSA area. |
| 166 |
type: str |
| 167 |
choices: |
| 168 |
- 'enable' |
| 169 |
- 'disable' |
| 170 |
nssa_translator_role: |
| 171 |
description: |
| 172 |
- NSSA translator role type. |
| 173 |
type: str |
| 174 |
choices: |
| 175 |
- 'candidate' |
| 176 |
- 'never' |
| 177 |
- 'always' |
| 178 |
range: |
| 179 |
description: |
| 180 |
- OSPF area range configuration. |
| 181 |
type: list |
| 182 |
elements: dict |
| 183 |
suboptions: |
| 184 |
advertise: |
| 185 |
description: |
| 186 |
- Enable/disable advertise status. |
| 187 |
type: str |
| 188 |
choices: |
| 189 |
- 'disable' |
| 190 |
- 'enable' |
| 191 |
id: |
| 192 |
description: |
| 193 |
- Range entry ID. see <a href='#notes'>Notes</a>. |
| 194 |
required: true |
| 195 |
type: int |
| 196 |
prefix: |
| 197 |
description: |
| 198 |
- Prefix. |
| 199 |
type: str |
| 200 |
substitute: |
| 201 |
description: |
| 202 |
- Substitute prefix. |
| 203 |
type: str |
| 204 |
substitute_status: |
| 205 |
description: |
| 206 |
- Enable/disable substitute status. |
| 207 |
type: str |
| 208 |
choices: |
| 209 |
- 'enable' |
| 210 |
- 'disable' |
| 211 |
shortcut: |
| 212 |
description: |
| 213 |
- Enable/disable shortcut option. |
| 214 |
type: str |
| 215 |
choices: |
| 216 |
- 'disable' |
| 217 |
- 'enable' |
| 218 |
- 'default' |
| 219 |
stub_type: |
| 220 |
description: |
| 221 |
- Stub summary setting. |
| 222 |
type: str |
| 223 |
choices: |
| 224 |
- 'no-summary' |
| 225 |
- 'summary' |
| 226 |
type: |
| 227 |
description: |
| 228 |
- Area type setting. |
| 229 |
type: str |
| 230 |
choices: |
| 231 |
- 'regular' |
| 232 |
- 'nssa' |
| 233 |
- 'stub' |
| 234 |
virtual_link: |
| 235 |
description: |
| 236 |
- OSPF virtual link configuration. |
| 237 |
type: list |
| 238 |
elements: dict |
| 239 |
suboptions: |
| 240 |
authentication: |
| 241 |
description: |
| 242 |
- Authentication type. |
| 243 |
type: str |
| 244 |
choices: |
| 245 |
- 'none' |
| 246 |
- 'text' |
| 247 |
- 'message-digest' |
| 248 |
- 'md5' |
| 249 |
authentication_key: |
| 250 |
description: |
| 251 |
- Authentication key. |
| 252 |
type: str |
| 253 |
dead_interval: |
| 254 |
description: |
| 255 |
- Dead interval. |
| 256 |
type: int |
| 257 |
hello_interval: |
| 258 |
description: |
| 259 |
- Hello interval. |
| 260 |
type: int |
| 261 |
keychain: |
| 262 |
description: |
| 263 |
- Message-digest key-chain name. Source router.key-chain.name. |
| 264 |
type: str |
| 265 |
md5_key: |
| 266 |
description: |
| 267 |
- MD5 key. |
| 268 |
type: str |
| 269 |
md5_keychain: |
| 270 |
description: |
| 271 |
- Authentication MD5 key-chain name. Source router.key-chain.name. |
| 272 |
type: str |
| 273 |
md5_keys: |
| 274 |
description: |
| 275 |
- MD5 key. |
| 276 |
type: list |
| 277 |
elements: dict |
| 278 |
suboptions: |
| 279 |
id: |
| 280 |
description: |
| 281 |
- Key ID (1 - 255). see <a href='#notes'>Notes</a>. |
| 282 |
required: true |
| 283 |
type: int |
| 284 |
key_string: |
| 285 |
description: |
| 286 |
- Password for the key. |
| 287 |
type: str |
| 288 |
name: |
| 289 |
description: |
| 290 |
- Virtual link entry name. |
| 291 |
required: true |
| 292 |
type: str |
| 293 |
peer: |
| 294 |
description: |
| 295 |
- Peer IP. |
| 296 |
type: str |
| 297 |
retransmit_interval: |
| 298 |
description: |
| 299 |
- Retransmit interval. |
| 300 |
type: int |
| 301 |
transmit_delay: |
| 302 |
description: |
| 303 |
- Transmit delay. |
| 304 |
type: int |
| 305 |
auto_cost_ref_bandwidth: |
| 306 |
description: |
| 307 |
- Reference bandwidth in terms of megabits per second. |
| 308 |
type: int |
| 309 |
bfd: |
| 310 |
description: |
| 311 |
- Bidirectional Forwarding Detection (BFD). |
| 312 |
type: str |
| 313 |
choices: |
| 314 |
- 'enable' |
| 315 |
- 'disable' |
| 316 |
database_overflow: |
| 317 |
description: |
| 318 |
- Enable/disable database overflow. |
| 319 |
type: str |
| 320 |
choices: |
| 321 |
- 'enable' |
| 322 |
- 'disable' |
| 323 |
database_overflow_max_lsas: |
| 324 |
description: |
| 325 |
- Database overflow maximum LSAs. |
| 326 |
type: int |
| 327 |
database_overflow_time_to_recover: |
| 328 |
description: |
| 329 |
- Database overflow time to recover (sec). |
| 330 |
type: int |
| 331 |
default_information_metric: |
| 332 |
description: |
| 333 |
- Default information metric. |
| 334 |
type: int |
| 335 |
default_information_metric_type: |
| 336 |
description: |
| 337 |
- Default information metric type. |
| 338 |
type: str |
| 339 |
choices: |
| 340 |
- '1' |
| 341 |
- '2' |
| 342 |
default_information_originate: |
| 343 |
description: |
| 344 |
- Enable/disable generation of default route. |
| 345 |
type: str |
| 346 |
choices: |
| 347 |
- 'enable' |
| 348 |
- 'always' |
| 349 |
- 'disable' |
| 350 |
default_information_route_map: |
| 351 |
description: |
| 352 |
- Default information route map. Source router.route-map.name. |
| 353 |
type: str |
| 354 |
default_metric: |
| 355 |
description: |
| 356 |
- Default metric of redistribute routes. |
| 357 |
type: int |
| 358 |
distance: |
| 359 |
description: |
| 360 |
- Distance of the route. |
| 361 |
type: int |
| 362 |
distance_external: |
| 363 |
description: |
| 364 |
- Administrative external distance. |
| 365 |
type: int |
| 366 |
distance_inter_area: |
| 367 |
description: |
| 368 |
- Administrative inter-area distance. |
| 369 |
type: int |
| 370 |
distance_intra_area: |
| 371 |
description: |
| 372 |
- Administrative intra-area distance. |
| 373 |
type: int |
| 374 |
distribute_list: |
| 375 |
description: |
| 376 |
- Distribute list configuration. |
| 377 |
type: list |
| 378 |
elements: dict |
| 379 |
suboptions: |
| 380 |
access_list: |
| 381 |
description: |
| 382 |
- Access list name. Source router.access-list.name. |
| 383 |
type: str |
| 384 |
id: |
| 385 |
description: |
| 386 |
- Distribute list entry ID. see <a href='#notes'>Notes</a>. |
| 387 |
required: true |
| 388 |
type: int |
| 389 |
protocol: |
| 390 |
description: |
| 391 |
- Protocol type. |
| 392 |
type: str |
| 393 |
choices: |
| 394 |
- 'connected' |
| 395 |
- 'static' |
| 396 |
- 'rip' |
| 397 |
distribute_list_in: |
| 398 |
description: |
| 399 |
- Filter incoming routes. Source router.access-list.name router.prefix-list.name. |
| 400 |
type: str |
| 401 |
distribute_route_map_in: |
| 402 |
description: |
| 403 |
- Filter incoming external routes by route-map. Source router.route-map.name. |
| 404 |
type: str |
| 405 |
log_neighbour_changes: |
| 406 |
description: |
| 407 |
- Log of OSPF neighbor changes. |
| 408 |
type: str |
| 409 |
choices: |
| 410 |
- 'enable' |
| 411 |
- 'disable' |
| 412 |
lsa_refresh_interval: |
| 413 |
description: |
| 414 |
- The minimal OSPF LSA update time interval |
| 415 |
type: int |
| 416 |
neighbor: |
| 417 |
description: |
| 418 |
- OSPF neighbor configuration are used when OSPF runs on non-broadcast media. |
| 419 |
type: list |
| 420 |
elements: dict |
| 421 |
suboptions: |
| 422 |
cost: |
| 423 |
description: |
| 424 |
- Cost of the interface, value range from 0 to 65535, 0 means auto-cost. |
| 425 |
type: int |
| 426 |
id: |
| 427 |
description: |
| 428 |
- Neighbor entry ID. see <a href='#notes'>Notes</a>. |
| 429 |
required: true |
| 430 |
type: int |
| 431 |
ip: |
| 432 |
description: |
| 433 |
- Interface IP address of the neighbor. |
| 434 |
type: str |
| 435 |
poll_interval: |
| 436 |
description: |
| 437 |
- Poll interval time in seconds. |
| 438 |
type: int |
| 439 |
priority: |
| 440 |
description: |
| 441 |
- Priority. |
| 442 |
type: int |
| 443 |
network: |
| 444 |
description: |
| 445 |
- OSPF network configuration. |
| 446 |
type: list |
| 447 |
elements: dict |
| 448 |
suboptions: |
| 449 |
area: |
| 450 |
description: |
| 451 |
- Attach the network to area. |
| 452 |
type: str |
| 453 |
comments: |
| 454 |
description: |
| 455 |
- Comment. |
| 456 |
type: str |
| 457 |
id: |
| 458 |
description: |
| 459 |
- Network entry ID. see <a href='#notes'>Notes</a>. |
| 460 |
required: true |
| 461 |
type: int |
| 462 |
prefix: |
| 463 |
description: |
| 464 |
- Prefix. |
| 465 |
type: str |
| 466 |
ospf_interface: |
| 467 |
description: |
| 468 |
- OSPF interface configuration. |
| 469 |
type: list |
| 470 |
elements: dict |
| 471 |
suboptions: |
| 472 |
authentication: |
| 473 |
description: |
| 474 |
- Authentication type. |
| 475 |
type: str |
| 476 |
choices: |
| 477 |
- 'none' |
| 478 |
- 'text' |
| 479 |
- 'message-digest' |
| 480 |
- 'md5' |
| 481 |
authentication_key: |
| 482 |
description: |
| 483 |
- Authentication key. |
| 484 |
type: str |
| 485 |
bfd: |
| 486 |
description: |
| 487 |
- Bidirectional Forwarding Detection (BFD). |
| 488 |
type: str |
| 489 |
choices: |
| 490 |
- 'global' |
| 491 |
- 'enable' |
| 492 |
- 'disable' |
| 493 |
comments: |
| 494 |
description: |
| 495 |
- Comment. |
| 496 |
type: str |
| 497 |
cost: |
| 498 |
description: |
| 499 |
- Cost of the interface, value range from 0 to 65535, 0 means auto-cost. |
| 500 |
type: int |
| 501 |
database_filter_out: |
| 502 |
description: |
| 503 |
- Enable/disable control of flooding out LSAs. |
| 504 |
type: str |
| 505 |
choices: |
| 506 |
- 'enable' |
| 507 |
- 'disable' |
| 508 |
dead_interval: |
| 509 |
description: |
| 510 |
- Dead interval. |
| 511 |
type: int |
| 512 |
hello_interval: |
| 513 |
description: |
| 514 |
- Hello interval. |
| 515 |
type: int |
| 516 |
hello_multiplier: |
| 517 |
description: |
| 518 |
- Number of hello packets within dead interval. |
| 519 |
type: int |
| 520 |
interface: |
| 521 |
description: |
| 522 |
- Configuration interface name. Source system.interface.name. |
| 523 |
type: str |
| 524 |
ip: |
| 525 |
description: |
| 526 |
- IP address. |
| 527 |
type: str |
| 528 |
keychain: |
| 529 |
description: |
| 530 |
- Message-digest key-chain name. Source router.key-chain.name. |
| 531 |
type: str |
| 532 |
linkdown_fast_failover: |
| 533 |
description: |
| 534 |
- Enable/disable fast link failover. |
| 535 |
type: str |
| 536 |
choices: |
| 537 |
- 'enable' |
| 538 |
- 'disable' |
| 539 |
md5_key: |
| 540 |
description: |
| 541 |
- MD5 key. |
| 542 |
type: str |
| 543 |
md5_keychain: |
| 544 |
description: |
| 545 |
- Authentication MD5 key-chain name. Source router.key-chain.name. |
| 546 |
type: str |
| 547 |
md5_keys: |
| 548 |
description: |
| 549 |
- MD5 key. |
| 550 |
type: list |
| 551 |
elements: dict |
| 552 |
suboptions: |
| 553 |
id: |
| 554 |
description: |
| 555 |
- Key ID (1 - 255). see <a href='#notes'>Notes</a>. |
| 556 |
required: true |
| 557 |
type: int |
| 558 |
key_string: |
| 559 |
description: |
| 560 |
- Password for the key. |
| 561 |
type: str |
| 562 |
mtu: |
| 563 |
description: |
| 564 |
- MTU for database description packets. |
| 565 |
type: int |
| 566 |
mtu_ignore: |
| 567 |
description: |
| 568 |
- Enable/disable ignore MTU. |
| 569 |
type: str |
| 570 |
choices: |
| 571 |
- 'enable' |
| 572 |
- 'disable' |
| 573 |
name: |
| 574 |
description: |
| 575 |
- Interface entry name. |
| 576 |
required: true |
| 577 |
type: str |
| 578 |
network_type: |
| 579 |
description: |
| 580 |
- Network type. |
| 581 |
type: str |
| 582 |
choices: |
| 583 |
- 'broadcast' |
| 584 |
- 'non-broadcast' |
| 585 |
- 'point-to-point' |
| 586 |
- 'point-to-multipoint' |
| 587 |
- 'point-to-multipoint-non-broadcast' |
| 588 |
prefix_length: |
| 589 |
description: |
| 590 |
- Prefix length. |
| 591 |
type: int |
| 592 |
priority: |
| 593 |
description: |
| 594 |
- Priority. |
| 595 |
type: int |
| 596 |
resync_timeout: |
| 597 |
description: |
| 598 |
- Graceful restart neighbor resynchronization timeout. |
| 599 |
type: int |
| 600 |
retransmit_interval: |
| 601 |
description: |
| 602 |
- Retransmit interval. |
| 603 |
type: int |
| 604 |
status: |
| 605 |
description: |
| 606 |
- Enable/disable status. |
| 607 |
type: str |
| 608 |
choices: |
| 609 |
- 'disable' |
| 610 |
- 'enable' |
| 611 |
transmit_delay: |
| 612 |
description: |
| 613 |
- Transmit delay. |
| 614 |
type: int |
| 615 |
passive_interface: |
| 616 |
description: |
| 617 |
- Passive interface configuration. |
| 618 |
type: list |
| 619 |
elements: dict |
| 620 |
suboptions: |
| 621 |
name: |
| 622 |
description: |
| 623 |
- Passive interface name. Source system.interface.name. |
| 624 |
required: true |
| 625 |
type: str |
| 626 |
redistribute: |
| 627 |
description: |
| 628 |
- Redistribute configuration. |
| 629 |
type: list |
| 630 |
elements: dict |
| 631 |
suboptions: |
| 632 |
metric: |
| 633 |
description: |
| 634 |
- Redistribute metric setting. |
| 635 |
type: int |
| 636 |
metric_type: |
| 637 |
description: |
| 638 |
- Metric type. |
| 639 |
type: str |
| 640 |
choices: |
| 641 |
- '1' |
| 642 |
- '2' |
| 643 |
name: |
| 644 |
description: |
| 645 |
- Redistribute name. |
| 646 |
required: true |
| 647 |
type: str |
| 648 |
routemap: |
| 649 |
description: |
| 650 |
- Route map name. Source router.route-map.name. |
| 651 |
type: str |
| 652 |
status: |
| 653 |
description: |
| 654 |
- Status. |
| 655 |
type: str |
| 656 |
choices: |
| 657 |
- 'enable' |
| 658 |
- 'disable' |
| 659 |
tag: |
| 660 |
description: |
| 661 |
- Tag value. |
| 662 |
type: int |
| 663 |
restart_mode: |
| 664 |
description: |
| 665 |
- OSPF restart mode (graceful or LLS). |
| 666 |
type: str |
| 667 |
choices: |
| 668 |
- 'none' |
| 669 |
- 'lls' |
| 670 |
- 'graceful-restart' |
| 671 |
restart_on_topology_change: |
| 672 |
description: |
| 673 |
- Enable/disable continuing graceful restart upon topology change. |
| 674 |
type: str |
| 675 |
choices: |
| 676 |
- 'enable' |
| 677 |
- 'disable' |
| 678 |
restart_period: |
| 679 |
description: |
| 680 |
- Graceful restart period. |
| 681 |
type: int |
| 682 |
rfc1583_compatible: |
| 683 |
description: |
| 684 |
- Enable/disable RFC1583 compatibility. |
| 685 |
type: str |
| 686 |
choices: |
| 687 |
- 'enable' |
| 688 |
- 'disable' |
| 689 |
router_id: |
| 690 |
description: |
| 691 |
- Router ID. |
| 692 |
type: str |
| 693 |
spf_timers: |
| 694 |
description: |
| 695 |
- SPF calculation frequency. |
| 696 |
type: str |
| 697 |
summary_address: |
| 698 |
description: |
| 699 |
- IP address summary configuration. |
| 700 |
type: list |
| 701 |
elements: dict |
| 702 |
suboptions: |
| 703 |
advertise: |
| 704 |
description: |
| 705 |
- Enable/disable advertise status. |
| 706 |
type: str |
| 707 |
choices: |
| 708 |
- 'disable' |
| 709 |
- 'enable' |
| 710 |
id: |
| 711 |
description: |
| 712 |
- Summary address entry ID. see <a href='#notes'>Notes</a>. |
| 713 |
required: true |
| 714 |
type: int |
| 715 |
prefix: |
| 716 |
description: |
| 717 |
- Prefix. |
| 718 |
type: str |
| 719 |
tag: |
| 720 |
description: |
| 721 |
- Tag value. |
| 722 |
type: int |
| 723 |
""" |
| 724 |
|
| 725 |
EXAMPLES = """ |
| 726 |
- name: Configure OSPF. |
| 727 |
fortinet.fortios.fortios_router_ospf: |
| 728 |
vdom: "{{ vdom }}" |
| 729 |
router_ospf: |
| 730 |
abr_type: "cisco" |
| 731 |
area: |
| 732 |
- |
| 733 |
authentication: "none" |
| 734 |
comments: "<your_own_value>" |
| 735 |
default_cost: "10" |
| 736 |
filter_list: |
| 737 |
- |
| 738 |
direction: "in" |
| 739 |
id: "10" |
| 740 |
list: "<your_own_value> (source router.access-list.name router.prefix-list.name)" |
| 741 |
id: "12" |
| 742 |
nssa_default_information_originate: "enable" |
| 743 |
nssa_default_information_originate_metric: "10" |
| 744 |
nssa_default_information_originate_metric_type: "1" |
| 745 |
nssa_redistribution: "enable" |
| 746 |
nssa_translator_role: "candidate" |
| 747 |
range: |
| 748 |
- |
| 749 |
advertise: "disable" |
| 750 |
id: "20" |
| 751 |
prefix: "<your_own_value>" |
| 752 |
substitute: "<your_own_value>" |
| 753 |
substitute_status: "enable" |
| 754 |
shortcut: "disable" |
| 755 |
stub_type: "no-summary" |
| 756 |
type: "regular" |
| 757 |
virtual_link: |
| 758 |
- |
| 759 |
authentication: "none" |
| 760 |
authentication_key: "<your_own_value>" |
| 761 |
dead_interval: "40" |
| 762 |
hello_interval: "10" |
| 763 |
keychain: "<your_own_value> (source router.key-chain.name)" |
| 764 |
md5_key: "<your_own_value>" |
| 765 |
md5_keychain: "<your_own_value> (source router.key-chain.name)" |
| 766 |
md5_keys: |
| 767 |
- |
| 768 |
id: "36" |
| 769 |
key_string: "<your_own_value>" |
| 770 |
name: "default_name_38" |
| 771 |
peer: "<your_own_value>" |
| 772 |
retransmit_interval: "5" |
| 773 |
transmit_delay: "1" |
| 774 |
auto_cost_ref_bandwidth: "1000" |
| 775 |
bfd: "enable" |
| 776 |
database_overflow: "enable" |
| 777 |
database_overflow_max_lsas: "10000" |
| 778 |
database_overflow_time_to_recover: "300" |
| 779 |
default_information_metric: "10" |
| 780 |
default_information_metric_type: "1" |
| 781 |
default_information_originate: "enable" |
| 782 |
default_information_route_map: "<your_own_value> (source router.route-map.name)" |
| 783 |
default_metric: "10" |
| 784 |
distance: "110" |
| 785 |
distance_external: "110" |
| 786 |
distance_inter_area: "110" |
| 787 |
distance_intra_area: "110" |
| 788 |
distribute_list: |
| 789 |
- |
| 790 |
access_list: "<your_own_value> (source router.access-list.name)" |
| 791 |
id: "58" |
| 792 |
protocol: "connected" |
| 793 |
distribute_list_in: "<your_own_value> (source router.access-list.name router.prefix-list.name)" |
| 794 |
distribute_route_map_in: "<your_own_value> (source router.route-map.name)" |
| 795 |
log_neighbour_changes: "enable" |
| 796 |
lsa_refresh_interval: "5" |
| 797 |
neighbor: |
| 798 |
- |
| 799 |
cost: "0" |
| 800 |
id: "66" |
| 801 |
ip: "<your_own_value>" |
| 802 |
poll_interval: "10" |
| 803 |
priority: "1" |
| 804 |
network: |
| 805 |
- |
| 806 |
area: "<your_own_value>" |
| 807 |
comments: "<your_own_value>" |
| 808 |
id: "73" |
| 809 |
prefix: "<your_own_value>" |
| 810 |
ospf_interface: |
| 811 |
- |
| 812 |
authentication: "none" |
| 813 |
authentication_key: "<your_own_value>" |
| 814 |
bfd: "global" |
| 815 |
comments: "<your_own_value>" |
| 816 |
cost: "0" |
| 817 |
database_filter_out: "enable" |
| 818 |
dead_interval: "0" |
| 819 |
hello_interval: "0" |
| 820 |
hello_multiplier: "0" |
| 821 |
interface: "<your_own_value> (source system.interface.name)" |
| 822 |
ip: "<your_own_value>" |
| 823 |
keychain: "<your_own_value> (source router.key-chain.name)" |
| 824 |
linkdown_fast_failover: "enable" |
| 825 |
md5_key: "<your_own_value>" |
| 826 |
md5_keychain: "<your_own_value> (source router.key-chain.name)" |
| 827 |
md5_keys: |
| 828 |
- |
| 829 |
id: "92" |
| 830 |
key_string: "<your_own_value>" |
| 831 |
mtu: "0" |
| 832 |
mtu_ignore: "enable" |
| 833 |
name: "default_name_96" |
| 834 |
network_type: "broadcast" |
| 835 |
prefix_length: "0" |
| 836 |
priority: "1" |
| 837 |
resync_timeout: "40" |
| 838 |
retransmit_interval: "5" |
| 839 |
status: "disable" |
| 840 |
transmit_delay: "1" |
| 841 |
passive_interface: |
| 842 |
- |
| 843 |
name: "default_name_105 (source system.interface.name)" |
| 844 |
redistribute: |
| 845 |
- |
| 846 |
metric: "0" |
| 847 |
metric_type: "1" |
| 848 |
name: "default_name_109" |
| 849 |
routemap: "<your_own_value> (source router.route-map.name)" |
| 850 |
status: "enable" |
| 851 |
tag: "0" |
| 852 |
restart_mode: "none" |
| 853 |
restart_on_topology_change: "enable" |
| 854 |
restart_period: "120" |
| 855 |
rfc1583_compatible: "enable" |
| 856 |
router_id: "<your_own_value>" |
| 857 |
spf_timers: "<your_own_value>" |
| 858 |
summary_address: |
| 859 |
- |
| 860 |
advertise: "disable" |
| 861 |
id: "121" |
| 862 |
prefix: "<your_own_value>" |
| 863 |
tag: "0" |
| 864 |
""" |
| 865 |
|
| 866 |
RETURN = """ |
| 867 |
build: |
| 868 |
description: Build number of the fortigate image |
| 869 |
returned: always |
| 870 |
type: str |
| 871 |
sample: '1547' |
| 872 |
http_method: |
| 873 |
description: Last method used to provision the content into FortiGate |
| 874 |
returned: always |
| 875 |
type: str |
| 876 |
sample: 'PUT' |
| 877 |
http_status: |
| 878 |
description: Last result given by FortiGate on last operation applied |
| 879 |
returned: always |
| 880 |
type: str |
| 881 |
sample: "200" |
| 882 |
mkey: |
| 883 |
description: Master key (id) used in the last call to FortiGate |
| 884 |
returned: success |
| 885 |
type: str |
| 886 |
sample: "id" |
| 887 |
name: |
| 888 |
description: Name of the table used to fulfill the request |
| 889 |
returned: always |
| 890 |
type: str |
| 891 |
sample: "urlfilter" |
| 892 |
path: |
| 893 |
description: Path of the table used to fulfill the request |
| 894 |
returned: always |
| 895 |
type: str |
| 896 |
sample: "webfilter" |
| 897 |
revision: |
| 898 |
description: Internal revision number |
| 899 |
returned: always |
| 900 |
type: str |
| 901 |
sample: "17.0.2.10658" |
| 902 |
serial: |
| 903 |
description: Serial number of the unit |
| 904 |
returned: always |
| 905 |
type: str |
| 906 |
sample: "FGVMEVYYQT3AB5352" |
| 907 |
status: |
| 908 |
description: Indication of the operation's result |
| 909 |
returned: always |
| 910 |
type: str |
| 911 |
sample: "success" |
| 912 |
vdom: |
| 913 |
description: Virtual domain used |
| 914 |
returned: always |
| 915 |
type: str |
| 916 |
sample: "root" |
| 917 |
version: |
| 918 |
description: Version of the FortiGate |
| 919 |
returned: always |
| 920 |
type: str |
| 921 |
sample: "v5.6.3" |
| 922 |
""" |
| 923 |
from ansible.module_utils.basic import AnsibleModule |
| 924 |
from ansible.module_utils.connection import Connection |
| 925 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 926 |
FortiOSHandler, |
| 927 |
) |
| 928 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 929 |
check_legacy_fortiosapi, |
| 930 |
) |
| 931 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 932 |
schema_to_module_spec, |
| 933 |
) |
| 934 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 935 |
check_schema_versioning, |
| 936 |
) |
| 937 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.common import ( |
| 938 |
FAIL_SOCKET_MSG, |
| 939 |
) |
| 940 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.data_post_processor import ( |
| 941 |
remove_invalid_fields, |
| 942 |
) |
| 943 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 944 |
is_same_comparison, |
| 945 |
) |
| 946 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 947 |
serialize, |
| 948 |
) |
| 949 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 950 |
find_current_values, |
| 951 |
) |
| 952 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 953 |
unify_data_format, |
| 954 |
) |
| 955 |
|
| 956 |
|
| 957 |
def filter_router_ospf_data(json): |
| 958 |
option_list = [ |
| 959 |
"abr_type", |
| 960 |
"area", |
| 961 |
"auto_cost_ref_bandwidth", |
| 962 |
"bfd", |
| 963 |
"database_overflow", |
| 964 |
"database_overflow_max_lsas", |
| 965 |
"database_overflow_time_to_recover", |
| 966 |
"default_information_metric", |
| 967 |
"default_information_metric_type", |
| 968 |
"default_information_originate", |
| 969 |
"default_information_route_map", |
| 970 |
"default_metric", |
| 971 |
"distance", |
| 972 |
"distance_external", |
| 973 |
"distance_inter_area", |
| 974 |
"distance_intra_area", |
| 975 |
"distribute_list", |
| 976 |
"distribute_list_in", |
| 977 |
"distribute_route_map_in", |
| 978 |
"log_neighbour_changes", |
| 979 |
"lsa_refresh_interval", |
| 980 |
"neighbor", |
| 981 |
"network", |
| 982 |
"ospf_interface", |
| 983 |
"passive_interface", |
| 984 |
"redistribute", |
| 985 |
"restart_mode", |
| 986 |
"restart_on_topology_change", |
| 987 |
"restart_period", |
| 988 |
"rfc1583_compatible", |
| 989 |
"router_id", |
| 990 |
"spf_timers", |
| 991 |
"summary_address", |
| 992 |
] |
| 993 |
|
| 994 |
json = remove_invalid_fields(json) |
| 995 |
dictionary = {} |
| 996 |
|
| 997 |
for attribute in option_list: |
| 998 |
if attribute in json and json[attribute] is not None: |
| 999 |
dictionary[attribute] = json[attribute] |
| 1000 |
|
| 1001 |
return dictionary |
| 1002 |
|
| 1003 |
|
| 1004 |
def underscore_to_hyphen(data): |
| 1005 |
new_data = None |
| 1006 |
if isinstance(data, list): |
| 1007 |
new_data = [] |
| 1008 |
for i, elem in enumerate(data): |
| 1009 |
new_data.append(underscore_to_hyphen(elem)) |
| 1010 |
elif isinstance(data, dict): |
| 1011 |
new_data = {} |
| 1012 |
for k, v in data.items(): |
| 1013 |
new_data[k.replace("_", "-")] = underscore_to_hyphen(v) |
| 1014 |
else: |
| 1015 |
return data |
| 1016 |
return new_data |
| 1017 |
|
| 1018 |
|
| 1019 |
def router_ospf(data, fos, check_mode=False): |
| 1020 |
|
| 1021 |
state = None |
| 1022 |
vdom = data["vdom"] |
| 1023 |
parameters = None |
| 1024 |
state = data.get("state", None) |
| 1025 |
router_ospf_data = data["router_ospf"] |
| 1026 |
|
| 1027 |
filtered_data = filter_router_ospf_data(router_ospf_data) |
| 1028 |
converted_data = underscore_to_hyphen(filtered_data) |
| 1029 |
|
| 1030 |
|
| 1031 |
if check_mode: |
| 1032 |
diff = { |
| 1033 |
"before": "", |
| 1034 |
"after": filtered_data, |
| 1035 |
} |
| 1036 |
mkeyname = fos.get_mkeyname(None, None) |
| 1037 |
mkey = fos.get_mkey("router", "ospf", filtered_data, vdom=vdom) |
| 1038 |
current_data = fos.get( |
| 1039 |
"router", "ospf", vdom=vdom, mkey=mkey, parameters=parameters |
| 1040 |
) |
| 1041 |
is_existed = ( |
| 1042 |
current_data |
| 1043 |
and current_data.get("http_status") == 200 |
| 1044 |
and ( |
| 1045 |
mkeyname |
| 1046 |
and isinstance(current_data.get("results"), list) |
| 1047 |
and len(current_data["results"]) > 0 |
| 1048 |
or not mkeyname |
| 1049 |
and current_data["results"] |
| 1050 |
) |
| 1051 |
) |
| 1052 |
|
| 1053 |
|
| 1054 |
if state == "present" or state is True or state is None: |
| 1055 |
|
| 1056 |
if mkeyname is not None and mkey is None: |
| 1057 |
return False, True, filtered_data, diff |
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
copied_filtered_data = filtered_data.copy() |
| 1062 |
copied_filtered_data.pop(mkeyname, None) |
| 1063 |
unified_filtered_data = unify_data_format(copied_filtered_data) |
| 1064 |
|
| 1065 |
current_data_results = current_data.get("results", {}) |
| 1066 |
current_config = ( |
| 1067 |
current_data_results[0] |
| 1068 |
if mkeyname |
| 1069 |
and isinstance(current_data_results, list) |
| 1070 |
and len(current_data_results) > 0 |
| 1071 |
else current_data_results |
| 1072 |
) |
| 1073 |
if is_existed: |
| 1074 |
unified_current_values = find_current_values( |
| 1075 |
unified_filtered_data, |
| 1076 |
unify_data_format(current_config), |
| 1077 |
) |
| 1078 |
|
| 1079 |
is_same = is_same_comparison( |
| 1080 |
serialize(unified_current_values), serialize(unified_filtered_data) |
| 1081 |
) |
| 1082 |
|
| 1083 |
return ( |
| 1084 |
False, |
| 1085 |
not is_same, |
| 1086 |
filtered_data, |
| 1087 |
{"before": unified_current_values, "after": unified_filtered_data}, |
| 1088 |
) |
| 1089 |
|
| 1090 |
|
| 1091 |
return False, True, filtered_data, diff |
| 1092 |
|
| 1093 |
if state == "absent": |
| 1094 |
if mkey is None: |
| 1095 |
return ( |
| 1096 |
False, |
| 1097 |
False, |
| 1098 |
filtered_data, |
| 1099 |
{"before": current_data["results"][0], "after": ""}, |
| 1100 |
) |
| 1101 |
|
| 1102 |
if is_existed: |
| 1103 |
return ( |
| 1104 |
False, |
| 1105 |
True, |
| 1106 |
filtered_data, |
| 1107 |
{"before": current_data["results"][0], "after": ""}, |
| 1108 |
) |
| 1109 |
return False, False, filtered_data, {} |
| 1110 |
|
| 1111 |
return True, False, {"reason: ": "Must provide state parameter"}, {} |
| 1112 |
|
| 1113 |
|
| 1114 |
data_copy = data.copy() |
| 1115 |
data_copy["router_ospf"] = filtered_data |
| 1116 |
fos.do_member_operation( |
| 1117 |
"router", |
| 1118 |
"ospf", |
| 1119 |
data_copy, |
| 1120 |
) |
| 1121 |
|
| 1122 |
return fos.set( |
| 1123 |
"router", "ospf", data=converted_data, vdom=vdom, parameters=parameters |
| 1124 |
) |
| 1125 |
|
| 1126 |
|
| 1127 |
def is_successful_status(resp): |
| 1128 |
return ( |
| 1129 |
"status" in resp |
| 1130 |
and resp["status"] == "success" |
| 1131 |
or "http_status" in resp |
| 1132 |
and resp["http_status"] == 200 |
| 1133 |
or "http_method" in resp |
| 1134 |
and resp["http_method"] == "DELETE" |
| 1135 |
and resp["http_status"] == 404 |
| 1136 |
) |
| 1137 |
|
| 1138 |
|
| 1139 |
def fortios_router(data, fos, check_mode): |
| 1140 |
|
| 1141 |
if data["router_ospf"]: |
| 1142 |
resp = router_ospf(data, fos, check_mode) |
| 1143 |
else: |
| 1144 |
fos._module.fail_json(msg="missing task body: %s" % ("router_ospf")) |
| 1145 |
if isinstance(resp, tuple) and len(resp) == 4: |
| 1146 |
return resp |
| 1147 |
return ( |
| 1148 |
not is_successful_status(resp), |
| 1149 |
is_successful_status(resp) |
| 1150 |
and (resp["revision_changed"] if "revision_changed" in resp else True), |
| 1151 |
resp, |
| 1152 |
{}, |
| 1153 |
) |
| 1154 |
|
| 1155 |
|
| 1156 |
versioned_schema = { |
| 1157 |
"v_range": [["v6.0.0", ""]], |
| 1158 |
"type": "dict", |
| 1159 |
"children": { |
| 1160 |
"abr_type": { |
| 1161 |
"v_range": [["v6.0.0", ""]], |
| 1162 |
"type": "string", |
| 1163 |
"options": [ |
| 1164 |
{"value": "cisco"}, |
| 1165 |
{"value": "ibm"}, |
| 1166 |
{"value": "shortcut"}, |
| 1167 |
{"value": "standard"}, |
| 1168 |
], |
| 1169 |
}, |
| 1170 |
"auto_cost_ref_bandwidth": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1171 |
"distance_external": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1172 |
"distance_inter_area": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1173 |
"distance_intra_area": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1174 |
"database_overflow": { |
| 1175 |
"v_range": [["v6.0.0", ""]], |
| 1176 |
"type": "string", |
| 1177 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1178 |
}, |
| 1179 |
"database_overflow_max_lsas": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1180 |
"database_overflow_time_to_recover": { |
| 1181 |
"v_range": [["v6.0.0", ""]], |
| 1182 |
"type": "integer", |
| 1183 |
}, |
| 1184 |
"default_information_originate": { |
| 1185 |
"v_range": [["v6.0.0", ""]], |
| 1186 |
"type": "string", |
| 1187 |
"options": [{"value": "enable"}, {"value": "always"}, {"value": "disable"}], |
| 1188 |
}, |
| 1189 |
"default_information_metric": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1190 |
"default_information_metric_type": { |
| 1191 |
"v_range": [["v6.0.0", ""]], |
| 1192 |
"type": "string", |
| 1193 |
"options": [{"value": "1"}, {"value": "2"}], |
| 1194 |
}, |
| 1195 |
"default_information_route_map": { |
| 1196 |
"v_range": [["v6.0.0", ""]], |
| 1197 |
"type": "string", |
| 1198 |
}, |
| 1199 |
"default_metric": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1200 |
"distance": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1201 |
"lsa_refresh_interval": {"v_range": [["v7.6.0", ""]], "type": "integer"}, |
| 1202 |
"rfc1583_compatible": { |
| 1203 |
"v_range": [["v6.0.0", ""]], |
| 1204 |
"type": "string", |
| 1205 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1206 |
}, |
| 1207 |
"router_id": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1208 |
"spf_timers": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1209 |
"bfd": { |
| 1210 |
"v_range": [["v6.0.0", ""]], |
| 1211 |
"type": "string", |
| 1212 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1213 |
}, |
| 1214 |
"log_neighbour_changes": { |
| 1215 |
"v_range": [["v6.0.0", ""]], |
| 1216 |
"type": "string", |
| 1217 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1218 |
}, |
| 1219 |
"distribute_list_in": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1220 |
"distribute_route_map_in": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1221 |
"restart_mode": { |
| 1222 |
"v_range": [["v6.0.0", ""]], |
| 1223 |
"type": "string", |
| 1224 |
"options": [ |
| 1225 |
{"value": "none"}, |
| 1226 |
{"value": "lls"}, |
| 1227 |
{"value": "graceful-restart"}, |
| 1228 |
], |
| 1229 |
}, |
| 1230 |
"restart_period": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1231 |
"restart_on_topology_change": { |
| 1232 |
"v_range": [["v7.2.0", ""]], |
| 1233 |
"type": "string", |
| 1234 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1235 |
}, |
| 1236 |
"area": { |
| 1237 |
"type": "list", |
| 1238 |
"elements": "dict", |
| 1239 |
"children": { |
| 1240 |
"id": {"v_range": [["v6.0.0", ""]], "type": "string", "required": True}, |
| 1241 |
"shortcut": { |
| 1242 |
"v_range": [["v6.0.0", ""]], |
| 1243 |
"type": "string", |
| 1244 |
"options": [ |
| 1245 |
{"value": "disable"}, |
| 1246 |
{"value": "enable"}, |
| 1247 |
{"value": "default"}, |
| 1248 |
], |
| 1249 |
}, |
| 1250 |
"authentication": { |
| 1251 |
"v_range": [["v6.0.0", ""]], |
| 1252 |
"type": "string", |
| 1253 |
"options": [ |
| 1254 |
{"value": "none"}, |
| 1255 |
{"value": "text"}, |
| 1256 |
{"value": "message-digest", "v_range": [["v7.0.1", ""]]}, |
| 1257 |
{"value": "md5", "v_range": [["v6.0.0", "v7.0.0"]]}, |
| 1258 |
], |
| 1259 |
}, |
| 1260 |
"default_cost": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1261 |
"nssa_translator_role": { |
| 1262 |
"v_range": [["v6.0.0", ""]], |
| 1263 |
"type": "string", |
| 1264 |
"options": [ |
| 1265 |
{"value": "candidate"}, |
| 1266 |
{"value": "never"}, |
| 1267 |
{"value": "always"}, |
| 1268 |
], |
| 1269 |
}, |
| 1270 |
"stub_type": { |
| 1271 |
"v_range": [["v6.0.0", ""]], |
| 1272 |
"type": "string", |
| 1273 |
"options": [{"value": "no-summary"}, {"value": "summary"}], |
| 1274 |
}, |
| 1275 |
"type": { |
| 1276 |
"v_range": [["v6.0.0", ""]], |
| 1277 |
"type": "string", |
| 1278 |
"options": [ |
| 1279 |
{"value": "regular"}, |
| 1280 |
{"value": "nssa"}, |
| 1281 |
{"value": "stub"}, |
| 1282 |
], |
| 1283 |
}, |
| 1284 |
"nssa_default_information_originate": { |
| 1285 |
"v_range": [["v6.0.0", ""]], |
| 1286 |
"type": "string", |
| 1287 |
"options": [ |
| 1288 |
{"value": "enable"}, |
| 1289 |
{"value": "always"}, |
| 1290 |
{"value": "disable"}, |
| 1291 |
], |
| 1292 |
}, |
| 1293 |
"nssa_default_information_originate_metric": { |
| 1294 |
"v_range": [["v6.0.0", ""]], |
| 1295 |
"type": "integer", |
| 1296 |
}, |
| 1297 |
"nssa_default_information_originate_metric_type": { |
| 1298 |
"v_range": [["v6.0.0", ""]], |
| 1299 |
"type": "string", |
| 1300 |
"options": [{"value": "1"}, {"value": "2"}], |
| 1301 |
}, |
| 1302 |
"nssa_redistribution": { |
| 1303 |
"v_range": [["v6.0.0", ""]], |
| 1304 |
"type": "string", |
| 1305 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1306 |
}, |
| 1307 |
"comments": {"v_range": [["v7.0.0", ""]], "type": "string"}, |
| 1308 |
"range": { |
| 1309 |
"type": "list", |
| 1310 |
"elements": "dict", |
| 1311 |
"children": { |
| 1312 |
"id": { |
| 1313 |
"v_range": [["v6.0.0", ""]], |
| 1314 |
"type": "integer", |
| 1315 |
"required": True, |
| 1316 |
}, |
| 1317 |
"prefix": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1318 |
"advertise": { |
| 1319 |
"v_range": [["v6.0.0", ""]], |
| 1320 |
"type": "string", |
| 1321 |
"options": [{"value": "disable"}, {"value": "enable"}], |
| 1322 |
}, |
| 1323 |
"substitute": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1324 |
"substitute_status": { |
| 1325 |
"v_range": [["v6.0.0", ""]], |
| 1326 |
"type": "string", |
| 1327 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1328 |
}, |
| 1329 |
}, |
| 1330 |
"v_range": [["v6.0.0", ""]], |
| 1331 |
}, |
| 1332 |
"virtual_link": { |
| 1333 |
"type": "list", |
| 1334 |
"elements": "dict", |
| 1335 |
"children": { |
| 1336 |
"name": { |
| 1337 |
"v_range": [["v6.0.0", ""]], |
| 1338 |
"type": "string", |
| 1339 |
"required": True, |
| 1340 |
}, |
| 1341 |
"authentication": { |
| 1342 |
"v_range": [["v6.0.0", ""]], |
| 1343 |
"type": "string", |
| 1344 |
"options": [ |
| 1345 |
{"value": "none"}, |
| 1346 |
{"value": "text"}, |
| 1347 |
{ |
| 1348 |
"value": "message-digest", |
| 1349 |
"v_range": [["v7.0.1", ""]], |
| 1350 |
}, |
| 1351 |
{"value": "md5", "v_range": [["v6.0.0", "v7.0.0"]]}, |
| 1352 |
], |
| 1353 |
}, |
| 1354 |
"authentication_key": { |
| 1355 |
"v_range": [["v6.0.0", ""]], |
| 1356 |
"type": "string", |
| 1357 |
}, |
| 1358 |
"keychain": {"v_range": [["v7.0.1", ""]], "type": "string"}, |
| 1359 |
"dead_interval": { |
| 1360 |
"v_range": [["v6.0.0", ""]], |
| 1361 |
"type": "integer", |
| 1362 |
}, |
| 1363 |
"hello_interval": { |
| 1364 |
"v_range": [["v6.0.0", ""]], |
| 1365 |
"type": "integer", |
| 1366 |
}, |
| 1367 |
"retransmit_interval": { |
| 1368 |
"v_range": [["v6.0.0", ""]], |
| 1369 |
"type": "integer", |
| 1370 |
}, |
| 1371 |
"transmit_delay": { |
| 1372 |
"v_range": [["v6.0.0", ""]], |
| 1373 |
"type": "integer", |
| 1374 |
}, |
| 1375 |
"peer": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1376 |
"md5_keys": { |
| 1377 |
"type": "list", |
| 1378 |
"elements": "dict", |
| 1379 |
"children": { |
| 1380 |
"id": { |
| 1381 |
"v_range": [["v6.2.0", ""]], |
| 1382 |
"type": "integer", |
| 1383 |
"required": True, |
| 1384 |
}, |
| 1385 |
"key_string": { |
| 1386 |
"v_range": [["v6.2.0", ""]], |
| 1387 |
"type": "string", |
| 1388 |
}, |
| 1389 |
}, |
| 1390 |
"v_range": [["v6.2.0", ""]], |
| 1391 |
}, |
| 1392 |
"md5_keychain": { |
| 1393 |
"v_range": [["v6.2.0", "v7.0.0"]], |
| 1394 |
"type": "string", |
| 1395 |
}, |
| 1396 |
"md5_key": { |
| 1397 |
"v_range": [["v6.0.0", "v6.0.11"]], |
| 1398 |
"type": "string", |
| 1399 |
}, |
| 1400 |
}, |
| 1401 |
"v_range": [["v6.0.0", ""]], |
| 1402 |
}, |
| 1403 |
"filter_list": { |
| 1404 |
"type": "list", |
| 1405 |
"elements": "dict", |
| 1406 |
"children": { |
| 1407 |
"id": { |
| 1408 |
"v_range": [["v6.0.0", ""]], |
| 1409 |
"type": "integer", |
| 1410 |
"required": True, |
| 1411 |
}, |
| 1412 |
"list": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1413 |
"direction": { |
| 1414 |
"v_range": [["v6.0.0", ""]], |
| 1415 |
"type": "string", |
| 1416 |
"options": [{"value": "in"}, {"value": "out"}], |
| 1417 |
}, |
| 1418 |
}, |
| 1419 |
"v_range": [["v6.0.0", ""]], |
| 1420 |
}, |
| 1421 |
}, |
| 1422 |
"v_range": [["v6.0.0", ""]], |
| 1423 |
}, |
| 1424 |
"ospf_interface": { |
| 1425 |
"type": "list", |
| 1426 |
"elements": "dict", |
| 1427 |
"children": { |
| 1428 |
"name": { |
| 1429 |
"v_range": [["v6.0.0", ""]], |
| 1430 |
"type": "string", |
| 1431 |
"required": True, |
| 1432 |
}, |
| 1433 |
"comments": {"v_range": [["v7.0.0", ""]], "type": "string"}, |
| 1434 |
"interface": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1435 |
"ip": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1436 |
"linkdown_fast_failover": { |
| 1437 |
"v_range": [["v7.6.0", ""]], |
| 1438 |
"type": "string", |
| 1439 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1440 |
}, |
| 1441 |
"authentication": { |
| 1442 |
"v_range": [["v6.0.0", ""]], |
| 1443 |
"type": "string", |
| 1444 |
"options": [ |
| 1445 |
{"value": "none"}, |
| 1446 |
{"value": "text"}, |
| 1447 |
{"value": "message-digest", "v_range": [["v7.0.1", ""]]}, |
| 1448 |
{"value": "md5", "v_range": [["v6.0.0", "v7.0.0"]]}, |
| 1449 |
], |
| 1450 |
}, |
| 1451 |
"authentication_key": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1452 |
"keychain": {"v_range": [["v7.0.1", ""]], "type": "string"}, |
| 1453 |
"prefix_length": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1454 |
"retransmit_interval": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1455 |
"transmit_delay": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1456 |
"cost": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1457 |
"priority": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1458 |
"dead_interval": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1459 |
"hello_interval": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1460 |
"hello_multiplier": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1461 |
"database_filter_out": { |
| 1462 |
"v_range": [["v6.0.0", ""]], |
| 1463 |
"type": "string", |
| 1464 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1465 |
}, |
| 1466 |
"mtu": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1467 |
"mtu_ignore": { |
| 1468 |
"v_range": [["v6.0.0", ""]], |
| 1469 |
"type": "string", |
| 1470 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1471 |
}, |
| 1472 |
"network_type": { |
| 1473 |
"v_range": [["v6.0.0", ""]], |
| 1474 |
"type": "string", |
| 1475 |
"options": [ |
| 1476 |
{"value": "broadcast"}, |
| 1477 |
{"value": "non-broadcast"}, |
| 1478 |
{"value": "point-to-point"}, |
| 1479 |
{"value": "point-to-multipoint"}, |
| 1480 |
{"value": "point-to-multipoint-non-broadcast"}, |
| 1481 |
], |
| 1482 |
}, |
| 1483 |
"bfd": { |
| 1484 |
"v_range": [["v6.0.0", ""]], |
| 1485 |
"type": "string", |
| 1486 |
"options": [ |
| 1487 |
{"value": "global"}, |
| 1488 |
{"value": "enable"}, |
| 1489 |
{"value": "disable"}, |
| 1490 |
], |
| 1491 |
}, |
| 1492 |
"status": { |
| 1493 |
"v_range": [["v6.0.0", ""]], |
| 1494 |
"type": "string", |
| 1495 |
"options": [{"value": "disable"}, {"value": "enable"}], |
| 1496 |
}, |
| 1497 |
"resync_timeout": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1498 |
"md5_keys": { |
| 1499 |
"type": "list", |
| 1500 |
"elements": "dict", |
| 1501 |
"children": { |
| 1502 |
"id": { |
| 1503 |
"v_range": [["v6.2.0", ""]], |
| 1504 |
"type": "integer", |
| 1505 |
"required": True, |
| 1506 |
}, |
| 1507 |
"key_string": {"v_range": [["v6.2.0", ""]], "type": "string"}, |
| 1508 |
}, |
| 1509 |
"v_range": [["v6.2.0", ""]], |
| 1510 |
}, |
| 1511 |
"md5_keychain": {"v_range": [["v6.2.0", "v7.0.0"]], "type": "string"}, |
| 1512 |
"md5_key": {"v_range": [["v6.0.0", "v6.0.11"]], "type": "string"}, |
| 1513 |
}, |
| 1514 |
"v_range": [["v6.0.0", ""]], |
| 1515 |
}, |
| 1516 |
"network": { |
| 1517 |
"type": "list", |
| 1518 |
"elements": "dict", |
| 1519 |
"children": { |
| 1520 |
"id": { |
| 1521 |
"v_range": [["v6.0.0", ""]], |
| 1522 |
"type": "integer", |
| 1523 |
"required": True, |
| 1524 |
}, |
| 1525 |
"prefix": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1526 |
"area": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1527 |
"comments": {"v_range": [["v7.0.0", ""]], "type": "string"}, |
| 1528 |
}, |
| 1529 |
"v_range": [["v6.0.0", ""]], |
| 1530 |
}, |
| 1531 |
"neighbor": { |
| 1532 |
"type": "list", |
| 1533 |
"elements": "dict", |
| 1534 |
"children": { |
| 1535 |
"id": { |
| 1536 |
"v_range": [["v6.0.0", ""]], |
| 1537 |
"type": "integer", |
| 1538 |
"required": True, |
| 1539 |
}, |
| 1540 |
"ip": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1541 |
"poll_interval": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1542 |
"cost": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1543 |
"priority": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1544 |
}, |
| 1545 |
"v_range": [["v6.0.0", ""]], |
| 1546 |
}, |
| 1547 |
"passive_interface": { |
| 1548 |
"type": "list", |
| 1549 |
"elements": "dict", |
| 1550 |
"children": { |
| 1551 |
"name": { |
| 1552 |
"v_range": [["v6.0.0", ""]], |
| 1553 |
"type": "string", |
| 1554 |
"required": True, |
| 1555 |
} |
| 1556 |
}, |
| 1557 |
"v_range": [["v6.0.0", ""]], |
| 1558 |
}, |
| 1559 |
"summary_address": { |
| 1560 |
"type": "list", |
| 1561 |
"elements": "dict", |
| 1562 |
"children": { |
| 1563 |
"id": { |
| 1564 |
"v_range": [["v6.0.0", ""]], |
| 1565 |
"type": "integer", |
| 1566 |
"required": True, |
| 1567 |
}, |
| 1568 |
"prefix": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1569 |
"tag": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1570 |
"advertise": { |
| 1571 |
"v_range": [["v6.0.0", ""]], |
| 1572 |
"type": "string", |
| 1573 |
"options": [{"value": "disable"}, {"value": "enable"}], |
| 1574 |
}, |
| 1575 |
}, |
| 1576 |
"v_range": [["v6.0.0", ""]], |
| 1577 |
}, |
| 1578 |
"distribute_list": { |
| 1579 |
"type": "list", |
| 1580 |
"elements": "dict", |
| 1581 |
"children": { |
| 1582 |
"id": { |
| 1583 |
"v_range": [["v6.0.0", ""]], |
| 1584 |
"type": "integer", |
| 1585 |
"required": True, |
| 1586 |
}, |
| 1587 |
"access_list": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1588 |
"protocol": { |
| 1589 |
"v_range": [["v6.0.0", ""]], |
| 1590 |
"type": "string", |
| 1591 |
"options": [ |
| 1592 |
{"value": "connected"}, |
| 1593 |
{"value": "static"}, |
| 1594 |
{"value": "rip"}, |
| 1595 |
], |
| 1596 |
}, |
| 1597 |
}, |
| 1598 |
"v_range": [["v6.0.0", ""]], |
| 1599 |
}, |
| 1600 |
"redistribute": { |
| 1601 |
"type": "list", |
| 1602 |
"elements": "dict", |
| 1603 |
"children": { |
| 1604 |
"name": { |
| 1605 |
"v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]], |
| 1606 |
"type": "string", |
| 1607 |
"required": True, |
| 1608 |
}, |
| 1609 |
"status": { |
| 1610 |
"v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]], |
| 1611 |
"type": "string", |
| 1612 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1613 |
}, |
| 1614 |
"metric": { |
| 1615 |
"v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]], |
| 1616 |
"type": "integer", |
| 1617 |
}, |
| 1618 |
"routemap": { |
| 1619 |
"v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]], |
| 1620 |
"type": "string", |
| 1621 |
}, |
| 1622 |
"metric_type": { |
| 1623 |
"v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]], |
| 1624 |
"type": "string", |
| 1625 |
"options": [{"value": "1"}, {"value": "2"}], |
| 1626 |
}, |
| 1627 |
"tag": { |
| 1628 |
"v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]], |
| 1629 |
"type": "integer", |
| 1630 |
}, |
| 1631 |
}, |
| 1632 |
"v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]], |
| 1633 |
}, |
| 1634 |
}, |
| 1635 |
} |
| 1636 |
|
| 1637 |
|
| 1638 |
def main(): |
| 1639 |
module_spec = schema_to_module_spec(versioned_schema) |
| 1640 |
mkeyname = None |
| 1641 |
fields = { |
| 1642 |
"access_token": {"required": False, "type": "str", "no_log": True}, |
| 1643 |
"enable_log": {"required": False, "type": "bool", "default": False}, |
| 1644 |
"vdom": {"required": False, "type": "str", "default": "root"}, |
| 1645 |
"member_path": {"required": False, "type": "str"}, |
| 1646 |
"member_state": { |
| 1647 |
"type": "str", |
| 1648 |
"required": False, |
| 1649 |
"choices": ["present", "absent"], |
| 1650 |
}, |
| 1651 |
"router_ospf": { |
| 1652 |
"required": False, |
| 1653 |
"type": "dict", |
| 1654 |
"default": None, |
| 1655 |
"options": {}, |
| 1656 |
}, |
| 1657 |
} |
| 1658 |
for attribute_name in module_spec["options"]: |
| 1659 |
fields["router_ospf"]["options"][attribute_name] = module_spec["options"][ |
| 1660 |
attribute_name |
| 1661 |
] |
| 1662 |
if mkeyname and mkeyname == attribute_name: |
| 1663 |
fields["router_ospf"]["options"][attribute_name]["required"] = True |
| 1664 |
|
| 1665 |
module = AnsibleModule(argument_spec=fields, supports_check_mode=True) |
| 1666 |
check_legacy_fortiosapi(module) |
| 1667 |
|
| 1668 |
is_error = False |
| 1669 |
has_changed = False |
| 1670 |
result = None |
| 1671 |
diff = None |
| 1672 |
|
| 1673 |
versions_check_result = None |
| 1674 |
if module._socket_path: |
| 1675 |
connection = Connection(module._socket_path) |
| 1676 |
if "access_token" in module.params: |
| 1677 |
connection.set_custom_option("access_token", module.params["access_token"]) |
| 1678 |
|
| 1679 |
if "enable_log" in module.params: |
| 1680 |
connection.set_custom_option("enable_log", module.params["enable_log"]) |
| 1681 |
else: |
| 1682 |
connection.set_custom_option("enable_log", False) |
| 1683 |
fos = FortiOSHandler(connection, module, mkeyname, admin_passwd_header=False) |
| 1684 |
versions_check_result = check_schema_versioning( |
| 1685 |
fos, versioned_schema, "router_ospf" |
| 1686 |
) |
| 1687 |
|
| 1688 |
is_error, has_changed, result, diff = fortios_router( |
| 1689 |
module.params, fos, module.check_mode |
| 1690 |
) |
| 1691 |
|
| 1692 |
else: |
| 1693 |
module.fail_json(**FAIL_SOCKET_MSG) |
| 1694 |
|
| 1695 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1696 |
module.warn( |
| 1697 |
"Ansible has detected version mismatch between FortOS system and your playbook, see more details by specifying option -vvv" |
| 1698 |
) |
| 1699 |
|
| 1700 |
if not is_error: |
| 1701 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1702 |
module.exit_json( |
| 1703 |
changed=has_changed, |
| 1704 |
version_check_warning=versions_check_result, |
| 1705 |
meta=result, |
| 1706 |
diff=diff, |
| 1707 |
) |
| 1708 |
else: |
| 1709 |
module.exit_json(changed=has_changed, meta=result, diff=diff) |
| 1710 |
else: |
| 1711 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1712 |
module.fail_json( |
| 1713 |
msg="Error in repo", |
| 1714 |
version_check_warning=versions_check_result, |
| 1715 |
meta=result, |
| 1716 |
) |
| 1717 |
else: |
| 1718 |
module.fail_json(msg="Error in repo", meta=result) |
| 1719 |
|
| 1720 |
|
| 1721 |
if __name__ == "__main__": |
| 1722 |
main() |