| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
# |
| 4 |
# Copyright: (c) 2023, ONODERA Masaru <[email protected]> |
| 5 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
from __future__ import absolute_import, division, print_function |
| 8 |
|
| 9 |
__metaclass__ = type |
| 10 |
|
| 11 |
|
| 12 |
DOCUMENTATION = """ |
| 13 |
--- |
| 14 |
module: zabbix_settings |
| 15 |
|
| 16 |
short_description: Update Zabbix global settings. |
| 17 |
|
| 18 |
description: |
| 19 |
- This module allows you to update Zabbix global settings. |
| 20 |
|
| 21 |
author: |
| 22 |
- ONODERA Masaru(@masa-orca) |
| 23 |
|
| 24 |
requirements: |
| 25 |
- "python >= 3.9" |
| 26 |
|
| 27 |
version_added: 2.1.0 |
| 28 |
|
| 29 |
options: |
| 30 |
default_lang: |
| 31 |
description: |
| 32 |
- Default language for users. |
| 33 |
required: false |
| 34 |
type: str |
| 35 |
default_timezone: |
| 36 |
description: |
| 37 |
- Default time zone for users. |
| 38 |
- Please set C(system) if you want to use system time zone. |
| 39 |
required: false |
| 40 |
type: str |
| 41 |
default_theme: |
| 42 |
description: |
| 43 |
- Default theme for users. |
| 44 |
required: false |
| 45 |
type: str |
| 46 |
choices: |
| 47 |
- blue-theme |
| 48 |
- dark-theme |
| 49 |
- hc-light |
| 50 |
- hc-dark |
| 51 |
search_limit: |
| 52 |
description: |
| 53 |
- A number of search and filter results limit. |
| 54 |
required: false |
| 55 |
type: int |
| 56 |
max_overview_table_size: |
| 57 |
description: |
| 58 |
- Max number of columns and rows in overview tables |
| 59 |
required: false |
| 60 |
type: int |
| 61 |
max_in_table: |
| 62 |
description: |
| 63 |
- Max count of elements to show inside table cell |
| 64 |
required: false |
| 65 |
type: int |
| 66 |
server_check_interval: |
| 67 |
description: |
| 68 |
- The Zabbix shows "Zabbix server is down" warning if C(true). |
| 69 |
required: false |
| 70 |
type: bool |
| 71 |
work_period: |
| 72 |
description: |
| 73 |
- Working time setting. |
| 74 |
- U(https://www.zabbix.com/documentation/current/en/manual/appendix/time_period) |
| 75 |
required: false |
| 76 |
type: str |
| 77 |
show_technical_errors: |
| 78 |
description: |
| 79 |
- The Zabbix shows PHP and SQL technical errors to users who are non-Super admin or belong to user groups with debug mode not enabled if C(true). |
| 80 |
required: false |
| 81 |
type: bool |
| 82 |
history_period: |
| 83 |
description: |
| 84 |
- Max period of displaying history data. |
| 85 |
- Accepts seconds and time unit with suffix (e.g. 24h). |
| 86 |
required: false |
| 87 |
type: str |
| 88 |
period_default: |
| 89 |
description: |
| 90 |
- Default period value for time filter. |
| 91 |
- Accepts seconds and time unit with suffix (e.g. 1h). |
| 92 |
required: false |
| 93 |
type: str |
| 94 |
max_period: |
| 95 |
description: |
| 96 |
- Max period for time filter. |
| 97 |
- Accepts seconds and time unit with suffix (e.g. 1y). |
| 98 |
required: false |
| 99 |
type: str |
| 100 |
severity_color_0: |
| 101 |
description: |
| 102 |
- A custom color for not classified severity. |
| 103 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 104 |
required: false |
| 105 |
type: str |
| 106 |
severity_color_1: |
| 107 |
description: |
| 108 |
- A custom color for information severity. |
| 109 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 110 |
required: false |
| 111 |
type: str |
| 112 |
severity_color_2: |
| 113 |
description: |
| 114 |
- A custom color for warning severity. |
| 115 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 116 |
required: false |
| 117 |
type: str |
| 118 |
severity_color_3: |
| 119 |
description: |
| 120 |
- A custom color for average severity. |
| 121 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 122 |
required: false |
| 123 |
type: str |
| 124 |
severity_color_4: |
| 125 |
description: |
| 126 |
- A custom color for high severity. |
| 127 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 128 |
required: false |
| 129 |
type: str |
| 130 |
severity_color_5: |
| 131 |
description: |
| 132 |
- A custom color for disaster severity. |
| 133 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 134 |
required: false |
| 135 |
type: str |
| 136 |
severity_name_0: |
| 137 |
description: |
| 138 |
- A custom name for not classified severity. |
| 139 |
required: false |
| 140 |
type: str |
| 141 |
severity_name_1: |
| 142 |
description: |
| 143 |
- A custom name for information severity. |
| 144 |
required: false |
| 145 |
type: str |
| 146 |
severity_name_2: |
| 147 |
description: |
| 148 |
- A custom name for warning severity. |
| 149 |
required: false |
| 150 |
type: str |
| 151 |
severity_name_3: |
| 152 |
description: |
| 153 |
- A custom name for average severity. |
| 154 |
required: false |
| 155 |
type: str |
| 156 |
severity_name_4: |
| 157 |
description: |
| 158 |
- A custom name for high severity. |
| 159 |
required: false |
| 160 |
type: str |
| 161 |
severity_name_5: |
| 162 |
description: |
| 163 |
- A custom name for disaster severity. |
| 164 |
required: false |
| 165 |
type: str |
| 166 |
custom_color: |
| 167 |
description: |
| 168 |
- Custom event color settings will be activated if C(true). |
| 169 |
required: false |
| 170 |
type: bool |
| 171 |
ok_period: |
| 172 |
description: |
| 173 |
- A time of period for displaying OK triggers. |
| 174 |
- Accepts seconds and time unit with suffix (e.g. 5m). |
| 175 |
required: false |
| 176 |
type: str |
| 177 |
blink_period: |
| 178 |
description: |
| 179 |
- A time of period for blinking status changed triggers. |
| 180 |
- Accepts seconds and time unit with suffix (e.g. 5m). |
| 181 |
required: false |
| 182 |
type: str |
| 183 |
problem_unack_color: |
| 184 |
description: |
| 185 |
- A custom color for unacknowledged PROBLEM events. |
| 186 |
- This setting will be activated if I(custom_color=true). |
| 187 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 188 |
required: false |
| 189 |
type: str |
| 190 |
problem_ack_color: |
| 191 |
description: |
| 192 |
- A custom color for acknowledged PROBLEM events. |
| 193 |
- This setting will be activated if I(custom_color=true). |
| 194 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 195 |
required: false |
| 196 |
type: str |
| 197 |
ok_unack_color: |
| 198 |
description: |
| 199 |
- A custom color for unacknowledged RESOLVED events. |
| 200 |
- This setting will be activated if I(custom_color=true). |
| 201 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 202 |
required: false |
| 203 |
type: str |
| 204 |
ok_ack_color: |
| 205 |
description: |
| 206 |
- A custom color for acknowledged RESOLVED events. |
| 207 |
- This setting will be activated if I(custom_color=true). |
| 208 |
- Please set hexadecimal color code (e.g. 00FF00). |
| 209 |
required: false |
| 210 |
type: str |
| 211 |
problem_unack_style: |
| 212 |
description: |
| 213 |
- Unacknowledged PROBLEM events blink if C(true). |
| 214 |
required: false |
| 215 |
type: bool |
| 216 |
problem_ack_style: |
| 217 |
description: |
| 218 |
- Acknowledged PROBLEM events blink if C(true). |
| 219 |
required: false |
| 220 |
type: bool |
| 221 |
ok_unack_style: |
| 222 |
description: |
| 223 |
- Unacknowledged RESOLVED events blink if C(true). |
| 224 |
required: false |
| 225 |
type: bool |
| 226 |
ok_ack_style: |
| 227 |
description: |
| 228 |
- Acknowledged RESOLVED events blink if C(true). |
| 229 |
required: false |
| 230 |
type: bool |
| 231 |
frontend_url: |
| 232 |
description: |
| 233 |
- A URL of frontend. |
| 234 |
- This parameter is used for url parameter of settings API. |
| 235 |
required: false |
| 236 |
type: str |
| 237 |
discovery_group: |
| 238 |
description: |
| 239 |
- A hostgroup which discovered hosts will belong to. |
| 240 |
required: false |
| 241 |
type: str |
| 242 |
default_inventory_mode: |
| 243 |
description: |
| 244 |
- A default value for host inventory mode. |
| 245 |
required: false |
| 246 |
type: str |
| 247 |
choices: |
| 248 |
- disabled |
| 249 |
- manual |
| 250 |
- automatic |
| 251 |
alert_usrgrp: |
| 252 |
description: |
| 253 |
- A name of user group which user belongs to receive an alerm message when database down. |
| 254 |
required: false |
| 255 |
type: str |
| 256 |
snmptrap_logging: |
| 257 |
description: |
| 258 |
- Logging unmatched SNMP traps will be ebabled if C(true). |
| 259 |
required: false |
| 260 |
type: bool |
| 261 |
login_attempts: |
| 262 |
description: |
| 263 |
- A number of login attempts you can try with non blocked. |
| 264 |
required: false |
| 265 |
type: int |
| 266 |
login_block: |
| 267 |
description: |
| 268 |
- A time of interval to reset login attempts when the user is blocked. |
| 269 |
- Accepts seconds and time unit with suffix (e.g. 5m). |
| 270 |
required: false |
| 271 |
type: str |
| 272 |
validate_uri_schemes: |
| 273 |
description: |
| 274 |
- Validate URI schemes if C(true). |
| 275 |
required: false |
| 276 |
type: bool |
| 277 |
uri_valid_schemes: |
| 278 |
description: |
| 279 |
- A list of valid URI scheme. |
| 280 |
required: false |
| 281 |
type: list |
| 282 |
elements: str |
| 283 |
x_frame_options: |
| 284 |
description: |
| 285 |
- A text of X-Frame-Options of HTTP header. |
| 286 |
required: false |
| 287 |
type: str |
| 288 |
iframe_sandboxing_enabled: |
| 289 |
description: |
| 290 |
- The Zabbix uses iframe sandboxing if C(true). |
| 291 |
required: false |
| 292 |
type: bool |
| 293 |
iframe_sandboxing_exceptions: |
| 294 |
description: |
| 295 |
- A text of iframe sandboxing exceptions. |
| 296 |
required: false |
| 297 |
type: str |
| 298 |
|
| 299 |
timeout_zabbix_agent: |
| 300 |
description: |
| 301 |
- A time of zabbix agent timeout. |
| 302 |
- This parameter is available since Zabbix 7.0 |
| 303 |
required: false |
| 304 |
type: str |
| 305 |
|
| 306 |
timeout_simple_check: |
| 307 |
description: |
| 308 |
- A time of simple check timeout. |
| 309 |
- This parameter is available since Zabbix 7.0 |
| 310 |
required: false |
| 311 |
type: str |
| 312 |
|
| 313 |
timeout_snmp_agent: |
| 314 |
description: |
| 315 |
- A time of SNMP agent timeout. |
| 316 |
- This parameter is available since Zabbix 7.0 |
| 317 |
required: false |
| 318 |
type: str |
| 319 |
|
| 320 |
timeout_external_check: |
| 321 |
description: |
| 322 |
- A time of external check timeout. |
| 323 |
- This parameter is available since Zabbix 7.0 |
| 324 |
required: false |
| 325 |
type: str |
| 326 |
|
| 327 |
timeout_db_monitor: |
| 328 |
description: |
| 329 |
- A time of db monitor timeout. |
| 330 |
- This parameter is available since Zabbix 7.0 |
| 331 |
required: false |
| 332 |
type: str |
| 333 |
|
| 334 |
timeout_http_agent: |
| 335 |
description: |
| 336 |
- A time of HTTP agent timeout. |
| 337 |
- This parameter is available since Zabbix 7.0 |
| 338 |
required: false |
| 339 |
type: str |
| 340 |
|
| 341 |
timeout_ssh_agent: |
| 342 |
description: |
| 343 |
- A time of SSH agent timeout. |
| 344 |
- This parameter is available since Zabbix 7.0 |
| 345 |
required: false |
| 346 |
type: str |
| 347 |
|
| 348 |
timeout_telnet_agent: |
| 349 |
description: |
| 350 |
- A time of telnet agent timeout. |
| 351 |
- This parameter is available since Zabbix 7.0 |
| 352 |
required: false |
| 353 |
type: str |
| 354 |
|
| 355 |
timeout_script: |
| 356 |
description: |
| 357 |
- A time of script timeout. |
| 358 |
- This parameter is available since Zabbix 7.0 |
| 359 |
required: false |
| 360 |
type: str |
| 361 |
|
| 362 |
timeout_browser: |
| 363 |
description: |
| 364 |
- A time of browser timeout. |
| 365 |
- This parameter is available since Zabbix 7.0 |
| 366 |
required: false |
| 367 |
type: str |
| 368 |
|
| 369 |
connect_timeout: |
| 370 |
description: |
| 371 |
- A time of connection timeout with Zabbix server. |
| 372 |
required: false |
| 373 |
type: str |
| 374 |
socket_timeout: |
| 375 |
description: |
| 376 |
- A time of network default timeout. |
| 377 |
required: false |
| 378 |
type: str |
| 379 |
media_type_test_timeout: |
| 380 |
description: |
| 381 |
- A time of network timeout for media type test. |
| 382 |
required: false |
| 383 |
type: str |
| 384 |
item_test_timeout: |
| 385 |
description: |
| 386 |
- A time of network timeout for item tests. |
| 387 |
required: false |
| 388 |
type: str |
| 389 |
script_timeout: |
| 390 |
description: |
| 391 |
- A time of network timeout for script execution. |
| 392 |
required: false |
| 393 |
type: str |
| 394 |
report_test_timeout: |
| 395 |
description: |
| 396 |
- A time of network timeout for scheduled report test. |
| 397 |
required: false |
| 398 |
type: str |
| 399 |
auditlog_enabled: |
| 400 |
description: |
| 401 |
- Enable audit logging if C(true). |
| 402 |
required: false |
| 403 |
type: bool |
| 404 |
auditlog_mode: |
| 405 |
description: |
| 406 |
- Enable logging of system actions (changes by low-level discovery, network discovery and autoregistration) if C(true). |
| 407 |
- This parameter is available since Zabbix 7.0 |
| 408 |
required: false |
| 409 |
type: bool |
| 410 |
geomaps_tile_provider: |
| 411 |
description: |
| 412 |
- A provider of Geomap tile. |
| 413 |
- Please set C(another) if you want use non default provider |
| 414 |
required: false |
| 415 |
type: str |
| 416 |
choices: |
| 417 |
- OpenStreetMap.Mapnik |
| 418 |
- OpenTopoMap |
| 419 |
- Stamen.TonerLite |
| 420 |
- Stamen.Terrain |
| 421 |
- USGS.USTopo |
| 422 |
- USGS.USImagery |
| 423 |
- another |
| 424 |
geomaps_tile_url: |
| 425 |
description: |
| 426 |
- A URL of geomap tile. |
| 427 |
required: false |
| 428 |
type: str |
| 429 |
geomaps_max_zoom: |
| 430 |
description: |
| 431 |
- Max zoom level of geomap. |
| 432 |
required: false |
| 433 |
type: str |
| 434 |
geomaps_attribution: |
| 435 |
description: |
| 436 |
- A text of Geomap attribution. |
| 437 |
required: false |
| 438 |
type: str |
| 439 |
vault_provider: |
| 440 |
description: |
| 441 |
- A name of vault provider. |
| 442 |
- This parameter is available since Zabbix 6.2. |
| 443 |
required: false |
| 444 |
type: str |
| 445 |
choices: |
| 446 |
- HashiCorp_Vault |
| 447 |
- CyberArk_Vault |
| 448 |
|
| 449 |
notes: |
| 450 |
- This module manages settings related with settings api except ha_failover_delay. |
| 451 |
|
| 452 |
extends_documentation_fragment: |
| 453 |
- community.zabbix.zabbix |
| 454 |
""" |
| 455 |
|
| 456 |
EXAMPLES = """ |
| 457 |
# If you want to use Username and Password to be authenticated by Zabbix Server |
| 458 |
- name: Set credentials to access Zabbix Server API |
| 459 |
ansible.builtin.set_fact: |
| 460 |
ansible_user: Admin |
| 461 |
ansible_httpapi_pass: zabbix |
| 462 |
|
| 463 |
# If you want to use API token to be authenticated by Zabbix Server |
| 464 |
# https://www.zabbix.com/documentation/current/en/manual/web_interface/frontend_sections/administration/general#api-tokens |
| 465 |
- name: Set API token |
| 466 |
ansible.builtin.set_fact: |
| 467 |
ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 |
| 468 |
|
| 469 |
- name: Update settings |
| 470 |
# set task level variables as we change ansible_connection plugin here |
| 471 |
vars: |
| 472 |
ansible_network_os: community.zabbix.zabbix |
| 473 |
ansible_connection: httpapi |
| 474 |
ansible_httpapi_port: 443 |
| 475 |
ansible_httpapi_use_ssl: true |
| 476 |
ansible_httpapi_validate_certs: false |
| 477 |
ansible_zabbix_url_path: "zabbixeu" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu |
| 478 |
ansible_host: zabbix-example-fqdn.org |
| 479 |
community.zabbix.zabbix_settings: |
| 480 |
alert_usrgrp: "0" |
| 481 |
auditlog_enabled: false |
| 482 |
auditlog_mode: false |
| 483 |
blink_period: "10m" |
| 484 |
timeout_zabbix_agent: "30s" |
| 485 |
connect_timeout: "30s" |
| 486 |
custom_color: false |
| 487 |
default_inventory_mode: automatic |
| 488 |
""" |
| 489 |
|
| 490 |
RETURN = """ |
| 491 |
msg: |
| 492 |
description: The result of the operation |
| 493 |
returned: success |
| 494 |
type: str |
| 495 |
sample: "Successfully update global settings" |
| 496 |
""" |
| 497 |
|
| 498 |
import re |
| 499 |
|
| 500 |
from ansible.module_utils.basic import AnsibleModule |
| 501 |
|
| 502 |
from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase |
| 503 |
from ansible.module_utils.compat.version import LooseVersion |
| 504 |
import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils |
| 505 |
|
| 506 |
|
| 507 |
class Settings(ZabbixBase): |
| 508 |
# get setting setting |
| 509 |
def get_settings(self): |
| 510 |
try: |
| 511 |
return self._zapi.settings.get({"output": "extend"}) |
| 512 |
except Exception as e: |
| 513 |
self._module.fail_json(msg="Failed to get settings: %s" % e) |
| 514 |
|
| 515 |
def _is_time(self, time): |
| 516 |
pattern = re.compile(r"^(\d+)([smhdwMy]?)$") |
| 517 |
search_result = pattern.search(time) |
| 518 |
if search_result is None: |
| 519 |
self._module.fail_json(msg="{0} is invalid value.".format(time)) |
| 520 |
return True |
| 521 |
|
| 522 |
def _is_color(self, color): |
| 523 |
pattern = re.compile(r"^[0-9a-fA-F]{6}$") |
| 524 |
search_result = pattern.search(color) |
| 525 |
if search_result is None: |
| 526 |
self._module.fail_json(msg="{0} is invalid value.".format(color)) |
| 527 |
return True |
| 528 |
|
| 529 |
def get_usrgrpid_from_name(self, usrgrp): |
| 530 |
usrgrpids = self._zapi.usergroup.get({"filter": {"name": usrgrp}}) |
| 531 |
if not usrgrpids or len(usrgrpids) > 1: |
| 532 |
self._module.fail_json("User group '%s' cannot be found" % usrgrp) |
| 533 |
return usrgrpids[0]["usrgrpid"] |
| 534 |
|
| 535 |
def get_groupid_from_name(self, hostgroup): |
| 536 |
groupid = self._zapi.hostgroup.get({"filter": {"name": hostgroup}}) |
| 537 |
if not groupid or len(groupid) > 1: |
| 538 |
self._module.fail_json("Host group '%s' cannot be found" % hostgroup) |
| 539 |
return groupid[0]["groupid"] |
| 540 |
|
| 541 |
def update_settings( |
| 542 |
self, |
| 543 |
current_settings, |
| 544 |
default_lang, |
| 545 |
default_timezone, |
| 546 |
default_theme, |
| 547 |
search_limit, |
| 548 |
max_overview_table_size, |
| 549 |
max_in_table, |
| 550 |
server_check_interval, |
| 551 |
work_period, |
| 552 |
show_technical_errors, |
| 553 |
history_period, |
| 554 |
period_default, |
| 555 |
max_period, |
| 556 |
severity_color_0, |
| 557 |
severity_color_1, |
| 558 |
severity_color_2, |
| 559 |
severity_color_3, |
| 560 |
severity_color_4, |
| 561 |
severity_color_5, |
| 562 |
severity_name_0, |
| 563 |
severity_name_1, |
| 564 |
severity_name_2, |
| 565 |
severity_name_3, |
| 566 |
severity_name_4, |
| 567 |
severity_name_5, |
| 568 |
custom_color, |
| 569 |
ok_period, |
| 570 |
blink_period, |
| 571 |
problem_unack_color, |
| 572 |
problem_ack_color, |
| 573 |
ok_unack_color, |
| 574 |
ok_ack_color, |
| 575 |
problem_unack_style, |
| 576 |
problem_ack_style, |
| 577 |
ok_unack_style, |
| 578 |
ok_ack_style, |
| 579 |
frontend_url, |
| 580 |
discovery_group, |
| 581 |
default_inventory_mode, |
| 582 |
alert_usrgrp, |
| 583 |
snmptrap_logging, |
| 584 |
login_attempts, |
| 585 |
login_block, |
| 586 |
validate_uri_schemes, |
| 587 |
uri_valid_schemes, |
| 588 |
x_frame_options, |
| 589 |
iframe_sandboxing_enabled, |
| 590 |
iframe_sandboxing_exceptions, |
| 591 |
timeout_zabbix_agent, |
| 592 |
timeout_simple_check, |
| 593 |
timeout_snmp_agent, |
| 594 |
timeout_external_check, |
| 595 |
timeout_db_monitor, |
| 596 |
timeout_http_agent, |
| 597 |
timeout_ssh_agent, |
| 598 |
timeout_telnet_agent, |
| 599 |
timeout_script, |
| 600 |
timeout_browser, |
| 601 |
connect_timeout, |
| 602 |
socket_timeout, |
| 603 |
media_type_test_timeout, |
| 604 |
item_test_timeout, |
| 605 |
script_timeout, |
| 606 |
report_test_timeout, |
| 607 |
auditlog_enabled, |
| 608 |
auditlog_mode, |
| 609 |
geomaps_tile_provider, |
| 610 |
geomaps_tile_url, |
| 611 |
geomaps_max_zoom, |
| 612 |
geomaps_attribution, |
| 613 |
vault_provider, |
| 614 |
): |
| 615 |
try: |
| 616 |
params = {} |
| 617 |
|
| 618 |
if isinstance(default_lang, str): |
| 619 |
if default_lang != current_settings["default_lang"]: |
| 620 |
params["default_lang"] = default_lang |
| 621 |
|
| 622 |
if isinstance(default_timezone, str): |
| 623 |
if default_timezone != current_settings["default_timezone"]: |
| 624 |
params["default_timezone"] = default_timezone |
| 625 |
|
| 626 |
if isinstance(default_theme, str): |
| 627 |
if default_theme != current_settings["default_theme"]: |
| 628 |
params["default_theme"] = default_theme |
| 629 |
|
| 630 |
if isinstance(search_limit, int): |
| 631 |
if str(search_limit) != current_settings["search_limit"]: |
| 632 |
params["search_limit"] = str(search_limit) |
| 633 |
|
| 634 |
if isinstance(max_overview_table_size, int): |
| 635 |
if ( |
| 636 |
str(max_overview_table_size) |
| 637 |
!= current_settings["max_overview_table_size"] |
| 638 |
): |
| 639 |
params["max_overview_table_size"] = str(max_overview_table_size) |
| 640 |
|
| 641 |
if isinstance(max_in_table, int): |
| 642 |
if str(max_in_table) != current_settings["max_in_table"]: |
| 643 |
params["max_in_table"] = str(max_in_table) |
| 644 |
|
| 645 |
if isinstance(server_check_interval, bool): |
| 646 |
if server_check_interval: |
| 647 |
if current_settings["server_check_interval"] != "10": |
| 648 |
params["server_check_interval"] = "10" |
| 649 |
else: |
| 650 |
if current_settings["server_check_interval"] != "0": |
| 651 |
params["server_check_interval"] = "0" |
| 652 |
|
| 653 |
if isinstance(work_period, str): |
| 654 |
if work_period != current_settings["work_period"]: |
| 655 |
params["work_period"] = work_period |
| 656 |
|
| 657 |
if isinstance(show_technical_errors, bool): |
| 658 |
if show_technical_errors: |
| 659 |
if current_settings["show_technical_errors"] != "1": |
| 660 |
params["show_technical_errors"] = "1" |
| 661 |
else: |
| 662 |
if current_settings["show_technical_errors"] != "0": |
| 663 |
params["show_technical_errors"] = "0" |
| 664 |
|
| 665 |
if isinstance(history_period, str): |
| 666 |
if self._is_time(history_period): |
| 667 |
if history_period != current_settings["history_period"]: |
| 668 |
params["history_period"] = history_period |
| 669 |
|
| 670 |
if isinstance(period_default, str): |
| 671 |
if self._is_time(period_default): |
| 672 |
if period_default != current_settings["period_default"]: |
| 673 |
params["period_default"] = period_default |
| 674 |
|
| 675 |
if isinstance(max_period, str): |
| 676 |
if self._is_time(max_period): |
| 677 |
if max_period != current_settings["max_period"]: |
| 678 |
params["max_period"] = max_period |
| 679 |
|
| 680 |
if isinstance(severity_color_0, str): |
| 681 |
if self._is_color(severity_color_0): |
| 682 |
if severity_color_0 != current_settings["severity_color_0"]: |
| 683 |
params["severity_color_0"] = severity_color_0 |
| 684 |
|
| 685 |
if isinstance(severity_color_1, str): |
| 686 |
if self._is_color(severity_color_1): |
| 687 |
if severity_color_1 != current_settings["severity_color_1"]: |
| 688 |
params["severity_color_1"] = severity_color_1 |
| 689 |
|
| 690 |
if isinstance(severity_color_2, str): |
| 691 |
if self._is_color(severity_color_2): |
| 692 |
if severity_color_2 != current_settings["severity_color_2"]: |
| 693 |
params["severity_color_2"] = severity_color_2 |
| 694 |
|
| 695 |
if isinstance(severity_color_3, str): |
| 696 |
if self._is_color(severity_color_3): |
| 697 |
if severity_color_3 != current_settings["severity_color_3"]: |
| 698 |
params["severity_color_3"] = severity_color_3 |
| 699 |
|
| 700 |
if isinstance(severity_color_4, str): |
| 701 |
if self._is_color(severity_color_4): |
| 702 |
if severity_color_4 != current_settings["severity_color_4"]: |
| 703 |
params["severity_color_4"] = severity_color_4 |
| 704 |
|
| 705 |
if isinstance(severity_color_5, str): |
| 706 |
if self._is_color(severity_color_5): |
| 707 |
if severity_color_5 != current_settings["severity_color_5"]: |
| 708 |
params["severity_color_5"] = severity_color_5 |
| 709 |
|
| 710 |
if isinstance(severity_name_0, str): |
| 711 |
if severity_name_0 != current_settings["severity_name_0"]: |
| 712 |
params["severity_name_0"] = severity_name_0 |
| 713 |
|
| 714 |
if isinstance(severity_name_1, str): |
| 715 |
if severity_name_1 != current_settings["severity_name_1"]: |
| 716 |
params["severity_name_1"] = severity_name_1 |
| 717 |
|
| 718 |
if isinstance(severity_name_2, str): |
| 719 |
if severity_name_2 != current_settings["severity_name_2"]: |
| 720 |
params["severity_name_2"] = severity_name_2 |
| 721 |
|
| 722 |
if isinstance(severity_name_3, str): |
| 723 |
if severity_name_3 != current_settings["severity_name_3"]: |
| 724 |
params["severity_name_3"] = severity_name_3 |
| 725 |
|
| 726 |
if isinstance(severity_name_4, str): |
| 727 |
if severity_name_4 != current_settings["severity_name_4"]: |
| 728 |
params["severity_name_4"] = severity_name_4 |
| 729 |
|
| 730 |
if isinstance(severity_name_5, str): |
| 731 |
if severity_name_5 != current_settings["severity_name_5"]: |
| 732 |
params["severity_name_5"] = severity_name_5 |
| 733 |
|
| 734 |
if isinstance(custom_color, bool): |
| 735 |
if custom_color: |
| 736 |
if current_settings["custom_color"] != "1": |
| 737 |
params["custom_color"] = "1" |
| 738 |
else: |
| 739 |
if current_settings["custom_color"] != "0": |
| 740 |
params["custom_color"] = "0" |
| 741 |
|
| 742 |
if isinstance(ok_period, str): |
| 743 |
if self._is_time(ok_period): |
| 744 |
if ok_period != current_settings["ok_period"]: |
| 745 |
params["ok_period"] = ok_period |
| 746 |
|
| 747 |
if isinstance(blink_period, str): |
| 748 |
if self._is_time(blink_period): |
| 749 |
if blink_period != current_settings["blink_period"]: |
| 750 |
params["blink_period"] = blink_period |
| 751 |
|
| 752 |
if isinstance(problem_unack_color, str): |
| 753 |
if self._is_color(problem_unack_color): |
| 754 |
if problem_unack_color != current_settings["problem_unack_color"]: |
| 755 |
params["problem_unack_color"] = problem_unack_color |
| 756 |
|
| 757 |
if isinstance(problem_ack_color, str): |
| 758 |
if self._is_color(problem_ack_color): |
| 759 |
if problem_ack_color != current_settings["problem_ack_color"]: |
| 760 |
params["problem_ack_color"] = problem_ack_color |
| 761 |
|
| 762 |
if isinstance(ok_unack_color, str): |
| 763 |
if self._is_color(ok_unack_color): |
| 764 |
if ok_unack_color != current_settings["ok_unack_color"]: |
| 765 |
params["ok_unack_color"] = ok_unack_color |
| 766 |
|
| 767 |
if isinstance(ok_ack_color, str): |
| 768 |
if self._is_color(ok_ack_color): |
| 769 |
if ok_ack_color != current_settings["ok_ack_color"]: |
| 770 |
params["ok_ack_color"] = ok_ack_color |
| 771 |
|
| 772 |
if isinstance(problem_unack_style, bool): |
| 773 |
if problem_unack_style: |
| 774 |
if current_settings["problem_unack_style"] != "1": |
| 775 |
params["problem_unack_style"] = "1" |
| 776 |
else: |
| 777 |
if current_settings["problem_unack_style"] != "0": |
| 778 |
params["problem_unack_style"] = "0" |
| 779 |
|
| 780 |
if isinstance(problem_ack_style, bool): |
| 781 |
if problem_ack_style: |
| 782 |
if current_settings["problem_ack_style"] != "1": |
| 783 |
params["problem_ack_style"] = "1" |
| 784 |
else: |
| 785 |
if current_settings["problem_ack_style"] != "0": |
| 786 |
params["problem_ack_style"] = "0" |
| 787 |
|
| 788 |
if isinstance(ok_unack_style, bool): |
| 789 |
if ok_unack_style: |
| 790 |
if current_settings["ok_unack_style"] != "1": |
| 791 |
params["ok_unack_style"] = "1" |
| 792 |
else: |
| 793 |
if current_settings["ok_unack_style"] != "0": |
| 794 |
params["ok_unack_style"] = "0" |
| 795 |
|
| 796 |
if isinstance(ok_ack_style, bool): |
| 797 |
if ok_ack_style: |
| 798 |
if current_settings["ok_ack_style"] != "1": |
| 799 |
params["ok_ack_style"] = "1" |
| 800 |
else: |
| 801 |
if current_settings["ok_ack_style"] != "0": |
| 802 |
params["ok_ack_style"] = "0" |
| 803 |
|
| 804 |
if isinstance(frontend_url, str): |
| 805 |
if frontend_url != current_settings["url"]: |
| 806 |
params["url"] = frontend_url |
| 807 |
|
| 808 |
if isinstance(discovery_group, str): |
| 809 |
discovery_groupid = self.get_groupid_from_name(discovery_group) |
| 810 |
if current_settings["discovery_groupid"] != discovery_groupid: |
| 811 |
params["discovery_groupid"] = discovery_groupid |
| 812 |
|
| 813 |
if isinstance(default_inventory_mode, str): |
| 814 |
_default_inventory_mode = str( |
| 815 |
zabbix_utils.helper_to_numeric_value( |
| 816 |
["disabled", "manual", "automatic"], default_inventory_mode |
| 817 |
) |
| 818 |
- 1 |
| 819 |
) |
| 820 |
if ( |
| 821 |
_default_inventory_mode |
| 822 |
!= current_settings["default_inventory_mode"] |
| 823 |
): |
| 824 |
params["default_inventory_mode"] = _default_inventory_mode |
| 825 |
|
| 826 |
if isinstance(alert_usrgrp, str): |
| 827 |
if alert_usrgrp != "0": |
| 828 |
alert_usrgrpid = self.get_usrgrpid_from_name(alert_usrgrp) |
| 829 |
else: |
| 830 |
alert_usrgrpid = alert_usrgrp |
| 831 |
if current_settings["alert_usrgrpid"] != alert_usrgrpid: |
| 832 |
params["alert_usrgrpid"] = alert_usrgrpid |
| 833 |
|
| 834 |
if isinstance(snmptrap_logging, bool): |
| 835 |
if snmptrap_logging: |
| 836 |
if current_settings["snmptrap_logging"] != "1": |
| 837 |
params["snmptrap_logging"] = "1" |
| 838 |
else: |
| 839 |
if current_settings["snmptrap_logging"] != "0": |
| 840 |
params["snmptrap_logging"] = "0" |
| 841 |
|
| 842 |
if isinstance(login_attempts, int): |
| 843 |
if str(login_attempts) != current_settings["login_attempts"]: |
| 844 |
params["login_attempts"] = str(login_attempts) |
| 845 |
|
| 846 |
if isinstance(login_block, str): |
| 847 |
if self._is_time(login_block): |
| 848 |
if login_block != current_settings["login_block"]: |
| 849 |
params["login_block"] = login_block |
| 850 |
|
| 851 |
if isinstance(validate_uri_schemes, bool): |
| 852 |
if validate_uri_schemes: |
| 853 |
if current_settings["validate_uri_schemes"] != "1": |
| 854 |
params["validate_uri_schemes"] = "1" |
| 855 |
else: |
| 856 |
if current_settings["validate_uri_schemes"] != "0": |
| 857 |
params["validate_uri_schemes"] = "0" |
| 858 |
|
| 859 |
if isinstance(uri_valid_schemes, list): |
| 860 |
current_uri_valid_schemes = current_settings["uri_valid_schemes"].split( |
| 861 |
"," |
| 862 |
) |
| 863 |
uri_valid_schemes.sort() |
| 864 |
current_uri_valid_schemes.sort() |
| 865 |
compare_result = [] |
| 866 |
zabbix_utils.helper_compare_lists( |
| 867 |
uri_valid_schemes, current_uri_valid_schemes, compare_result |
| 868 |
) |
| 869 |
if len(compare_result) != 0: |
| 870 |
params["uri_valid_schemes"] = ",".join(uri_valid_schemes) |
| 871 |
|
| 872 |
if isinstance(x_frame_options, str): |
| 873 |
if x_frame_options != current_settings["x_frame_options"]: |
| 874 |
params["x_frame_options"] = x_frame_options |
| 875 |
|
| 876 |
if isinstance(iframe_sandboxing_enabled, bool): |
| 877 |
if iframe_sandboxing_enabled: |
| 878 |
if current_settings["iframe_sandboxing_enabled"] != "1": |
| 879 |
params["iframe_sandboxing_enabled"] = "1" |
| 880 |
else: |
| 881 |
if current_settings["iframe_sandboxing_enabled"] != "0": |
| 882 |
params["iframe_sandboxing_enabled"] = "0" |
| 883 |
|
| 884 |
if isinstance(iframe_sandboxing_exceptions, str): |
| 885 |
if ( |
| 886 |
iframe_sandboxing_exceptions |
| 887 |
!= current_settings["iframe_sandboxing_exceptions"] |
| 888 |
): |
| 889 |
params[ |
| 890 |
"iframe_sandboxing_exceptions" |
| 891 |
] = iframe_sandboxing_exceptions |
| 892 |
|
| 893 |
if LooseVersion(self._zbx_api_version) >= LooseVersion("7.0"): |
| 894 |
if isinstance(timeout_zabbix_agent, str): |
| 895 |
if self._is_time(timeout_zabbix_agent): |
| 896 |
if timeout_zabbix_agent != current_settings["timeout_zabbix_agent"]: |
| 897 |
params["timeout_zabbix_agent"] = timeout_zabbix_agent |
| 898 |
|
| 899 |
if isinstance(timeout_simple_check, str): |
| 900 |
if self._is_time(timeout_simple_check): |
| 901 |
if timeout_simple_check != current_settings["timeout_simple_check"]: |
| 902 |
params["timeout_simple_check"] = timeout_simple_check |
| 903 |
|
| 904 |
if isinstance(timeout_snmp_agent, str): |
| 905 |
if self._is_time(timeout_snmp_agent): |
| 906 |
if timeout_snmp_agent != current_settings["timeout_snmp_agent"]: |
| 907 |
params["timeout_snmp_agent"] = timeout_snmp_agent |
| 908 |
|
| 909 |
if isinstance(timeout_external_check, str): |
| 910 |
if self._is_time(timeout_external_check): |
| 911 |
if timeout_external_check != current_settings["timeout_external_check"]: |
| 912 |
params["timeout_external_check"] = timeout_external_check |
| 913 |
|
| 914 |
if isinstance(timeout_db_monitor, str): |
| 915 |
if self._is_time(timeout_db_monitor): |
| 916 |
if timeout_db_monitor != current_settings["timeout_db_monitor"]: |
| 917 |
params["timeout_db_monitor"] = timeout_db_monitor |
| 918 |
|
| 919 |
if isinstance(timeout_http_agent, str): |
| 920 |
if self._is_time(timeout_http_agent): |
| 921 |
if timeout_http_agent != current_settings["timeout_http_agent"]: |
| 922 |
params["timeout_http_agent"] = timeout_http_agent |
| 923 |
|
| 924 |
if isinstance(timeout_ssh_agent, str): |
| 925 |
if self._is_time(timeout_ssh_agent): |
| 926 |
if timeout_ssh_agent != current_settings["timeout_ssh_agent"]: |
| 927 |
params["timeout_ssh_agent"] = timeout_ssh_agent |
| 928 |
|
| 929 |
if isinstance(timeout_telnet_agent, str): |
| 930 |
if self._is_time(timeout_telnet_agent): |
| 931 |
if timeout_telnet_agent != current_settings["timeout_telnet_agent"]: |
| 932 |
params["timeout_telnet_agent"] = timeout_telnet_agent |
| 933 |
|
| 934 |
if isinstance(timeout_script, str): |
| 935 |
if self._is_time(timeout_script): |
| 936 |
if timeout_script != current_settings["timeout_script"]: |
| 937 |
params["timeout_script"] = timeout_script |
| 938 |
|
| 939 |
if isinstance(timeout_browser, str): |
| 940 |
if self._is_time(timeout_browser): |
| 941 |
if timeout_browser != current_settings["timeout_browser"]: |
| 942 |
params["timeout_browser"] = timeout_browser |
| 943 |
|
| 944 |
if isinstance(auditlog_mode, bool): |
| 945 |
if auditlog_mode: |
| 946 |
if current_settings["auditlog_mode"] != "1": |
| 947 |
params["auditlog_mode"] = "1" |
| 948 |
else: |
| 949 |
if current_settings["auditlog_mode"] != "0": |
| 950 |
params["auditlog_mode"] = "0" |
| 951 |
|
| 952 |
else: |
| 953 |
if isinstance(timeout_zabbix_agent, str): |
| 954 |
self._module.fail_json(msg="'timeout_zabbix_agent' unsupported in Zabbix server versions prior to 7.0") |
| 955 |
|
| 956 |
if isinstance(timeout_simple_check, str): |
| 957 |
self._module.fail_json(msg="'timeout_simple_check' unsupported in Zabbix server versions prior to 7.0") |
| 958 |
|
| 959 |
if isinstance(timeout_snmp_agent, str): |
| 960 |
self._module.fail_json(msg="'timeout_snmp_agent' unsupported in Zabbix server versions prior to 7.0") |
| 961 |
|
| 962 |
if isinstance(timeout_external_check, str): |
| 963 |
self._module.fail_json(msg="'timeout_external_check' unsupported in Zabbix server versions prior to 7.0") |
| 964 |
|
| 965 |
if isinstance(timeout_db_monitor, str): |
| 966 |
self._module.fail_json(msg="'timeout_db_monitor' unsupported in Zabbix server versions prior to 7.0") |
| 967 |
|
| 968 |
if isinstance(timeout_http_agent, str): |
| 969 |
self._module.fail_json(msg="'timeout_http_agent' unsupported in Zabbix server versions prior to 7.0") |
| 970 |
|
| 971 |
if isinstance(timeout_ssh_agent, str): |
| 972 |
self._module.fail_json(msg="'timeout_ssh_agent' unsupported in Zabbix server versions prior to 7.0") |
| 973 |
|
| 974 |
if isinstance(timeout_telnet_agent, str): |
| 975 |
self._module.fail_json(msg="'timeout_telnet_agent' unsupported in Zabbix server versions prior to 7.0") |
| 976 |
|
| 977 |
if isinstance(timeout_script, str): |
| 978 |
self._module.fail_json(msg="'timeout_script' unsupported in Zabbix server versions prior to 7.0") |
| 979 |
|
| 980 |
if isinstance(timeout_browser, str): |
| 981 |
self._module.fail_json(msg="'timeout_browser' unsupported in Zabbix server versions prior to 7.0") |
| 982 |
|
| 983 |
if isinstance(auditlog_mode, bool): |
| 984 |
self._module.fail_json(msg="'auditlog_mode' is unsupported in Zabbix server versions prior to 7.0") |
| 985 |
|
| 986 |
if isinstance(connect_timeout, str): |
| 987 |
if self._is_time(connect_timeout): |
| 988 |
if connect_timeout != current_settings["connect_timeout"]: |
| 989 |
params["connect_timeout"] = connect_timeout |
| 990 |
|
| 991 |
if isinstance(socket_timeout, str): |
| 992 |
if self._is_time(socket_timeout): |
| 993 |
if socket_timeout != current_settings["socket_timeout"]: |
| 994 |
params["socket_timeout"] = socket_timeout |
| 995 |
|
| 996 |
if isinstance(media_type_test_timeout, str): |
| 997 |
if self._is_time(media_type_test_timeout): |
| 998 |
if ( |
| 999 |
media_type_test_timeout |
| 1000 |
!= current_settings["media_type_test_timeout"] |
| 1001 |
): |
| 1002 |
params["media_type_test_timeout"] = media_type_test_timeout |
| 1003 |
|
| 1004 |
if isinstance(item_test_timeout, str): |
| 1005 |
if self._is_time(item_test_timeout): |
| 1006 |
if item_test_timeout != current_settings["item_test_timeout"]: |
| 1007 |
params["item_test_timeout"] = item_test_timeout |
| 1008 |
|
| 1009 |
if isinstance(script_timeout, str): |
| 1010 |
if self._is_time(script_timeout): |
| 1011 |
if script_timeout != current_settings["script_timeout"]: |
| 1012 |
params["script_timeout"] = script_timeout |
| 1013 |
|
| 1014 |
if isinstance(report_test_timeout, str): |
| 1015 |
if self._is_time(report_test_timeout): |
| 1016 |
if report_test_timeout != current_settings["report_test_timeout"]: |
| 1017 |
params["report_test_timeout"] = report_test_timeout |
| 1018 |
|
| 1019 |
if isinstance(auditlog_enabled, bool): |
| 1020 |
if auditlog_enabled: |
| 1021 |
if current_settings["auditlog_enabled"] != "1": |
| 1022 |
params["auditlog_enabled"] = "1" |
| 1023 |
else: |
| 1024 |
if current_settings["auditlog_enabled"] != "0": |
| 1025 |
params["auditlog_enabled"] = "0" |
| 1026 |
|
| 1027 |
if isinstance(geomaps_tile_provider, str): |
| 1028 |
_geomaps_tile_provider = geomaps_tile_provider |
| 1029 |
if geomaps_tile_provider == "another": |
| 1030 |
_geomaps_tile_provider = "" |
| 1031 |
if _geomaps_tile_provider != current_settings["geomaps_tile_provider"]: |
| 1032 |
params["geomaps_tile_provider"] = _geomaps_tile_provider |
| 1033 |
|
| 1034 |
if isinstance(geomaps_tile_url, str): |
| 1035 |
if geomaps_tile_url != current_settings["geomaps_tile_url"]: |
| 1036 |
params["geomaps_tile_url"] = geomaps_tile_url |
| 1037 |
|
| 1038 |
if isinstance(geomaps_max_zoom, int): |
| 1039 |
if str(geomaps_max_zoom) != current_settings["geomaps_max_zoom"]: |
| 1040 |
params["geomaps_max_zoom"] = str(geomaps_max_zoom) |
| 1041 |
|
| 1042 |
if isinstance(geomaps_attribution, str): |
| 1043 |
if geomaps_attribution != current_settings["geomaps_attribution"]: |
| 1044 |
params["geomaps_attribution"] = geomaps_attribution |
| 1045 |
|
| 1046 |
if LooseVersion(self._zbx_api_version) >= LooseVersion("7.0"): |
| 1047 |
if isinstance(vault_provider, str): |
| 1048 |
_vault_provider = str( |
| 1049 |
zabbix_utils.helper_to_numeric_value( |
| 1050 |
["HashiCorp_Vault", "CyberArk_Vault"], vault_provider |
| 1051 |
) |
| 1052 |
) |
| 1053 |
if _vault_provider != current_settings["vault_provider"]: |
| 1054 |
params["vault_provider"] = _vault_provider |
| 1055 |
|
| 1056 |
if params != {}: |
| 1057 |
if self._module.check_mode: |
| 1058 |
self._module.exit_json(changed=True) |
| 1059 |
self._zapi.settings.update(params) |
| 1060 |
self._module.exit_json( |
| 1061 |
changed=True, result="Successfully updated global settings" |
| 1062 |
) |
| 1063 |
else: |
| 1064 |
if self._module.check_mode: |
| 1065 |
self._module.exit_json(changed=False) |
| 1066 |
self._module.exit_json( |
| 1067 |
changed=False, result="Settings are already up to date" |
| 1068 |
) |
| 1069 |
except Exception as e: |
| 1070 |
self._module.fail_json(msg="Failed to update global settings: %s" % e) |
| 1071 |
|
| 1072 |
|
| 1073 |
def main(): |
| 1074 |
argument_spec = zabbix_utils.zabbix_common_argument_spec() |
| 1075 |
argument_spec.update( |
| 1076 |
dict( |
| 1077 |
default_lang=dict(type="str"), |
| 1078 |
default_timezone=dict(type="str"), |
| 1079 |
default_theme=dict( |
| 1080 |
type="str", choices=["blue-theme", "dark-theme", "hc-light", "hc-dark"] |
| 1081 |
), |
| 1082 |
search_limit=dict(type="int"), |
| 1083 |
max_overview_table_size=dict(type="int"), |
| 1084 |
max_in_table=dict(type="int"), |
| 1085 |
server_check_interval=dict(type="bool"), |
| 1086 |
work_period=dict(type="str"), |
| 1087 |
show_technical_errors=dict(type="bool"), |
| 1088 |
history_period=dict(type="str"), |
| 1089 |
period_default=dict(type="str"), |
| 1090 |
max_period=dict(type="str"), |
| 1091 |
severity_color_0=dict(type="str"), |
| 1092 |
severity_color_1=dict(type="str"), |
| 1093 |
severity_color_2=dict(type="str"), |
| 1094 |
severity_color_3=dict(type="str"), |
| 1095 |
severity_color_4=dict(type="str"), |
| 1096 |
severity_color_5=dict(type="str"), |
| 1097 |
severity_name_0=dict(type="str"), |
| 1098 |
severity_name_1=dict(type="str"), |
| 1099 |
severity_name_2=dict(type="str"), |
| 1100 |
severity_name_3=dict(type="str"), |
| 1101 |
severity_name_4=dict(type="str"), |
| 1102 |
severity_name_5=dict(type="str"), |
| 1103 |
custom_color=dict(type="bool"), |
| 1104 |
ok_period=dict(type="str"), |
| 1105 |
blink_period=dict(type="str"), |
| 1106 |
problem_unack_color=dict(type="str"), |
| 1107 |
problem_ack_color=dict(type="str"), |
| 1108 |
ok_unack_color=dict(type="str"), |
| 1109 |
ok_ack_color=dict(type="str"), |
| 1110 |
problem_unack_style=dict(type="bool"), |
| 1111 |
problem_ack_style=dict(type="bool"), |
| 1112 |
ok_unack_style=dict(type="bool"), |
| 1113 |
ok_ack_style=dict(type="bool"), |
| 1114 |
frontend_url=dict(type="str"), |
| 1115 |
discovery_group=dict(type="str"), |
| 1116 |
default_inventory_mode=dict( |
| 1117 |
type="str", choices=["disabled", "manual", "automatic"] |
| 1118 |
), |
| 1119 |
alert_usrgrp=dict(type="str"), |
| 1120 |
snmptrap_logging=dict(type="bool"), |
| 1121 |
login_attempts=dict(type="int"), |
| 1122 |
login_block=dict(type="str"), |
| 1123 |
validate_uri_schemes=dict(type="bool"), |
| 1124 |
uri_valid_schemes=dict(type="list", elements="str"), |
| 1125 |
x_frame_options=dict(type="str"), |
| 1126 |
iframe_sandboxing_enabled=dict(type="bool"), |
| 1127 |
iframe_sandboxing_exceptions=dict(type="str"), |
| 1128 |
timeout_zabbix_agent=dict(type="str"), |
| 1129 |
timeout_simple_check=dict(type="str"), |
| 1130 |
timeout_snmp_agent=dict(type="str"), |
| 1131 |
timeout_external_check=dict(type="str"), |
| 1132 |
timeout_db_monitor=dict(type="str"), |
| 1133 |
timeout_http_agent=dict(type="str"), |
| 1134 |
timeout_ssh_agent=dict(type="str"), |
| 1135 |
timeout_telnet_agent=dict(type="str"), |
| 1136 |
timeout_script=dict(type="str"), |
| 1137 |
timeout_browser=dict(type="str"), |
| 1138 |
connect_timeout=dict(type="str"), |
| 1139 |
socket_timeout=dict(type="str"), |
| 1140 |
media_type_test_timeout=dict(type="str"), |
| 1141 |
item_test_timeout=dict(type="str"), |
| 1142 |
script_timeout=dict(type="str"), |
| 1143 |
report_test_timeout=dict(type="str"), |
| 1144 |
auditlog_enabled=dict(type="bool"), |
| 1145 |
auditlog_mode=dict(type="bool"), |
| 1146 |
geomaps_tile_provider=dict( |
| 1147 |
type="str", |
| 1148 |
choices=[ |
| 1149 |
"OpenStreetMap.Mapnik", |
| 1150 |
"OpenTopoMap", |
| 1151 |
"Stamen.TonerLite", |
| 1152 |
"Stamen.Terrain", |
| 1153 |
"USGS.USTopo", |
| 1154 |
"USGS.USImagery", |
| 1155 |
"another", |
| 1156 |
], |
| 1157 |
), |
| 1158 |
geomaps_tile_url=dict(type="str"), |
| 1159 |
geomaps_max_zoom=dict(type="str"), |
| 1160 |
geomaps_attribution=dict(type="str"), |
| 1161 |
vault_provider=dict( |
| 1162 |
type="str", choices=["HashiCorp_Vault", "CyberArk_Vault"] |
| 1163 |
), |
| 1164 |
) |
| 1165 |
) |
| 1166 |
module = AnsibleModule( |
| 1167 |
argument_spec=argument_spec, |
| 1168 |
required_if=[ |
| 1169 |
[ |
| 1170 |
"geomaps_tile_provider", |
| 1171 |
"another", |
| 1172 |
["geomaps_tile_url", "geomaps_max_zoom", "geomaps_attribution"], |
| 1173 |
], |
| 1174 |
], |
| 1175 |
supports_check_mode=True, |
| 1176 |
) |
| 1177 |
|
| 1178 |
default_lang = module.params["default_lang"] |
| 1179 |
default_timezone = module.params["default_timezone"] |
| 1180 |
default_theme = module.params["default_theme"] |
| 1181 |
search_limit = module.params["search_limit"] |
| 1182 |
max_overview_table_size = module.params["max_overview_table_size"] |
| 1183 |
max_in_table = module.params["max_in_table"] |
| 1184 |
server_check_interval = module.params["server_check_interval"] |
| 1185 |
work_period = module.params["work_period"] |
| 1186 |
show_technical_errors = module.params["show_technical_errors"] |
| 1187 |
history_period = module.params["history_period"] |
| 1188 |
period_default = module.params["period_default"] |
| 1189 |
max_period = module.params["max_period"] |
| 1190 |
severity_color_0 = module.params["severity_color_0"] |
| 1191 |
severity_color_1 = module.params["severity_color_1"] |
| 1192 |
severity_color_2 = module.params["severity_color_2"] |
| 1193 |
severity_color_3 = module.params["severity_color_3"] |
| 1194 |
severity_color_4 = module.params["severity_color_4"] |
| 1195 |
severity_color_5 = module.params["severity_color_5"] |
| 1196 |
severity_name_0 = module.params["severity_name_0"] |
| 1197 |
severity_name_1 = module.params["severity_name_1"] |
| 1198 |
severity_name_2 = module.params["severity_name_2"] |
| 1199 |
severity_name_3 = module.params["severity_name_3"] |
| 1200 |
severity_name_4 = module.params["severity_name_4"] |
| 1201 |
severity_name_5 = module.params["severity_name_5"] |
| 1202 |
custom_color = module.params["custom_color"] |
| 1203 |
ok_period = module.params["ok_period"] |
| 1204 |
blink_period = module.params["blink_period"] |
| 1205 |
problem_unack_color = module.params["problem_unack_color"] |
| 1206 |
problem_ack_color = module.params["problem_ack_color"] |
| 1207 |
ok_unack_color = module.params["ok_unack_color"] |
| 1208 |
ok_ack_color = module.params["ok_ack_color"] |
| 1209 |
problem_unack_style = module.params["problem_unack_style"] |
| 1210 |
problem_ack_style = module.params["problem_ack_style"] |
| 1211 |
ok_unack_style = module.params["ok_unack_style"] |
| 1212 |
ok_ack_style = module.params["ok_ack_style"] |
| 1213 |
frontend_url = module.params["frontend_url"] |
| 1214 |
discovery_group = module.params["discovery_group"] |
| 1215 |
default_inventory_mode = module.params["default_inventory_mode"] |
| 1216 |
alert_usrgrp = module.params["alert_usrgrp"] |
| 1217 |
snmptrap_logging = module.params["snmptrap_logging"] |
| 1218 |
login_attempts = module.params["login_attempts"] |
| 1219 |
login_block = module.params["login_block"] |
| 1220 |
validate_uri_schemes = module.params["validate_uri_schemes"] |
| 1221 |
uri_valid_schemes = module.params["uri_valid_schemes"] |
| 1222 |
x_frame_options = module.params["x_frame_options"] |
| 1223 |
iframe_sandboxing_enabled = module.params["iframe_sandboxing_enabled"] |
| 1224 |
iframe_sandboxing_exceptions = module.params["iframe_sandboxing_exceptions"] |
| 1225 |
timeout_zabbix_agent = module.params["timeout_zabbix_agent"] |
| 1226 |
timeout_simple_check = module.params["timeout_simple_check"] |
| 1227 |
timeout_snmp_agent = module.params["timeout_snmp_agent"] |
| 1228 |
timeout_external_check = module.params["timeout_external_check"] |
| 1229 |
timeout_db_monitor = module.params["timeout_db_monitor"] |
| 1230 |
timeout_http_agent = module.params["timeout_http_agent"] |
| 1231 |
timeout_ssh_agent = module.params["timeout_ssh_agent"] |
| 1232 |
timeout_telnet_agent = module.params["timeout_telnet_agent"] |
| 1233 |
timeout_script = module.params["timeout_script"] |
| 1234 |
timeout_browser = module.params["timeout_browser"] |
| 1235 |
connect_timeout = module.params["connect_timeout"] |
| 1236 |
socket_timeout = module.params["socket_timeout"] |
| 1237 |
media_type_test_timeout = module.params["media_type_test_timeout"] |
| 1238 |
item_test_timeout = module.params["item_test_timeout"] |
| 1239 |
script_timeout = module.params["script_timeout"] |
| 1240 |
report_test_timeout = module.params["report_test_timeout"] |
| 1241 |
auditlog_enabled = module.params["auditlog_enabled"] |
| 1242 |
auditlog_mode = module.params["auditlog_mode"] |
| 1243 |
geomaps_tile_provider = module.params["geomaps_tile_provider"] |
| 1244 |
geomaps_tile_url = module.params["geomaps_tile_url"] |
| 1245 |
geomaps_max_zoom = module.params["geomaps_max_zoom"] |
| 1246 |
geomaps_attribution = module.params["geomaps_attribution"] |
| 1247 |
vault_provider = module.params["vault_provider"] |
| 1248 |
|
| 1249 |
settings = Settings(module) |
| 1250 |
|
| 1251 |
current_settings = settings.get_settings() |
| 1252 |
settings.update_settings( |
| 1253 |
current_settings, |
| 1254 |
default_lang, |
| 1255 |
default_timezone, |
| 1256 |
default_theme, |
| 1257 |
search_limit, |
| 1258 |
max_overview_table_size, |
| 1259 |
max_in_table, |
| 1260 |
server_check_interval, |
| 1261 |
work_period, |
| 1262 |
show_technical_errors, |
| 1263 |
history_period, |
| 1264 |
period_default, |
| 1265 |
max_period, |
| 1266 |
severity_color_0, |
| 1267 |
severity_color_1, |
| 1268 |
severity_color_2, |
| 1269 |
severity_color_3, |
| 1270 |
severity_color_4, |
| 1271 |
severity_color_5, |
| 1272 |
severity_name_0, |
| 1273 |
severity_name_1, |
| 1274 |
severity_name_2, |
| 1275 |
severity_name_3, |
| 1276 |
severity_name_4, |
| 1277 |
severity_name_5, |
| 1278 |
custom_color, |
| 1279 |
ok_period, |
| 1280 |
blink_period, |
| 1281 |
problem_unack_color, |
| 1282 |
problem_ack_color, |
| 1283 |
ok_unack_color, |
| 1284 |
ok_ack_color, |
| 1285 |
problem_unack_style, |
| 1286 |
problem_ack_style, |
| 1287 |
ok_unack_style, |
| 1288 |
ok_ack_style, |
| 1289 |
frontend_url, |
| 1290 |
discovery_group, |
| 1291 |
default_inventory_mode, |
| 1292 |
alert_usrgrp, |
| 1293 |
snmptrap_logging, |
| 1294 |
login_attempts, |
| 1295 |
login_block, |
| 1296 |
validate_uri_schemes, |
| 1297 |
uri_valid_schemes, |
| 1298 |
x_frame_options, |
| 1299 |
iframe_sandboxing_enabled, |
| 1300 |
iframe_sandboxing_exceptions, |
| 1301 |
timeout_zabbix_agent, |
| 1302 |
timeout_simple_check, |
| 1303 |
timeout_snmp_agent, |
| 1304 |
timeout_external_check, |
| 1305 |
timeout_db_monitor, |
| 1306 |
timeout_http_agent, |
| 1307 |
timeout_ssh_agent, |
| 1308 |
timeout_telnet_agent, |
| 1309 |
timeout_script, |
| 1310 |
timeout_browser, |
| 1311 |
connect_timeout, |
| 1312 |
socket_timeout, |
| 1313 |
media_type_test_timeout, |
| 1314 |
item_test_timeout, |
| 1315 |
script_timeout, |
| 1316 |
report_test_timeout, |
| 1317 |
auditlog_enabled, |
| 1318 |
auditlog_mode, |
| 1319 |
geomaps_tile_provider, |
| 1320 |
geomaps_tile_url, |
| 1321 |
geomaps_max_zoom, |
| 1322 |
geomaps_attribution, |
| 1323 |
vault_provider, |
| 1324 |
) |
| 1325 |
|
| 1326 |
|
| 1327 |
if __name__ == "__main__": |
| 1328 |
main() |