| 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_accprofile |
| 23 |
short_description: Configure access profiles for system administrators 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 accprofile 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 |
state: |
| 80 |
description: |
| 81 |
- Indicates whether to create or remove the object. |
| 82 |
type: str |
| 83 |
required: true |
| 84 |
choices: |
| 85 |
- 'present' |
| 86 |
- 'absent' |
| 87 |
system_accprofile: |
| 88 |
description: |
| 89 |
- Configure access profiles for system administrators. |
| 90 |
default: null |
| 91 |
type: dict |
| 92 |
suboptions: |
| 93 |
admintimeout: |
| 94 |
description: |
| 95 |
- Administrator timeout for this access profile (0 - 480 min). |
| 96 |
type: int |
| 97 |
admintimeout_override: |
| 98 |
description: |
| 99 |
- Enable/disable overriding the global administrator idle timeout. |
| 100 |
type: str |
| 101 |
choices: |
| 102 |
- 'enable' |
| 103 |
- 'disable' |
| 104 |
authgrp: |
| 105 |
description: |
| 106 |
- Administrator access to Users and Devices. |
| 107 |
type: str |
| 108 |
choices: |
| 109 |
- 'none' |
| 110 |
- 'read' |
| 111 |
- 'read-write' |
| 112 |
cli_config: |
| 113 |
description: |
| 114 |
- Enable/disable permission to run config commands. |
| 115 |
type: str |
| 116 |
choices: |
| 117 |
- 'enable' |
| 118 |
- 'disable' |
| 119 |
cli_diagnose: |
| 120 |
description: |
| 121 |
- Enable/disable permission to run diagnostic commands. |
| 122 |
type: str |
| 123 |
choices: |
| 124 |
- 'enable' |
| 125 |
- 'disable' |
| 126 |
cli_exec: |
| 127 |
description: |
| 128 |
- Enable/disable permission to run execute commands. |
| 129 |
type: str |
| 130 |
choices: |
| 131 |
- 'enable' |
| 132 |
- 'disable' |
| 133 |
cli_get: |
| 134 |
description: |
| 135 |
- Enable/disable permission to run get commands. |
| 136 |
type: str |
| 137 |
choices: |
| 138 |
- 'enable' |
| 139 |
- 'disable' |
| 140 |
cli_show: |
| 141 |
description: |
| 142 |
- Enable/disable permission to run show commands. |
| 143 |
type: str |
| 144 |
choices: |
| 145 |
- 'enable' |
| 146 |
- 'disable' |
| 147 |
comments: |
| 148 |
description: |
| 149 |
- Comment. |
| 150 |
type: str |
| 151 |
ftviewgrp: |
| 152 |
description: |
| 153 |
- FortiView. |
| 154 |
type: str |
| 155 |
choices: |
| 156 |
- 'none' |
| 157 |
- 'read' |
| 158 |
- 'read-write' |
| 159 |
fwgrp: |
| 160 |
description: |
| 161 |
- Administrator access to the Firewall configuration. |
| 162 |
type: str |
| 163 |
choices: |
| 164 |
- 'none' |
| 165 |
- 'read' |
| 166 |
- 'read-write' |
| 167 |
- 'custom' |
| 168 |
fwgrp_permission: |
| 169 |
description: |
| 170 |
- Custom firewall permission. |
| 171 |
type: dict |
| 172 |
suboptions: |
| 173 |
address: |
| 174 |
description: |
| 175 |
- Address Configuration. |
| 176 |
type: str |
| 177 |
choices: |
| 178 |
- 'none' |
| 179 |
- 'read' |
| 180 |
- 'read-write' |
| 181 |
others: |
| 182 |
description: |
| 183 |
- Other Firewall Configuration. |
| 184 |
type: str |
| 185 |
choices: |
| 186 |
- 'none' |
| 187 |
- 'read' |
| 188 |
- 'read-write' |
| 189 |
policy: |
| 190 |
description: |
| 191 |
- Policy Configuration. |
| 192 |
type: str |
| 193 |
choices: |
| 194 |
- 'none' |
| 195 |
- 'read' |
| 196 |
- 'read-write' |
| 197 |
schedule: |
| 198 |
description: |
| 199 |
- Schedule Configuration. |
| 200 |
type: str |
| 201 |
choices: |
| 202 |
- 'none' |
| 203 |
- 'read' |
| 204 |
- 'read-write' |
| 205 |
service: |
| 206 |
description: |
| 207 |
- Service Configuration. |
| 208 |
type: str |
| 209 |
choices: |
| 210 |
- 'none' |
| 211 |
- 'read' |
| 212 |
- 'read-write' |
| 213 |
loggrp: |
| 214 |
description: |
| 215 |
- Administrator access to Logging and Reporting including viewing log messages. |
| 216 |
type: str |
| 217 |
choices: |
| 218 |
- 'none' |
| 219 |
- 'read' |
| 220 |
- 'read-write' |
| 221 |
- 'custom' |
| 222 |
loggrp_permission: |
| 223 |
description: |
| 224 |
- Custom Log & Report permission. |
| 225 |
type: dict |
| 226 |
suboptions: |
| 227 |
config: |
| 228 |
description: |
| 229 |
- Log & Report configuration. |
| 230 |
type: str |
| 231 |
choices: |
| 232 |
- 'none' |
| 233 |
- 'read' |
| 234 |
- 'read-write' |
| 235 |
data_access: |
| 236 |
description: |
| 237 |
- Log & Report Data Access. |
| 238 |
type: str |
| 239 |
choices: |
| 240 |
- 'none' |
| 241 |
- 'read' |
| 242 |
- 'read-write' |
| 243 |
report_access: |
| 244 |
description: |
| 245 |
- Log & Report Report Access. |
| 246 |
type: str |
| 247 |
choices: |
| 248 |
- 'none' |
| 249 |
- 'read' |
| 250 |
- 'read-write' |
| 251 |
threat_weight: |
| 252 |
description: |
| 253 |
- Log & Report Threat Weight. |
| 254 |
type: str |
| 255 |
choices: |
| 256 |
- 'none' |
| 257 |
- 'read' |
| 258 |
- 'read-write' |
| 259 |
name: |
| 260 |
description: |
| 261 |
- Profile name. |
| 262 |
required: true |
| 263 |
type: str |
| 264 |
netgrp: |
| 265 |
description: |
| 266 |
- Network Configuration. |
| 267 |
type: str |
| 268 |
choices: |
| 269 |
- 'none' |
| 270 |
- 'read' |
| 271 |
- 'read-write' |
| 272 |
- 'custom' |
| 273 |
netgrp_permission: |
| 274 |
description: |
| 275 |
- Custom network permission. |
| 276 |
type: dict |
| 277 |
suboptions: |
| 278 |
cfg: |
| 279 |
description: |
| 280 |
- Network Configuration. |
| 281 |
type: str |
| 282 |
choices: |
| 283 |
- 'none' |
| 284 |
- 'read' |
| 285 |
- 'read-write' |
| 286 |
packet_capture: |
| 287 |
description: |
| 288 |
- Packet Capture Configuration. |
| 289 |
type: str |
| 290 |
choices: |
| 291 |
- 'none' |
| 292 |
- 'read' |
| 293 |
- 'read-write' |
| 294 |
route_cfg: |
| 295 |
description: |
| 296 |
- Router Configuration. |
| 297 |
type: str |
| 298 |
choices: |
| 299 |
- 'none' |
| 300 |
- 'read' |
| 301 |
- 'read-write' |
| 302 |
scope: |
| 303 |
description: |
| 304 |
- 'Scope of admin access: global or specific VDOM(s).' |
| 305 |
type: str |
| 306 |
choices: |
| 307 |
- 'vdom' |
| 308 |
- 'global' |
| 309 |
secfabgrp: |
| 310 |
description: |
| 311 |
- Security Fabric. |
| 312 |
type: str |
| 313 |
choices: |
| 314 |
- 'none' |
| 315 |
- 'read' |
| 316 |
- 'read-write' |
| 317 |
- 'custom' |
| 318 |
secfabgrp_permission: |
| 319 |
description: |
| 320 |
- Custom Security Fabric permissions. |
| 321 |
type: dict |
| 322 |
suboptions: |
| 323 |
csffoo: |
| 324 |
description: |
| 325 |
- Fabric Overlay Orchestrator profiles and settings. |
| 326 |
type: str |
| 327 |
choices: |
| 328 |
- 'none' |
| 329 |
- 'read' |
| 330 |
- 'read-write' |
| 331 |
csfsys: |
| 332 |
description: |
| 333 |
- Security Fabric system profiles and settings. |
| 334 |
type: str |
| 335 |
choices: |
| 336 |
- 'none' |
| 337 |
- 'read' |
| 338 |
- 'read-write' |
| 339 |
mmsgtp: |
| 340 |
description: |
| 341 |
- UTM permission. |
| 342 |
type: str |
| 343 |
choices: |
| 344 |
- 'none' |
| 345 |
- 'read' |
| 346 |
- 'read-write' |
| 347 |
sysgrp: |
| 348 |
description: |
| 349 |
- System Configuration. |
| 350 |
type: str |
| 351 |
choices: |
| 352 |
- 'none' |
| 353 |
- 'read' |
| 354 |
- 'read-write' |
| 355 |
- 'custom' |
| 356 |
sysgrp_permission: |
| 357 |
description: |
| 358 |
- Custom system permission. |
| 359 |
type: dict |
| 360 |
suboptions: |
| 361 |
admin: |
| 362 |
description: |
| 363 |
- Administrator Users. |
| 364 |
type: str |
| 365 |
choices: |
| 366 |
- 'none' |
| 367 |
- 'read' |
| 368 |
- 'read-write' |
| 369 |
cfg: |
| 370 |
description: |
| 371 |
- System Configuration. |
| 372 |
type: str |
| 373 |
choices: |
| 374 |
- 'none' |
| 375 |
- 'read' |
| 376 |
- 'read-write' |
| 377 |
mnt: |
| 378 |
description: |
| 379 |
- Maintenance. |
| 380 |
type: str |
| 381 |
choices: |
| 382 |
- 'none' |
| 383 |
- 'read' |
| 384 |
- 'read-write' |
| 385 |
upd: |
| 386 |
description: |
| 387 |
- FortiGuard Updates. |
| 388 |
type: str |
| 389 |
choices: |
| 390 |
- 'none' |
| 391 |
- 'read' |
| 392 |
- 'read-write' |
| 393 |
system_diagnostics: |
| 394 |
description: |
| 395 |
- Enable/disable permission to run system diagnostic commands. |
| 396 |
type: str |
| 397 |
choices: |
| 398 |
- 'enable' |
| 399 |
- 'disable' |
| 400 |
system_execute_ssh: |
| 401 |
description: |
| 402 |
- Enable/disable permission to execute SSH commands. |
| 403 |
type: str |
| 404 |
choices: |
| 405 |
- 'enable' |
| 406 |
- 'disable' |
| 407 |
system_execute_telnet: |
| 408 |
description: |
| 409 |
- Enable/disable permission to execute TELNET commands. |
| 410 |
type: str |
| 411 |
choices: |
| 412 |
- 'enable' |
| 413 |
- 'disable' |
| 414 |
utmgrp: |
| 415 |
description: |
| 416 |
- Administrator access to Security Profiles. |
| 417 |
type: str |
| 418 |
choices: |
| 419 |
- 'none' |
| 420 |
- 'read' |
| 421 |
- 'read-write' |
| 422 |
- 'custom' |
| 423 |
utmgrp_permission: |
| 424 |
description: |
| 425 |
- Custom Security Profile permissions. |
| 426 |
type: dict |
| 427 |
suboptions: |
| 428 |
antivirus: |
| 429 |
description: |
| 430 |
- Antivirus profiles and settings. |
| 431 |
type: str |
| 432 |
choices: |
| 433 |
- 'none' |
| 434 |
- 'read' |
| 435 |
- 'read-write' |
| 436 |
application_control: |
| 437 |
description: |
| 438 |
- Application Control profiles and settings. |
| 439 |
type: str |
| 440 |
choices: |
| 441 |
- 'none' |
| 442 |
- 'read' |
| 443 |
- 'read-write' |
| 444 |
casb: |
| 445 |
description: |
| 446 |
- Inline CASB filter profile and settings |
| 447 |
type: str |
| 448 |
choices: |
| 449 |
- 'none' |
| 450 |
- 'read' |
| 451 |
- 'read-write' |
| 452 |
data_leak_prevention: |
| 453 |
description: |
| 454 |
- DLP profiles and settings. |
| 455 |
type: str |
| 456 |
choices: |
| 457 |
- 'none' |
| 458 |
- 'read' |
| 459 |
- 'read-write' |
| 460 |
data_loss_prevention: |
| 461 |
description: |
| 462 |
- DLP profiles and settings. |
| 463 |
type: str |
| 464 |
choices: |
| 465 |
- 'none' |
| 466 |
- 'read' |
| 467 |
- 'read-write' |
| 468 |
dlp: |
| 469 |
description: |
| 470 |
- DLP profiles and settings. |
| 471 |
type: str |
| 472 |
choices: |
| 473 |
- 'none' |
| 474 |
- 'read' |
| 475 |
- 'read-write' |
| 476 |
dnsfilter: |
| 477 |
description: |
| 478 |
- DNS Filter profiles and settings. |
| 479 |
type: str |
| 480 |
choices: |
| 481 |
- 'none' |
| 482 |
- 'read' |
| 483 |
- 'read-write' |
| 484 |
emailfilter: |
| 485 |
description: |
| 486 |
- Email Filter and settings. |
| 487 |
type: str |
| 488 |
choices: |
| 489 |
- 'none' |
| 490 |
- 'read' |
| 491 |
- 'read-write' |
| 492 |
endpoint_control: |
| 493 |
description: |
| 494 |
- FortiClient Profiles. |
| 495 |
type: str |
| 496 |
choices: |
| 497 |
- 'none' |
| 498 |
- 'read' |
| 499 |
- 'read-write' |
| 500 |
file_filter: |
| 501 |
description: |
| 502 |
- File-filter profiles and settings. |
| 503 |
type: str |
| 504 |
choices: |
| 505 |
- 'none' |
| 506 |
- 'read' |
| 507 |
- 'read-write' |
| 508 |
icap: |
| 509 |
description: |
| 510 |
- ICAP profiles and settings. |
| 511 |
type: str |
| 512 |
choices: |
| 513 |
- 'none' |
| 514 |
- 'read' |
| 515 |
- 'read-write' |
| 516 |
ips: |
| 517 |
description: |
| 518 |
- IPS profiles and settings. |
| 519 |
type: str |
| 520 |
choices: |
| 521 |
- 'none' |
| 522 |
- 'read' |
| 523 |
- 'read-write' |
| 524 |
mmsgtp: |
| 525 |
description: |
| 526 |
- UTM permission. |
| 527 |
type: str |
| 528 |
choices: |
| 529 |
- 'none' |
| 530 |
- 'read' |
| 531 |
- 'read-write' |
| 532 |
spamfilter: |
| 533 |
description: |
| 534 |
- AntiSpam filter and settings. |
| 535 |
type: str |
| 536 |
choices: |
| 537 |
- 'none' |
| 538 |
- 'read' |
| 539 |
- 'read-write' |
| 540 |
telemetry: |
| 541 |
description: |
| 542 |
- Telemetry profile and settings. |
| 543 |
type: str |
| 544 |
choices: |
| 545 |
- 'none' |
| 546 |
- 'read' |
| 547 |
- 'read-write' |
| 548 |
videofilter: |
| 549 |
description: |
| 550 |
- Video filter profiles and settings. |
| 551 |
type: str |
| 552 |
choices: |
| 553 |
- 'none' |
| 554 |
- 'read' |
| 555 |
- 'read-write' |
| 556 |
virtual_patch: |
| 557 |
description: |
| 558 |
- Virtual patch profiles and settings. |
| 559 |
type: str |
| 560 |
choices: |
| 561 |
- 'none' |
| 562 |
- 'read' |
| 563 |
- 'read-write' |
| 564 |
voip: |
| 565 |
description: |
| 566 |
- VoIP profiles and settings. |
| 567 |
type: str |
| 568 |
choices: |
| 569 |
- 'none' |
| 570 |
- 'read' |
| 571 |
- 'read-write' |
| 572 |
waf: |
| 573 |
description: |
| 574 |
- Web Application Firewall profiles and settings. |
| 575 |
type: str |
| 576 |
choices: |
| 577 |
- 'none' |
| 578 |
- 'read' |
| 579 |
- 'read-write' |
| 580 |
webfilter: |
| 581 |
description: |
| 582 |
- Web Filter profiles and settings. |
| 583 |
type: str |
| 584 |
choices: |
| 585 |
- 'none' |
| 586 |
- 'read' |
| 587 |
- 'read-write' |
| 588 |
vpngrp: |
| 589 |
description: |
| 590 |
- Administrator access to IPsec, SSL, PPTP, and L2TP VPN. |
| 591 |
type: str |
| 592 |
choices: |
| 593 |
- 'none' |
| 594 |
- 'read' |
| 595 |
- 'read-write' |
| 596 |
wanoptgrp: |
| 597 |
description: |
| 598 |
- Administrator access to WAN Opt & Cache. |
| 599 |
type: str |
| 600 |
choices: |
| 601 |
- 'none' |
| 602 |
- 'read' |
| 603 |
- 'read-write' |
| 604 |
wifi: |
| 605 |
description: |
| 606 |
- Administrator access to the WiFi controller and Switch controller. |
| 607 |
type: str |
| 608 |
choices: |
| 609 |
- 'none' |
| 610 |
- 'read' |
| 611 |
- 'read-write' |
| 612 |
""" |
| 613 |
|
| 614 |
EXAMPLES = """ |
| 615 |
- name: Configure access profiles for system administrators. |
| 616 |
fortinet.fortios.fortios_system_accprofile: |
| 617 |
vdom: "{{ vdom }}" |
| 618 |
state: "present" |
| 619 |
access_token: "<your_own_value>" |
| 620 |
system_accprofile: |
| 621 |
admintimeout: "10" |
| 622 |
admintimeout_override: "enable" |
| 623 |
authgrp: "none" |
| 624 |
cli_config: "enable" |
| 625 |
cli_diagnose: "enable" |
| 626 |
cli_exec: "enable" |
| 627 |
cli_get: "enable" |
| 628 |
cli_show: "enable" |
| 629 |
comments: "<your_own_value>" |
| 630 |
ftviewgrp: "none" |
| 631 |
fwgrp: "none" |
| 632 |
fwgrp_permission: |
| 633 |
address: "none" |
| 634 |
others: "none" |
| 635 |
policy: "none" |
| 636 |
schedule: "none" |
| 637 |
service: "none" |
| 638 |
loggrp: "none" |
| 639 |
loggrp_permission: |
| 640 |
config: "none" |
| 641 |
data_access: "none" |
| 642 |
report_access: "none" |
| 643 |
threat_weight: "none" |
| 644 |
name: "default_name_26" |
| 645 |
netgrp: "none" |
| 646 |
netgrp_permission: |
| 647 |
cfg: "none" |
| 648 |
packet_capture: "none" |
| 649 |
route_cfg: "none" |
| 650 |
scope: "vdom" |
| 651 |
secfabgrp: "none" |
| 652 |
secfabgrp_permission: |
| 653 |
csffoo: "none" |
| 654 |
csfsys: "none" |
| 655 |
mmsgtp: "none" |
| 656 |
sysgrp: "none" |
| 657 |
sysgrp_permission: |
| 658 |
admin: "none" |
| 659 |
cfg: "none" |
| 660 |
mnt: "none" |
| 661 |
upd: "none" |
| 662 |
system_diagnostics: "enable" |
| 663 |
system_execute_ssh: "enable" |
| 664 |
system_execute_telnet: "enable" |
| 665 |
utmgrp: "none" |
| 666 |
utmgrp_permission: |
| 667 |
antivirus: "none" |
| 668 |
application_control: "none" |
| 669 |
casb: "none" |
| 670 |
data_leak_prevention: "none" |
| 671 |
data_loss_prevention: "none" |
| 672 |
dlp: "none" |
| 673 |
dnsfilter: "none" |
| 674 |
emailfilter: "none" |
| 675 |
endpoint_control: "none" |
| 676 |
file_filter: "none" |
| 677 |
icap: "none" |
| 678 |
ips: "none" |
| 679 |
mmsgtp: "none" |
| 680 |
spamfilter: "none" |
| 681 |
telemetry: "none" |
| 682 |
videofilter: "none" |
| 683 |
virtual_patch: "none" |
| 684 |
voip: "none" |
| 685 |
waf: "none" |
| 686 |
webfilter: "none" |
| 687 |
vpngrp: "none" |
| 688 |
wanoptgrp: "none" |
| 689 |
wifi: "none" |
| 690 |
""" |
| 691 |
|
| 692 |
RETURN = """ |
| 693 |
build: |
| 694 |
description: Build number of the fortigate image |
| 695 |
returned: always |
| 696 |
type: str |
| 697 |
sample: '1547' |
| 698 |
http_method: |
| 699 |
description: Last method used to provision the content into FortiGate |
| 700 |
returned: always |
| 701 |
type: str |
| 702 |
sample: 'PUT' |
| 703 |
http_status: |
| 704 |
description: Last result given by FortiGate on last operation applied |
| 705 |
returned: always |
| 706 |
type: str |
| 707 |
sample: "200" |
| 708 |
mkey: |
| 709 |
description: Master key (id) used in the last call to FortiGate |
| 710 |
returned: success |
| 711 |
type: str |
| 712 |
sample: "id" |
| 713 |
name: |
| 714 |
description: Name of the table used to fulfill the request |
| 715 |
returned: always |
| 716 |
type: str |
| 717 |
sample: "urlfilter" |
| 718 |
path: |
| 719 |
description: Path of the table used to fulfill the request |
| 720 |
returned: always |
| 721 |
type: str |
| 722 |
sample: "webfilter" |
| 723 |
revision: |
| 724 |
description: Internal revision number |
| 725 |
returned: always |
| 726 |
type: str |
| 727 |
sample: "17.0.2.10658" |
| 728 |
serial: |
| 729 |
description: Serial number of the unit |
| 730 |
returned: always |
| 731 |
type: str |
| 732 |
sample: "FGVMEVYYQT3AB5352" |
| 733 |
status: |
| 734 |
description: Indication of the operation's result |
| 735 |
returned: always |
| 736 |
type: str |
| 737 |
sample: "success" |
| 738 |
vdom: |
| 739 |
description: Virtual domain used |
| 740 |
returned: always |
| 741 |
type: str |
| 742 |
sample: "root" |
| 743 |
version: |
| 744 |
description: Version of the FortiGate |
| 745 |
returned: always |
| 746 |
type: str |
| 747 |
sample: "v5.6.3" |
| 748 |
""" |
| 749 |
from ansible.module_utils.basic import AnsibleModule |
| 750 |
from ansible.module_utils.connection import Connection |
| 751 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 752 |
FortiOSHandler, |
| 753 |
) |
| 754 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 755 |
check_legacy_fortiosapi, |
| 756 |
) |
| 757 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 758 |
schema_to_module_spec, |
| 759 |
) |
| 760 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 761 |
check_schema_versioning, |
| 762 |
) |
| 763 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.common import ( |
| 764 |
FAIL_SOCKET_MSG, |
| 765 |
) |
| 766 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.data_post_processor import ( |
| 767 |
remove_invalid_fields, |
| 768 |
) |
| 769 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 770 |
is_same_comparison, |
| 771 |
) |
| 772 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 773 |
serialize, |
| 774 |
) |
| 775 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 776 |
find_current_values, |
| 777 |
) |
| 778 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 779 |
unify_data_format, |
| 780 |
) |
| 781 |
|
| 782 |
|
| 783 |
def filter_system_accprofile_data(json): |
| 784 |
option_list = [ |
| 785 |
"admintimeout", |
| 786 |
"admintimeout_override", |
| 787 |
"authgrp", |
| 788 |
"cli_config", |
| 789 |
"cli_diagnose", |
| 790 |
"cli_exec", |
| 791 |
"cli_get", |
| 792 |
"cli_show", |
| 793 |
"comments", |
| 794 |
"ftviewgrp", |
| 795 |
"fwgrp", |
| 796 |
"fwgrp_permission", |
| 797 |
"loggrp", |
| 798 |
"loggrp_permission", |
| 799 |
"name", |
| 800 |
"netgrp", |
| 801 |
"netgrp_permission", |
| 802 |
"scope", |
| 803 |
"secfabgrp", |
| 804 |
"secfabgrp_permission", |
| 805 |
"sysgrp", |
| 806 |
"sysgrp_permission", |
| 807 |
"system_diagnostics", |
| 808 |
"system_execute_ssh", |
| 809 |
"system_execute_telnet", |
| 810 |
"utmgrp", |
| 811 |
"utmgrp_permission", |
| 812 |
"vpngrp", |
| 813 |
"wanoptgrp", |
| 814 |
"wifi", |
| 815 |
] |
| 816 |
|
| 817 |
json = remove_invalid_fields(json) |
| 818 |
dictionary = {} |
| 819 |
|
| 820 |
for attribute in option_list: |
| 821 |
if attribute in json and json[attribute] is not None: |
| 822 |
dictionary[attribute] = json[attribute] |
| 823 |
|
| 824 |
return dictionary |
| 825 |
|
| 826 |
|
| 827 |
def underscore_to_hyphen(data): |
| 828 |
new_data = None |
| 829 |
if isinstance(data, list): |
| 830 |
new_data = [] |
| 831 |
for i, elem in enumerate(data): |
| 832 |
new_data.append(underscore_to_hyphen(elem)) |
| 833 |
elif isinstance(data, dict): |
| 834 |
new_data = {} |
| 835 |
for k, v in data.items(): |
| 836 |
new_data[k.replace("_", "-")] = underscore_to_hyphen(v) |
| 837 |
else: |
| 838 |
return data |
| 839 |
return new_data |
| 840 |
|
| 841 |
|
| 842 |
def system_accprofile(data, fos, check_mode=False): |
| 843 |
|
| 844 |
state = None |
| 845 |
vdom = data["vdom"] |
| 846 |
parameters = None |
| 847 |
state = data.get("state", None) |
| 848 |
system_accprofile_data = data["system_accprofile"] |
| 849 |
|
| 850 |
filtered_data = filter_system_accprofile_data(system_accprofile_data) |
| 851 |
converted_data = underscore_to_hyphen(filtered_data) |
| 852 |
|
| 853 |
|
| 854 |
if check_mode: |
| 855 |
diff = { |
| 856 |
"before": "", |
| 857 |
"after": filtered_data, |
| 858 |
} |
| 859 |
mkeyname = fos.get_mkeyname(None, None) |
| 860 |
mkey = fos.get_mkey("system", "accprofile", filtered_data, vdom=vdom) |
| 861 |
current_data = fos.get( |
| 862 |
"system", "accprofile", vdom=vdom, mkey=mkey, parameters=parameters |
| 863 |
) |
| 864 |
is_existed = ( |
| 865 |
current_data |
| 866 |
and current_data.get("http_status") == 200 |
| 867 |
and ( |
| 868 |
mkeyname |
| 869 |
and isinstance(current_data.get("results"), list) |
| 870 |
and len(current_data["results"]) > 0 |
| 871 |
or not mkeyname |
| 872 |
and current_data["results"] |
| 873 |
) |
| 874 |
) |
| 875 |
|
| 876 |
|
| 877 |
if state == "present" or state is True or state is None: |
| 878 |
|
| 879 |
if mkeyname is not None and mkey is None: |
| 880 |
return False, True, filtered_data, diff |
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
copied_filtered_data = filtered_data.copy() |
| 885 |
copied_filtered_data.pop(mkeyname, None) |
| 886 |
unified_filtered_data = unify_data_format(copied_filtered_data) |
| 887 |
|
| 888 |
current_data_results = current_data.get("results", {}) |
| 889 |
current_config = ( |
| 890 |
current_data_results[0] |
| 891 |
if mkeyname |
| 892 |
and isinstance(current_data_results, list) |
| 893 |
and len(current_data_results) > 0 |
| 894 |
else current_data_results |
| 895 |
) |
| 896 |
if is_existed: |
| 897 |
unified_current_values = find_current_values( |
| 898 |
unified_filtered_data, |
| 899 |
unify_data_format(current_config), |
| 900 |
) |
| 901 |
|
| 902 |
is_same = is_same_comparison( |
| 903 |
serialize(unified_current_values), serialize(unified_filtered_data) |
| 904 |
) |
| 905 |
|
| 906 |
return ( |
| 907 |
False, |
| 908 |
not is_same, |
| 909 |
filtered_data, |
| 910 |
{"before": unified_current_values, "after": unified_filtered_data}, |
| 911 |
) |
| 912 |
|
| 913 |
|
| 914 |
return False, True, filtered_data, diff |
| 915 |
|
| 916 |
if state == "absent": |
| 917 |
if mkey is None: |
| 918 |
return ( |
| 919 |
False, |
| 920 |
False, |
| 921 |
filtered_data, |
| 922 |
{"before": current_data["results"][0], "after": ""}, |
| 923 |
) |
| 924 |
|
| 925 |
if is_existed: |
| 926 |
return ( |
| 927 |
False, |
| 928 |
True, |
| 929 |
filtered_data, |
| 930 |
{"before": current_data["results"][0], "after": ""}, |
| 931 |
) |
| 932 |
return False, False, filtered_data, {} |
| 933 |
|
| 934 |
return True, False, {"reason: ": "Must provide state parameter"}, {} |
| 935 |
|
| 936 |
|
| 937 |
data_copy = data.copy() |
| 938 |
data_copy["system_accprofile"] = filtered_data |
| 939 |
fos.do_member_operation( |
| 940 |
"system", |
| 941 |
"accprofile", |
| 942 |
data_copy, |
| 943 |
) |
| 944 |
|
| 945 |
if state == "present" or state is True: |
| 946 |
return fos.set( |
| 947 |
"system", |
| 948 |
"accprofile", |
| 949 |
data=converted_data, |
| 950 |
vdom=vdom, |
| 951 |
parameters=parameters, |
| 952 |
) |
| 953 |
|
| 954 |
elif state == "absent": |
| 955 |
return fos.delete( |
| 956 |
"system", |
| 957 |
"accprofile", |
| 958 |
mkey=converted_data["name"], |
| 959 |
vdom=vdom, |
| 960 |
parameters=parameters, |
| 961 |
) |
| 962 |
else: |
| 963 |
fos._module.fail_json(msg="state must be present or absent!") |
| 964 |
|
| 965 |
|
| 966 |
def is_successful_status(resp): |
| 967 |
return ( |
| 968 |
"status" in resp |
| 969 |
and resp["status"] == "success" |
| 970 |
or "http_status" in resp |
| 971 |
and resp["http_status"] == 200 |
| 972 |
or "http_method" in resp |
| 973 |
and resp["http_method"] == "DELETE" |
| 974 |
and resp["http_status"] == 404 |
| 975 |
) |
| 976 |
|
| 977 |
|
| 978 |
def fortios_system(data, fos, check_mode): |
| 979 |
|
| 980 |
if data["system_accprofile"]: |
| 981 |
resp = system_accprofile(data, fos, check_mode) |
| 982 |
else: |
| 983 |
fos._module.fail_json(msg="missing task body: %s" % ("system_accprofile")) |
| 984 |
if isinstance(resp, tuple) and len(resp) == 4: |
| 985 |
return resp |
| 986 |
return ( |
| 987 |
not is_successful_status(resp), |
| 988 |
is_successful_status(resp) |
| 989 |
and (resp["revision_changed"] if "revision_changed" in resp else True), |
| 990 |
resp, |
| 991 |
{}, |
| 992 |
) |
| 993 |
|
| 994 |
|
| 995 |
versioned_schema = { |
| 996 |
"type": "list", |
| 997 |
"elements": "dict", |
| 998 |
"children": { |
| 999 |
"name": {"v_range": [["v6.0.0", ""]], "type": "string", "required": True}, |
| 1000 |
"scope": { |
| 1001 |
"v_range": [["v6.0.0", ""]], |
| 1002 |
"type": "string", |
| 1003 |
"options": [{"value": "vdom"}, {"value": "global"}], |
| 1004 |
}, |
| 1005 |
"comments": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1006 |
"secfabgrp": { |
| 1007 |
"v_range": [["v6.0.0", ""]], |
| 1008 |
"type": "string", |
| 1009 |
"options": [ |
| 1010 |
{"value": "none"}, |
| 1011 |
{"value": "read"}, |
| 1012 |
{"value": "read-write"}, |
| 1013 |
{"value": "custom", "v_range": [["v7.6.5", ""]]}, |
| 1014 |
], |
| 1015 |
}, |
| 1016 |
"ftviewgrp": { |
| 1017 |
"v_range": [["v6.0.0", ""]], |
| 1018 |
"type": "string", |
| 1019 |
"options": [{"value": "none"}, {"value": "read"}, {"value": "read-write"}], |
| 1020 |
}, |
| 1021 |
"authgrp": { |
| 1022 |
"v_range": [["v6.0.0", ""]], |
| 1023 |
"type": "string", |
| 1024 |
"options": [{"value": "none"}, {"value": "read"}, {"value": "read-write"}], |
| 1025 |
}, |
| 1026 |
"sysgrp": { |
| 1027 |
"v_range": [["v6.0.0", ""]], |
| 1028 |
"type": "string", |
| 1029 |
"options": [ |
| 1030 |
{"value": "none"}, |
| 1031 |
{"value": "read"}, |
| 1032 |
{"value": "read-write"}, |
| 1033 |
{"value": "custom"}, |
| 1034 |
], |
| 1035 |
}, |
| 1036 |
"netgrp": { |
| 1037 |
"v_range": [["v6.0.0", ""]], |
| 1038 |
"type": "string", |
| 1039 |
"options": [ |
| 1040 |
{"value": "none"}, |
| 1041 |
{"value": "read"}, |
| 1042 |
{"value": "read-write"}, |
| 1043 |
{"value": "custom"}, |
| 1044 |
], |
| 1045 |
}, |
| 1046 |
"loggrp": { |
| 1047 |
"v_range": [["v6.0.0", ""]], |
| 1048 |
"type": "string", |
| 1049 |
"options": [ |
| 1050 |
{"value": "none"}, |
| 1051 |
{"value": "read"}, |
| 1052 |
{"value": "read-write"}, |
| 1053 |
{"value": "custom"}, |
| 1054 |
], |
| 1055 |
}, |
| 1056 |
"fwgrp": { |
| 1057 |
"v_range": [["v6.0.0", ""]], |
| 1058 |
"type": "string", |
| 1059 |
"options": [ |
| 1060 |
{"value": "none"}, |
| 1061 |
{"value": "read"}, |
| 1062 |
{"value": "read-write"}, |
| 1063 |
{"value": "custom"}, |
| 1064 |
], |
| 1065 |
}, |
| 1066 |
"vpngrp": { |
| 1067 |
"v_range": [["v6.0.0", ""]], |
| 1068 |
"type": "string", |
| 1069 |
"options": [{"value": "none"}, {"value": "read"}, {"value": "read-write"}], |
| 1070 |
}, |
| 1071 |
"utmgrp": { |
| 1072 |
"v_range": [["v6.0.0", ""]], |
| 1073 |
"type": "string", |
| 1074 |
"options": [ |
| 1075 |
{"value": "none"}, |
| 1076 |
{"value": "read"}, |
| 1077 |
{"value": "read-write"}, |
| 1078 |
{"value": "custom"}, |
| 1079 |
], |
| 1080 |
}, |
| 1081 |
"wanoptgrp": { |
| 1082 |
"v_range": [["v6.0.0", "v7.4.1"], ["v7.4.3", ""]], |
| 1083 |
"type": "string", |
| 1084 |
"options": [ |
| 1085 |
{"value": "none", "v_range": [["v6.0.0", ""]]}, |
| 1086 |
{"value": "read", "v_range": [["v6.0.0", ""]]}, |
| 1087 |
{"value": "read-write", "v_range": [["v6.0.0", ""]]}, |
| 1088 |
], |
| 1089 |
}, |
| 1090 |
"wifi": { |
| 1091 |
"v_range": [["v6.0.0", ""]], |
| 1092 |
"type": "string", |
| 1093 |
"options": [{"value": "none"}, {"value": "read"}, {"value": "read-write"}], |
| 1094 |
}, |
| 1095 |
"netgrp_permission": { |
| 1096 |
"v_range": [["v6.0.0", ""]], |
| 1097 |
"type": "dict", |
| 1098 |
"children": { |
| 1099 |
"cfg": { |
| 1100 |
"v_range": [["v6.0.0", ""]], |
| 1101 |
"type": "string", |
| 1102 |
"options": [ |
| 1103 |
{"value": "none"}, |
| 1104 |
{"value": "read"}, |
| 1105 |
{"value": "read-write"}, |
| 1106 |
], |
| 1107 |
}, |
| 1108 |
"packet_capture": { |
| 1109 |
"v_range": [["v6.0.0", ""]], |
| 1110 |
"type": "string", |
| 1111 |
"options": [ |
| 1112 |
{"value": "none"}, |
| 1113 |
{"value": "read"}, |
| 1114 |
{"value": "read-write"}, |
| 1115 |
], |
| 1116 |
}, |
| 1117 |
"route_cfg": { |
| 1118 |
"v_range": [["v6.0.0", ""]], |
| 1119 |
"type": "string", |
| 1120 |
"options": [ |
| 1121 |
{"value": "none"}, |
| 1122 |
{"value": "read"}, |
| 1123 |
{"value": "read-write"}, |
| 1124 |
], |
| 1125 |
}, |
| 1126 |
}, |
| 1127 |
}, |
| 1128 |
"sysgrp_permission": { |
| 1129 |
"v_range": [["v6.0.0", ""]], |
| 1130 |
"type": "dict", |
| 1131 |
"children": { |
| 1132 |
"admin": { |
| 1133 |
"v_range": [["v6.0.0", ""]], |
| 1134 |
"type": "string", |
| 1135 |
"options": [ |
| 1136 |
{"value": "none"}, |
| 1137 |
{"value": "read"}, |
| 1138 |
{"value": "read-write"}, |
| 1139 |
], |
| 1140 |
}, |
| 1141 |
"upd": { |
| 1142 |
"v_range": [["v6.0.0", ""]], |
| 1143 |
"type": "string", |
| 1144 |
"options": [ |
| 1145 |
{"value": "none"}, |
| 1146 |
{"value": "read"}, |
| 1147 |
{"value": "read-write"}, |
| 1148 |
], |
| 1149 |
}, |
| 1150 |
"cfg": { |
| 1151 |
"v_range": [["v6.0.0", ""]], |
| 1152 |
"type": "string", |
| 1153 |
"options": [ |
| 1154 |
{"value": "none"}, |
| 1155 |
{"value": "read"}, |
| 1156 |
{"value": "read-write"}, |
| 1157 |
], |
| 1158 |
}, |
| 1159 |
"mnt": { |
| 1160 |
"v_range": [["v6.0.0", ""]], |
| 1161 |
"type": "string", |
| 1162 |
"options": [ |
| 1163 |
{"value": "none"}, |
| 1164 |
{"value": "read"}, |
| 1165 |
{"value": "read-write"}, |
| 1166 |
], |
| 1167 |
}, |
| 1168 |
}, |
| 1169 |
}, |
| 1170 |
"fwgrp_permission": { |
| 1171 |
"v_range": [["v6.0.0", ""]], |
| 1172 |
"type": "dict", |
| 1173 |
"children": { |
| 1174 |
"policy": { |
| 1175 |
"v_range": [["v6.0.0", ""]], |
| 1176 |
"type": "string", |
| 1177 |
"options": [ |
| 1178 |
{"value": "none"}, |
| 1179 |
{"value": "read"}, |
| 1180 |
{"value": "read-write"}, |
| 1181 |
], |
| 1182 |
}, |
| 1183 |
"address": { |
| 1184 |
"v_range": [["v6.0.0", ""]], |
| 1185 |
"type": "string", |
| 1186 |
"options": [ |
| 1187 |
{"value": "none"}, |
| 1188 |
{"value": "read"}, |
| 1189 |
{"value": "read-write"}, |
| 1190 |
], |
| 1191 |
}, |
| 1192 |
"service": { |
| 1193 |
"v_range": [["v6.0.0", ""]], |
| 1194 |
"type": "string", |
| 1195 |
"options": [ |
| 1196 |
{"value": "none"}, |
| 1197 |
{"value": "read"}, |
| 1198 |
{"value": "read-write"}, |
| 1199 |
], |
| 1200 |
}, |
| 1201 |
"schedule": { |
| 1202 |
"v_range": [["v6.0.0", ""]], |
| 1203 |
"type": "string", |
| 1204 |
"options": [ |
| 1205 |
{"value": "none"}, |
| 1206 |
{"value": "read"}, |
| 1207 |
{"value": "read-write"}, |
| 1208 |
], |
| 1209 |
}, |
| 1210 |
"others": { |
| 1211 |
"v_range": [["v7.0.1", ""]], |
| 1212 |
"type": "string", |
| 1213 |
"options": [ |
| 1214 |
{"value": "none"}, |
| 1215 |
{"value": "read"}, |
| 1216 |
{"value": "read-write"}, |
| 1217 |
], |
| 1218 |
}, |
| 1219 |
}, |
| 1220 |
}, |
| 1221 |
"loggrp_permission": { |
| 1222 |
"v_range": [["v6.0.0", ""]], |
| 1223 |
"type": "dict", |
| 1224 |
"children": { |
| 1225 |
"config": { |
| 1226 |
"v_range": [["v6.0.0", ""]], |
| 1227 |
"type": "string", |
| 1228 |
"options": [ |
| 1229 |
{"value": "none"}, |
| 1230 |
{"value": "read"}, |
| 1231 |
{"value": "read-write"}, |
| 1232 |
], |
| 1233 |
}, |
| 1234 |
"data_access": { |
| 1235 |
"v_range": [["v6.0.0", ""]], |
| 1236 |
"type": "string", |
| 1237 |
"options": [ |
| 1238 |
{"value": "none"}, |
| 1239 |
{"value": "read"}, |
| 1240 |
{"value": "read-write"}, |
| 1241 |
], |
| 1242 |
}, |
| 1243 |
"report_access": { |
| 1244 |
"v_range": [["v6.0.0", ""]], |
| 1245 |
"type": "string", |
| 1246 |
"options": [ |
| 1247 |
{"value": "none"}, |
| 1248 |
{"value": "read"}, |
| 1249 |
{"value": "read-write"}, |
| 1250 |
], |
| 1251 |
}, |
| 1252 |
"threat_weight": { |
| 1253 |
"v_range": [["v6.0.0", ""]], |
| 1254 |
"type": "string", |
| 1255 |
"options": [ |
| 1256 |
{"value": "none"}, |
| 1257 |
{"value": "read"}, |
| 1258 |
{"value": "read-write"}, |
| 1259 |
], |
| 1260 |
}, |
| 1261 |
}, |
| 1262 |
}, |
| 1263 |
"utmgrp_permission": { |
| 1264 |
"v_range": [["v6.0.0", ""]], |
| 1265 |
"type": "dict", |
| 1266 |
"children": { |
| 1267 |
"antivirus": { |
| 1268 |
"v_range": [["v6.0.0", ""]], |
| 1269 |
"type": "string", |
| 1270 |
"options": [ |
| 1271 |
{"value": "none"}, |
| 1272 |
{"value": "read"}, |
| 1273 |
{"value": "read-write"}, |
| 1274 |
], |
| 1275 |
}, |
| 1276 |
"ips": { |
| 1277 |
"v_range": [["v6.0.0", ""]], |
| 1278 |
"type": "string", |
| 1279 |
"options": [ |
| 1280 |
{"value": "none"}, |
| 1281 |
{"value": "read"}, |
| 1282 |
{"value": "read-write"}, |
| 1283 |
], |
| 1284 |
}, |
| 1285 |
"webfilter": { |
| 1286 |
"v_range": [["v6.0.0", ""]], |
| 1287 |
"type": "string", |
| 1288 |
"options": [ |
| 1289 |
{"value": "none"}, |
| 1290 |
{"value": "read"}, |
| 1291 |
{"value": "read-write"}, |
| 1292 |
], |
| 1293 |
}, |
| 1294 |
"emailfilter": { |
| 1295 |
"v_range": [["v6.2.0", ""]], |
| 1296 |
"type": "string", |
| 1297 |
"options": [ |
| 1298 |
{"value": "none"}, |
| 1299 |
{"value": "read"}, |
| 1300 |
{"value": "read-write"}, |
| 1301 |
], |
| 1302 |
}, |
| 1303 |
"dlp": { |
| 1304 |
"v_range": [["v7.4.4", ""]], |
| 1305 |
"type": "string", |
| 1306 |
"options": [ |
| 1307 |
{"value": "none"}, |
| 1308 |
{"value": "read"}, |
| 1309 |
{"value": "read-write"}, |
| 1310 |
], |
| 1311 |
}, |
| 1312 |
"file_filter": { |
| 1313 |
"v_range": [["v6.4.0", ""]], |
| 1314 |
"type": "string", |
| 1315 |
"options": [ |
| 1316 |
{"value": "none"}, |
| 1317 |
{"value": "read"}, |
| 1318 |
{"value": "read-write"}, |
| 1319 |
], |
| 1320 |
}, |
| 1321 |
"application_control": { |
| 1322 |
"v_range": [["v6.0.0", ""]], |
| 1323 |
"type": "string", |
| 1324 |
"options": [ |
| 1325 |
{"value": "none"}, |
| 1326 |
{"value": "read"}, |
| 1327 |
{"value": "read-write"}, |
| 1328 |
], |
| 1329 |
}, |
| 1330 |
"icap": { |
| 1331 |
"v_range": [["v6.0.0", ""]], |
| 1332 |
"type": "string", |
| 1333 |
"options": [ |
| 1334 |
{"value": "none"}, |
| 1335 |
{"value": "read"}, |
| 1336 |
{"value": "read-write"}, |
| 1337 |
], |
| 1338 |
}, |
| 1339 |
"voip": { |
| 1340 |
"v_range": [["v6.0.0", ""]], |
| 1341 |
"type": "string", |
| 1342 |
"options": [ |
| 1343 |
{"value": "none"}, |
| 1344 |
{"value": "read"}, |
| 1345 |
{"value": "read-write"}, |
| 1346 |
], |
| 1347 |
}, |
| 1348 |
"waf": { |
| 1349 |
"v_range": [["v6.0.0", ""]], |
| 1350 |
"type": "string", |
| 1351 |
"options": [ |
| 1352 |
{"value": "none"}, |
| 1353 |
{"value": "read"}, |
| 1354 |
{"value": "read-write"}, |
| 1355 |
], |
| 1356 |
}, |
| 1357 |
"dnsfilter": { |
| 1358 |
"v_range": [["v6.0.0", ""]], |
| 1359 |
"type": "string", |
| 1360 |
"options": [ |
| 1361 |
{"value": "none"}, |
| 1362 |
{"value": "read"}, |
| 1363 |
{"value": "read-write"}, |
| 1364 |
], |
| 1365 |
}, |
| 1366 |
"endpoint_control": { |
| 1367 |
"v_range": [["v6.0.0", ""]], |
| 1368 |
"type": "string", |
| 1369 |
"options": [ |
| 1370 |
{"value": "none"}, |
| 1371 |
{"value": "read"}, |
| 1372 |
{"value": "read-write"}, |
| 1373 |
], |
| 1374 |
}, |
| 1375 |
"videofilter": { |
| 1376 |
"v_range": [["v7.2.0", ""]], |
| 1377 |
"type": "string", |
| 1378 |
"options": [ |
| 1379 |
{"value": "none"}, |
| 1380 |
{"value": "read"}, |
| 1381 |
{"value": "read-write"}, |
| 1382 |
], |
| 1383 |
}, |
| 1384 |
"virtual_patch": { |
| 1385 |
"v_range": [["v7.4.1", ""]], |
| 1386 |
"type": "string", |
| 1387 |
"options": [ |
| 1388 |
{"value": "none"}, |
| 1389 |
{"value": "read"}, |
| 1390 |
{"value": "read-write"}, |
| 1391 |
], |
| 1392 |
}, |
| 1393 |
"casb": { |
| 1394 |
"v_range": [["v7.4.1", ""]], |
| 1395 |
"type": "string", |
| 1396 |
"options": [ |
| 1397 |
{"value": "none"}, |
| 1398 |
{"value": "read"}, |
| 1399 |
{"value": "read-write"}, |
| 1400 |
], |
| 1401 |
}, |
| 1402 |
"telemetry": { |
| 1403 |
"v_range": [["v7.6.4", ""]], |
| 1404 |
"type": "string", |
| 1405 |
"options": [ |
| 1406 |
{"value": "none"}, |
| 1407 |
{"value": "read"}, |
| 1408 |
{"value": "read-write"}, |
| 1409 |
], |
| 1410 |
}, |
| 1411 |
"mmsgtp": { |
| 1412 |
"v_range": [ |
| 1413 |
["v6.0.0", "v7.0.8"], |
| 1414 |
["v7.2.0", "v7.2.4"], |
| 1415 |
["v7.4.3", "v7.6.4"], |
| 1416 |
], |
| 1417 |
"type": "string", |
| 1418 |
"options": [ |
| 1419 |
{"value": "none"}, |
| 1420 |
{"value": "read"}, |
| 1421 |
{"value": "read-write"}, |
| 1422 |
], |
| 1423 |
}, |
| 1424 |
"data_leak_prevention": { |
| 1425 |
"v_range": [["v7.2.4", "v7.4.3"]], |
| 1426 |
"type": "string", |
| 1427 |
"options": [ |
| 1428 |
{"value": "none"}, |
| 1429 |
{"value": "read"}, |
| 1430 |
{"value": "read-write"}, |
| 1431 |
], |
| 1432 |
}, |
| 1433 |
"data_loss_prevention": { |
| 1434 |
"v_range": [["v6.0.0", "v7.2.2"]], |
| 1435 |
"type": "string", |
| 1436 |
"options": [ |
| 1437 |
{"value": "none"}, |
| 1438 |
{"value": "read"}, |
| 1439 |
{"value": "read-write"}, |
| 1440 |
], |
| 1441 |
}, |
| 1442 |
"spamfilter": { |
| 1443 |
"v_range": [["v6.0.0", "v6.0.11"]], |
| 1444 |
"type": "string", |
| 1445 |
"options": [ |
| 1446 |
{"value": "none"}, |
| 1447 |
{"value": "read"}, |
| 1448 |
{"value": "read-write"}, |
| 1449 |
], |
| 1450 |
}, |
| 1451 |
}, |
| 1452 |
}, |
| 1453 |
"secfabgrp_permission": { |
| 1454 |
"v_range": [["v7.6.5", ""]], |
| 1455 |
"type": "dict", |
| 1456 |
"children": { |
| 1457 |
"csfsys": { |
| 1458 |
"v_range": [["v7.6.5", ""]], |
| 1459 |
"type": "string", |
| 1460 |
"options": [ |
| 1461 |
{"value": "none"}, |
| 1462 |
{"value": "read"}, |
| 1463 |
{"value": "read-write"}, |
| 1464 |
], |
| 1465 |
}, |
| 1466 |
"csffoo": { |
| 1467 |
"v_range": [["v7.6.5", ""]], |
| 1468 |
"type": "string", |
| 1469 |
"options": [ |
| 1470 |
{"value": "none"}, |
| 1471 |
{"value": "read"}, |
| 1472 |
{"value": "read-write"}, |
| 1473 |
], |
| 1474 |
}, |
| 1475 |
"mmsgtp": { |
| 1476 |
"v_range": [["v7.6.5", ""]], |
| 1477 |
"type": "string", |
| 1478 |
"options": [ |
| 1479 |
{"value": "none"}, |
| 1480 |
{"value": "read"}, |
| 1481 |
{"value": "read-write"}, |
| 1482 |
], |
| 1483 |
}, |
| 1484 |
}, |
| 1485 |
}, |
| 1486 |
"admintimeout_override": { |
| 1487 |
"v_range": [["v6.0.0", ""]], |
| 1488 |
"type": "string", |
| 1489 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1490 |
}, |
| 1491 |
"admintimeout": {"v_range": [["v6.0.0", ""]], "type": "integer"}, |
| 1492 |
"cli_diagnose": { |
| 1493 |
"v_range": [["v7.4.2", ""]], |
| 1494 |
"type": "string", |
| 1495 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1496 |
}, |
| 1497 |
"cli_get": { |
| 1498 |
"v_range": [["v7.4.2", ""]], |
| 1499 |
"type": "string", |
| 1500 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1501 |
}, |
| 1502 |
"cli_show": { |
| 1503 |
"v_range": [["v7.4.2", ""]], |
| 1504 |
"type": "string", |
| 1505 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1506 |
}, |
| 1507 |
"cli_exec": { |
| 1508 |
"v_range": [["v7.4.2", ""]], |
| 1509 |
"type": "string", |
| 1510 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1511 |
}, |
| 1512 |
"cli_config": { |
| 1513 |
"v_range": [["v7.4.2", ""]], |
| 1514 |
"type": "string", |
| 1515 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1516 |
}, |
| 1517 |
"system_execute_ssh": { |
| 1518 |
"v_range": [["v7.2.1", ""]], |
| 1519 |
"type": "string", |
| 1520 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1521 |
}, |
| 1522 |
"system_execute_telnet": { |
| 1523 |
"v_range": [["v7.2.1", ""]], |
| 1524 |
"type": "string", |
| 1525 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1526 |
}, |
| 1527 |
"system_diagnostics": { |
| 1528 |
"v_range": [["v6.4.0", "v7.4.1"]], |
| 1529 |
"type": "string", |
| 1530 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1531 |
}, |
| 1532 |
}, |
| 1533 |
"v_range": [["v6.0.0", ""]], |
| 1534 |
} |
| 1535 |
|
| 1536 |
|
| 1537 |
def main(): |
| 1538 |
module_spec = schema_to_module_spec(versioned_schema) |
| 1539 |
mkeyname = "name" |
| 1540 |
fields = { |
| 1541 |
"access_token": {"required": False, "type": "str", "no_log": True}, |
| 1542 |
"enable_log": {"required": False, "type": "bool", "default": False}, |
| 1543 |
"vdom": {"required": False, "type": "str", "default": "root"}, |
| 1544 |
"member_path": {"required": False, "type": "str"}, |
| 1545 |
"member_state": { |
| 1546 |
"type": "str", |
| 1547 |
"required": False, |
| 1548 |
"choices": ["present", "absent"], |
| 1549 |
}, |
| 1550 |
"state": {"required": True, "type": "str", "choices": ["present", "absent"]}, |
| 1551 |
"system_accprofile": { |
| 1552 |
"required": False, |
| 1553 |
"type": "dict", |
| 1554 |
"default": None, |
| 1555 |
"options": {}, |
| 1556 |
}, |
| 1557 |
} |
| 1558 |
for attribute_name in module_spec["options"]: |
| 1559 |
fields["system_accprofile"]["options"][attribute_name] = module_spec["options"][ |
| 1560 |
attribute_name |
| 1561 |
] |
| 1562 |
if mkeyname and mkeyname == attribute_name: |
| 1563 |
fields["system_accprofile"]["options"][attribute_name]["required"] = True |
| 1564 |
|
| 1565 |
module = AnsibleModule(argument_spec=fields, supports_check_mode=True) |
| 1566 |
check_legacy_fortiosapi(module) |
| 1567 |
|
| 1568 |
is_error = False |
| 1569 |
has_changed = False |
| 1570 |
result = None |
| 1571 |
diff = None |
| 1572 |
|
| 1573 |
versions_check_result = None |
| 1574 |
if module._socket_path: |
| 1575 |
connection = Connection(module._socket_path) |
| 1576 |
if "access_token" in module.params: |
| 1577 |
connection.set_custom_option("access_token", module.params["access_token"]) |
| 1578 |
|
| 1579 |
if "enable_log" in module.params: |
| 1580 |
connection.set_custom_option("enable_log", module.params["enable_log"]) |
| 1581 |
else: |
| 1582 |
connection.set_custom_option("enable_log", False) |
| 1583 |
fos = FortiOSHandler(connection, module, mkeyname, admin_passwd_header=False) |
| 1584 |
versions_check_result = check_schema_versioning( |
| 1585 |
fos, versioned_schema, "system_accprofile" |
| 1586 |
) |
| 1587 |
|
| 1588 |
is_error, has_changed, result, diff = fortios_system( |
| 1589 |
module.params, fos, module.check_mode |
| 1590 |
) |
| 1591 |
|
| 1592 |
else: |
| 1593 |
module.fail_json(**FAIL_SOCKET_MSG) |
| 1594 |
|
| 1595 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1596 |
module.warn( |
| 1597 |
"Ansible has detected version mismatch between FortOS system and your playbook, see more details by specifying option -vvv" |
| 1598 |
) |
| 1599 |
|
| 1600 |
if not is_error: |
| 1601 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1602 |
module.exit_json( |
| 1603 |
changed=has_changed, |
| 1604 |
version_check_warning=versions_check_result, |
| 1605 |
meta=result, |
| 1606 |
diff=diff, |
| 1607 |
) |
| 1608 |
else: |
| 1609 |
module.exit_json(changed=has_changed, meta=result, diff=diff) |
| 1610 |
else: |
| 1611 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1612 |
module.fail_json( |
| 1613 |
msg="Error in repo", |
| 1614 |
version_check_warning=versions_check_result, |
| 1615 |
meta=result, |
| 1616 |
) |
| 1617 |
else: |
| 1618 |
module.fail_json(msg="Error in repo", meta=result) |
| 1619 |
|
| 1620 |
|
| 1621 |
if __name__ == "__main__": |
| 1622 |
main() |