| 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_admin |
| 23 |
short_description: Configure admin users 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 admin 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_admin: |
| 88 |
description: |
| 89 |
- Configure admin users. |
| 90 |
default: null |
| 91 |
type: dict |
| 92 |
suboptions: |
| 93 |
accprofile: |
| 94 |
description: |
| 95 |
- Access profile for this administrator. Access profiles control administrator access to FortiGate features. Source system.accprofile.name. |
| 96 |
type: str |
| 97 |
accprofile_override: |
| 98 |
description: |
| 99 |
- Enable to use the name of an access profile provided by the remote authentication server to control the FortiGate features that this |
| 100 |
administrator can access. |
| 101 |
type: str |
| 102 |
choices: |
| 103 |
- 'enable' |
| 104 |
- 'disable' |
| 105 |
allow_remove_admin_session: |
| 106 |
description: |
| 107 |
- Enable/disable allow admin session to be removed by privileged admin users. |
| 108 |
type: str |
| 109 |
choices: |
| 110 |
- 'enable' |
| 111 |
- 'disable' |
| 112 |
comments: |
| 113 |
description: |
| 114 |
- Comment. |
| 115 |
type: str |
| 116 |
email_to: |
| 117 |
description: |
| 118 |
- This administrator"s email address. |
| 119 |
type: str |
| 120 |
force_password_change: |
| 121 |
description: |
| 122 |
- Enable/disable force password change on next login. |
| 123 |
type: str |
| 124 |
choices: |
| 125 |
- 'enable' |
| 126 |
- 'disable' |
| 127 |
fortitoken: |
| 128 |
description: |
| 129 |
- This administrator"s FortiToken serial number. |
| 130 |
type: str |
| 131 |
guest_auth: |
| 132 |
description: |
| 133 |
- Enable/disable guest authentication. |
| 134 |
type: str |
| 135 |
choices: |
| 136 |
- 'disable' |
| 137 |
- 'enable' |
| 138 |
guest_lang: |
| 139 |
description: |
| 140 |
- Guest management portal language. Source system.custom-language.name. |
| 141 |
type: str |
| 142 |
guest_usergroups: |
| 143 |
description: |
| 144 |
- Select guest user groups. |
| 145 |
type: list |
| 146 |
elements: dict |
| 147 |
suboptions: |
| 148 |
name: |
| 149 |
description: |
| 150 |
- Select guest user groups. |
| 151 |
required: true |
| 152 |
type: str |
| 153 |
gui_dashboard: |
| 154 |
description: |
| 155 |
- GUI dashboards. |
| 156 |
type: list |
| 157 |
elements: dict |
| 158 |
suboptions: |
| 159 |
columns: |
| 160 |
description: |
| 161 |
- Number of columns. |
| 162 |
type: int |
| 163 |
id: |
| 164 |
description: |
| 165 |
- Dashboard ID. see <a href='#notes'>Notes</a>. |
| 166 |
required: true |
| 167 |
type: int |
| 168 |
layout_type: |
| 169 |
description: |
| 170 |
- Layout type. |
| 171 |
type: str |
| 172 |
choices: |
| 173 |
- 'responsive' |
| 174 |
- 'fixed' |
| 175 |
name: |
| 176 |
description: |
| 177 |
- Dashboard name. |
| 178 |
type: str |
| 179 |
permanent: |
| 180 |
description: |
| 181 |
- Permanent dashboard (can"t be removed via the GUI). |
| 182 |
type: str |
| 183 |
choices: |
| 184 |
- 'disable' |
| 185 |
- 'enable' |
| 186 |
scope: |
| 187 |
description: |
| 188 |
- Dashboard scope. |
| 189 |
type: str |
| 190 |
choices: |
| 191 |
- 'global' |
| 192 |
- 'vdom' |
| 193 |
vdom: |
| 194 |
description: |
| 195 |
- Virtual domain. Source system.vdom.name. |
| 196 |
type: str |
| 197 |
widget: |
| 198 |
description: |
| 199 |
- Dashboard widgets. |
| 200 |
type: list |
| 201 |
elements: dict |
| 202 |
suboptions: |
| 203 |
fabric_device: |
| 204 |
description: |
| 205 |
- Fabric device to monitor. |
| 206 |
type: str |
| 207 |
fabric_device_widget_name: |
| 208 |
description: |
| 209 |
- Fabric device widget name. |
| 210 |
type: str |
| 211 |
fabric_device_widget_visualization_type: |
| 212 |
description: |
| 213 |
- Visualization type for fabric device widget. |
| 214 |
type: str |
| 215 |
fortiview_device: |
| 216 |
description: |
| 217 |
- FortiView device. |
| 218 |
type: str |
| 219 |
fortiview_filters: |
| 220 |
description: |
| 221 |
- FortiView filters. |
| 222 |
type: list |
| 223 |
elements: dict |
| 224 |
suboptions: |
| 225 |
id: |
| 226 |
description: |
| 227 |
- FortiView Filter ID. see <a href='#notes'>Notes</a>. |
| 228 |
required: true |
| 229 |
type: int |
| 230 |
key: |
| 231 |
description: |
| 232 |
- Filter key. |
| 233 |
type: str |
| 234 |
value: |
| 235 |
description: |
| 236 |
- Filter value. |
| 237 |
type: str |
| 238 |
fortiview_sort_by: |
| 239 |
description: |
| 240 |
- FortiView sort by. |
| 241 |
type: str |
| 242 |
fortiview_timeframe: |
| 243 |
description: |
| 244 |
- FortiView timeframe. |
| 245 |
type: str |
| 246 |
fortiview_type: |
| 247 |
description: |
| 248 |
- FortiView type. |
| 249 |
type: str |
| 250 |
fortiview_visualization: |
| 251 |
description: |
| 252 |
- FortiView visualization. |
| 253 |
type: str |
| 254 |
height: |
| 255 |
description: |
| 256 |
- Height. |
| 257 |
type: int |
| 258 |
id: |
| 259 |
description: |
| 260 |
- Widget ID. see <a href='#notes'>Notes</a>. |
| 261 |
required: true |
| 262 |
type: int |
| 263 |
industry: |
| 264 |
description: |
| 265 |
- Security Audit Rating industry. |
| 266 |
type: str |
| 267 |
choices: |
| 268 |
- 'default' |
| 269 |
- 'custom' |
| 270 |
interface: |
| 271 |
description: |
| 272 |
- Interface to monitor. Source system.interface.name. |
| 273 |
type: str |
| 274 |
region: |
| 275 |
description: |
| 276 |
- Security Audit Rating region. |
| 277 |
type: str |
| 278 |
choices: |
| 279 |
- 'default' |
| 280 |
- 'custom' |
| 281 |
title: |
| 282 |
description: |
| 283 |
- Widget title. |
| 284 |
type: str |
| 285 |
type: |
| 286 |
description: |
| 287 |
- Widget type. |
| 288 |
type: str |
| 289 |
choices: |
| 290 |
- 'sysinfo' |
| 291 |
- 'licinfo' |
| 292 |
- 'forticloud' |
| 293 |
- 'cpu-usage' |
| 294 |
- 'memory-usage' |
| 295 |
- 'disk-usage' |
| 296 |
- 'log-rate' |
| 297 |
- 'sessions' |
| 298 |
- 'session-rate' |
| 299 |
- 'tr-history' |
| 300 |
- 'analytics' |
| 301 |
- 'usb-modem' |
| 302 |
- 'admins' |
| 303 |
- 'security-fabric' |
| 304 |
- 'security-fabric-ranking' |
| 305 |
- 'sensor-info' |
| 306 |
- 'ha-status' |
| 307 |
- 'vulnerability-summary' |
| 308 |
- 'host-scan-summary' |
| 309 |
- 'fortiview' |
| 310 |
- 'botnet-activity' |
| 311 |
- 'fabric-device' |
| 312 |
- 'fortimail' |
| 313 |
width: |
| 314 |
description: |
| 315 |
- Width. |
| 316 |
type: int |
| 317 |
x_pos: |
| 318 |
description: |
| 319 |
- X position. |
| 320 |
type: int |
| 321 |
y_pos: |
| 322 |
description: |
| 323 |
- Y position. |
| 324 |
type: int |
| 325 |
gui_global_menu_favorites: |
| 326 |
description: |
| 327 |
- Favorite GUI menu IDs for the global VDOM. |
| 328 |
type: list |
| 329 |
elements: dict |
| 330 |
suboptions: |
| 331 |
id: |
| 332 |
description: |
| 333 |
- Select menu ID. |
| 334 |
required: true |
| 335 |
type: str |
| 336 |
gui_new_feature_acknowledge: |
| 337 |
description: |
| 338 |
- Acknowledgement of new features. |
| 339 |
type: list |
| 340 |
elements: dict |
| 341 |
suboptions: |
| 342 |
id: |
| 343 |
description: |
| 344 |
- Select menu ID. |
| 345 |
required: true |
| 346 |
type: str |
| 347 |
gui_vdom_menu_favorites: |
| 348 |
description: |
| 349 |
- Favorite GUI menu IDs for VDOMs. |
| 350 |
type: list |
| 351 |
elements: dict |
| 352 |
suboptions: |
| 353 |
id: |
| 354 |
description: |
| 355 |
- Select menu ID. |
| 356 |
required: true |
| 357 |
type: str |
| 358 |
hidden: |
| 359 |
description: |
| 360 |
- Admin user hidden attribute. |
| 361 |
type: int |
| 362 |
history0: |
| 363 |
description: |
| 364 |
- history0 |
| 365 |
type: str |
| 366 |
history1: |
| 367 |
description: |
| 368 |
- history1 |
| 369 |
type: str |
| 370 |
ip6_trusthost1: |
| 371 |
description: |
| 372 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 373 |
type: str |
| 374 |
ip6_trusthost10: |
| 375 |
description: |
| 376 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 377 |
type: str |
| 378 |
ip6_trusthost2: |
| 379 |
description: |
| 380 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 381 |
type: str |
| 382 |
ip6_trusthost3: |
| 383 |
description: |
| 384 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 385 |
type: str |
| 386 |
ip6_trusthost4: |
| 387 |
description: |
| 388 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 389 |
type: str |
| 390 |
ip6_trusthost5: |
| 391 |
description: |
| 392 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 393 |
type: str |
| 394 |
ip6_trusthost6: |
| 395 |
description: |
| 396 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 397 |
type: str |
| 398 |
ip6_trusthost7: |
| 399 |
description: |
| 400 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 401 |
type: str |
| 402 |
ip6_trusthost8: |
| 403 |
description: |
| 404 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 405 |
type: str |
| 406 |
ip6_trusthost9: |
| 407 |
description: |
| 408 |
- Any IPv6 address from which the administrator can connect to the FortiGate unit. Default allows access from any IPv6 address. |
| 409 |
type: str |
| 410 |
login_time: |
| 411 |
description: |
| 412 |
- Record user login time. |
| 413 |
type: list |
| 414 |
elements: dict |
| 415 |
suboptions: |
| 416 |
last_failed_login: |
| 417 |
description: |
| 418 |
- Last failed login time. |
| 419 |
type: str |
| 420 |
last_login: |
| 421 |
description: |
| 422 |
- Last successful login time. |
| 423 |
type: str |
| 424 |
usr_name: |
| 425 |
description: |
| 426 |
- User name. |
| 427 |
required: true |
| 428 |
type: str |
| 429 |
name: |
| 430 |
description: |
| 431 |
- User name. |
| 432 |
required: true |
| 433 |
type: str |
| 434 |
password: |
| 435 |
description: |
| 436 |
- Admin user password. |
| 437 |
type: str |
| 438 |
password_expire: |
| 439 |
description: |
| 440 |
- Password expire time. |
| 441 |
type: str |
| 442 |
peer_auth: |
| 443 |
description: |
| 444 |
- Set to enable peer certificate authentication (for HTTPS admin access). |
| 445 |
type: str |
| 446 |
choices: |
| 447 |
- 'enable' |
| 448 |
- 'disable' |
| 449 |
peer_group: |
| 450 |
description: |
| 451 |
- Name of peer group defined under config user group which has PKI members. Used for peer certificate authentication (for HTTPS admin |
| 452 |
access). |
| 453 |
type: str |
| 454 |
radius_vdom_override: |
| 455 |
description: |
| 456 |
- Enable to use the names of VDOMs provided by the remote authentication server to control the VDOMs that this administrator can access. |
| 457 |
type: str |
| 458 |
choices: |
| 459 |
- 'enable' |
| 460 |
- 'disable' |
| 461 |
remote_auth: |
| 462 |
description: |
| 463 |
- Enable/disable authentication using a remote RADIUS, LDAP, or TACACS+ server. |
| 464 |
type: str |
| 465 |
choices: |
| 466 |
- 'enable' |
| 467 |
- 'disable' |
| 468 |
remote_group: |
| 469 |
description: |
| 470 |
- User group name used for remote auth. |
| 471 |
type: str |
| 472 |
schedule: |
| 473 |
description: |
| 474 |
- Firewall schedule used to restrict when the administrator can log in. No schedule means no restrictions. |
| 475 |
type: str |
| 476 |
sms_custom_server: |
| 477 |
description: |
| 478 |
- Custom SMS server to send SMS messages to. Source system.sms-server.name. |
| 479 |
type: str |
| 480 |
sms_phone: |
| 481 |
description: |
| 482 |
- Phone number on which the administrator receives SMS messages. |
| 483 |
type: str |
| 484 |
sms_server: |
| 485 |
description: |
| 486 |
- Send SMS messages using the FortiGuard SMS server or a custom server. |
| 487 |
type: str |
| 488 |
choices: |
| 489 |
- 'fortiguard' |
| 490 |
- 'custom' |
| 491 |
ssh_certificate: |
| 492 |
description: |
| 493 |
- Select the certificate to be used by the FortiGate for authentication with an SSH client. Source certificate.remote.name. |
| 494 |
type: str |
| 495 |
ssh_public_key1: |
| 496 |
description: |
| 497 |
- Public key of an SSH client. The client is authenticated without being asked for credentials. Create the public-private key pair in the |
| 498 |
SSH client application. |
| 499 |
type: str |
| 500 |
ssh_public_key2: |
| 501 |
description: |
| 502 |
- Public key of an SSH client. The client is authenticated without being asked for credentials. Create the public-private key pair in the |
| 503 |
SSH client application. |
| 504 |
type: str |
| 505 |
ssh_public_key3: |
| 506 |
description: |
| 507 |
- Public key of an SSH client. The client is authenticated without being asked for credentials. Create the public-private key pair in the |
| 508 |
SSH client application. |
| 509 |
type: str |
| 510 |
trusthost1: |
| 511 |
description: |
| 512 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 513 |
from any IPv4 address. |
| 514 |
type: str |
| 515 |
trusthost10: |
| 516 |
description: |
| 517 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 518 |
from any IPv4 address. |
| 519 |
type: str |
| 520 |
trusthost2: |
| 521 |
description: |
| 522 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 523 |
from any IPv4 address. |
| 524 |
type: str |
| 525 |
trusthost3: |
| 526 |
description: |
| 527 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 528 |
from any IPv4 address. |
| 529 |
type: str |
| 530 |
trusthost4: |
| 531 |
description: |
| 532 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 533 |
from any IPv4 address. |
| 534 |
type: str |
| 535 |
trusthost5: |
| 536 |
description: |
| 537 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 538 |
from any IPv4 address. |
| 539 |
type: str |
| 540 |
trusthost6: |
| 541 |
description: |
| 542 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 543 |
from any IPv4 address. |
| 544 |
type: str |
| 545 |
trusthost7: |
| 546 |
description: |
| 547 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 548 |
from any IPv4 address. |
| 549 |
type: str |
| 550 |
trusthost8: |
| 551 |
description: |
| 552 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 553 |
from any IPv4 address. |
| 554 |
type: str |
| 555 |
trusthost9: |
| 556 |
description: |
| 557 |
- Any IPv4 address or subnet address and netmask from which the administrator can connect to the FortiGate unit. Default allows access |
| 558 |
from any IPv4 address. |
| 559 |
type: str |
| 560 |
two_factor: |
| 561 |
description: |
| 562 |
- Enable/disable two-factor authentication. |
| 563 |
type: str |
| 564 |
choices: |
| 565 |
- 'disable' |
| 566 |
- 'fortitoken' |
| 567 |
- 'fortitoken-cloud' |
| 568 |
- 'email' |
| 569 |
- 'sms' |
| 570 |
two_factor_authentication: |
| 571 |
description: |
| 572 |
- Authentication method by FortiToken Cloud. |
| 573 |
type: str |
| 574 |
choices: |
| 575 |
- 'fortitoken' |
| 576 |
- 'email' |
| 577 |
- 'sms' |
| 578 |
two_factor_notification: |
| 579 |
description: |
| 580 |
- Notification method for user activation by FortiToken Cloud. |
| 581 |
type: str |
| 582 |
choices: |
| 583 |
- 'email' |
| 584 |
- 'sms' |
| 585 |
vdom: |
| 586 |
description: |
| 587 |
- Virtual domain(s) that the administrator can access. |
| 588 |
type: list |
| 589 |
elements: dict |
| 590 |
suboptions: |
| 591 |
name: |
| 592 |
description: |
| 593 |
- Virtual domain name. Source system.vdom.name. |
| 594 |
required: true |
| 595 |
type: str |
| 596 |
vdom_override: |
| 597 |
description: |
| 598 |
- Enable to use the names of VDOMs provided by the remote authentication server to control the VDOMs that this administrator can access. |
| 599 |
type: str |
| 600 |
choices: |
| 601 |
- 'enable' |
| 602 |
- 'disable' |
| 603 |
wildcard: |
| 604 |
description: |
| 605 |
- Enable/disable wildcard RADIUS authentication. |
| 606 |
type: str |
| 607 |
choices: |
| 608 |
- 'enable' |
| 609 |
- 'disable' |
| 610 |
""" |
| 611 |
|
| 612 |
EXAMPLES = """ |
| 613 |
- name: Configure admin users. |
| 614 |
fortinet.fortios.fortios_system_admin: |
| 615 |
vdom: "{{ vdom }}" |
| 616 |
state: "present" |
| 617 |
access_token: "<your_own_value>" |
| 618 |
system_admin: |
| 619 |
accprofile: "<your_own_value> (source system.accprofile.name)" |
| 620 |
accprofile_override: "enable" |
| 621 |
allow_remove_admin_session: "enable" |
| 622 |
comments: "<your_own_value>" |
| 623 |
email_to: "<your_own_value>" |
| 624 |
force_password_change: "enable" |
| 625 |
fortitoken: "<your_own_value>" |
| 626 |
guest_auth: "disable" |
| 627 |
guest_lang: "<your_own_value> (source system.custom-language.name)" |
| 628 |
guest_usergroups: |
| 629 |
- |
| 630 |
name: "default_name_13" |
| 631 |
gui_dashboard: |
| 632 |
- |
| 633 |
columns: "10" |
| 634 |
id: "16" |
| 635 |
layout_type: "responsive" |
| 636 |
name: "default_name_18" |
| 637 |
permanent: "disable" |
| 638 |
scope: "global" |
| 639 |
vdom: "<your_own_value> (source system.vdom.name)" |
| 640 |
widget: |
| 641 |
- |
| 642 |
fabric_device: "<your_own_value>" |
| 643 |
fabric_device_widget_name: "<your_own_value>" |
| 644 |
fabric_device_widget_visualization_type: "<your_own_value>" |
| 645 |
fortiview_device: "<your_own_value>" |
| 646 |
fortiview_filters: |
| 647 |
- |
| 648 |
id: "28" |
| 649 |
key: "<your_own_value>" |
| 650 |
value: "<your_own_value>" |
| 651 |
fortiview_sort_by: "<your_own_value>" |
| 652 |
fortiview_timeframe: "<your_own_value>" |
| 653 |
fortiview_type: "<your_own_value>" |
| 654 |
fortiview_visualization: "<your_own_value>" |
| 655 |
height: "25" |
| 656 |
id: "36" |
| 657 |
industry: "default" |
| 658 |
interface: "<your_own_value> (source system.interface.name)" |
| 659 |
region: "default" |
| 660 |
title: "<your_own_value>" |
| 661 |
type: "sysinfo" |
| 662 |
width: "25" |
| 663 |
x_pos: "500" |
| 664 |
y_pos: "500" |
| 665 |
gui_global_menu_favorites: |
| 666 |
- |
| 667 |
id: "46" |
| 668 |
gui_new_feature_acknowledge: |
| 669 |
- |
| 670 |
id: "48" |
| 671 |
gui_vdom_menu_favorites: |
| 672 |
- |
| 673 |
id: "50" |
| 674 |
hidden: "127" |
| 675 |
history0: "<your_own_value>" |
| 676 |
history1: "<your_own_value>" |
| 677 |
ip6_trusthost1: "myhostname" |
| 678 |
ip6_trusthost10: "myhostname" |
| 679 |
ip6_trusthost2: "myhostname" |
| 680 |
ip6_trusthost3: "myhostname" |
| 681 |
ip6_trusthost4: "myhostname" |
| 682 |
ip6_trusthost5: "myhostname" |
| 683 |
ip6_trusthost6: "myhostname" |
| 684 |
ip6_trusthost7: "myhostname" |
| 685 |
ip6_trusthost8: "myhostname" |
| 686 |
ip6_trusthost9: "myhostname" |
| 687 |
login_time: |
| 688 |
- |
| 689 |
last_failed_login: "<your_own_value>" |
| 690 |
last_login: "<your_own_value>" |
| 691 |
usr_name: "<your_own_value>" |
| 692 |
name: "default_name_68" |
| 693 |
password: "<your_own_value>" |
| 694 |
password_expire: "<your_own_value>" |
| 695 |
peer_auth: "enable" |
| 696 |
peer_group: "<your_own_value>" |
| 697 |
radius_vdom_override: "enable" |
| 698 |
remote_auth: "enable" |
| 699 |
remote_group: "<your_own_value>" |
| 700 |
schedule: "<your_own_value>" |
| 701 |
sms_custom_server: "<your_own_value> (source system.sms-server.name)" |
| 702 |
sms_phone: "<your_own_value>" |
| 703 |
sms_server: "fortiguard" |
| 704 |
ssh_certificate: "<your_own_value> (source certificate.remote.name)" |
| 705 |
ssh_public_key1: "<your_own_value>" |
| 706 |
ssh_public_key2: "<your_own_value>" |
| 707 |
ssh_public_key3: "<your_own_value>" |
| 708 |
trusthost1: "myhostname" |
| 709 |
trusthost10: "myhostname" |
| 710 |
trusthost2: "myhostname" |
| 711 |
trusthost3: "myhostname" |
| 712 |
trusthost4: "myhostname" |
| 713 |
trusthost5: "myhostname" |
| 714 |
trusthost6: "myhostname" |
| 715 |
trusthost7: "myhostname" |
| 716 |
trusthost8: "myhostname" |
| 717 |
trusthost9: "myhostname" |
| 718 |
two_factor: "disable" |
| 719 |
two_factor_authentication: "fortitoken" |
| 720 |
two_factor_notification: "email" |
| 721 |
vdom: |
| 722 |
- |
| 723 |
name: "default_name_98 (source system.vdom.name)" |
| 724 |
vdom_override: "enable" |
| 725 |
wildcard: "enable" |
| 726 |
""" |
| 727 |
|
| 728 |
RETURN = """ |
| 729 |
build: |
| 730 |
description: Build number of the fortigate image |
| 731 |
returned: always |
| 732 |
type: str |
| 733 |
sample: '1547' |
| 734 |
http_method: |
| 735 |
description: Last method used to provision the content into FortiGate |
| 736 |
returned: always |
| 737 |
type: str |
| 738 |
sample: 'PUT' |
| 739 |
http_status: |
| 740 |
description: Last result given by FortiGate on last operation applied |
| 741 |
returned: always |
| 742 |
type: str |
| 743 |
sample: "200" |
| 744 |
mkey: |
| 745 |
description: Master key (id) used in the last call to FortiGate |
| 746 |
returned: success |
| 747 |
type: str |
| 748 |
sample: "id" |
| 749 |
name: |
| 750 |
description: Name of the table used to fulfill the request |
| 751 |
returned: always |
| 752 |
type: str |
| 753 |
sample: "urlfilter" |
| 754 |
path: |
| 755 |
description: Path of the table used to fulfill the request |
| 756 |
returned: always |
| 757 |
type: str |
| 758 |
sample: "webfilter" |
| 759 |
revision: |
| 760 |
description: Internal revision number |
| 761 |
returned: always |
| 762 |
type: str |
| 763 |
sample: "17.0.2.10658" |
| 764 |
serial: |
| 765 |
description: Serial number of the unit |
| 766 |
returned: always |
| 767 |
type: str |
| 768 |
sample: "FGVMEVYYQT3AB5352" |
| 769 |
status: |
| 770 |
description: Indication of the operation's result |
| 771 |
returned: always |
| 772 |
type: str |
| 773 |
sample: "success" |
| 774 |
vdom: |
| 775 |
description: Virtual domain used |
| 776 |
returned: always |
| 777 |
type: str |
| 778 |
sample: "root" |
| 779 |
version: |
| 780 |
description: Version of the FortiGate |
| 781 |
returned: always |
| 782 |
type: str |
| 783 |
sample: "v5.6.3" |
| 784 |
""" |
| 785 |
from ansible.module_utils.basic import AnsibleModule |
| 786 |
from ansible.module_utils.connection import Connection |
| 787 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 788 |
FortiOSHandler, |
| 789 |
) |
| 790 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 791 |
check_legacy_fortiosapi, |
| 792 |
) |
| 793 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 794 |
schema_to_module_spec, |
| 795 |
) |
| 796 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import ( |
| 797 |
check_schema_versioning, |
| 798 |
) |
| 799 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.common import ( |
| 800 |
FAIL_SOCKET_MSG, |
| 801 |
) |
| 802 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.data_post_processor import ( |
| 803 |
remove_invalid_fields, |
| 804 |
) |
| 805 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 806 |
is_same_comparison, |
| 807 |
) |
| 808 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 809 |
serialize, |
| 810 |
) |
| 811 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 812 |
find_current_values, |
| 813 |
) |
| 814 |
from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import ( |
| 815 |
unify_data_format, |
| 816 |
) |
| 817 |
|
| 818 |
|
| 819 |
def filter_system_admin_data(json): |
| 820 |
option_list = [ |
| 821 |
"accprofile", |
| 822 |
"accprofile_override", |
| 823 |
"allow_remove_admin_session", |
| 824 |
"comments", |
| 825 |
"email_to", |
| 826 |
"force_password_change", |
| 827 |
"fortitoken", |
| 828 |
"guest_auth", |
| 829 |
"guest_lang", |
| 830 |
"guest_usergroups", |
| 831 |
"gui_dashboard", |
| 832 |
"gui_global_menu_favorites", |
| 833 |
"gui_new_feature_acknowledge", |
| 834 |
"gui_vdom_menu_favorites", |
| 835 |
"hidden", |
| 836 |
"history0", |
| 837 |
"history1", |
| 838 |
"ip6_trusthost1", |
| 839 |
"ip6_trusthost10", |
| 840 |
"ip6_trusthost2", |
| 841 |
"ip6_trusthost3", |
| 842 |
"ip6_trusthost4", |
| 843 |
"ip6_trusthost5", |
| 844 |
"ip6_trusthost6", |
| 845 |
"ip6_trusthost7", |
| 846 |
"ip6_trusthost8", |
| 847 |
"ip6_trusthost9", |
| 848 |
"login_time", |
| 849 |
"name", |
| 850 |
"password", |
| 851 |
"password_expire", |
| 852 |
"peer_auth", |
| 853 |
"peer_group", |
| 854 |
"radius_vdom_override", |
| 855 |
"remote_auth", |
| 856 |
"remote_group", |
| 857 |
"schedule", |
| 858 |
"sms_custom_server", |
| 859 |
"sms_phone", |
| 860 |
"sms_server", |
| 861 |
"ssh_certificate", |
| 862 |
"ssh_public_key1", |
| 863 |
"ssh_public_key2", |
| 864 |
"ssh_public_key3", |
| 865 |
"trusthost1", |
| 866 |
"trusthost10", |
| 867 |
"trusthost2", |
| 868 |
"trusthost3", |
| 869 |
"trusthost4", |
| 870 |
"trusthost5", |
| 871 |
"trusthost6", |
| 872 |
"trusthost7", |
| 873 |
"trusthost8", |
| 874 |
"trusthost9", |
| 875 |
"two_factor", |
| 876 |
"two_factor_authentication", |
| 877 |
"two_factor_notification", |
| 878 |
"vdom", |
| 879 |
"vdom_override", |
| 880 |
"wildcard", |
| 881 |
] |
| 882 |
|
| 883 |
json = remove_invalid_fields(json) |
| 884 |
dictionary = {} |
| 885 |
|
| 886 |
for attribute in option_list: |
| 887 |
if attribute in json and json[attribute] is not None: |
| 888 |
dictionary[attribute] = json[attribute] |
| 889 |
|
| 890 |
return dictionary |
| 891 |
|
| 892 |
|
| 893 |
def underscore_to_hyphen(data): |
| 894 |
new_data = None |
| 895 |
if isinstance(data, list): |
| 896 |
new_data = [] |
| 897 |
for i, elem in enumerate(data): |
| 898 |
new_data.append(underscore_to_hyphen(elem)) |
| 899 |
elif isinstance(data, dict): |
| 900 |
new_data = {} |
| 901 |
for k, v in data.items(): |
| 902 |
new_data[k.replace("_", "-")] = underscore_to_hyphen(v) |
| 903 |
else: |
| 904 |
return data |
| 905 |
return new_data |
| 906 |
|
| 907 |
|
| 908 |
def system_admin(data, fos, check_mode=False): |
| 909 |
|
| 910 |
state = None |
| 911 |
vdom = data["vdom"] |
| 912 |
parameters = None |
| 913 |
state = data.get("state", None) |
| 914 |
admin_passwd = data.get("admin_passwd", None) |
| 915 |
if admin_passwd is True: |
| 916 |
request_headers = {"X-Admin-Passwd": True} |
| 917 |
elif admin_passwd is None or ( |
| 918 |
isinstance(admin_passwd, str) and len(admin_passwd) == 0 |
| 919 |
): |
| 920 |
request_headers = None |
| 921 |
else: |
| 922 |
request_headers = {"X-Admin-Passwd": str(admin_passwd)} |
| 923 |
system_admin_data = data["system_admin"] |
| 924 |
|
| 925 |
filtered_data = filter_system_admin_data(system_admin_data) |
| 926 |
converted_data = underscore_to_hyphen(filtered_data) |
| 927 |
|
| 928 |
|
| 929 |
if check_mode: |
| 930 |
diff = { |
| 931 |
"before": "", |
| 932 |
"after": filtered_data, |
| 933 |
} |
| 934 |
mkeyname = fos.get_mkeyname(None, None) |
| 935 |
mkey = fos.get_mkey("system", "admin", filtered_data, vdom=vdom) |
| 936 |
current_data = fos.get( |
| 937 |
"system", |
| 938 |
"admin", |
| 939 |
vdom=vdom, |
| 940 |
mkey=mkey, |
| 941 |
parameters=parameters, |
| 942 |
headers=request_headers, |
| 943 |
) |
| 944 |
is_existed = ( |
| 945 |
current_data |
| 946 |
and current_data.get("http_status") == 200 |
| 947 |
and ( |
| 948 |
mkeyname |
| 949 |
and isinstance(current_data.get("results"), list) |
| 950 |
and len(current_data["results"]) > 0 |
| 951 |
or not mkeyname |
| 952 |
and current_data["results"] |
| 953 |
) |
| 954 |
) |
| 955 |
|
| 956 |
|
| 957 |
if state == "present" or state is True or state is None: |
| 958 |
|
| 959 |
if mkeyname is not None and mkey is None: |
| 960 |
return False, True, filtered_data, diff |
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
copied_filtered_data = filtered_data.copy() |
| 965 |
copied_filtered_data.pop(mkeyname, None) |
| 966 |
unified_filtered_data = unify_data_format(copied_filtered_data) |
| 967 |
|
| 968 |
current_data_results = current_data.get("results", {}) |
| 969 |
current_config = ( |
| 970 |
current_data_results[0] |
| 971 |
if mkeyname |
| 972 |
and isinstance(current_data_results, list) |
| 973 |
and len(current_data_results) > 0 |
| 974 |
else current_data_results |
| 975 |
) |
| 976 |
if is_existed: |
| 977 |
unified_current_values = find_current_values( |
| 978 |
unified_filtered_data, |
| 979 |
unify_data_format(current_config), |
| 980 |
) |
| 981 |
|
| 982 |
is_same = is_same_comparison( |
| 983 |
serialize(unified_current_values), serialize(unified_filtered_data) |
| 984 |
) |
| 985 |
|
| 986 |
return ( |
| 987 |
False, |
| 988 |
not is_same, |
| 989 |
filtered_data, |
| 990 |
{"before": unified_current_values, "after": unified_filtered_data}, |
| 991 |
) |
| 992 |
|
| 993 |
|
| 994 |
return False, True, filtered_data, diff |
| 995 |
|
| 996 |
if state == "absent": |
| 997 |
if mkey is None: |
| 998 |
return ( |
| 999 |
False, |
| 1000 |
False, |
| 1001 |
filtered_data, |
| 1002 |
{"before": current_data["results"][0], "after": ""}, |
| 1003 |
) |
| 1004 |
|
| 1005 |
if is_existed: |
| 1006 |
return ( |
| 1007 |
False, |
| 1008 |
True, |
| 1009 |
filtered_data, |
| 1010 |
{"before": current_data["results"][0], "after": ""}, |
| 1011 |
) |
| 1012 |
return False, False, filtered_data, {} |
| 1013 |
|
| 1014 |
return True, False, {"reason: ": "Must provide state parameter"}, {} |
| 1015 |
|
| 1016 |
|
| 1017 |
data_copy = data.copy() |
| 1018 |
data_copy["system_admin"] = filtered_data |
| 1019 |
fos.do_member_operation( |
| 1020 |
"system", |
| 1021 |
"admin", |
| 1022 |
data_copy, |
| 1023 |
) |
| 1024 |
|
| 1025 |
if state == "present" or state is True: |
| 1026 |
return fos.set( |
| 1027 |
"system", |
| 1028 |
"admin", |
| 1029 |
data=converted_data, |
| 1030 |
vdom=vdom, |
| 1031 |
parameters=parameters, |
| 1032 |
headers=request_headers, |
| 1033 |
) |
| 1034 |
|
| 1035 |
elif state == "absent": |
| 1036 |
return fos.delete( |
| 1037 |
"system", |
| 1038 |
"admin", |
| 1039 |
mkey=converted_data["name"], |
| 1040 |
vdom=vdom, |
| 1041 |
parameters=parameters, |
| 1042 |
headers=request_headers, |
| 1043 |
) |
| 1044 |
else: |
| 1045 |
fos._module.fail_json(msg="state must be present or absent!") |
| 1046 |
|
| 1047 |
|
| 1048 |
def is_successful_status(resp): |
| 1049 |
return ( |
| 1050 |
"status" in resp |
| 1051 |
and resp["status"] == "success" |
| 1052 |
or "http_status" in resp |
| 1053 |
and resp["http_status"] == 200 |
| 1054 |
or "http_method" in resp |
| 1055 |
and resp["http_method"] == "DELETE" |
| 1056 |
and resp["http_status"] == 404 |
| 1057 |
) |
| 1058 |
|
| 1059 |
|
| 1060 |
def fortios_system(data, fos, check_mode): |
| 1061 |
|
| 1062 |
if data["system_admin"]: |
| 1063 |
resp = system_admin(data, fos, check_mode) |
| 1064 |
else: |
| 1065 |
fos._module.fail_json(msg="missing task body: %s" % ("system_admin")) |
| 1066 |
if isinstance(resp, tuple) and len(resp) == 4: |
| 1067 |
return resp |
| 1068 |
return ( |
| 1069 |
not is_successful_status(resp), |
| 1070 |
is_successful_status(resp) |
| 1071 |
and (resp["revision_changed"] if "revision_changed" in resp else True), |
| 1072 |
resp, |
| 1073 |
{}, |
| 1074 |
) |
| 1075 |
|
| 1076 |
|
| 1077 |
versioned_schema = { |
| 1078 |
"type": "list", |
| 1079 |
"elements": "dict", |
| 1080 |
"children": { |
| 1081 |
"name": {"v_range": [["v6.0.0", ""]], "type": "string", "required": True}, |
| 1082 |
"vdom": { |
| 1083 |
"type": "list", |
| 1084 |
"elements": "dict", |
| 1085 |
"children": { |
| 1086 |
"name": { |
| 1087 |
"v_range": [["v6.0.0", ""]], |
| 1088 |
"type": "string", |
| 1089 |
"required": True, |
| 1090 |
} |
| 1091 |
}, |
| 1092 |
"v_range": [["v6.0.0", ""]], |
| 1093 |
}, |
| 1094 |
"remote_auth": { |
| 1095 |
"v_range": [["v6.0.0", ""]], |
| 1096 |
"type": "string", |
| 1097 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1098 |
}, |
| 1099 |
"remote_group": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1100 |
"wildcard": { |
| 1101 |
"v_range": [["v6.0.0", ""]], |
| 1102 |
"type": "string", |
| 1103 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1104 |
}, |
| 1105 |
"password": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1106 |
"peer_auth": { |
| 1107 |
"v_range": [["v6.0.0", ""]], |
| 1108 |
"type": "string", |
| 1109 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1110 |
}, |
| 1111 |
"peer_group": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1112 |
"trusthost1": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1113 |
"trusthost2": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1114 |
"trusthost3": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1115 |
"trusthost4": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1116 |
"trusthost5": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1117 |
"trusthost6": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1118 |
"trusthost7": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1119 |
"trusthost8": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1120 |
"trusthost9": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1121 |
"trusthost10": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1122 |
"ip6_trusthost1": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1123 |
"ip6_trusthost2": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1124 |
"ip6_trusthost3": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1125 |
"ip6_trusthost4": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1126 |
"ip6_trusthost5": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1127 |
"ip6_trusthost6": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1128 |
"ip6_trusthost7": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1129 |
"ip6_trusthost8": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1130 |
"ip6_trusthost9": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1131 |
"ip6_trusthost10": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1132 |
"accprofile": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1133 |
"allow_remove_admin_session": { |
| 1134 |
"v_range": [["v6.0.0", ""]], |
| 1135 |
"type": "string", |
| 1136 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1137 |
}, |
| 1138 |
"comments": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1139 |
"ssh_public_key1": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1140 |
"ssh_public_key2": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1141 |
"ssh_public_key3": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1142 |
"ssh_certificate": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1143 |
"schedule": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1144 |
"accprofile_override": { |
| 1145 |
"v_range": [["v6.0.0", ""]], |
| 1146 |
"type": "string", |
| 1147 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1148 |
}, |
| 1149 |
"vdom_override": { |
| 1150 |
"v_range": [["v7.2.1", ""]], |
| 1151 |
"type": "string", |
| 1152 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1153 |
}, |
| 1154 |
"password_expire": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1155 |
"force_password_change": { |
| 1156 |
"v_range": [["v6.0.0", ""]], |
| 1157 |
"type": "string", |
| 1158 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1159 |
}, |
| 1160 |
"two_factor": { |
| 1161 |
"v_range": [["v6.0.0", ""]], |
| 1162 |
"type": "string", |
| 1163 |
"options": [ |
| 1164 |
{"value": "disable"}, |
| 1165 |
{"value": "fortitoken"}, |
| 1166 |
{"value": "fortitoken-cloud", "v_range": [["v6.2.0", ""]]}, |
| 1167 |
{"value": "email"}, |
| 1168 |
{"value": "sms"}, |
| 1169 |
], |
| 1170 |
}, |
| 1171 |
"two_factor_authentication": { |
| 1172 |
"v_range": [["v6.2.0", "v6.2.0"], ["v6.2.5", ""]], |
| 1173 |
"type": "string", |
| 1174 |
"options": [{"value": "fortitoken"}, {"value": "email"}, {"value": "sms"}], |
| 1175 |
}, |
| 1176 |
"two_factor_notification": { |
| 1177 |
"v_range": [["v6.2.0", "v6.2.0"], ["v6.2.5", ""]], |
| 1178 |
"type": "string", |
| 1179 |
"options": [{"value": "email"}, {"value": "sms"}], |
| 1180 |
}, |
| 1181 |
"fortitoken": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1182 |
"email_to": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1183 |
"sms_server": { |
| 1184 |
"v_range": [["v6.0.0", ""]], |
| 1185 |
"type": "string", |
| 1186 |
"options": [{"value": "fortiguard"}, {"value": "custom"}], |
| 1187 |
}, |
| 1188 |
"sms_custom_server": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1189 |
"sms_phone": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1190 |
"guest_auth": { |
| 1191 |
"v_range": [["v6.0.0", ""]], |
| 1192 |
"type": "string", |
| 1193 |
"options": [{"value": "disable"}, {"value": "enable"}], |
| 1194 |
}, |
| 1195 |
"guest_usergroups": { |
| 1196 |
"type": "list", |
| 1197 |
"elements": "dict", |
| 1198 |
"children": { |
| 1199 |
"name": { |
| 1200 |
"v_range": [["v6.0.0", ""]], |
| 1201 |
"type": "string", |
| 1202 |
"required": True, |
| 1203 |
} |
| 1204 |
}, |
| 1205 |
"v_range": [["v6.0.0", ""]], |
| 1206 |
}, |
| 1207 |
"guest_lang": {"v_range": [["v6.0.0", ""]], "type": "string"}, |
| 1208 |
"radius_vdom_override": { |
| 1209 |
"v_range": [["v6.0.0", "v7.2.0"]], |
| 1210 |
"type": "string", |
| 1211 |
"options": [{"value": "enable"}, {"value": "disable"}], |
| 1212 |
}, |
| 1213 |
"gui_dashboard": { |
| 1214 |
"type": "list", |
| 1215 |
"elements": "dict", |
| 1216 |
"children": { |
| 1217 |
"id": { |
| 1218 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1219 |
"type": "integer", |
| 1220 |
"required": True, |
| 1221 |
}, |
| 1222 |
"name": { |
| 1223 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1224 |
"type": "string", |
| 1225 |
}, |
| 1226 |
"vdom": {"v_range": [["v6.2.3", "v6.2.3"]], "type": "string"}, |
| 1227 |
"layout_type": { |
| 1228 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1229 |
"type": "string", |
| 1230 |
"options": [{"value": "responsive"}, {"value": "fixed"}], |
| 1231 |
}, |
| 1232 |
"permanent": { |
| 1233 |
"v_range": [["v6.2.3", "v6.2.3"]], |
| 1234 |
"type": "string", |
| 1235 |
"options": [{"value": "disable"}, {"value": "enable"}], |
| 1236 |
}, |
| 1237 |
"columns": { |
| 1238 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1239 |
"type": "integer", |
| 1240 |
}, |
| 1241 |
"widget": { |
| 1242 |
"type": "list", |
| 1243 |
"elements": "dict", |
| 1244 |
"children": { |
| 1245 |
"id": { |
| 1246 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1247 |
"type": "integer", |
| 1248 |
"required": True, |
| 1249 |
}, |
| 1250 |
"type": { |
| 1251 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1252 |
"type": "string", |
| 1253 |
"options": [ |
| 1254 |
{"value": "sysinfo"}, |
| 1255 |
{"value": "licinfo"}, |
| 1256 |
{"value": "forticloud"}, |
| 1257 |
{"value": "cpu-usage"}, |
| 1258 |
{"value": "memory-usage"}, |
| 1259 |
{"value": "disk-usage"}, |
| 1260 |
{"value": "log-rate"}, |
| 1261 |
{"value": "sessions"}, |
| 1262 |
{"value": "session-rate"}, |
| 1263 |
{"value": "tr-history"}, |
| 1264 |
{"value": "analytics"}, |
| 1265 |
{"value": "usb-modem"}, |
| 1266 |
{"value": "admins"}, |
| 1267 |
{"value": "security-fabric"}, |
| 1268 |
{"value": "security-fabric-ranking"}, |
| 1269 |
{"value": "sensor-info"}, |
| 1270 |
{"value": "ha-status"}, |
| 1271 |
{"value": "vulnerability-summary"}, |
| 1272 |
{"value": "host-scan-summary"}, |
| 1273 |
{"value": "fortiview"}, |
| 1274 |
{"value": "botnet-activity"}, |
| 1275 |
{ |
| 1276 |
"value": "fabric-device", |
| 1277 |
"v_range": [["v6.2.3", "v6.2.3"]], |
| 1278 |
}, |
| 1279 |
{ |
| 1280 |
"value": "fortimail", |
| 1281 |
"v_range": [["v6.0.0", "v6.0.11"]], |
| 1282 |
}, |
| 1283 |
], |
| 1284 |
}, |
| 1285 |
"x_pos": { |
| 1286 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1287 |
"type": "integer", |
| 1288 |
}, |
| 1289 |
"y_pos": { |
| 1290 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1291 |
"type": "integer", |
| 1292 |
}, |
| 1293 |
"width": { |
| 1294 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1295 |
"type": "integer", |
| 1296 |
}, |
| 1297 |
"height": { |
| 1298 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1299 |
"type": "integer", |
| 1300 |
}, |
| 1301 |
"interface": { |
| 1302 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1303 |
"type": "string", |
| 1304 |
}, |
| 1305 |
"region": { |
| 1306 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1307 |
"type": "string", |
| 1308 |
"options": [{"value": "default"}, {"value": "custom"}], |
| 1309 |
}, |
| 1310 |
"industry": { |
| 1311 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1312 |
"type": "string", |
| 1313 |
"options": [{"value": "default"}, {"value": "custom"}], |
| 1314 |
}, |
| 1315 |
"fabric_device": { |
| 1316 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1317 |
"type": "string", |
| 1318 |
}, |
| 1319 |
"fabric_device_widget_name": { |
| 1320 |
"v_range": [["v6.2.3", "v6.2.3"]], |
| 1321 |
"type": "string", |
| 1322 |
}, |
| 1323 |
"fabric_device_widget_visualization_type": { |
| 1324 |
"v_range": [["v6.2.3", "v6.2.3"]], |
| 1325 |
"type": "string", |
| 1326 |
}, |
| 1327 |
"title": { |
| 1328 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1329 |
"type": "string", |
| 1330 |
}, |
| 1331 |
"fortiview_type": { |
| 1332 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1333 |
"type": "string", |
| 1334 |
}, |
| 1335 |
"fortiview_sort_by": { |
| 1336 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1337 |
"type": "string", |
| 1338 |
}, |
| 1339 |
"fortiview_timeframe": { |
| 1340 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1341 |
"type": "string", |
| 1342 |
}, |
| 1343 |
"fortiview_visualization": { |
| 1344 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1345 |
"type": "string", |
| 1346 |
}, |
| 1347 |
"fortiview_device": { |
| 1348 |
"v_range": [["v6.2.3", "v6.2.3"]], |
| 1349 |
"type": "string", |
| 1350 |
}, |
| 1351 |
"fortiview_filters": { |
| 1352 |
"type": "list", |
| 1353 |
"elements": "dict", |
| 1354 |
"children": { |
| 1355 |
"id": { |
| 1356 |
"v_range": [ |
| 1357 |
["v6.0.0", "v6.0.11"], |
| 1358 |
["v6.2.3", "v6.2.3"], |
| 1359 |
], |
| 1360 |
"type": "integer", |
| 1361 |
"required": True, |
| 1362 |
}, |
| 1363 |
"key": { |
| 1364 |
"v_range": [ |
| 1365 |
["v6.0.0", "v6.0.11"], |
| 1366 |
["v6.2.3", "v6.2.3"], |
| 1367 |
], |
| 1368 |
"type": "string", |
| 1369 |
}, |
| 1370 |
"value": { |
| 1371 |
"v_range": [ |
| 1372 |
["v6.0.0", "v6.0.11"], |
| 1373 |
["v6.2.3", "v6.2.3"], |
| 1374 |
], |
| 1375 |
"type": "string", |
| 1376 |
}, |
| 1377 |
}, |
| 1378 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1379 |
}, |
| 1380 |
}, |
| 1381 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1382 |
}, |
| 1383 |
"scope": { |
| 1384 |
"v_range": [["v6.0.0", "v6.0.11"]], |
| 1385 |
"type": "string", |
| 1386 |
"options": [{"value": "global"}, {"value": "vdom"}], |
| 1387 |
}, |
| 1388 |
}, |
| 1389 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1390 |
}, |
| 1391 |
"history0": { |
| 1392 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1393 |
"type": "string", |
| 1394 |
}, |
| 1395 |
"history1": { |
| 1396 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1397 |
"type": "string", |
| 1398 |
}, |
| 1399 |
"login_time": { |
| 1400 |
"type": "list", |
| 1401 |
"elements": "dict", |
| 1402 |
"children": { |
| 1403 |
"usr_name": { |
| 1404 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1405 |
"type": "string", |
| 1406 |
"required": True, |
| 1407 |
}, |
| 1408 |
"last_login": { |
| 1409 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1410 |
"type": "string", |
| 1411 |
}, |
| 1412 |
"last_failed_login": { |
| 1413 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1414 |
"type": "string", |
| 1415 |
}, |
| 1416 |
}, |
| 1417 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1418 |
}, |
| 1419 |
"gui_global_menu_favorites": { |
| 1420 |
"type": "list", |
| 1421 |
"elements": "dict", |
| 1422 |
"children": { |
| 1423 |
"id": { |
| 1424 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1425 |
"type": "string", |
| 1426 |
"required": True, |
| 1427 |
} |
| 1428 |
}, |
| 1429 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1430 |
}, |
| 1431 |
"gui_vdom_menu_favorites": { |
| 1432 |
"type": "list", |
| 1433 |
"elements": "dict", |
| 1434 |
"children": { |
| 1435 |
"id": { |
| 1436 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1437 |
"type": "string", |
| 1438 |
"required": True, |
| 1439 |
} |
| 1440 |
}, |
| 1441 |
"v_range": [["v6.0.0", "v6.0.11"], ["v6.2.3", "v6.2.3"]], |
| 1442 |
}, |
| 1443 |
"gui_new_feature_acknowledge": { |
| 1444 |
"type": "list", |
| 1445 |
"elements": "dict", |
| 1446 |
"children": { |
| 1447 |
"id": { |
| 1448 |
"v_range": [["v6.2.3", "v6.2.3"]], |
| 1449 |
"type": "string", |
| 1450 |
"required": True, |
| 1451 |
} |
| 1452 |
}, |
| 1453 |
"v_range": [["v6.2.3", "v6.2.3"]], |
| 1454 |
}, |
| 1455 |
"hidden": {"v_range": [["v6.0.0", "v6.0.11"]], "type": "integer"}, |
| 1456 |
}, |
| 1457 |
"v_range": [["v6.0.0", ""]], |
| 1458 |
} |
| 1459 |
|
| 1460 |
|
| 1461 |
def main(): |
| 1462 |
module_spec = schema_to_module_spec(versioned_schema) |
| 1463 |
mkeyname = "name" |
| 1464 |
fields = { |
| 1465 |
"access_token": {"required": False, "type": "str", "no_log": True}, |
| 1466 |
"enable_log": {"required": False, "type": "bool", "default": False}, |
| 1467 |
"vdom": {"required": False, "type": "str", "default": "root"}, |
| 1468 |
"member_path": {"required": False, "type": "str"}, |
| 1469 |
"member_state": { |
| 1470 |
"type": "str", |
| 1471 |
"required": False, |
| 1472 |
"choices": ["present", "absent"], |
| 1473 |
}, |
| 1474 |
"state": {"required": True, "type": "str", "choices": ["present", "absent"]}, |
| 1475 |
"system_admin": { |
| 1476 |
"required": False, |
| 1477 |
"type": "dict", |
| 1478 |
"default": None, |
| 1479 |
"options": {}, |
| 1480 |
}, |
| 1481 |
} |
| 1482 |
for attribute_name in module_spec["options"]: |
| 1483 |
fields["system_admin"]["options"][attribute_name] = module_spec["options"][ |
| 1484 |
attribute_name |
| 1485 |
] |
| 1486 |
if mkeyname and mkeyname == attribute_name: |
| 1487 |
fields["system_admin"]["options"][attribute_name]["required"] = True |
| 1488 |
|
| 1489 |
module = AnsibleModule(argument_spec=fields, supports_check_mode=True) |
| 1490 |
check_legacy_fortiosapi(module) |
| 1491 |
|
| 1492 |
is_error = False |
| 1493 |
has_changed = False |
| 1494 |
result = None |
| 1495 |
diff = None |
| 1496 |
|
| 1497 |
versions_check_result = None |
| 1498 |
if module._socket_path: |
| 1499 |
connection = Connection(module._socket_path) |
| 1500 |
if "access_token" in module.params: |
| 1501 |
connection.set_custom_option("access_token", module.params["access_token"]) |
| 1502 |
|
| 1503 |
if "enable_log" in module.params: |
| 1504 |
connection.set_custom_option("enable_log", module.params["enable_log"]) |
| 1505 |
else: |
| 1506 |
connection.set_custom_option("enable_log", False) |
| 1507 |
|
| 1508 |
|
| 1509 |
try: |
| 1510 |
if connection.get_option("password"): |
| 1511 |
module.params["admin_passwd"] = True |
| 1512 |
except Exception: |
| 1513 |
pass |
| 1514 |
fos = FortiOSHandler(connection, module, mkeyname) |
| 1515 |
versions_check_result = check_schema_versioning( |
| 1516 |
fos, versioned_schema, "system_admin" |
| 1517 |
) |
| 1518 |
|
| 1519 |
is_error, has_changed, result, diff = fortios_system( |
| 1520 |
module.params, fos, module.check_mode |
| 1521 |
) |
| 1522 |
|
| 1523 |
else: |
| 1524 |
module.fail_json(**FAIL_SOCKET_MSG) |
| 1525 |
|
| 1526 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1527 |
module.warn( |
| 1528 |
"Ansible has detected version mismatch between FortOS system and your playbook, see more details by specifying option -vvv" |
| 1529 |
) |
| 1530 |
|
| 1531 |
if not is_error: |
| 1532 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1533 |
module.exit_json( |
| 1534 |
changed=has_changed, |
| 1535 |
version_check_warning=versions_check_result, |
| 1536 |
meta=result, |
| 1537 |
diff=diff, |
| 1538 |
) |
| 1539 |
else: |
| 1540 |
module.exit_json(changed=has_changed, meta=result, diff=diff) |
| 1541 |
else: |
| 1542 |
if versions_check_result and versions_check_result["matched"] is False: |
| 1543 |
module.fail_json( |
| 1544 |
msg="Error in repo", |
| 1545 |
version_check_warning=versions_check_result, |
| 1546 |
meta=result, |
| 1547 |
) |
| 1548 |
else: |
| 1549 |
module.fail_json(msg="Error in repo", meta=result) |
| 1550 |
|
| 1551 |
|
| 1552 |
if __name__ == "__main__": |
| 1553 |
main() |