| 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_system_ha |
| 23 |
short_description: Configure HA 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 system feature and ha 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 |
system_ha: |
| 80 |
description: |
| 81 |
- Configure HA. |
| 82 |
default: null |
| 83 |
type: dict |
| 84 |
suboptions: |
| 85 |
arps: |
| 86 |
description: |
| 87 |
- Number of gratuitous ARPs (1 - 60). Lower to reduce traffic. Higher to reduce failover time. |
| 88 |
type: int |
| 89 |
arps_interval: |
| 90 |
description: |
| 91 |
- Time between gratuitous ARPs (1 - 20 sec). Lower to reduce failover time. Higher to reduce traffic. |
| 92 |
type: int |
| 93 |
authentication: |
| 94 |
description: |
| 95 |
- Enable/disable heartbeat message authentication. |
| 96 |
type: str |
| 97 |
choices: |
| 98 |
- 'enable' |
| 99 |
- 'disable' |
| 100 |
auto_virtual_mac_interface: |
| 101 |
description: |
| 102 |
- The physical interface that will be assigned an auto-generated virtual MAC address. |
| 103 |
type: list |
| 104 |
elements: dict |
| 105 |
suboptions: |
| 106 |
interface_name: |
| 107 |
description: |
| 108 |
- Interface name. Source system.interface.name. |
| 109 |
required: true |
| 110 |
type: str |
| 111 |
backup_hbdev: |
| 112 |
description: |
| 113 |
- Backup heartbeat interfaces. Must be the same for all members. |
| 114 |
type: list |
| 115 |
elements: dict |
| 116 |
suboptions: |
| 117 |
name: |
| 118 |
description: |
| 119 |
- Interface name. Source system.interface.name. |
| 120 |
required: true |
| 121 |
type: str |
| 122 |
bounce_intf_upon_failover: |
| 123 |
description: |
| 124 |
- Enable/disable notification of kernel to bring down and up all monitored interfaces. The setting is used during failovers if gratuitous |
| 125 |
ARPs do not update the network. |
| 126 |
type: str |
| 127 |
choices: |
| 128 |
- 'enable' |
| 129 |
- 'disable' |
| 130 |
check_secondary_dev_health: |
| 131 |
description: |
| 132 |
- Enable/disable secondary dev health check for session load-balance in HA A-A mode. |
| 133 |
type: str |
| 134 |
choices: |
| 135 |
- 'enable' |
| 136 |
- 'disable' |
| 137 |
cpu_threshold: |
| 138 |
description: |
| 139 |
- Dynamic weighted load balancing CPU usage weight and high and low thresholds. |
| 140 |
type: str |
| 141 |
encryption: |
| 142 |
description: |
| 143 |
- Enable/disable heartbeat message encryption. |
| 144 |
type: str |
| 145 |
choices: |
| 146 |
- 'enable' |
| 147 |
- 'disable' |
| 148 |
evpn_ttl: |
| 149 |
description: |
| 150 |
- HA EVPN FDB TTL on primary box (5 - 3600 sec). |
| 151 |
type: int |
| 152 |
failover_hold_time: |
| 153 |
description: |
| 154 |
- Time to wait before failover (0 - 300 sec), to avoid flip. |
| 155 |
type: int |
| 156 |
ftp_proxy_threshold: |
| 157 |
description: |
| 158 |
- Dynamic weighted load balancing weight and high and low number of FTP proxy sessions. |
| 159 |
type: str |
| 160 |
gratuitous_arps: |
| 161 |
description: |
| 162 |
- Enable/disable gratuitous ARPs. Disable if link-failed-signal enabled. |
| 163 |
type: str |
| 164 |
choices: |
| 165 |
- 'enable' |
| 166 |
- 'disable' |
| 167 |
group_id: |
| 168 |
description: |
| 169 |
- HA group ID (0 - 1023; or 0 - 7 when there are more than 2 vclusters). Must be the same for all members. |
| 170 |
type: int |
| 171 |
group_name: |
| 172 |
description: |
| 173 |
- Cluster group name. Must be the same for all members. |
| 174 |
type: str |
| 175 |
ha_direct: |
| 176 |
description: |
| 177 |
- Enable/disable using ha-mgmt interface for syslog, remote authentication (RADIUS), FortiAnalyzer, FortiSandbox, sFlow, and Netflow. |
| 178 |
type: str |
| 179 |
choices: |
| 180 |
- 'enable' |
| 181 |
- 'disable' |
| 182 |
ha_eth_type: |
| 183 |
description: |
| 184 |
- HA heartbeat packet Ethertype (4-digit hex). |
| 185 |
type: str |
| 186 |
ha_mgmt_interfaces: |
| 187 |
description: |
| 188 |
- Reserve interfaces to manage individual cluster units. |
| 189 |
type: list |
| 190 |
elements: dict |
| 191 |
suboptions: |
| 192 |
dst: |
| 193 |
description: |
| 194 |
- Default route destination for reserved HA management interface. |
| 195 |
type: str |
| 196 |
dst6: |
| 197 |
description: |
| 198 |
- Default IPv6 destination for reserved HA management interface. |
| 199 |
type: str |
| 200 |
gateway: |
| 201 |
description: |
| 202 |
- Default route gateway for reserved HA management interface. |
| 203 |
type: str |
| 204 |
gateway6: |
| 205 |
description: |
| 206 |
- Default IPv6 gateway for reserved HA management interface. |
| 207 |
type: str |
| 208 |
id: |
| 209 |
description: |
| 210 |
- Table ID. see <a href='#notes'>Notes</a>. |
| 211 |
required: true |
| 212 |
type: int |
| 213 |
interface: |
| 214 |
description: |
| 215 |
- Interface to reserve for HA management. Source system.interface.name. |
| 216 |
type: str |
| 217 |
ha_mgmt_status: |
| 218 |
description: |
| 219 |
- Enable to reserve interfaces to manage individual cluster units. |
| 220 |
type: str |
| 221 |
choices: |
| 222 |
- 'enable' |
| 223 |
- 'disable' |
| 224 |
ha_uptime_diff_margin: |
| 225 |
description: |
| 226 |
- Normally you would only reduce this value for failover testing. |
| 227 |
type: int |
| 228 |
hb_interval: |
| 229 |
description: |
| 230 |
- Time between sending heartbeat packets (1 - 20). Increase to reduce false positives. |
| 231 |
type: int |
| 232 |
hb_interval_in_milliseconds: |
| 233 |
description: |
| 234 |
- Units of heartbeat interval time between sending heartbeat packets. Default is 100ms. |
| 235 |
type: str |
| 236 |
choices: |
| 237 |
- '100ms' |
| 238 |
- '10ms' |
| 239 |
hb_lost_threshold: |
| 240 |
description: |
| 241 |
- Number of lost heartbeats to signal a failure (1 - 60). Increase to reduce false positives. |
| 242 |
type: int |
| 243 |
hbdev: |
| 244 |
description: |
| 245 |
- Heartbeat interfaces. Must be the same for all members. |
| 246 |
type: list |
| 247 |
elements: str |
| 248 |
hc_eth_type: |
| 249 |
description: |
| 250 |
- Transparent mode HA heartbeat packet Ethertype (4-digit hex). |
| 251 |
type: str |
| 252 |
hello_holddown: |
| 253 |
description: |
| 254 |
- Time to wait before changing from hello to work state (5 - 300 sec). |
| 255 |
type: int |
| 256 |
http_proxy_threshold: |
| 257 |
description: |
| 258 |
- Dynamic weighted load balancing weight and high and low number of HTTP proxy sessions. |
| 259 |
type: str |
| 260 |
imap_proxy_threshold: |
| 261 |
description: |
| 262 |
- Dynamic weighted load balancing weight and high and low number of IMAP proxy sessions. |
| 263 |
type: str |
| 264 |
inter_cluster_session_sync: |
| 265 |
description: |
| 266 |
- Enable/disable synchronization of sessions among HA clusters. |
| 267 |
type: str |
| 268 |
choices: |
| 269 |
- 'enable' |
| 270 |
- 'disable' |
| 271 |
ipsec_phase2_proposal: |
| 272 |
description: |
| 273 |
- IPsec phase2 proposal. |
| 274 |
type: list |
| 275 |
elements: str |
| 276 |
choices: |
| 277 |
- 'aes128-sha1' |
| 278 |
- 'aes128-sha256' |
| 279 |
- 'aes128-sha384' |
| 280 |
- 'aes128-sha512' |
| 281 |
- 'aes192-sha1' |
| 282 |
- 'aes192-sha256' |
| 283 |
- 'aes192-sha384' |
| 284 |
- 'aes192-sha512' |
| 285 |
- 'aes256-sha1' |
| 286 |
- 'aes256-sha256' |
| 287 |
- 'aes256-sha384' |
| 288 |
- 'aes256-sha512' |
| 289 |
- 'aes128gcm' |
| 290 |
- 'aes256gcm' |
| 291 |
- 'chacha20poly1305' |
| 292 |
key: |
| 293 |
description: |
| 294 |
- Key. |
| 295 |
type: str |
| 296 |
l2ep_eth_type: |
| 297 |
description: |
| 298 |
- Telnet session HA heartbeat packet Ethertype (4-digit hex). |
| 299 |
type: str |
| 300 |
link_failed_signal: |
| 301 |
description: |
| 302 |
- Enable to shut down all interfaces for 1 sec after a failover. Use if gratuitous ARPs do not update network. |
| 303 |
type: str |
| 304 |
choices: |
| 305 |
- 'enable' |
| 306 |
- 'disable' |
| 307 |
load_balance_all: |
| 308 |
description: |
| 309 |
- Enable to load balance TCP sessions. Disable to load balance proxy sessions only. |
| 310 |
type: str |
| 311 |
choices: |
| 312 |
- 'enable' |
| 313 |
- 'disable' |
| 314 |
logical_sn: |
| 315 |
description: |
| 316 |
- Enable/disable usage of the logical serial number. |
| 317 |
type: str |
| 318 |
choices: |
| 319 |
- 'enable' |
| 320 |
- 'disable' |
| 321 |
memory_based_failover: |
| 322 |
description: |
| 323 |
- Enable/disable memory based failover. |
| 324 |
type: str |
| 325 |
choices: |
| 326 |
- 'enable' |
| 327 |
- 'disable' |
| 328 |
memory_compatible_mode: |
| 329 |
description: |
| 330 |
- Enable/disable memory compatible mode. |
| 331 |
type: str |
| 332 |
choices: |
| 333 |
- 'enable' |
| 334 |
- 'disable' |
| 335 |
memory_failover_flip_timeout: |
| 336 |
description: |
| 337 |
- Time to wait between subsequent memory based failovers in minutes (6 - 2147483647). |
| 338 |
type: int |
| 339 |
memory_failover_monitor_period: |
| 340 |
description: |
| 341 |
- Duration of high memory usage before memory based failover is triggered in seconds (1 - 300). |
| 342 |
type: int |
| 343 |
memory_failover_sample_rate: |
| 344 |
description: |
| 345 |
- Rate at which memory usage is sampled in order to measure memory usage in seconds (1 - 60). |
| 346 |
type: int |
| 347 |
memory_failover_threshold: |
| 348 |
description: |
| 349 |
- Memory usage threshold to trigger memory based failover (0 means using conserve mode threshold in system.global). |
| 350 |
type: int |
| 351 |
memory_threshold: |
| 352 |
description: |
| 353 |
- Dynamic weighted load balancing memory usage weight and high and low thresholds. |
| 354 |
type: str |
| 355 |
mode: |
| 356 |
description: |
| 357 |
- HA mode. Must be the same for all members. FGSP requires standalone. |
| 358 |
type: str |
| 359 |
choices: |
| 360 |
- 'standalone' |
| 361 |
- 'a-a' |
| 362 |
- 'a-p' |
| 363 |
monitor: |
| 364 |
description: |
| 365 |
- Interfaces to check for port monitoring (or link failure). Source system.interface.name. |
| 366 |
type: list |
| 367 |
elements: str |
| 368 |
multicast_ttl: |
| 369 |
description: |
| 370 |
- HA multicast TTL on primary (5 - 3600 sec). |
| 371 |
type: int |
| 372 |
nntp_proxy_threshold: |
| 373 |
description: |
| 374 |
- Dynamic weighted load balancing weight and high and low number of NNTP proxy sessions. |
| 375 |
type: str |
| 376 |
override: |
| 377 |
description: |
| 378 |
- Enable and increase the priority of the unit that should always be primary (master). |
| 379 |
type: str |
| 380 |
choices: |
| 381 |
- 'enable' |
| 382 |
- 'disable' |
| 383 |
override_wait_time: |
| 384 |
description: |
| 385 |
- Delay negotiating if override is enabled (0 - 3600 sec). Reduces how often the cluster negotiates. |
| 386 |
type: int |
| 387 |
password: |
| 388 |
description: |
| 389 |
- Cluster password. Must be the same for all members. |
| 390 |
type: str |
| 391 |
pingserver_failover_threshold: |
| 392 |
description: |
| 393 |
- Remote IP monitoring failover threshold (0 - 50). |
| 394 |
type: int |
| 395 |
pingserver_flip_timeout: |
| 396 |
description: |
| 397 |
- Time to wait in minutes before renegotiating after a remote IP monitoring failover. |
| 398 |
type: int |
| 399 |
pingserver_monitor_interface: |
| 400 |
description: |
| 401 |
- Interfaces to check for remote IP monitoring. Source system.interface.name. |
| 402 |
type: list |
| 403 |
elements: str |
| 404 |
pingserver_secondary_force_reset: |
| 405 |
description: |
| 406 |
- Enable to force the cluster to negotiate after a remote IP monitoring failover. |
| 407 |
type: str |
| 408 |
choices: |
| 409 |
- 'enable' |
| 410 |
- 'disable' |
| 411 |
pingserver_slave_force_reset: |
| 412 |
description: |
| 413 |
- Enable to force the cluster to negotiate after a remote IP monitoring failover. |
| 414 |
type: str |
| 415 |
choices: |
| 416 |
- 'enable' |
| 417 |
- 'disable' |
| 418 |
pop3_proxy_threshold: |
| 419 |
description: |
| 420 |
- Dynamic weighted load balancing weight and high and low number of POP3 proxy sessions. |
| 421 |
type: str |
| 422 |
priority: |
| 423 |
description: |
| 424 |
- Increase the priority to select the primary unit (0 - 255). |
| 425 |
type: int |
| 426 |
route_hold: |
| 427 |
description: |
| 428 |
- Time to wait between routing table updates to the cluster (0 - 3600 sec). |
| 429 |
type: int |
| 430 |
route_ttl: |
| 431 |
description: |
| 432 |
- TTL for primary unit routes (5 - 3600 sec). Increase to maintain active routes during failover. |
| 433 |
type: int |
| 434 |
route_wait: |
| 435 |
description: |
| 436 |
- Time to wait before sending new routes to the cluster (0 - 3600 sec). |
| 437 |
type: int |
| 438 |
schedule: |
| 439 |
description: |
| 440 |
- Type of A-A load balancing. Use none if you have external load balancers. |
| 441 |
type: str |
| 442 |
choices: |
| 443 |
- 'none' |
| 444 |
- 'leastconnection' |
| 445 |
- 'round-robin' |
| 446 |
- 'weight-round-robin' |
| 447 |
- 'random' |
| 448 |
- 'ip' |
| 449 |
- 'ipport' |
| 450 |
- 'hub' |
| 451 |
secondary_vcluster: |
| 452 |
description: |
| 453 |
- Configure virtual cluster 2. |
| 454 |
type: dict |
| 455 |
suboptions: |
| 456 |
monitor: |
| 457 |
description: |
| 458 |
- Interfaces to check for port monitoring (or link failure). Source system.interface.name. |
| 459 |
type: list |
| 460 |
elements: str |
| 461 |
override: |
| 462 |
description: |
| 463 |
- Enable and increase the priority of the unit that should always be primary. |
| 464 |
type: str |
| 465 |
choices: |
| 466 |
- 'enable' |
| 467 |
- 'disable' |
| 468 |
override_wait_time: |
| 469 |
description: |
| 470 |
- Delay negotiating if override is enabled (0 - 3600 sec). Reduces how often the cluster negotiates. |
| 471 |
type: int |
| 472 |
pingserver_failover_threshold: |
| 473 |
description: |
| 474 |
- Remote IP monitoring failover threshold (0 - 50). |
| 475 |
type: int |
| 476 |
pingserver_monitor_interface: |
| 477 |
description: |
| 478 |
- Interfaces to check for remote IP monitoring. Source system.interface.name. |
| 479 |
type: list |
| 480 |
elements: str |
| 481 |
pingserver_secondary_force_reset: |
| 482 |
description: |
| 483 |
- Enable to force the cluster to negotiate after a remote IP monitoring failover. |
| 484 |
type: str |
| 485 |
choices: |
| 486 |
- 'enable' |
| 487 |
- 'disable' |
| 488 |
pingserver_slave_force_reset: |
| 489 |
description: |
| 490 |
- Enable to force the cluster to negotiate after a remote IP monitoring failover. |
| 491 |
type: str |
| 492 |
choices: |
| 493 |
- 'enable' |
| 494 |
- 'disable' |
| 495 |
priority: |
| 496 |
description: |
| 497 |
- Increase the priority to select the primary unit (0 - 255). |
| 498 |
type: int |
| 499 |
vcluster_id: |
| 500 |
description: |
| 501 |
- Cluster ID. |
| 502 |
type: int |
| 503 |
vdom: |
| 504 |
description: |
| 505 |
- VDOMs in virtual cluster 2. |
| 506 |
type: str |
| 507 |
session_pickup: |
| 508 |
description: |
| 509 |
- Enable/disable session pickup. Enabling it can reduce session down time when fail over happens. |
| 510 |
type: str |
| 511 |
choices: |
| 512 |
- 'enable' |
| 513 |
- 'disable' |
| 514 |
session_pickup_connectionless: |
| 515 |
description: |
| 516 |
- Enable/disable UDP and ICMP session sync. |
| 517 |
type: str |
| 518 |
choices: |
| 519 |
- 'enable' |
| 520 |
- 'disable' |
| 521 |
session_pickup_delay: |
| 522 |
description: |
| 523 |
- Enable to sync sessions longer than 30 sec. Only longer lived sessions need to be synced. |
| 524 |
type: str |
| 525 |
choices: |
| 526 |
- 'enable' |
| 527 |
- 'disable' |
| 528 |
session_pickup_expectation: |
| 529 |
description: |
| 530 |
- Enable/disable session helper expectation session sync for FGSP. |
| 531 |
type: str |
| 532 |
choices: |
| 533 |
- 'enable' |
| 534 |
- 'disable' |
| 535 |
session_pickup_nat: |
| 536 |
description: |
| 537 |
- Enable/disable NAT session sync for FGSP. |
| 538 |
type: str |
| 539 |
choices: |
| 540 |
- 'enable' |
| 541 |
- 'disable' |
| 542 |
session_sync_dev: |
| 543 |
description: |
| 544 |
- Offload session-sync process to kernel and sync sessions using connected interface(s) directly. Source system.interface.name. |
| 545 |
type: list |
| 546 |
elements: str |
| 547 |
smtp_proxy_threshold: |
| 548 |
description: |
| 549 |
- Dynamic weighted load balancing weight and high and low number of SMTP proxy sessions. |
| 550 |
type: str |
| 551 |
ssd_failover: |
| 552 |
description: |
| 553 |
- Enable/disable automatic HA failover on SSD disk failure. |
| 554 |
type: str |
| 555 |
choices: |
| 556 |
- 'enable' |
| 557 |
- 'disable' |
| 558 |
standalone_config_sync: |
| 559 |
description: |
| 560 |
- Enable/disable FGSP configuration synchronization. |
| 561 |
type: str |
| 562 |
choices: |
| 563 |
- 'enable' |
| 564 |
- 'disable' |
| 565 |
standalone_mgmt_vdom: |
| 566 |
description: |
| 567 |
- Enable/disable standalone management VDOM. |
| 568 |
type: str |
| 569 |
choices: |
| 570 |
- 'enable' |
| 571 |
- 'disable' |
| 572 |
sync_config: |
| 573 |
description: |
| 574 |
- Enable/disable configuration synchronization. |
| 575 |
type: str |
| 576 |
choices: |
| 577 |
- 'enable' |
| 578 |
- 'disable' |
| 579 |
sync_packet_balance: |
| 580 |
description: |
| 581 |
- Enable/disable HA packet distribution to multiple CPUs. |
| 582 |
type: str |
| 583 |
choices: |
| 584 |
- 'enable' |
| 585 |
- 'disable' |
| 586 |
unicast_gateway: |
| 587 |
description: |
| 588 |
- Default route gateway for unicast interface. |
| 589 |
type: str |
| 590 |
unicast_hb: |
| 591 |
description: |
| 592 |
- Enable/disable unicast heartbeat. |
| 593 |
type: str |
| 594 |
choices: |
| 595 |
- 'enable' |
| 596 |
- 'disable' |
| 597 |
unicast_hb_netmask: |
| 598 |
description: |
| 599 |
- Unicast heartbeat netmask. |
| 600 |
type: str |
| 601 |
unicast_hb_peerip: |
| 602 |
description: |
| 603 |
- Unicast heartbeat peer IP. |
| 604 |
type: str |
| 605 |
unicast_peers: |
| 606 |
description: |
| 607 |
- Number of unicast peers. |
| 608 |
type: list |
| 609 |
elements: dict |
| 610 |
suboptions: |
| 611 |
id: |
| 612 |
description: |
| 613 |
- Table ID. see <a href='#notes'>Notes</a>. |
| 614 |
required: true |
| 615 |
type: int |
| 616 |
peer_ip: |
| 617 |
description: |
| 618 |
- Unicast peer IP. |
| 619 |
type: str |
| 620 |
unicast_status: |
| 621 |
description: |
| 622 |
- Enable/disable unicast connection. |
| 623 |
type: str |
| 624 |
choices: |
| 625 |
- 'enable' |
| 626 |
- 'disable' |
| 627 |
uninterruptible_primary_wait: |
| 628 |
description: |
| 629 |
- Number of minutes the primary HA unit waits before the secondary HA unit is considered upgraded and the system is started before |
| 630 |
starting its own upgrade (15 - 300). |
| 631 |
type: int |
| 632 |
uninterruptible_upgrade: |
| 633 |
description: |
| 634 |
- Enable to upgrade a cluster without blocking network traffic. |
| 635 |
type: str |
| 636 |
choices: |
| 637 |
- 'enable' |
| 638 |
- 'disable' |
| 639 |
upgrade_mode: |
| 640 |
description: |
| 641 |
- The mode to upgrade a cluster. |
| 642 |
type: str |
| 643 |
choices: |
| 644 |
- 'simultaneous' |
| 645 |
- 'uninterruptible' |
| 646 |
- 'local-only' |
| 647 |
- 'secondary-only' |
| 648 |
vcluster: |
| 649 |
description: |
| 650 |
- Virtual cluster table. |
| 651 |
type: list |
| 652 |
elements: dict |
| 653 |
suboptions: |
| 654 |
monitor: |
| 655 |
description: |
| 656 |
- Interfaces to check for port monitoring (or link failure). Source system.interface.name. |
| 657 |
type: list |
| 658 |
elements: str |
| 659 |
override: |
| 660 |
description: |
| 661 |
- Enable and increase the priority of the unit that should always be primary (master). |
| 662 |
type: str |
| 663 |
choices: |
| 664 |
- 'enable' |
| 665 |
- 'disable' |
| 666 |
override_wait_time: |
| 667 |
description: |
| 668 |
- Delay negotiating if override is enabled (0 - 3600 sec). Reduces how often the cluster negotiates. |
| 669 |
type: int |
| 670 |
pingserver_failover_threshold: |
| 671 |
description: |
| 672 |
- Remote IP monitoring failover threshold (0 - 50). |
| 673 |
type: int |
| 674 |
pingserver_flip_timeout: |
| 675 |
description: |
| 676 |
- Time to wait in minutes before renegotiating after a remote IP monitoring failover. |
| 677 |
type: int |
| 678 |
pingserver_monitor_interface: |
| 679 |
description: |
| 680 |
- Interfaces to check for remote IP monitoring. Source system.interface.name. |
| 681 |
type: list |
| 682 |
elements: str |
| 683 |
pingserver_secondary_force_reset: |
| 684 |
description: |
| 685 |
- Enable to force the cluster to negotiate after a remote IP monitoring failover. |
| 686 |
type: str |
| 687 |
choices: |
| 688 |
- 'enable' |
| 689 |
- 'disable' |
| 690 |
pingserver_slave_force_reset: |
| 691 |
description: |
| 692 |
- Enable to force the cluster to negotiate after a remote IP monitoring failover. |
| 693 |
type: str |
| 694 |
choices: |
| 695 |
- 'enable' |
| 696 |
- 'disable' |
| 697 |
priority: |
| 698 |
description: |
| 699 |
- Increase the priority to select the primary unit (0 - 255). |
| 700 |
type: int |
| 701 |
vcluster_id: |
| 702 |
description: |
| 703 |
- ID. see <a href='#notes'>Notes</a>. |
| 704 |
required: true |
| 705 |
type: int |
| 706 |
vdom: |
| 707 |
description: |
| 708 |
- Virtual domain(s) in the virtual cluster. |
| 709 |
type: list |
| 710 |
elements: dict |
| 711 |
suboptions: |
| 712 |
name: |
| 713 |
description: |
| 714 |
- Virtual domain name. Source system.vdom.name. |
| 715 |
required: true |
| 716 |
type: str |
| 717 |
vcluster_id: |
| 718 |
description: |
| 719 |
- Cluster ID. |
| 720 |
type: int |
| 721 |
vcluster_status: |
| 722 |
description: |
| 723 |
- Enable/disable virtual cluster for virtual clustering. |
| 724 |
type: str |
| 725 |
choices: |
| 726 |
- 'enable' |
| 727 |
- 'disable' |
| 728 |
vcluster2: |
| 729 |
description: |
| 730 |
- Enable/disable virtual cluster 2 for virtual clustering. |
| 731 |
type: str |
| 732 |
choices: |
| 733 |
- 'enable' |
| 734 |
- 'disable' |
| 735 |
vdom: |
| 736 |
description: |
| 737 |
- VDOMs in virtual cluster 1. |
| 738 |
type: str |
| 739 |
weight: |
| 740 |
description: |
| 741 |
- Weight-round-robin weight for each cluster unit. Syntax <priority> <weight>. |
| 742 |
type: str |
| 743 |
""" |
| 744 |
|
| 745 |
EXAMPLES = """ |
| 746 |
- name: Configure HA. |
| 747 |
fortinet.fortios.fortios_system_ha: |
| 748 |
vdom: "{{ vdom }}" |
| 749 |
system_ha: |
| 750 |
arps: "5" |
| 751 |
arps_interval: "8" |
| 752 |
authentication: "enable" |
| 753 |
auto_virtual_mac_interface: |
| 754 |
- |
| 755 |
interface_name: "<your_own_value> (source system.interface.name)" |
| 756 |
backup_hbdev: |
| 757 |
- |
| 758 |
name: "default_name_9 (source system.interface.name)" |
| 759 |
bounce_intf_upon_failover: "enable" |
| 760 |
check_secondary_dev_health: "enable" |
| 761 |
cpu_threshold: "<your_own_value>" |
| 762 |
encryption: "enable" |
| 763 |
evpn_ttl: "60" |
| 764 |
failover_hold_time: "0" |
| 765 |
ftp_proxy_threshold: "<your_own_value>" |
| 766 |
gratuitous_arps: "enable" |
| 767 |
group_id: "0" |
| 768 |
group_name: "<your_own_value>" |
| 769 |
ha_direct: "enable" |
| 770 |
ha_eth_type: "<your_own_value>" |
| 771 |
ha_mgmt_interfaces: |
| 772 |
- |
| 773 |
dst: "<your_own_value>" |
| 774 |
dst6: "<your_own_value>" |
| 775 |
gateway: "<your_own_value>" |
| 776 |
gateway6: "<your_own_value>" |
| 777 |
id: "27" |
| 778 |
interface: "<your_own_value> (source system.interface.name)" |
| 779 |
ha_mgmt_status: "enable" |
| 780 |
ha_uptime_diff_margin: "300" |
| 781 |
hb_interval: "2" |
| 782 |
hb_interval_in_milliseconds: "100ms" |
| 783 |
hb_lost_threshold: "6" |
| 784 |
hbdev: "<your_own_value>" |
| 785 |
hc_eth_type: "<your_own_value>" |
| 786 |
hello_holddown: "20" |
| 787 |
http_proxy_threshold: "<your_own_value>" |
| 788 |
imap_proxy_threshold: "<your_own_value>" |
| 789 |
inter_cluster_session_sync: "enable" |
| 790 |
ipsec_phase2_proposal: "aes128-sha1" |
| 791 |
key: "<your_own_value>" |
| 792 |
l2ep_eth_type: "<your_own_value>" |
| 793 |
link_failed_signal: "enable" |
| 794 |
load_balance_all: "enable" |
| 795 |
logical_sn: "enable" |
| 796 |
memory_based_failover: "enable" |
| 797 |
memory_compatible_mode: "enable" |
| 798 |
memory_failover_flip_timeout: "6" |
| 799 |
memory_failover_monitor_period: "60" |
| 800 |
memory_failover_sample_rate: "1" |
| 801 |
memory_failover_threshold: "0" |
| 802 |
memory_threshold: "<your_own_value>" |
| 803 |
mode: "standalone" |
| 804 |
monitor: "<your_own_value> (source system.interface.name)" |
| 805 |
multicast_ttl: "600" |
| 806 |
nntp_proxy_threshold: "<your_own_value>" |
| 807 |
override: "enable" |
| 808 |
override_wait_time: "0" |
| 809 |
password: "<your_own_value>" |
| 810 |
pingserver_failover_threshold: "0" |
| 811 |
pingserver_flip_timeout: "60" |
| 812 |
pingserver_monitor_interface: "<your_own_value> (source system.interface.name)" |
| 813 |
pingserver_secondary_force_reset: "enable" |
| 814 |
pingserver_slave_force_reset: "enable" |
| 815 |
pop3_proxy_threshold: "<your_own_value>" |
| 816 |
priority: "128" |
| 817 |
route_hold: "10" |
| 818 |
route_ttl: "10" |
| 819 |
route_wait: "0" |
| 820 |
schedule: "none" |
| 821 |
secondary_vcluster: |
| 822 |
monitor: "<your_own_value> (source system.interface.name)" |
| 823 |
override: "enable" |
| 824 |
override_wait_time: "0" |
| 825 |
pingserver_failover_threshold: "0" |
| 826 |
pingserver_monitor_interface: "<your_own_value> (source system.interface.name)" |
| 827 |
pingserver_secondary_force_reset: "enable" |
| 828 |
pingserver_slave_force_reset: "enable" |
| 829 |
priority: "128" |
| 830 |
vcluster_id: "1" |
| 831 |
vdom: "<your_own_value>" |
| 832 |
session_pickup: "enable" |
| 833 |
session_pickup_connectionless: "enable" |
| 834 |
session_pickup_delay: "enable" |
| 835 |
session_pickup_expectation: "enable" |
| 836 |
session_pickup_nat: "enable" |
| 837 |
session_sync_dev: "<your_own_value> (source system.interface.name)" |
| 838 |
smtp_proxy_threshold: "<your_own_value>" |
| 839 |
ssd_failover: "enable" |
| 840 |
standalone_config_sync: "enable" |
| 841 |
standalone_mgmt_vdom: "enable" |
| 842 |
sync_config: "enable" |
| 843 |
sync_packet_balance: "enable" |
| 844 |
unicast_gateway: "<your_own_value>" |
| 845 |
unicast_hb: "enable" |
| 846 |
unicast_hb_netmask: "<your_own_value>" |
| 847 |
unicast_hb_peerip: "<your_own_value>" |
| 848 |
unicast_peers: |
| 849 |
- |
| 850 |
id: "99" |
| 851 |
peer_ip: "<your_own_value>" |
| 852 |
unicast_status: "enable" |
| 853 |
uninterruptible_primary_wait: "30" |
| 854 |
uninterruptible_upgrade: "enable" |
| 855 |
upgrade_mode: "simultaneous" |
| 856 |
vcluster: |
| 857 |
- |
| 858 |
monitor: "<your_own_value> (source system.interface.name)" |
| 859 |
override: "enable" |
| 860 |
override_wait_time: "0" |
| 861 |
pingserver_failover_threshold: "0" |
| 862 |
pingserver_flip_timeout: "60" |
| 863 |
pingserver_monitor_interface: "<your_own_value> (source system.interface.name)" |
| 864 |
pingserver_secondary_force_reset: "enable" |
| 865 |
pingserver_slave_force_reset: "enable" |
| 866 |
priority: "128" |
| 867 |
vcluster_id: "<you_own_value>" |
| 868 |
vdom: |
| 869 |
- |
| 870 |
name: "default_name_117 (source system.vdom.name)" |
| 871 |
vcluster_id: "0" |
| 872 |
vcluster_status: "enable" |
| 873 |
vcluster2: "enable" |
| 874 |
vdom: "<your_own_value>" |
| 875 |
weight: "<your_own_value>" |
| 876 |
""" |
| 877 |
|
| 878 |
RETURN = """ |
| 879 |
build: |
| 880 |
description: Build number of the fortigate image |
| 881 |
returned: always |
| 882 |
type: str |
| 883 |
sample: '1547' |
| 884 |
http_method: |
| 885 |
description: Last method used to provision the content into FortiGate |
| 886 |
returned: always |
| 887 |
type: str |
| 888 |
sample: 'PUT' |
| 889 |
http_status: |
| 890 |
description: Last result given by FortiGate on last operation applied |
| 891 |
returned: always |
| 892 |
type: str |
| 893 |
sample: "200" |
| 894 |
mkey: |
| 895 |
description: Master key (id) used in the last call to FortiGate |
| 896 |
returned: success |
| 897 |
type: str |
| 898 |
sample: "id" |
| 899 |
name: |
| 900 |
description: Name of the table used to fulfill the request |
| 901 |
returned: always |
| 902 |
type: str |
| 903 |
sample: "urlfilter" |
| 904 |
path: |
| 905 |
description: Path of the table used to fulfill the request |
| 906 |
returned: always |
| 907 |
type: str |
| 908 |
sample: "webfilter" |
| 909 |
revision: |
| 910 |
description: Internal revision number |
| 911 |
returned: always |
| 912 |
type: str |
| 913 |
sample: "17.0.2.10658" |
| 914 |
serial: |
| 915 |
description: Serial number of the unit |
| 916 |
returned: always |
| 917 |
type: str |
| 918 |
sample: "FGVMEVYYQT3AB5352" |
| 919 |
status: |
| 920 |
description: Indication of the operation's result |
| 921 |
returned: always |
| 922 |
type: str |
| 923 |
sample: "success" |
| 924 |
vdom: |
| 925 |
description: Virtual domain used |
| 926 |
returned: always |
| 927 |
type: str |
| 928 |
sample: "root" |
| 929 |
version: |
| 930 |
description: Version of the FortiGate |
| 931 |
returned: always |
| 932 |
type: str |
| 933 |
sample: "v5.6.3" |
| 934 |
""" |
| 935 |
from ansible.module_utils.basic import AnsibleModule |
| 936 |
from ansible.module_utils.connection import Connection |
| 937 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 938 |
FortiOSHandler, |
| 939 |
) |
| 940 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 941 |
check_legacy_fortiosapi, |
| 942 |
) |
| 943 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 944 |
schema_to_module_spec, |
| 945 |
) |
| 946 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 947 |
check_schema_versioning, |
| 948 |
) |
| 949 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.common import ( |
| 950 |
FAIL_SOCKET_MSG, |
| 951 |
) |
| 952 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.data_post_processor import ( |
| 953 |
remove_invalid_fields, |
| 954 |
) |
| 955 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 956 |
is_same_comparison, |
| 957 |
) |
| 958 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 959 |
serialize, |
| 960 |
) |
| 961 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 962 |
find_current_values, |
| 963 |
) |
| 964 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 965 |
unify_data_format, |
| 966 |
) |
| 967 |
|
| 968 |
|
| 969 |
def filter_system_ha_data(json): |
| 970 |
option_list = [ |
| 971 |
"arps", |
| 972 |
"arps_interval", |
| 973 |
"authentication", |
| 974 |
"auto_virtual_mac_interface", |
| 975 |
"backup_hbdev", |
| 976 |
"bounce_intf_upon_failover", |
| 977 |
"check_secondary_dev_health", |
| 978 |
"cpu_threshold", |
| 979 |
"encryption", |
| 980 |
"evpn_ttl", |
| 981 |
"failover_hold_time", |
| 982 |
"ftp_proxy_threshold", |
| 983 |
"gratuitous_arps", |
| 984 |
"group_id", |
| 985 |
"group_name", |
| 986 |
"ha_direct", |
| 987 |
"ha_eth_type", |
| 988 |
"ha_mgmt_interfaces", |
| 989 |
"ha_mgmt_status", |
| 990 |
"ha_uptime_diff_margin", |
| 991 |
"hb_interval", |
| 992 |
"hb_interval_in_milliseconds", |
| 993 |
"hb_lost_threshold", |
| 994 |
"hbdev", |
| 995 |
"hc_eth_type", |
| 996 |
"hello_holddown", |
| 997 |
"http_proxy_threshold", |
| 998 |
"imap_proxy_threshold", |
| 999 |
"inter_cluster_session_sync", |
| 1000 |
"ipsec_phase2_proposal", |
| 1001 |
"key", |
| 1002 |
"l2ep_eth_type", |
| 1003 |
"link_failed_signal", |
| 1004 |
"load_balance_all", |
| 1005 |
"logical_sn", |
| 1006 |
"memory_based_failover", |
| 1007 |
"memory_compatible_mode", |
| 1008 |
"memory_failover_flip_timeout", |
| 1009 |
"memory_failover_monitor_period", |
| 1010 |
"memory_failover_sample_rate", |
| 1011 |
"memory_failover_threshold", |
| 1012 |
"memory_threshold", |
| 1013 |
"mode", |
| 1014 |
"monitor", |
| 1015 |
"multicast_ttl", |
| 1016 |
"nntp_proxy_threshold", |
| 1017 |
"override", |
| 1018 |
"override_wait_time", |
| 1019 |
"password", |
| 1020 |
"pingserver_failover_threshold", |
| 1021 |
"pingserver_flip_timeout", |
| 1022 |
"pingserver_monitor_interface", |
| 1023 |
"pingserver_secondary_force_reset", |
| 1024 |
"pingserver_slave_force_reset", |
| 1025 |
"pop3_proxy_threshold", |
| 1026 |
"priority", |
| 1027 |
"route_hold", |
| 1028 |
"route_ttl", |
| 1029 |
"route_wait", |
| 1030 |
"schedule", |
| 1031 |
"secondary_vcluster", |
| 1032 |
"session_pickup", |
| 1033 |
"session_pickup_connectionless", |
| 1034 |
"session_pickup_delay", |
| 1035 |
"session_pickup_expectation", |
| 1036 |
"session_pickup_nat", |
| 1037 |
"session_sync_dev", |
| 1038 |
"smtp_proxy_threshold", |
| 1039 |
"ssd_failover", |
| 1040 |
"standalone_config_sync", |
| 1041 |
"standalone_mgmt_vdom", |
| 1042 |
"sync_config", |
| 1043 |
"sync_packet_balance", |
| 1044 |
"unicast_gateway", |
| 1045 |
"unicast_hb", |
| 1046 |
"unicast_hb_netmask", |
| 1047 |
"unicast_hb_peerip", |
| 1048 |
"unicast_peers", |
| 1049 |
"unicast_status", |
| 1050 |
"uninterruptible_primary_wait", |
| 1051 |
"uninterruptible_upgrade", |
| 1052 |
"upgrade_mode", |
| 1053 |
"vcluster", |
| 1054 |
"vcluster_id", |
| 1055 |
"vcluster_status", |
| 1056 |
"vcluster2", |
| 1057 |
"vdom", |
| 1058 |
"weight", |
| 1059 |
] |
| 1060 |
|
| 1061 |
json = remove_invalid_fields(json) |
| 1062 |
dictionary = {} |
| 1063 |
|
| 1064 |
for attribute in option_list: |
| 1065 |
if attribute in json and json[attribute] is not None: |
| 1066 |
dictionary[attribute] = json[attribute] |
| 1067 |
|
| 1068 |
return dictionary |
| 1069 |
|
| 1070 |
|
| 1071 |
def flatten_single_path(data, path, index): |
| 1072 |
if ( |
| 1073 |
not data |
| 1074 |
or index == len(path) |
| 1075 |
or path[index] not in data |
| 1076 |
or (not data[path[index]] and not isinstance(data[path[index]], list)) |
| 1077 |
): |
| 1078 |
return |
| 1079 |
|
| 1080 |
if index == len(path) - 1: |
| 1081 |
data[path[index]] = " ".join(str(elem) for elem in data[path[index]]) |
| 1082 |
if len(data[path[index]]) == 0: |
| 1083 |
data[path[index]] = None |
| 1084 |
elif isinstance(data[path[index]], list): |
| 1085 |
for value in data[path[index]]: |
| 1086 |
flatten_single_path(value, path, index + 1) |
| 1087 |
else: |
| 1088 |
flatten_single_path(data[path[index]], path, index + 1) |
| 1089 |
|
| 1090 |
|
| 1091 |
def flatten_multilists_attributes(data): |
| 1092 |
multilist_attrs = [ |
| 1093 |
["hbdev"], |
| 1094 |
["session_sync_dev"], |
| 1095 |
["monitor"], |
| 1096 |
["pingserver_monitor_interface"], |
| 1097 |
["vcluster", "monitor"], |
| 1098 |
["vcluster", "pingserver_monitor_interface"], |
| 1099 |
["ipsec_phase2_proposal"], |
| 1100 |
["secondary_vcluster", "monitor"], |
| 1101 |
["secondary_vcluster", "pingserver_monitor_interface"], |
| 1102 |
] |
| 1103 |
|
| 1104 |
for attr in multilist_attrs: |
| 1105 |
flatten_single_path(data, attr, 0) |
| 1106 |
|
| 1107 |
return data |
| 1108 |
|
| 1109 |
|
| 1110 |
def underscore_to_hyphen(data): |
| 1111 |
new_data = None |
| 1112 |
if isinstance(data, list): |
| 1113 |
new_data = [] |
| 1114 |
for i, elem in enumerate(data): |
| 1115 |
new_data.append(underscore_to_hyphen(elem)) |
| 1116 |
elif isinstance(data, dict): |
| 1117 |
new_data = {} |
| 1118 |
for k, v in data.items(): |
| 1119 |
new_data[k.replace("_", "-")] = underscore_to_hyphen(v) |
| 1120 |
else: |
| 1121 |
return data |
| 1122 |
return new_data |
| 1123 |
|
| 1124 |
|
| 1125 |
def system_ha(data, fos, check_mode=False): |
| 1126 |
|
| 1127 |
state = None |
| 1128 |
vdom = data["vdom"] |
| 1129 |
parameters = None |
| 1130 |
state = data.get("state", None) |
| 1131 |
system_ha_data = data["system_ha"] |
| 1132 |
|
| 1133 |
filtered_data = filter_system_ha_data(system_ha_data) |
| 1134 |
filtered_data = flatten_multilists_attributes(filtered_data) |
| 1135 |
converted_data = underscore_to_hyphen(filtered_data) |
| 1136 |
|
| 1137 |
|
| 1138 |
if check_mode: |
| 1139 |
diff = { |
| 1140 |
"before": "", |
| 1141 |
"after": filtered_data, |
| 1142 |
} |
| 1143 |
mkeyname = fos.get_mkeyname(None, None) |
| 1144 |
mkey = fos.get_mkey("system", "ha", filtered_data, vdom=vdom) |
| 1145 |
current_data = fos.get( |
| 1146 |
"system", "ha", vdom=vdom, mkey=mkey, parameters=parameters |
| 1147 |
) |
| 1148 |
is_existed = ( |
| 1149 |
current_data |
| 1150 |
and current_data.get("http_status") == 200 |
| 1151 |
and ( |
| 1152 |
mkeyname |
| 1153 |
and isinstance(current_data.get("results"), list) |
| 1154 |
and len(current_data["results"]) > 0 |
| 1155 |
or not mkeyname |
| 1156 |
and current_data["results"] |
| 1157 |
) |
| 1158 |
) |
| 1159 |
|
| 1160 |
|
| 1161 |
if state == "present" or state is True or state is None: |
| 1162 |
|
| 1163 |
if mkeyname is not None and mkey is None: |
| 1164 |
return False, True, filtered_data, diff |
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
copied_filtered_data = filtered_data.copy() |
| 1169 |
copied_filtered_data.pop(mkeyname, None) |
| 1170 |
unified_filtered_data = unify_data_format(copied_filtered_data) |
| 1171 |
|
| 1172 |
current_data_results = current_data.get("results", {}) |
| 1173 |
current_config = ( |
| 1174 |
current_data_results[0] |
| 1175 |
if mkeyname |
| 1176 |
and isinstance(current_data_results, list) |
| 1177 |
and len(current_data_results) > 0 |
| 1178 |
else current_data_results |
| 1179 |
) |
| 1180 |
if is_existed: |
| 1181 |
unified_current_values = find_current_values( |
| 1182 |
unified_filtered_data, |
| 1183 |
unify_data_format(current_config), |
| 1184 |
) |
| 1185 |
|
| 1186 |
is_same = is_same_comparison( |
| 1187 |
serialize(unified_current_values), serialize(unified_filtered_data) |
| 1188 |
) |
| 1189 |
|
| 1190 |
return ( |
| 1191 |
False, |
| 1192 |
not is_same, |
| 1193 |
filtered_data, |
| 1194 |
{"before": unified_current_values, "after": unified_filtered_data}, |
| 1195 |
) |
| 1196 |
|
| 1197 |
|
| 1198 |
return False, True, filtered_data, diff |
| 1199 |
|
| 1200 |
if state == "absent": |
| 1201 |
if mkey is None: |
| 1202 |
return ( |
| 1203 |
False, |
| 1204 |
False, |
| 1205 |
filtered_data, |
| 1206 |
{"before": current_data["results"][0], "after": ""}, |
| 1207 |
) |
| 1208 |
|
| 1209 |
if is_existed: |
| 1210 |
return ( |
| 1211 |
False, |
| 1212 |
True, |
| 1213 |
filtered_data, |
| 1214 |
{"before": current_data["results"][0], "after": ""}, |
| 1215 |
) |
| 1216 |
return False, False, filtered_data, {} |
| 1217 |
|
| 1218 |
return True, False, {"reason: ": "Must provide state parameter"}, {} |
| 1219 |
|
| 1220 |
|
| 1221 |
data_copy = data.copy() |
| 1222 |
data_copy["system_ha"] = filtered_data |
| 1223 |
fos.do_member_operation( |
| 1224 |
"system", |
| 1225 |
"ha", |
| 1226 |
data_copy, |
| 1227 |
) |
| 1228 |
|
| 1229 |
return fos.set( |
| 1230 |
"system", "ha", data=converted_data, vdom=vdom, parameters=parameters |
| 1231 |
) |
| 1232 |
|
| 1233 |
|
| 1234 |
def is_successful_status(resp): |
| 1235 |
return ( |
| 1236 |
"status" in resp |
| 1237 |
and resp["status"] == "success" |
| 1238 |
or "http_status" in resp |
| 1239 |
and resp["http_status"] == 200 |
| 1240 |
or "http_method" in resp |
| 1241 |
and resp["http_method"] == "DELETE" |
| 1242 |
and resp["http_status"] == 404 |
| 1243 |
) |
| 1244 |
|
| 1245 |
|
| 1246 |
def fortios_system(data, fos, check_mode): |
| 1247 |
|
| 1248 |
if data["system_ha"]: |
| 1249 |
resp = system_ha(data, fos, check_mode) |
| 1250 |
else: |
| 1251 |
fos._module.fail_json(msg="missing task body: %s" % ("system_ha")) |
| 1252 |
if isinstance(resp, tuple) and len(resp) == 4: |
| 1253 |
return resp |
| 1254 |
return ( |
| 1255 |
not is_successful_status(resp), |
| 1256 |
is_successful_status(resp) |
| 1257 |
and (resp["revision_changed"] if "revision_changed" in resp else True), |
| 1258 |
resp, |
| 1259 |
{}, |
| 1260 |
) |
| 1261 |
|
| 1262 |
|
| 1263 |
versioned_schema = { |
| 1264 |
"v_range": [["v6.0.0", ""]], |
| 1265 |
"type": "dict", |
| 1266 |
"children": { |
| 1267 |
"group_id": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1268 |
"group_name": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1269 |
"mode": { |
| 1270 |
"v_range": [["v6.0.0", ""]], |
| 1271 |
"type": "string", |
| 1272 |
"options": [{"value": "standalone"}, {"value": "a-a"}, {"value": "a-p"}], |
| 1273 |
}, |
| 1274 |
"sync_packet_balance": { |
| 1275 |
"v_range": [["v6.0.0", ""]], |
| 1276 |
"type": "string", |
| 1277 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1278 |
}, |
| 1279 |
"password": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1280 |
"key": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1281 |
"hbdev": { |
| 1282 |
"v_range": [["v6.0.0", ""]], |
| 1283 |
"type": "list", |
| 1284 |
"multiple_values": True, |
| 1285 |
"elements": "str", |
| 1286 |
}, |
| 1287 |
"auto_virtual_mac_interface": { |
| 1288 |
"type": "list", |
| 1289 |
"elements": "dict", |
| 1290 |
"children": { |
| 1291 |
"interface_name": { |
| 1292 |
"v_range": [["v7.6.0", ""]], |
| 1293 |
"type": "string", |
| 1294 |
"required": True, |
| 1295 |
} |
| 1296 |
}, |
| 1297 |
"v_range": [["v7.6.0", ""]], |
| 1298 |
}, |
| 1299 |
"backup_hbdev": { |
| 1300 |
"type": "list", |
| 1301 |
"elements": "dict", |
| 1302 |
"children": { |
| 1303 |
"name": { |
| 1304 |
"v_range": [["v7.6.0", ""]], |
| 1305 |
"type": "string", |
| 1306 |
"required": True, |
| 1307 |
} |
| 1308 |
}, |
| 1309 |
"v_range": [["v7.6.0", ""]], |
| 1310 |
}, |
| 1311 |
"session_sync_dev": { |
| 1312 |
"v_range": [["v6.0.0", ""]], |
| 1313 |
"type": "list", |
| 1314 |
"multiple_values": True, |
| 1315 |
"elements": "str", |
| 1316 |
}, |
| 1317 |
"route_ttl": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1318 |
"route_wait": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1319 |
"route_hold": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1320 |
"multicast_ttl": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1321 |
"evpn_ttl": {"v_range": [["v7.4.0", ""]], "type": "integer"}, |
| 1322 |
"load_balance_all": { |
| 1323 |
"v_range": [["v6.0.0", ""]], |
| 1324 |
"type": "string", |
| 1325 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1326 |
}, |
| 1327 |
"sync_config": { |
| 1328 |
"v_range": [["v6.0.0", ""]], |
| 1329 |
"type": "string", |
| 1330 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1331 |
}, |
| 1332 |
"encryption": { |
| 1333 |
"v_range": [["v6.0.0", ""]], |
| 1334 |
"type": "string", |
| 1335 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1336 |
}, |
| 1337 |
"authentication": { |
| 1338 |
"v_range": [["v6.0.0", ""]], |
| 1339 |
"type": "string", |
| 1340 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1341 |
}, |
| 1342 |
"hb_interval": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1343 |
"hb_interval_in_milliseconds": { |
| 1344 |
"v_range": [["v7.0.0", ""]], |
| 1345 |
"type": "string", |
| 1346 |
"options": [{"value": "100ms"}, {"value": "10ms"}], |
| 1347 |
}, |
| 1348 |
"hb_lost_threshold": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1349 |
"hello_holddown": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1350 |
"gratuitous_arps": { |
| 1351 |
"v_range": [["v6.0.0", ""]], |
| 1352 |
"type": "string", |
| 1353 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1354 |
}, |
| 1355 |
"arps": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1356 |
"arps_interval": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1357 |
"session_pickup": { |
| 1358 |
"v_range": [["v6.0.0", ""]], |
| 1359 |
"type": "string", |
| 1360 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1361 |
}, |
| 1362 |
"session_pickup_connectionless": { |
| 1363 |
"v_range": [["v6.0.0", ""]], |
| 1364 |
"type": "string", |
| 1365 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1366 |
}, |
| 1367 |
"session_pickup_expectation": { |
| 1368 |
"v_range": [["v6.0.0", ""]], |
| 1369 |
"type": "string", |
| 1370 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1371 |
}, |
| 1372 |
"session_pickup_nat": { |
| 1373 |
"v_range": [["v6.0.0", ""]], |
| 1374 |
"type": "string", |
| 1375 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1376 |
}, |
| 1377 |
"session_pickup_delay": { |
| 1378 |
"v_range": [["v6.0.0", ""]], |
| 1379 |
"type": "string", |
| 1380 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1381 |
}, |
| 1382 |
"link_failed_signal": { |
| 1383 |
"v_range": [["v6.0.0", ""]], |
| 1384 |
"type": "string", |
| 1385 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1386 |
}, |
| 1387 |
"upgrade_mode": { |
| 1388 |
"v_range": [["v7.4.1", ""]], |
| 1389 |
"type": "string", |
| 1390 |
"options": [ |
| 1391 |
{"value": "simultaneous"}, |
| 1392 |
{"value": "uninterruptible"}, |
| 1393 |
{"value": "local-only"}, |
| 1394 |
{"value": "secondary-only"}, |
| 1395 |
], |
| 1396 |
}, |
| 1397 |
"uninterruptible_primary_wait": { |
| 1398 |
"v_range": [["v7.0.2", ""]], |
| 1399 |
"type": "integer", |
| 1400 |
}, |
| 1401 |
"standalone_mgmt_vdom": { |
| 1402 |
"v_range": [["v6.0.0", ""]], |
| 1403 |
"type": "string", |
| 1404 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1405 |
}, |
| 1406 |
"ha_mgmt_status": { |
| 1407 |
"v_range": [["v6.0.0", ""]], |
| 1408 |
"type": "string", |
| 1409 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1410 |
}, |
| 1411 |
"ha_mgmt_interfaces": { |
| 1412 |
"type": "list", |
| 1413 |
"elements": "dict", |
| 1414 |
"children": { |
| 1415 |
"id": { |
| 1416 |
"v_range": [["v6.0.0", ""]], |
| 1417 |
"type": "integer", |
| 1418 |
"required": True, |
| 1419 |
}, |
| 1420 |
"interface": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1421 |
"dst": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1422 |
"gateway": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1423 |
"dst6": {"v_range": [["v7.6.3", ""]], "type": "string"}, |
| 1424 |
"gateway6": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1425 |
}, |
| 1426 |
"v_range": [["v6.0.0", ""]], |
| 1427 |
}, |
| 1428 |
"ha_eth_type": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1429 |
"hc_eth_type": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1430 |
"l2ep_eth_type": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1431 |
"ha_uptime_diff_margin": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1432 |
"standalone_config_sync": { |
| 1433 |
"v_range": [["v6.0.0", ""]], |
| 1434 |
"type": "string", |
| 1435 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1436 |
}, |
| 1437 |
"schedule": { |
| 1438 |
"v_range": [["v6.0.0", ""]], |
| 1439 |
"type": "string", |
| 1440 |
"options": [ |
| 1441 |
{"value": "none"}, |
| 1442 |
{"value": "leastconnection"}, |
| 1443 |
{"value": "round-robin"}, |
| 1444 |
{"value": "weight-round-robin"}, |
| 1445 |
{"value": "random"}, |
| 1446 |
{"value": "ip"}, |
| 1447 |
{"value": "ipport"}, |
| 1448 |
{"value": "hub", "v_range": [["v6.0.0", "v7.2.0"]]}, |
| 1449 |
], |
| 1450 |
}, |
| 1451 |
"weight": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1452 |
"cpu_threshold": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1453 |
"memory_threshold": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1454 |
"http_proxy_threshold": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1455 |
"ftp_proxy_threshold": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1456 |
"imap_proxy_threshold": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1457 |
"nntp_proxy_threshold": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1458 |
"pop3_proxy_threshold": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1459 |
"smtp_proxy_threshold": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1460 |
"override": { |
| 1461 |
"v_range": [["v6.0.0", ""]], |
| 1462 |
"type": "string", |
| 1463 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1464 |
}, |
| 1465 |
"priority": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1466 |
"override_wait_time": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1467 |
"monitor": { |
| 1468 |
"v_range": [["v6.0.0", ""]], |
| 1469 |
"type": "list", |
| 1470 |
"multiple_values": True, |
| 1471 |
"elements": "str", |
| 1472 |
}, |
| 1473 |
"pingserver_monitor_interface": { |
| 1474 |
"v_range": [["v6.0.0", ""]], |
| 1475 |
"type": "list", |
| 1476 |
"multiple_values": True, |
| 1477 |
"elements": "str", |
| 1478 |
}, |
| 1479 |
"pingserver_failover_threshold": { |
| 1480 |
"v_range": [["v6.0.0", ""]], |
| 1481 |
"type": "integer", |
| 1482 |
}, |
| 1483 |
"pingserver_secondary_force_reset": { |
| 1484 |
"v_range": [["v6.4.4", "v7.0.12"], ["v7.2.1", ""]], |
| 1485 |
"type": "string", |
| 1486 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1487 |
}, |
| 1488 |
"pingserver_flip_timeout": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1489 |
"vcluster_status": { |
| 1490 |
"v_range": [["v7.2.0", ""]], |
| 1491 |
"type": "string", |
| 1492 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1493 |
}, |
| 1494 |
"vcluster": { |
| 1495 |
"type": "list", |
| 1496 |
"elements": "dict", |
| 1497 |
"children": { |
| 1498 |
"vcluster_id": { |
| 1499 |
"v_range": [["v7.2.0", ""]], |
| 1500 |
"type": "integer", |
| 1501 |
"required": True, |
| 1502 |
}, |
| 1503 |
"override": { |
| 1504 |
"v_range": [["v7.2.0", ""]], |
| 1505 |
"type": "string", |
| 1506 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1507 |
}, |
| 1508 |
"priority": {"v_range": [["v7.2.0", ""]], "type": "integer"}, |
| 1509 |
"override_wait_time": {"v_range": [["v7.2.0", ""]], "type": "integer"}, |
| 1510 |
"monitor": { |
| 1511 |
"v_range": [["v7.2.0", ""]], |
| 1512 |
"type": "list", |
| 1513 |
"multiple_values": True, |
| 1514 |
"elements": "str", |
| 1515 |
}, |
| 1516 |
"pingserver_monitor_interface": { |
| 1517 |
"v_range": [["v7.2.0", ""]], |
| 1518 |
"type": "list", |
| 1519 |
"multiple_values": True, |
| 1520 |
"elements": "str", |
| 1521 |
}, |
| 1522 |
"pingserver_failover_threshold": { |
| 1523 |
"v_range": [["v7.2.0", ""]], |
| 1524 |
"type": "integer", |
| 1525 |
}, |
| 1526 |
"pingserver_secondary_force_reset": { |
| 1527 |
"v_range": [["v7.2.1", ""]], |
| 1528 |
"type": "string", |
| 1529 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1530 |
}, |
| 1531 |
"pingserver_flip_timeout": { |
| 1532 |
"v_range": [["v7.4.2", ""]], |
| 1533 |
"type": "integer", |
| 1534 |
}, |
| 1535 |
"vdom": { |
| 1536 |
"type": "list", |
| 1537 |
"elements": "dict", |
| 1538 |
"children": { |
| 1539 |
"name": { |
| 1540 |
"v_range": [["v7.2.0", ""]], |
| 1541 |
"type": "string", |
| 1542 |
"required": True, |
| 1543 |
} |
| 1544 |
}, |
| 1545 |
"v_range": [["v7.2.0", ""]], |
| 1546 |
}, |
| 1547 |
"pingserver_slave_force_reset": { |
| 1548 |
"v_range": [["v7.2.0", "v7.2.0"]], |
| 1549 |
"type": "string", |
| 1550 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1551 |
}, |
| 1552 |
}, |
| 1553 |
"v_range": [["v7.2.0", ""]], |
| 1554 |
}, |
| 1555 |
"ha_direct": { |
| 1556 |
"v_range": [["v6.0.0", ""]], |
| 1557 |
"type": "string", |
| 1558 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1559 |
}, |
| 1560 |
"ssd_failover": { |
| 1561 |
"v_range": [["v6.2.0", "v7.4.1"], ["v7.4.3", ""]], |
| 1562 |
"type": "string", |
| 1563 |
"options": [ |
| 1564 |
{"value": "enable", "v_range": [["v6.2.0", ""]]}, |
| 1565 |
{"value": "disable", "v_range": [["v6.2.0", ""]]}, |
| 1566 |
], |
| 1567 |
}, |
| 1568 |
"memory_compatible_mode": { |
| 1569 |
"v_range": [["v6.0.0", ""]], |
| 1570 |
"type": "string", |
| 1571 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1572 |
}, |
| 1573 |
"memory_based_failover": { |
| 1574 |
"v_range": [["v7.0.0", ""]], |
| 1575 |
"type": "string", |
| 1576 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1577 |
}, |
| 1578 |
"memory_failover_threshold": {"v_range": [["v7.0.0", ""]], "type": "integer"}, |
| 1579 |
"memory_failover_monitor_period": { |
| 1580 |
"v_range": [["v7.0.0", ""]], |
| 1581 |
"type": "integer", |
| 1582 |
}, |
| 1583 |
"memory_failover_sample_rate": {"v_range": [["v7.0.0", ""]], "type": "integer"}, |
| 1584 |
"memory_failover_flip_timeout": { |
| 1585 |
"v_range": [["v7.0.0", ""]], |
| 1586 |
"type": "integer", |
| 1587 |
}, |
| 1588 |
"failover_hold_time": {"v_range": [["v7.0.0", ""]], "type": "integer"}, |
| 1589 |
"check_secondary_dev_health": { |
| 1590 |
"v_range": [["v7.6.0", ""]], |
| 1591 |
"type": "string", |
| 1592 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1593 |
}, |
| 1594 |
"ipsec_phase2_proposal": { |
| 1595 |
"v_range": [["v7.4.2", ""]], |
| 1596 |
"type": "list", |
| 1597 |
"options": [ |
| 1598 |
{"value": "aes128-sha1"}, |
| 1599 |
{"value": "aes128-sha256"}, |
| 1600 |
{"value": "aes128-sha384"}, |
| 1601 |
{"value": "aes128-sha512"}, |
| 1602 |
{"value": "aes192-sha1"}, |
| 1603 |
{"value": "aes192-sha256"}, |
| 1604 |
{"value": "aes192-sha384"}, |
| 1605 |
{"value": "aes192-sha512"}, |
| 1606 |
{"value": "aes256-sha1"}, |
| 1607 |
{"value": "aes256-sha256"}, |
| 1608 |
{"value": "aes256-sha384"}, |
| 1609 |
{"value": "aes256-sha512"}, |
| 1610 |
{"value": "aes128gcm"}, |
| 1611 |
{"value": "aes256gcm"}, |
| 1612 |
{"value": "chacha20poly1305"}, |
| 1613 |
], |
| 1614 |
"multiple_values": True, |
| 1615 |
"elements": "str", |
| 1616 |
}, |
| 1617 |
"bounce_intf_upon_failover": { |
| 1618 |
"v_range": [["v7.6.4", ""]], |
| 1619 |
"type": "string", |
| 1620 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1621 |
}, |
| 1622 |
"unicast_hb": { |
| 1623 |
"v_range": [], |
| 1624 |
"type": "string", |
| 1625 |
"options": [ |
| 1626 |
{ |
| 1627 |
"value": "enable", |
| 1628 |
"v_range": [ |
| 1629 |
["v7.0.0", "v7.0.12"], |
| 1630 |
["v7.2.1", "v7.2.2"], |
| 1631 |
["v7.4.0", "v7.6.1"], |
| 1632 |
], |
| 1633 |
}, |
| 1634 |
{ |
| 1635 |
"value": "disable", |
| 1636 |
"v_range": [ |
| 1637 |
["v7.0.0", "v7.0.12"], |
| 1638 |
["v7.2.1", "v7.2.2"], |
| 1639 |
["v7.4.0", "v7.6.1"], |
| 1640 |
], |
| 1641 |
}, |
| 1642 |
], |
| 1643 |
}, |
| 1644 |
"unicast_hb_peerip": {"v_range": [], "type": "string"}, |
| 1645 |
"unicast_hb_netmask": {"v_range": [], "type": "string"}, |
| 1646 |
"unicast_status": { |
| 1647 |
"v_range": [], |
| 1648 |
"type": "string", |
| 1649 |
"options": [ |
| 1650 |
{ |
| 1651 |
"value": "enable", |
| 1652 |
"v_range": [ |
| 1653 |
["v7.0.0", "v7.0.12"], |
| 1654 |
["v7.2.1", "v7.2.2"], |
| 1655 |
["v7.4.0", "v7.6.1"], |
| 1656 |
], |
| 1657 |
}, |
| 1658 |
{ |
| 1659 |
"value": "disable", |
| 1660 |
"v_range": [ |
| 1661 |
["v7.0.0", "v7.0.12"], |
| 1662 |
["v7.2.1", "v7.2.2"], |
| 1663 |
["v7.4.0", "v7.6.1"], |
| 1664 |
], |
| 1665 |
}, |
| 1666 |
], |
| 1667 |
}, |
| 1668 |
"unicast_gateway": {"v_range": [], "type": "string"}, |
| 1669 |
"unicast_peers": { |
| 1670 |
"type": "list", |
| 1671 |
"elements": "dict", |
| 1672 |
"children": { |
| 1673 |
"id": { |
| 1674 |
"v_range": [ |
| 1675 |
["v7.0.0", "v7.0.12"], |
| 1676 |
["v7.2.1", "v7.2.2"], |
| 1677 |
["v7.4.0", "v7.6.1"], |
| 1678 |
], |
| 1679 |
"type": "integer", |
| 1680 |
"required": True, |
| 1681 |
}, |
| 1682 |
"peer_ip": { |
| 1683 |
"v_range": [ |
| 1684 |
["v7.0.0", "v7.0.12"], |
| 1685 |
["v7.2.1", "v7.2.2"], |
| 1686 |
["v7.4.0", "v7.6.1"], |
| 1687 |
], |
| 1688 |
"type": "string", |
| 1689 |
}, |
| 1690 |
}, |
| 1691 |
"v_range": [], |
| 1692 |
}, |
| 1693 |
"logical_sn": { |
| 1694 |
"v_range": [["v6.2.0", "v7.6.0"]], |
| 1695 |
"type": "string", |
| 1696 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1697 |
}, |
| 1698 |
"uninterruptible_upgrade": { |
| 1699 |
"v_range": [["v6.0.0", "v7.4.0"]], |
| 1700 |
"type": "string", |
| 1701 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1702 |
}, |
| 1703 |
"pingserver_slave_force_reset": { |
| 1704 |
"v_range": [["v6.0.0", "v6.4.1"], ["v7.2.0", "v7.2.0"]], |
| 1705 |
"type": "string", |
| 1706 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1707 |
}, |
| 1708 |
"vdom": {"v_range": [["v6.0.0", "v7.0.12"]], "type": "string"}, |
| 1709 |
"vcluster2": { |
| 1710 |
"v_range": [["v6.0.0", "v7.0.12"]], |
| 1711 |
"type": "string", |
| 1712 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1713 |
}, |
| 1714 |
"secondary_vcluster": { |
| 1715 |
"v_range": [["v6.0.0", "v7.0.12"]], |
| 1716 |
"type": "dict", |
| 1717 |
"children": { |
| 1718 |
"override": { |
| 1719 |
"v_range": [["v6.0.0", "v7.0.12"]], |
| 1720 |
"type": "string", |
| 1721 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1722 |
}, |
| 1723 |
"priority": {"v_range": [["v6.0.0", "v7.0.12"]], "type": "integer"}, |
| 1724 |
"override_wait_time": { |
| 1725 |
"v_range": [["v6.0.0", "v7.0.12"]], |
| 1726 |
"type": "integer", |
| 1727 |
}, |
| 1728 |
"monitor": { |
| 1729 |
"v_range": [["v6.0.0", "v7.0.12"]], |
| 1730 |
"type": "list", |
| 1731 |
"multiple_values": True, |
| 1732 |
"elements": "str", |
| 1733 |
}, |
| 1734 |
"pingserver_monitor_interface": { |
| 1735 |
"v_range": [["v6.0.0", "v7.0.12"]], |
| 1736 |
"type": "list", |
| 1737 |
"multiple_values": True, |
| 1738 |
"elements": "str", |
| 1739 |
}, |
| 1740 |
"pingserver_failover_threshold": { |
| 1741 |
"v_range": [["v6.0.0", "v7.0.12"]], |
| 1742 |
"type": "integer", |
| 1743 |
}, |
| 1744 |
"pingserver_secondary_force_reset": { |
| 1745 |
"v_range": [["v6.4.4", "v7.0.12"]], |
| 1746 |
"type": "string", |
| 1747 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1748 |
}, |
| 1749 |
"vdom": {"v_range": [["v6.0.0", "v7.0.12"]], "type": "string"}, |
| 1750 |
"vcluster_id": {"v_range": [["v6.0.0", "v7.0.5"]], "type": "integer"}, |
| 1751 |
"pingserver_slave_force_reset": { |
| 1752 |
"v_range": [["v6.0.0", "v6.4.1"]], |
| 1753 |
"type": "string", |
| 1754 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1755 |
}, |
| 1756 |
}, |
| 1757 |
}, |
| 1758 |
"vcluster_id": {"v_range": [["v6.0.0", "v7.0.5"]], "type": "integer"}, |
| 1759 |
"inter_cluster_session_sync": { |
| 1760 |
"v_range": [["v6.0.0", "v6.2.7"]], |
| 1761 |
"type": "string", |
| 1762 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1763 |
}, |
| 1764 |
}, |
| 1765 |
} |
| 1766 |
|
| 1767 |
|
| 1768 |
def main(): |
| 1769 |
module_spec = schema_to_module_spec(versioned_schema) |
| 1770 |
mkeyname = None |
| 1771 |
fields = { |
| 1772 |
"access_token": {"required": False, "type": "str", "no_log": True}, |
| 1773 |
"enable_log": {"required": False, "type": "bool", "default": False}, |
| 1774 |
"vdom": {"required": False, "type": "str", "default": "root"}, |
| 1775 |
"member_path": {"required": False, "type": "str"}, |
| 1776 |
"member_state": { |
| 1777 |
"type": "str", |
| 1778 |
"required": False, |
| 1779 |
"choices": ["present", "absent"], |
| 1780 |
}, |
| 1781 |
"system_ha": { |
| 1782 |
"required": False, |
| 1783 |
"type": "dict", |
| 1784 |
"default": None, |
| 1785 |
"options": {}, |
| 1786 |
}, |
| 1787 |
} |
| 1788 |
for attribute_name in module_spec["options"]: |
| 1789 |
fields["system_ha"]["options"][attribute_name] = module_spec["options"][ |
| 1790 |
attribute_name |
| 1791 |
] |
| 1792 |
if mkeyname and mkeyname == attribute_name: |
| 1793 |
fields["system_ha"]["options"][attribute_name]["required"] = True |
| 1794 |
|
| 1795 |
module = AnsibleModule(argument_spec=fields, supports_check_mode=True) |
| 1796 |
check_legacy_fortiosapi(module) |
| 1797 |
|
| 1798 |
is_error = False |
| 1799 |
has_changed = False |
| 1800 |
result = None |
| 1801 |
diff = None |
| 1802 |
|
| 1803 |
versions_check_result = None |
| 1804 |
if module._socket_path: |
| 1805 |
connection = Connection(module._socket_path) |
| 1806 |
if "access_token" in module.params: |
| 1807 |
connection.set_custom_option("access_token", module.params["access_token"]) |
| 1808 |
|
| 1809 |
if "enable_log" in module.params: |
| 1810 |
connection.set_custom_option("enable_log", module.params["enable_log"]) |
| 1811 |
else: |
| 1812 |
connection.set_custom_option("enable_log", False) |
| 1813 |
fos = FortiOSHandler(connection, module, mkeyname, admin_passwd_header=False) |
| 1814 |
versions_check_result = check_schema_versioning( |
| 1815 |
fos, versioned_schema, "system_ha" |
| 1816 |
) |
| 1817 |
|
| 1818 |
is_error, has_changed, result, diff = fortios_system( |
| 1819 |
module.params, fos, module.check_mode |
| 1820 |
) |
| 1821 |
|
| 1822 |
else: |
| 1823 |
module.fail_json(**FAIL_SOCKET_MSG) |
| 1824 |
|
| 1825 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1826 |
module.warn( |
| 1827 |
"Ansible has detected version mismatch between FortOS system and your playbook, see more details by specifying option -vvv" |
| 1828 |
) |
| 1829 |
|
| 1830 |
if not is_error: |
| 1831 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1832 |
module.exit_json( |
| 1833 |
changed=has_changed, |
| 1834 |
version_check_warning=versions_check_result, |
| 1835 |
meta=result, |
| 1836 |
diff=diff, |
| 1837 |
) |
| 1838 |
else: |
| 1839 |
module.exit_json(changed=has_changed, meta=result, diff=diff) |
| 1840 |
else: |
| 1841 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1842 |
module.fail_json( |
| 1843 |
msg="Error in repo", |
| 1844 |
version_check_warning=versions_check_result, |
| 1845 |
meta=result, |
| 1846 |
) |
| 1847 |
else: |
| 1848 |
module.fail_json(msg="Error in repo", meta=result) |
| 1849 |
|
| 1850 |
|
| 1851 |
if __name__ == "__main__": |
| 1852 |
main() |