From a453ac31f3428614cceb99027f8efbdb9258a40b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 14 May 2024 22:03:01 +0200 Subject: Adding upstream version 2.10.7+merged+base+2.10.8+dfsg. Signed-off-by: Daniel Baumann --- .../zabbix/.github/ISSUE_TEMPLATE/bug_report.md | 59 + .../.github/ISSUE_TEMPLATE/feature_request.md | 25 + .../community/zabbix/.github/workflows/agent.yml | 83 + .../zabbix/.github/workflows/javagateway.yml | 58 + .../.github/workflows/plugins-integration.yml | 78 + .../community/zabbix/.github/workflows/proxy.yml | 81 + .../zabbix/.github/workflows/repo-sanity.yml | 81 + .../community/zabbix/.github/workflows/server.yml | 71 + .../community/zabbix/.github/workflows/web.yml | 70 + .../community/zabbix/.gitignore | 17 + .../community/zabbix/CHANGELOG.rst | 232 ++ .../community/zabbix/CODE_OF_CONDUCT.md | 82 + .../community/zabbix/CONTRIBUTING.md | 169 ++ .../community/zabbix/FILES.json | 2714 ++++++++++++++++++++ .../ansible_collections/community/zabbix/LICENSE | 674 +++++ .../community/zabbix/MANIFEST.json | 33 + .../ansible_collections/community/zabbix/README.md | 166 ++ .../community/zabbix/changelogs/.plugin-cache.yaml | 115 + .../community/zabbix/changelogs/changelog.yaml | 316 +++ .../community/zabbix/changelogs/config.yaml | 31 + .../community/zabbix/changelogs/fragments/.gitkeep | 0 .../community/zabbix/docker-compose.yml | 37 + .../community/zabbix/docs/PUBLISHING_TO_GALAXY.md | 24 + .../community/zabbix/docs/RELEASE.md | 46 + .../community/zabbix/docs/UPGRADE.md | 126 + .../community/zabbix/docs/ZABBIX_AGENT_ROLE.md | 509 ++++ .../zabbix/docs/ZABBIX_JAVAGATEWAY_ROLE.md | 143 ++ .../community/zabbix/docs/ZABBIX_PROXY_ROLE.md | 342 +++ .../community/zabbix/docs/ZABBIX_SERVER_ROLE.md | 339 +++ .../community/zabbix/docs/ZABBIX_WEB_ROLE.md | 322 +++ .../community/zabbix/meta/runtime.yml | 2 + .../community/zabbix/molecule/requirements.txt | 11 + .../zabbix/molecule/zabbix_agent/converge.yml | 5 + .../zabbix/molecule/zabbix_agent/molecule.yml | 71 + .../zabbix/molecule/zabbix_agent/prepare.yml | 86 + .../molecule/zabbix_agent/tests/test_agent.py | 66 + .../molecule/zabbix_agent/tests/test_agent2.py | 67 + .../molecule/zabbix_agent/tests/test_docker.py | 22 + .../molecule/zabbix_javagateway/converge.yml | 6 + .../molecule/zabbix_javagateway/molecule.yml | 27 + .../zabbix/molecule/zabbix_javagateway/prepare.yml | 57 + .../zabbix_javagateway/tests/test_default.py | 23 + .../zabbix/molecule/zabbix_proxy/converge.yml | 4 + .../zabbix/molecule/zabbix_proxy/destroy.yml | 25 + .../zabbix/molecule/zabbix_proxy/molecule.yml | 56 + .../zabbix/molecule/zabbix_proxy/prepare.yml | 129 + .../molecule/zabbix_proxy/tests/test_default.py | 62 + .../zabbix/molecule/zabbix_server/converge.yml | 5 + .../zabbix/molecule/zabbix_server/destroy.yml | 25 + .../zabbix/molecule/zabbix_server/molecule.yml | 52 + .../zabbix/molecule/zabbix_server/prepare.yml | 116 + .../molecule/zabbix_server/tests/test_default.py | 62 + .../zabbix/molecule/zabbix_web/converge.yml | 5 + .../zabbix/molecule/zabbix_web/destroy.yml | 25 + .../zabbix/molecule/zabbix_web/molecule.yml | 96 + .../zabbix/molecule/zabbix_web/prepare.yml | 146 ++ .../zabbix/molecule/zabbix_web/requirements.yml | 5 + .../molecule/zabbix_web/tests/test_default.py | 58 + .../zabbix/plugins/doc_fragments/zabbix.py | 50 + .../zabbix/plugins/module_utils/__init__.py | 0 .../community/zabbix/plugins/module_utils/base.py | 27 + .../zabbix/plugins/module_utils/helpers.py | 145 ++ .../zabbix/plugins/module_utils/wrappers.py | 77 + .../community/zabbix/plugins/modules/__init__.py | 0 .../zabbix/plugins/modules/zabbix_action.py | 2054 +++++++++++++++ .../plugins/modules/zabbix_discovery_rule.py | 691 +++++ .../zabbix/plugins/modules/zabbix_group.py | 176 ++ .../zabbix/plugins/modules/zabbix_group_facts.py | 93 + .../zabbix/plugins/modules/zabbix_group_info.py | 93 + .../zabbix/plugins/modules/zabbix_host.py | 1205 +++++++++ .../plugins/modules/zabbix_host_events_info.py | 296 +++ .../zabbix/plugins/modules/zabbix_host_facts.py | 213 ++ .../zabbix/plugins/modules/zabbix_host_info.py | 213 ++ .../zabbix/plugins/modules/zabbix_hostmacro.py | 223 ++ .../zabbix/plugins/modules/zabbix_maintenance.py | 365 +++ .../community/zabbix/plugins/modules/zabbix_map.py | 790 ++++++ .../zabbix/plugins/modules/zabbix_mediatype.py | 787 ++++++ .../zabbix/plugins/modules/zabbix_proxy.py | 430 ++++ .../zabbix/plugins/modules/zabbix_screen.py | 448 ++++ .../zabbix/plugins/modules/zabbix_service.py | 252 ++ .../zabbix/plugins/modules/zabbix_template.py | 771 ++++++ .../zabbix/plugins/modules/zabbix_template_info.py | 232 ++ .../zabbix/plugins/modules/zabbix_user.py | 696 +++++ .../zabbix/plugins/modules/zabbix_user_info.py | 132 + .../zabbix/plugins/modules/zabbix_usergroup.py | 498 ++++ .../zabbix/plugins/modules/zabbix_valuemap.py | 295 +++ .../community/zabbix/roles/zabbix_agent/README.md | 509 ++++ .../zabbix/roles/zabbix_agent/defaults/main.yml | 267 ++ .../zabbix/roles/zabbix_agent/files/sample.conf | 3 + .../zabbix_agent/files/win_sample/doSomething.ps1 | 0 .../zabbix/roles/zabbix_agent/handlers/main.yml | 36 + .../zabbix/roles/zabbix_agent/meta/main.yml | 42 + .../molecule/with-server/Dockerfile.j2 | 14 + .../zabbix_agent/molecule/with-server/INSTALL.rst | 26 + .../zabbix_agent/molecule/with-server/molecule.yml | 81 + .../zabbix_agent/molecule/with-server/playbook.yml | 24 + .../zabbix_agent/molecule/with-server/prepare.yml | 114 + .../molecule/with-server/requirements.yml | 5 + .../molecule/with-server/tests/test_agent.py | 44 + .../molecule/with-server/tests/test_default.py | 41 + .../zabbix/roles/zabbix_agent/tasks/Darwin.yml | 170 ++ .../zabbix/roles/zabbix_agent/tasks/Debian.yml | 197 ++ .../zabbix/roles/zabbix_agent/tasks/Docker.yml | 33 + .../zabbix/roles/zabbix_agent/tasks/Linux.yml | 216 ++ .../zabbix/roles/zabbix_agent/tasks/RedHat.yml | 133 + .../zabbix/roles/zabbix_agent/tasks/Suse.yml | 53 + .../zabbix/roles/zabbix_agent/tasks/Windows.yml | 164 ++ .../zabbix/roles/zabbix_agent/tasks/api.yml | 135 + .../zabbix/roles/zabbix_agent/tasks/firewall.yml | 53 + .../zabbix/roles/zabbix_agent/tasks/macOS.yml | 24 + .../zabbix/roles/zabbix_agent/tasks/main.yml | 109 + .../zabbix/roles/zabbix_agent/tasks/remove.yml | 20 + .../zabbix/roles/zabbix_agent/tasks/selinux.yml | 102 + .../roles/zabbix_agent/tasks/tlspsk_auto.yml | 85 + .../zabbix_agent/tasks/tlspsk_auto_agent2.yml | 85 + .../roles/zabbix_agent/tasks/userparameter.yml | 85 + .../zabbix_agent/templates/userparameters/mysql.j2 | 3 + .../templates/userparameters/win_sample.j2 | 1 + .../zabbix_agent/templates/zabbix_agent2.conf.j2 | 453 ++++ .../zabbix_agent/templates/zabbix_agentd.conf.j2 | 366 +++ .../zabbix/roles/zabbix_agent/vars/Darwin.yml | 6 + .../zabbix/roles/zabbix_agent/vars/Debian.yml | 7 + .../zabbix/roles/zabbix_agent/vars/RedHat.yml | 7 + .../zabbix/roles/zabbix_agent/vars/Sangoma.yml | 7 + .../zabbix/roles/zabbix_agent/vars/Suse.yml | 7 + .../zabbix/roles/zabbix_agent/vars/Windows.yml | 4 + .../zabbix/roles/zabbix_agent/vars/zabbix.yml | 191 ++ .../zabbix/roles/zabbix_javagateway/README.md | 143 ++ .../roles/zabbix_javagateway/defaults/main.yml | 32 + .../roles/zabbix_javagateway/files/systemd.service | 15 + .../roles/zabbix_javagateway/handlers/main.yml | 16 + .../zabbix/roles/zabbix_javagateway/meta/main.yml | 23 + .../roles/zabbix_javagateway/tasks/Debian.yml | 73 + .../roles/zabbix_javagateway/tasks/RedHat.yml | 34 + .../zabbix/roles/zabbix_javagateway/tasks/main.yml | 42 + .../templates/zabbix_java_gateway.conf.j2 | 23 + .../roles/zabbix_javagateway/vars/Debian.yml | 6 + .../roles/zabbix_javagateway/vars/RedHat.yml | 6 + .../zabbix/roles/zabbix_javagateway/vars/main.yml | 2 + .../roles/zabbix_javagateway/vars/zabbix.yml | 188 ++ .../community/zabbix/roles/zabbix_proxy/README.md | 342 +++ .../zabbix/roles/zabbix_proxy/defaults/main.yml | 162 ++ .../roles/zabbix_proxy/files/install_semodule.bsx | Bin 0 -> 1102 bytes .../zabbix/roles/zabbix_proxy/handlers/main.yml | 29 + .../zabbix/roles/zabbix_proxy/meta/main.yml | 27 + .../zabbix/roles/zabbix_proxy/requirements.yml | 3 + .../zabbix/roles/zabbix_proxy/tasks/Debian.yml | 229 ++ .../zabbix/roles/zabbix_proxy/tasks/RedHat.yml | 243 ++ .../zabbix/roles/zabbix_proxy/tasks/main.yml | 143 ++ .../zabbix/roles/zabbix_proxy/tasks/mysql.yml | 157 ++ .../zabbix/roles/zabbix_proxy/tasks/postgresql.yml | 85 + .../zabbix/roles/zabbix_proxy/tasks/selinux.yml | 50 + .../zabbix/roles/zabbix_proxy/tasks/sqlite3.yml | 48 + .../zabbix_proxy/templates/zabbix_proxy.conf.j2 | 604 +++++ .../zabbix/roles/zabbix_proxy/vars/Amazon.yml | 2 + .../zabbix/roles/zabbix_proxy/vars/main.yml | 2 + .../zabbix/roles/zabbix_proxy/vars/zabbix.yml | 188 ++ .../community/zabbix/roles/zabbix_server/README.md | 339 +++ .../zabbix/roles/zabbix_server/defaults/main.yml | 145 ++ .../roles/zabbix_server/files/install_semodule.bsx | Bin 0 -> 1102 bytes .../zabbix/roles/zabbix_server/handlers/main.yml | 30 + .../zabbix/roles/zabbix_server/meta/main.yml | 26 + .../zabbix/roles/zabbix_server/requirements.yml | 4 + .../zabbix/roles/zabbix_server/tasks/Debian.yml | 216 ++ .../zabbix/roles/zabbix_server/tasks/RedHat.yml | 205 ++ .../zabbix/roles/zabbix_server/tasks/main.yml | 51 + .../zabbix/roles/zabbix_server/tasks/mysql.yml | 277 ++ .../roles/zabbix_server/tasks/postgresql.yml | 171 ++ .../zabbix/roles/zabbix_server/tasks/scripts.yml | 20 + .../zabbix/roles/zabbix_server/tasks/selinux.yml | 124 + .../zabbix_server/templates/zabbix_server.conf.j2 | 663 +++++ .../zabbix/roles/zabbix_server/vars/Debian.yml | 6 + .../zabbix/roles/zabbix_server/vars/RedHat.yml | 6 + .../zabbix/roles/zabbix_server/vars/main.yml | 2 + .../zabbix/roles/zabbix_server/vars/zabbix.yml | 188 ++ .../community/zabbix/roles/zabbix_web/README.md | 322 +++ .../zabbix/roles/zabbix_web/defaults/main.yml | 124 + .../zabbix/roles/zabbix_web/handlers/main.yml | 54 + .../zabbix/roles/zabbix_web/meta/main.yml | 28 + .../zabbix/roles/zabbix_web/tasks/Debian.yml | 91 + .../zabbix/roles/zabbix_web/tasks/RedHat.yml | 170 ++ .../zabbix/roles/zabbix_web/tasks/access.yml | 32 + .../zabbix/roles/zabbix_web/tasks/apache.yml | 35 + .../roles/zabbix_web/tasks/apache_Debian.yml | 53 + .../roles/zabbix_web/tasks/apache_RedHat.yml | 15 + .../zabbix/roles/zabbix_web/tasks/main.yml | 99 + .../zabbix/roles/zabbix_web/tasks/nginx.yml | 144 ++ .../zabbix/roles/zabbix_web/tasks/php_Debian.yml | 44 + .../zabbix/roles/zabbix_web/tasks/selinux.yml | 81 + .../zabbix_web/templates/apache_vhost.conf.j2 | 187 ++ .../roles/zabbix_web/templates/nginx_vhost.conf.j2 | 109 + .../roles/zabbix_web/templates/php-fpm.conf.j2 | 35 + .../roles/zabbix_web/templates/zabbix.conf.php.j2 | 42 + .../zabbix/roles/zabbix_web/vars/Debian-10.yml | 3 + .../zabbix/roles/zabbix_web/vars/Debian-8.yml | 3 + .../zabbix/roles/zabbix_web/vars/Debian-9.yml | 3 + .../zabbix/roles/zabbix_web/vars/Debian.yml | 20 + .../zabbix/roles/zabbix_web/vars/RedHat-7.yml | 8 + .../zabbix/roles/zabbix_web/vars/RedHat-8.yml | 8 + .../zabbix/roles/zabbix_web/vars/RedHat.yml | 18 + .../zabbix/roles/zabbix_web/vars/Ubuntu-18.yml | 3 + .../zabbix/roles/zabbix_web/vars/Ubuntu-20.yml | 3 + .../zabbix/roles/zabbix_web/vars/zabbix.yml | 188 ++ .../community/zabbix/scripts/inventory/zabbix.ini | 20 + .../community/zabbix/scripts/inventory/zabbix.py | 196 ++ .../targets/setup_zabbix/defaults/main.yml | 4 + .../targets/setup_zabbix/tasks/main.yml | 40 + .../targets/test_zabbix_action/meta/main.yml | 2 + .../targets/test_zabbix_action/tasks/main.yml | 1169 +++++++++ .../test_zabbix_discovery_rule/meta/main.yml | 2 + .../test_zabbix_discovery_rule/tasks/main.yml | 295 +++ .../targets/test_zabbix_group/meta/main.yml | 2 + .../targets/test_zabbix_group/tasks/main.yml | 112 + .../targets/test_zabbix_group_info/meta/main.yml | 2 + .../targets/test_zabbix_group_info/tasks/main.yml | 62 + .../targets/test_zabbix_host/meta/main.yml | 2 + .../targets/test_zabbix_host/tasks/main.yml | 12 + .../test_zabbix_host/tasks/zabbix_host_doc.yml | 83 + .../test_zabbix_host/tasks/zabbix_host_setup.yml | 20 + .../tasks/zabbix_host_teardown.yml | 10 + .../test_zabbix_host/tasks/zabbix_host_tests.yml | 1488 +++++++++++ .../targets/test_zabbix_host_info/meta/main.yml | 2 + .../targets/test_zabbix_host_info/tasks/main.yml | 159 ++ .../targets/test_zabbix_hostmacro/meta/main.yml | 2 + .../targets/test_zabbix_hostmacro/tasks/main.yml | 160 ++ .../targets/test_zabbix_maintenance/aliases | 1 + .../targets/test_zabbix_maintenance/meta/main.yml | 2 + .../targets/test_zabbix_maintenance/tasks/main.yml | 260 ++ .../targets/test_zabbix_mediatype/meta/main.yml | 2 + .../targets/test_zabbix_mediatype/tasks/main.yml | 696 +++++ .../integration/targets/test_zabbix_proxy/aliases | 1 + .../targets/test_zabbix_proxy/meta/main.yml | 2 + .../targets/test_zabbix_proxy/tasks/main.yml | 365 +++ .../targets/test_zabbix_screen/meta/main.yml | 2 + .../targets/test_zabbix_screen/tasks/main.yml | 146 ++ .../targets/test_zabbix_service/meta/main.yml | 2 + .../targets/test_zabbix_service/tasks/main.yml | 397 +++ .../files/template1-changed_50_lower.json | 51 + .../files/template1-changed_52_higher.json | 51 + .../files/template1_50_lower.json | 47 + .../files/template1_52_higher.json | 47 + .../files/template2_50_lower.xml | 53 + .../files/template2_52_higher.xml | 53 + .../targets/test_zabbix_template/meta/main.yml | 2 + .../targets/test_zabbix_template/tasks/main.yml | 408 +++ .../test_zabbix_template_info/meta/main.yml | 2 + .../test_zabbix_template_info/tasks/main.yml | 86 + .../targets/test_zabbix_user/meta/main.yml | 2 + .../test_zabbix_user/tasks/for_zabbix_50_lower.yml | 1020 ++++++++ .../tasks/for_zabbix_52_higher.yml | 1077 ++++++++ .../targets/test_zabbix_user/tasks/main.yml | 10 + .../targets/test_zabbix_user_info/meta/main.yml | 2 + .../targets/test_zabbix_user_info/tasks/main.yml | 208 ++ .../targets/test_zabbix_usergroup/meta/main.yml | 2 + .../targets/test_zabbix_usergroup/tasks/main.yml | 138 + .../community/zabbix/tests/sanity/ignore-2.10.txt | 48 + .../community/zabbix/tests/sanity/ignore-2.11.txt | 48 + .../community/zabbix/tests/sanity/ignore-2.9.txt | 48 + .../community/zabbix/tests/sanity/requirements.txt | 4 + .../ansible_collections/community/zabbix/tox.ini | 39 + 260 files changed, 40009 insertions(+) create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.github/ISSUE_TEMPLATE/bug_report.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.github/ISSUE_TEMPLATE/feature_request.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/agent.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/javagateway.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/plugins-integration.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/proxy.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/repo-sanity.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/server.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/web.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/.gitignore create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/CHANGELOG.rst create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/CODE_OF_CONDUCT.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/CONTRIBUTING.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/FILES.json create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/LICENSE create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/MANIFEST.json create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/README.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/changelogs/.plugin-cache.yaml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/changelogs/changelog.yaml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/changelogs/config.yaml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/changelogs/fragments/.gitkeep create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/docker-compose.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/docs/PUBLISHING_TO_GALAXY.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/docs/RELEASE.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/docs/UPGRADE.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_AGENT_ROLE.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_JAVAGATEWAY_ROLE.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_PROXY_ROLE.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_SERVER_ROLE.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_WEB_ROLE.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/meta/runtime.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/requirements.txt create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/converge.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/molecule.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/prepare.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_agent.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_agent2.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_docker.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/converge.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/molecule.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/prepare.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/tests/test_default.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/converge.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/destroy.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/tests/test_default.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/converge.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/destroy.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/molecule.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/prepare.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/tests/test_default.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/converge.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/destroy.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/molecule.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/prepare.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/requirements.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/tests/test_default.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/doc_fragments/zabbix.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/__init__.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/base.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/helpers.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/wrappers.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/__init__.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_action.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_discovery_rule.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group_facts.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group_info.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_events_info.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_facts.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_info.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_hostmacro.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_maintenance.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_map.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_mediatype.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_proxy.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_screen.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_service.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_template_info.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_user.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_user_info.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_usergroup.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_valuemap.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/README.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/files/sample.conf create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/files/win_sample/doSomething.ps1 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/handlers/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/Dockerfile.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/INSTALL.rst create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/molecule.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/playbook.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/prepare.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/requirements.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/tests/test_agent.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/tests/test_default.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Darwin.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Docker.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Linux.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Suse.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Windows.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/api.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/firewall.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/macOS.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/remove.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/selinux.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/tlspsk_auto.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/userparameter.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/userparameters/mysql.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/userparameters/win_sample.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/zabbix_agent2.conf.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/zabbix_agentd.conf.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Darwin.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Sangoma.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Suse.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Windows.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/zabbix.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/README.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/files/systemd.service create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/handlers/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/templates/zabbix_java_gateway.conf.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/zabbix.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/README.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/defaults/main.yml create mode 100755 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/files/install_semodule.bsx create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/handlers/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/requirements.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/mysql.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/postgresql.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/selinux.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/sqlite3.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/templates/zabbix_proxy.conf.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/Amazon.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/zabbix.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/README.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/defaults/main.yml create mode 100755 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/files/install_semodule.bsx create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/handlers/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/requirements.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/mysql.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/postgresql.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/scripts.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/selinux.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/templates/zabbix_server.conf.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/zabbix.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/README.md create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/handlers/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/access.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache_Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache_RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/nginx.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/php_Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/selinux.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/apache_vhost.conf.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/nginx_vhost.conf.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/php-fpm.conf.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/zabbix.conf.php.j2 create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-10.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-8.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-9.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat-7.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat-8.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Ubuntu-18.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Ubuntu-20.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/zabbix.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/scripts/inventory/zabbix.ini create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/scripts/inventory/zabbix.py create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/aliases create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/aliases create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_50_lower.json create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_52_higher.json create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_50_lower.json create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_52_higher.json create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_52_higher.xml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_52_higher.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.10.txt create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.11.txt create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.9.txt create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/requirements.txt create mode 100644 collections-debian-merged/ansible_collections/community/zabbix/tox.ini (limited to 'collections-debian-merged/ansible_collections/community/zabbix') diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.github/ISSUE_TEMPLATE/bug_report.md b/collections-debian-merged/ansible_collections/community/zabbix/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..025b9e65 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,59 @@ +--- +name: Bug report +about: Create a report to help us improve +title: +labels: +assignees: + +--- + + + + + +##### SUMMARY + + +##### ISSUE TYPE +- Bug Report + +##### COMPONENT NAME + + +##### ANSIBLE VERSION + +```paste below + +``` + +##### CONFIGURATION + +```paste below + +``` + +##### OS / ENVIRONMENT / Zabbix Version + + + +##### STEPS TO REPRODUCE + + + +```yaml + +``` + + + +##### EXPECTED RESULTS + + + +##### ACTUAL RESULTS + + + +```paste below + +``` \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.github/ISSUE_TEMPLATE/feature_request.md b/collections-debian-merged/ansible_collections/community/zabbix/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..033d0feb --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,25 @@ +--- +name: ✨ Feature request +about: Suggest an idea for this project +--- + + + +##### SUMMARY + + +##### ISSUE TYPE +- Feature Idea + +##### COMPONENT NAME + + +##### ADDITIONAL INFORMATION + + + +```yaml + +``` + + diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/agent.yml b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/agent.yml new file mode 100644 index 00000000..e451af22 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/agent.yml @@ -0,0 +1,83 @@ +name: "community.zabbix.zabbix_agent" +on: + push: + paths: + - 'roles/zabbix_agent/**' + - 'molecule/zabbix_agent/**' + - 'molecule/requirements.txt' + - '.github/workflows/agent.yml' + pull_request: + paths: + - 'roles/zabbix_agent/**' + - 'molecule/zabbix_agent/**' + - 'molecule/requirements.txt' + - '.github/workflows/agent.yml' +jobs: + molecule: + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + molecule_distro: + - container: centos + image: geerlingguy/docker-centos8-ansible:latest + group: agent + - container: centos2 + image: geerlingguy/docker-centos8-ansible:latest + group: agent2 + - container: centos + image: geerlingguy/docker-centos7-ansible:latest + group: agent + - container: fedora32 + image: geerlingguy/docker-fedora32-ansible:latest + group: agent + - container: ubuntu + image: geerlingguy/docker-ubuntu2004-ansible + group: agent + - container: pgsql-ubuntu + image: geerlingguy/docker-ubuntu1804-ansible + group: agent + - container: debian + image: geerlingguy/docker-debian10-ansible + group: agent + - container: debian + image: geerlingguy/docker-debian9-ansible + group: agent + - container: debian + image: geerlingguy/docker-debian8-ansible + group: agent + - container: mint + image: wdijkerman/mint19.3-amd64 + command: /sbin/init + group: agent + collection_role: + - zabbix_agent + steps: + - name: Check out code + uses: actions/checkout@v1 + + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r molecule/requirements.txt + + - name: Build the collection + run: | + collection_file=$( basename $(ansible-galaxy collection build -f | awk -F" " '{print $NF}')) + echo "COLLECTION_FILE=$collection_file" >> $GITHUB_ENV + + - name: Install the collection + run: ansible-galaxy collection install $COLLECTION_FILE + + - name: Run role tests + run: >- + MY_MOLECULE_CONTAINER=${{ matrix.molecule_distro.container }} + MY_MOLECULE_IMAGE=${{ matrix.molecule_distro.image }} + MY_MOLECULE_GROUP=${{ matrix.molecule_distro.group }} + MY_MOLECULE_DOCKER_COMMAND=${{ matrix.molecule_distro.command }} + molecule test -s ${{ matrix.collection_role }} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/javagateway.yml b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/javagateway.yml new file mode 100644 index 00000000..30b838e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/javagateway.yml @@ -0,0 +1,58 @@ +name: "community.zabbix.zabbix_javagateway" +on: + push: + paths: + - 'roles/zabbix_javagateway/**' + - 'molecule/zabbix_javagateway/**' + - 'molecule/requirements.txt' + - '.github/workflows/javagateway.yml' + pull_request: + paths: + - 'roles/zabbix_javagateway/**' + - 'molecule/zabbix_javagateway/**' + - 'molecule/requirements.txt' + - '.github/workflows/javagateway.yml' +jobs: + molecule: + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + molecule_distro: + - container: centos + image: geerlingguy/docker-centos8-ansible:latest + - container: ubuntu + image: geerlingguy/docker-ubuntu2004-ansible + - container: debian + image: geerlingguy/docker-debian10-ansible + collection_role: + - zabbix_javagateway + steps: + - name: Check out code + uses: actions/checkout@v1 + + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r molecule/requirements.txt + + - name: Build the collection + run: | + collection_file=$( basename $(ansible-galaxy collection build -f | awk -F" " '{print $NF}')) + echo "COLLECTION_FILE=$collection_file" >> $GITHUB_ENV + + - name: Install the collection + run: ansible-galaxy collection install $COLLECTION_FILE + + - name: Run role tests + run: >- + MY_MOLECULE_CONTAINER=${{ matrix.molecule_distro.container }} + MY_MOLECULE_IMAGE=${{ matrix.molecule_distro.image }} + MY_MOLECULE_GROUP=${{ matrix.molecule_distro.group }} + MY_MOLECULE_DOCKER_COMMAND=${{ matrix.molecule_distro.command }} + molecule test -s ${{ matrix.collection_role }} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/plugins-integration.yml b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/plugins-integration.yml new file mode 100644 index 00000000..7b4db1a4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/plugins-integration.yml @@ -0,0 +1,78 @@ +name: plugins-integration +on: + push: + paths: + - 'plugins/**' + - 'tests/integration/**' + - '.github/workflows/plugins-integration.yml' + pull_request: + paths: + - 'plugins/**' + - 'tests/integration/**' + - '.github/workflows/plugins-integration.yml' + +jobs: + integration: + runs-on: ubuntu-latest + name: I (${{ matrix.zabbix_container.version}} Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}}) + strategy: + fail-fast: false + matrix: + zabbix_container: + - version: "3.0" + - version: "4.0" + - version: "4.4" + - version: "5.0" + - version: "5.2" + ansible: + # - stable-2.9 # Only if your collection supports Ansible 2.9 + - stable-2.10 + - devel + python: + - 2.7 + - 3.7 + exclude: + - python: 3.8 # blocked by ansible/ansible#70155 + + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + path: ansible_collections/community/zabbix + + - name: Set up Python ${{ matrix.ansible }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + + - name: Install ansible-base (${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Install dependencies + run: pip install docker-compose zabbix-api + + # For Zabbix integration tests we need to test against different versions of + # the Zabbix server. To do this we spin up a Docker container using the `matrix` + # of version and ports specified earlier. + - name: Zabbix container server provisioning + run: docker-compose up -d + working-directory: ./ansible_collections/community/zabbix + env: + zabbix_version: ${{ matrix.zabbix_container.version }} + + # Run the integration tests + # As we need to connect to an existing docker container we can't use `--docker` here as the VMs would be on different + # (non-routing) networks, so we run them locally and ensure any required dependencies are installed via `--requirements` + - name: Run integration test + run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --requirements --coverage + working-directory: ./ansible_collections/community/zabbix + + # ansible-test support producing code coverage date + - name: Generate coverage report + run: ansible-test coverage xml -v --requirements --group-by command --group-by version + working-directory: ./ansible_collections/community/zabbix + + # See the repots at https://codecov.io/gh/ansible-collections/community.zabbix + - uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: false diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/proxy.yml b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/proxy.yml new file mode 100644 index 00000000..bb194a9d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/proxy.yml @@ -0,0 +1,81 @@ +name: "community.zabbix.zabbix_proxy" +on: + push: + paths: + - 'roles/zabbix_proxy/**' + - 'molecule/zabbix_proxy/**' + - 'molecule/requirements.txt' + - '.github/workflows/proxy.yml' + pull_request: + paths: + - 'roles/zabbix_proxy/**' + - 'molecule/zabbix_proxy/**' + - 'molecule/requirements.txt' + - '.github/workflows/proxy.yml' +jobs: + molecule: + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + molecule_distro: + - container: mysql-centos + image: geerlingguy/docker-centos8-ansible:latest + group: mysql + - container: pgsql-centos + image: geerlingguy/docker-centos8-ansible:latest + group: postgresql + - container: sqlite-centos + image: geerlingguy/docker-centos8-ansible:latest + group: sqlite3 + - container: mysql-ubuntu + image: geerlingguy/docker-ubuntu2004-ansible + group: mysql + - container: pgsql-ubuntu + image: geerlingguy/docker-ubuntu2004-ansible + group: postgresql + command: /sbin/init + - container: sqlite-ubuntu + image: geerlingguy/docker-ubuntu2004-ansible + group: sqlite3 + command: /sbin/init + - container: mysql-debian + image: geerlingguy/docker-debian10-ansible + group: mysql + - container: pgsql-debian + image: geerlingguy/docker-debian10-ansible + group: postgresql + - container: sqlite-debian + image: geerlingguy/docker-debian10-ansible + group: sqlite3 + collection_role: + - zabbix_proxy + steps: + - name: Check out code + uses: actions/checkout@v1 + + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r molecule/requirements.txt + + - name: Build the collection + run: | + collection_file=$( basename $(ansible-galaxy collection build -f | awk -F" " '{print $NF}')) + echo "COLLECTION_FILE=$collection_file" >> $GITHUB_ENV + + - name: Install the collection + run: ansible-galaxy collection install $COLLECTION_FILE + + - name: Run role tests + run: >- + MY_MOLECULE_CONTAINER=${{ matrix.molecule_distro.container }} + MY_MOLECULE_IMAGE=${{ matrix.molecule_distro.image }} + MY_MOLECULE_GROUP=${{ matrix.molecule_distro.group }} + MY_MOLECULE_DOCKER_COMMAND=${{ matrix.molecule_distro.command }} + molecule test -s ${{ matrix.collection_role }} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/repo-sanity.yml b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/repo-sanity.yml new file mode 100644 index 00000000..969cada8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/repo-sanity.yml @@ -0,0 +1,81 @@ +name: repo-sanity +on: + push: + pull_request: + +jobs: + tox-linters: + name: Tox-Lint (py${{ matrix.python }}) + strategy: + matrix: + python: + - 2.7 + - 3.7 + - 3.8 + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + path: ansible_collections/community/zabbix + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies + run: pip install flake8 tox + + - name: Run lint test for py2 + run: tox -elinters-py2 -vv + working-directory: ./ansible_collections/community/zabbix + if: matrix.python == '2.7' + + - name: Run lint test for py3 + run: tox -elinters-py3 -vv + working-directory: ./ansible_collections/community/zabbix + if: matrix.python != '2.7' + + sanity: + name: Sanity (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) + strategy: + matrix: + ansible: + # It's important that Sanity is tested against all stable-X.Y branches + # Testing against `devel` may fail as new tests are added. + # - stable-2.9 # Only if your collection supports Ansible 2.9 + - stable-2.10 + - devel + python: + - 2.7 + - 3.7 + - 3.8 + exclude: + - python: 3.8 # blocked by ansible/ansible#70155 + runs-on: ubuntu-latest + steps: + + # ansible-test requires the collection to be in a directory in the form + # .../ansible_collections/NAMESPACE/COLLECTION_NAME/ + + - name: Check out code + uses: actions/checkout@v2 + with: + path: ansible_collections/community/zabbix + + - name: Set up Python ${{ matrix.ansible }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + + # Install the head of the given branch (devel, stable-2.10) + - name: Install ansible-base (${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + # run ansible-test sanity inside of Docker. + # The docker container has all the pinned dependencies that are required. + # Explicity specify the version of Python we want to test + - name: Run sanity tests + run: ansible-test sanity --docker -v --color --python ${{ matrix.python }} + working-directory: ./ansible_collections/community/zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/server.yml b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/server.yml new file mode 100644 index 00000000..347d1424 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/server.yml @@ -0,0 +1,71 @@ +name: "community.zabbix.zabbix_server" +on: + push: + paths: + - 'roles/zabbix_server/**' + - 'molecule/zabbix_server/**' + - 'molecule/requirements.txt' + - '.github/workflows/server.yml' + pull_request: + paths: + - 'roles/zabbix_server/**' + - 'molecule/zabbix_server/**' + - 'molecule/requirements.txt' + - '.github/workflows/server.yml' +jobs: + molecule: + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + molecule_distro: + - container: mysql-centos + image: geerlingguy/docker-centos8-ansible:latest + group: mysql + - container: pgsql-centos + image: geerlingguy/docker-centos8-ansible:latest + group: postgresql + - container: mysql-ubuntu + image: geerlingguy/docker-ubuntu2004-ansible + group: mysql + - container: pgsql-ubuntu + image: geerlingguy/docker-ubuntu2004-ansible + group: postgresql + command: /sbin/init + - container: mysql-debian + image: geerlingguy/docker-debian10-ansible + group: mysql + - container: pgsql-debian + image: geerlingguy/docker-debian10-ansible + group: postgresql + collection_role: + - zabbix_server + steps: + - name: Check out code + uses: actions/checkout@v1 + + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r molecule/requirements.txt + + - name: Build the collection + run: | + collection_file=$( basename $(ansible-galaxy collection build -f | awk -F" " '{print $NF}')) + echo "COLLECTION_FILE=$collection_file" >> $GITHUB_ENV + + - name: Install the collection + run: ansible-galaxy collection install $COLLECTION_FILE + + - name: Run role tests + run: >- + MY_MOLECULE_CONTAINER=${{ matrix.molecule_distro.container }} + MY_MOLECULE_IMAGE=${{ matrix.molecule_distro.image }} + MY_MOLECULE_GROUP=${{ matrix.molecule_distro.group }} + MY_MOLECULE_DOCKER_COMMAND=${{ matrix.molecule_distro.command }} + molecule test -s ${{ matrix.collection_role }} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/web.yml b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/web.yml new file mode 100644 index 00000000..f34f0b6b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.github/workflows/web.yml @@ -0,0 +1,70 @@ +name: "community.zabbix.zabbix_web" +on: + push: + paths: + - 'roles/zabbix_web/**' + - 'molecule/zabbix_web/**' + - 'molecule/requirements.txt' + - '.github/workflows/web.yml' + pull_request: + paths: + - 'roles/zabbix_web/**' + - 'molecule/zabbix_web/**' + - 'molecule/requirements.txt' + - '.github/workflows/web.yml' +jobs: + molecule: + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + molecule_distro: + - container: mysql-centos8 + image: geerlingguy/docker-centos8-ansible:latest + group: mysql + - container: pgsql-centos8 + image: geerlingguy/docker-centos8-ansible:latest + group: postgresql + - container: mysql-ubuntu18 + image: geerlingguy/docker-ubuntu1804-ansible + group: mysql + - container: pgsql-ubuntu20 + image: geerlingguy/docker-ubuntu2004-ansible + group: postgresql + - container: mysql-debian + image: geerlingguy/docker-debian10-ansible + group: mysql + - container: pgsql-debian + image: geerlingguy/docker-debian10-ansible + group: postgresql + collection_role: + - zabbix_web + steps: + - name: Check out code + uses: actions/checkout@v1 + + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r molecule/requirements.txt + + - name: Build the collection + run: | + collection_file=$( basename $(ansible-galaxy collection build -f | awk -F" " '{print $NF}')) + echo "COLLECTION_FILE=$collection_file" >> $GITHUB_ENV + + - name: Install the collection + run: ansible-galaxy collection install $COLLECTION_FILE + + - name: Run role tests + run: >- + MY_MOLECULE_CONTAINER=${{ matrix.molecule_distro.container }} + MY_MOLECULE_IMAGE=${{ matrix.molecule_distro.image }} + MY_MOLECULE_GROUP=${{ matrix.molecule_distro.group }} + MY_MOLECULE_DOCKER_COMMAND=${{ matrix.molecule_distro.command }} + molecule test -s ${{ matrix.collection_role }} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/.gitignore b/collections-debian-merged/ansible_collections/community/zabbix/.gitignore new file mode 100644 index 00000000..340b1280 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/.gitignore @@ -0,0 +1,17 @@ +tests/output +__pycache__ + +# ignore visual studio code things +.vscode + +# ignore Python Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# unit test +.tox/ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/CHANGELOG.rst b/collections-debian-merged/ansible_collections/community/zabbix/CHANGELOG.rst new file mode 100644 index 00000000..f8544113 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/CHANGELOG.rst @@ -0,0 +1,232 @@ +============================== +community.zabbix Release Notes +============================== + +.. contents:: Topics + + +v1.2.0 +====== + +Minor Changes +------------- + +- Updated the roles to support Zabbix 5.2. +- zabbix_agent - Added a new property `zabbix_agent_dont_detect_ip` when set to true, it won't detect the ips and no need to install the python module `netaddr`. +- zabbix_agent - Added parameter `zabbix_agent_package_remove` when set to `true` and `zabbix_agent2` is set to `true` it will uninstall the `zabbix-agent` service and package. +- zabbix_agent - added `zabbix_agent_install_agent_only` Will only install the Zabbix Agent package and not the `zabbix-sender` or `zabbix-get` packages. +- zabbix_template - Fixed to decode Unicode Escape of multibyte strings in an importing template data(https://github.com/ansible-collections/community.zabbix/pull/226). +- zabbix_user - added new parameters to set timezone and role_name for users (https://github.com/ansible-collections/community.zabbix/pull/260). +- zabbix_user - user_medias now defaults to None and is optional (https://github.com/ansible-collections/community.zabbix/pull/264). +- zabbix_web - added `zabbix_web_rhel_release` which enable scl on RHEL (https://github.com/ansible-collections/community.zabbix/pull/266). +- zabbix_web - quality of life improvements when using Nginx (https://github.com/ansible-collections/community.zabbix/pull/304). + +Bugfixes +-------- + +- When installing the Zabbix packages, we disable all other yum repositories except the one for the Zabbix. +- zabbix_agent - Agent 2 also be able to use userparameters file. +- zabbix_agent - Also work on SLES 12 sp5 +- zabbix_agent - Documented the property 'zabbix_proxy_ip' in the documentation. +- zabbix_agent - There was an task that wasn't able to use an http(s)_proxy environment while installing an package. +- zabbix_agent - Windows - Able to create PSK file +- zabbix_agent - Windows - Fixing download links to proper version/url +- zabbix_agent - Windows - Removal of not working property +- zabbix_agent - Zabbix packages were not able to install properly on Fedora. When the packages are installed, the version will be appended to the package name. This is eofr all RedHat related OS'es. +- zabbix_agent - fixed issue with zabbix_agent2_tlspsk_auto having no effect when using zabbix_agent2 +- zabbix_agent - fixed issue with zabbix_api_create_hosts and TLS configuration when using zabbix_agent2, where zabbix_agent_tls* settings were used instead of zabbix_agent2_tls* +- zabbix_host - module will no longer require ``interfaces`` to be present when creating host with Zabbix 5.2 (https://github.com/ansible-collections/community.zabbix/pull/291). +- zabbix_host - should no longer fail with 'host cannot have more than one default interface' error (https://github.com/ansible-collections/community.zabbix/pull/309). +- zabbix_proxy (role) - Added missing paragraph for the SQLite3 as database. +- zabbix_proxy (role) - The become option was missing in some essential tasks when installing the Zabbix Proxy with SQLite3 as database. +- zabbix_proxy (role) - Various documentation fixes removing the Zabbix Server and replaced it with actual Zabbix Proxy information. +- zabbix_proxy - Added new property 'zabbix_proxy_ip' to determine ip for host running the Zabbix Proxy. +- zabbix_proxy - The 'interface' option was missing when creating an Proxy via the API. +- zabbix_template - fixed documentation for ``macros`` argument (https://github.com/ansible-collections/community.zabbix/pull/296). +- zabbix_template - fixed encode error when using Python2 (https://github.com/ansible-collections/community.zabbix/pull/297). +- zabbix_template - fixed issue when importing templates to zabbix version. >= 5.2 +- zabbix_template_info - fixed encode error when using Python2 (https://github.com/ansible-collections/community.zabbix/pull/297). +- zabbix_user - disable no_log warning for option override_password. +- zabbix_user - fixed issue where module couldn't create a user since Zabbix 5.2 (https://github.com/ansible-collections/community.zabbix/pull/260). +- zabbix_web - fixed issue Role cannot install Zabbix web 5.0 on RHEL 7 (https://github.com/ansible-collections/community.zabbix/issues/202). + +v1.1.0 +====== + +Release Summary +--------------- + +| Release date: 2020-10-22 + + +Minor Changes +------------- + +- all roles - added ``zabbix_{agent,web,server,proxy,javagateway}_conf_mode`` option for configuring a mode of the configuration file for each Zabbix service. +- zabbix_proxy (role) - added an option ``innodb_default_row_format`` for MariaDB/MySQL if it isn't set to ``dynamic``. +- zabbix_server - fixed installation output when using MySQL database to not print PostgreSQL. +- zabbix_user - ``passwd`` no longer required when ALL groups in ``usrgrps`` use LDAP as ``gui_access`` (see `#240 `_). +- zabbix_user - no longer requires ``usrgrps`` when ``state=absent`` (see `#240 `_). +- zabbix_web - added several configuration options for the PHP-FPM setup to configure the listen (socket) file. +- zabbix_web - added support for configuring Zabbix Web with Nginx, same way as with Apache. + +Bugfixes +-------- + +- all roles - missing ``become`` set to ``true`` was added to each task that requires admin privleges. +- zabbix_agent - added new properties and updated documentation to allow for correct Zabbix Agent2 configuration. +- zabbix_agent - fixed bug where Nginx prevented Apache from working as it was part of the FPM configuration. + +v1.0.0 +====== + +Release Summary +--------------- + +| Release date: 2020-08-16 + + +Minor Changes +------------- + +- Added the possibility to configure the ``mode`` for the ``zabbix_{agent,server,proxy}_include`` directories. +- all roles - added the possibility to configure the ``mode`` for the ``yum`` repositories files in case it contains credentials. +- zabbix_agent - ``zabbix-sender`` and ``zabbix-get`` will not be installed when ``zabbix_repo`` is set to ``epel``, as they are not part of the repository. +- zabbix_agent - added option to change between HTTP/HTTPS with ``zabbix_repo_yum_schema``. +- zabbix_agent - can also install the zabbix-agent2 application when ``zabbix_agent2`` is set to ``true``. +- zabbix_proxy (role) - a user and group are created on the host when ``zabbix_repo`` is set to ``epel``. +- zabbix_proxy (role) - now supports ``startpreprocessors`` setting and encryption when connecting to database (see `#164 `_). +- zabbix_server - a user and group are created on the host when ``zabbix_repo`` is set to ``epel``. +- zabbix_server - added option to change between HTTP/HTTPS with ``zabbix_repo_yum_schema``. +- zabbix_server - now supports ``startpreprocessors`` setting and encryption when connecting to database (see `#164 `_). +- zabbix_web - a property is added ``zabbix_web_doubleprecision`` which currently is set to ``false`` for default installations. For new installations this should be set to ``True``. For upgraded installations, please read database `upgrade notes `_ (Paragraph "Enabling extended range of numeric (float) values") before enabling this option. +- zabbix_web - added option to change between HTTP/HTTPS with ``zabbix_repo_yum_schema``. +- zabbix_web - don't remove the files that Zabbix will install during installation when you don't want to configure a virtual host configuration. + +Breaking Changes / Porting Guide +-------------------------------- + +- zabbix_javagateway - options ``javagateway_pidfile``, ``javagateway_listenip``, ``javagateway_listenport`` and ``javagateway_startpollers`` renamed to ``zabbix_javagateway_xyz`` (see `UPGRADE.md `_). + +Bugfixes +-------- + +- all roles - a ``handler`` is configured when ``zabbix_http(s)_proxy`` is defined which will remove the proxy line from the repository files. This results that execution of the roles are not idempotent anymore. +- zabbix_proxy (role) - ``StartPreprocessors`` only works with version 4.2 or higher. When a lower version is used, it will not be added to the configuration. +- zabbix_proxy (role) - only install the sql files that needs to be executed for when ``zabbix_repo`` is set to ``epel``. +- zabbix_server - ``StartPreprocessors`` only works with version 4.2 or higher. When a lower version is used, it will not be added to the configuration. +- zabbix_server - only install the sql files that needs to be executed for when ``zabbix_repo`` is set to ``epel``. + +v0.3.0 +====== + +Release Summary +--------------- + +| Release date: 2020-07-26 + + +Minor Changes +------------- + +- All roles now **support Zabbix 5.0** and by default install this version (see `#131 `_ and `#121 `_). +- Roles will now install gnupg on Debian OS family if not present. +- zabbix_action - no longer requires ``password`` and ``ssh_*key_file`` parameters at the same time for ``remote_command`` operations of type SSH. +- zabbix_action - parameter ``ssh_auth_type`` for SSH ``remote_command`` operation now correctly identifies which other parameters are required. +- zabbix_discovery_rule - refactoring module to use ``module_utils`` classes and functions, adjust return values on success, add documentation for return values. +- zabbix_discovery_rule - refactoring the module to remove unnecessary variables and fix a variable typo. +- zabbix_mediatype - new options ``message_templates``, ``description`` and many more related to ``type=webhook``. +- zabbix_mediatype - now supports new ``webhook`` media type. + +Bugfixes +-------- + +- zabbix_action - choices for the ``inventory`` paramter sub option in ``*operations`` arguments have been clarified to ``manual`` and ``automatic``. +- zabbix_action - fixed error on changed API fields ``*default_message`` and ``*default_subject`` for Zabbix 5.0 (see `#92 `_). +- zabbix_action - module will no longer fail when searching for global script provided to ``script_name`` parameter. +- zabbix_action - now correctly selects mediatype for the (normal|recovery|update) operations with Zabbix 4.4 and newer. +- zabbix_agent - fixed installation of agent on Windows to directories with spaces. +- zabbix_agent - role should no longer fail when looking for ``getenforce`` binary. +- zabbix_host - module will no longer convert context part of user macro to upper case. +- zabbix_proxy (role) - will now correctly install python3-libsemanage on RHEL OS family. +- zabbix_service - fixed the zabbix_service has no idempotency with Zabbix 5.0. +- zabbix_web - now no longer fails when rendering apache vhost template. + +New Modules +----------- + +- community.zabbix.zabbix_discovery_rule - Create/delete/update Zabbix discovery rules +- community.zabbix.zabbix_usergroup - Create/delete/update Zabbix user groups + +v0.2.0 +====== + +Release Summary +--------------- + +| Release date: 2020-06-15 + +Minor Changes +------------- + +- Documentation for roles moved to ``docs/`` sub-directory in the collection. +- New **role zabbix_agent** - previously known as dj-wasabi/zabbix-agent (also see `UPGRADE.md `_ for each role). +- New **role zabbix_javagateway** - previously known as dj-wasabi/zabbix-javagateway. +- New **role zabbix_proxy** - previously known as dj-wasabi/zabbix-proxy. +- New **role zabbix_server** - previously known as dj-wasabi/zabbix-server. +- New **role zabbix_web** - previously known as dj-wasabi/zabbix-web. +- zabbix_action - new alias ``update_operations`` for ``acknowledge_operations`` parameter. +- zabbix_host - ``macros`` now support new macro types ``text`` and ``secret``. +- zabbix_host - new option ``details`` (additional SNMP details) for ``interfaces`` parameter. +- zabbix_host - now supports Zabbix 5.0. +- zabbix_proxy (module) - now supports Zabbix 5.0. +- zabbix_screen - ``host_group`` parameter now accepts multiple groups. + +Bugfixes +-------- + +- zabbix_action - documented ``value2`` parameter and ``notify_all_involved`` option. +- zabbix_maintenance - changing value of ``description`` parameter now actually updates maintenance's description. +- zabbix_template - is now able to perform ``state=dump`` when using ``ansible-playbook --check``. +- zabbix_template - no longer imports template from ``template_json`` or ``template_xml`` when using ``ansible-playbook --check``. + +v0.1.0 +====== + +Release Summary +--------------- + +| Release date: 2020-06-15 + + +Minor Changes +------------- + +- zabbix inventory plugin now no longer prints DeprecationWarning when used with Python3 due to SafeConfigParser. +- zabbix_action - arguments ``event_source`` and ``esc_period`` no longer required when ``state=absent``. +- zabbix_host - fixed inventory_mode key error, which occurs with Zabbix 4.4.1 or more (see `#65304 `_). +- zabbix_host - was not possible to update a host where visible_name was not set in zabbix. +- zabbix_mediatype - Fixed to support zabbix 4.4 or more and python3 (see `#67693 `_). +- zabbix_template - fixed error when providing empty ``link_templates`` to the module (see `#66417 `_). +- zabbix_template - fixed invalid (non-importable) output provided by exporting XML (see `#66466 `_). +- zabbix_user - Fixed an issue where module failed with zabbix 4.4 or above (see `#67475 `_). + +Deprecated Features +------------------- + +- zabbix_proxy (module) - deprecates ``interface`` sub-options ``type`` and ``main`` when proxy type is set to passive via ``status=passive``. Make sure these suboptions are removed from your playbook as they were never supported by Zabbix in the first place. + +Bugfixes +-------- + +- zabbix_action - allow str values for ``esc_period`` options (see `#66841 `_). +- zabbix_action - no longer requires ``esc_period`` and ``event_source`` arguments when ``state=absent``. +- zabbix_host - now supports configuring user macros and host tags on the managed host (see `#66777 `_). +- zabbix_host_info - ``host_name`` based search results now include host groups. +- zabbix_hostmacro - ``macro_name`` now accepts macros in zabbix native format as well (e.g. ``{$MACRO}``). +- zabbix_hostmacro - ``macro_value`` is no longer required when ``state=absent``. +- zabbix_proxy (module) - ``interface`` sub-options ``type`` and ``main`` are now deprecated and will be removed in community.general 3.0.0. Also, the values passed to ``interface`` are now checked for correct types and unexpected keys. +- zabbix_proxy (module) - added option proxy_address for comma-delimited list of IP/CIDR addresses or DNS names to accept active proxy requests from. +- zabbix_template - add new option omit_date to remove date from exported/dumped template (see `#67302 `_). +- zabbix_template - adding new update rule templateLinkage.deleteMissing for newer zabbix versions (see `#66747 `_). +- zabbix_template_info - add new option omit_date to remove date from exported/dumped template (see `#67302 `_). diff --git a/collections-debian-merged/ansible_collections/community/zabbix/CODE_OF_CONDUCT.md b/collections-debian-merged/ansible_collections/community/zabbix/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..4fa46f96 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/CODE_OF_CONDUCT.md @@ -0,0 +1,82 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting one of the project maintainers at: +* d3defi@gmail.com +* sky.jokerxx@gmail.com +* github@werner-dijkerman.nl + +Or Ansible project directly at codeofconduct@ansible.com. + +All complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/collections-debian-merged/ansible_collections/community/zabbix/CONTRIBUTING.md b/collections-debian-merged/ansible_collections/community/zabbix/CONTRIBUTING.md new file mode 100644 index 00000000..4ab09065 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/CONTRIBUTING.md @@ -0,0 +1,169 @@ +# Contribution guidelines + +**Table of contents** + +- [Contribution guidelines](#contribution-guidelines) + * [Contributing](#contributing) + * [Coding guidelines](#coding-guidelines) + + [Zabbix roles](#zabbix-roles) + + [Zabbix modules](#zabbix-modules) + * [Testing and Development](#testing-and-development) + + [Testing Zabbix roles](#testing-zabbix-roles) + + [Testing Zabbix modules](#testing-zabbix-modules) +- [Additional information](#additional-information) + * [Virtualenv](#virtualenv) + * [Links](#links) + +Thank you very much for taking time to improve this Ansible collection. We appreciate your every contribution. Please make sure you are familiar with the content presented in this document to avoid any delays during reviews or merge. + +Please note that this project is released with following codes of conduct and by participating in the project you agree to abide by them: +* [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md) +* [Community Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html) + +If you are interested in joining us as a maintainer, please open an issue. + +## Contributing + +1. Fork this repository with community Zabbix collection. +2. Create a new branch and apply your changes to it. In addition to that: + 1. Ensure that any changes you introduce to this collection are reflected in the documentation. + 2. Ensure that your PR contains valid [changelog fragment](https://docs.ansible.com/ansible/devel/community/development_process.html#changelogs). + 3. Include tests with your contribution to ensure that future pull requests will not break your functionality. + 4. Make sure that tests succeed. +3. Push the branch to your forked repository. +4. Submit a new pull request into this collection. + +*Notes:* +* Pull requests that fail during the tests will not be merged. If you have trouble narrowing down cause of a failure and would like some help, do not hesitate to ask for it in comments. +* If you plan to propose an extensive feature or breaking change, please open an issue first. This allows collection maintainers to comment on such change in advance and avoid possible rejection of such contribution. + +## Coding guidelines + +Style guides are important because they ensure consistency in the content, look, and feel of a book or a website. Any contributions to this collection must adhere to the following rules: + +* [Ansible style guide](http://docs.ansible.com/ansible/latest/dev_guide/style_guide/). +* Use "Ansible" when referring to the product and ``ansible`` when referring to the command line tool, package and so on. + +### Zabbix roles + +* Playbooks should be written in multi-line YAML format using ``key: value``. + * The form ``key=value`` is suitable for ``ansible`` ad-hoc execution, not for ``ansible-playbook``. +* Every task should always have a ``name:`` keyword associated with it. + +### Zabbix modules + +These rules are required for any contributions proposing a new Zabbix module or updating an existing one. Modules should: + +* Be compatible with [currently supported Zabbix releases](https://www.zabbix.com/life_cycle_and_release_policy). +* Include the same set of general options as other Zabbix modules: + * In `DOCUMENTATION` block via `extends_documentation_fragment` keyword. + * In module `argument_spec` as a set of module parameters. +* Implement proper logout mechanism as other modules do. +* Use the same version of `zabbix-api` library as defined in collection requirements. +* Comply with [Ansible module best practices](https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_best_practices.html). + +## Testing and Development + +It is recommended to use Docker for the testing as this repository is utilizing it for its own CI. Read [Docker installation guide](https://docs.docker.com/install/) for more information. + +Make sure you start your work on the current state of the repository with `main` branch up to date. The best way to both try new changes and run shipped tests is by cloning the repository to Ansible project: + +```bash +cd / +mkdir -p collections/ansible_collections/community +git clone git@github.com:/community.zabbix.git collections/ansible_collections/community/zabbix +``` + +Functionality can be verified by looking at the documentation of a module: +```bash +ansible-doc community.zabbix.zabbix_host +``` + +Once this is done, you can reference modules and roles from testing playbook likes this: + +```yaml +- hosts: myserver + roles: + - role: community.zabbix.zabbix_agent + zabbix_agent_server: 10.0.0.1 + ... + + tasks: + - name: Configure Zabbix host + community.zabbix.zabbix_host: + server_url: http://10.0.0.1/ + ... + delegate_to: localhost +``` + +### Testing Zabbix roles + +*This section is subject to change as our CI regarding roles is being reworked and may not work for you right now!* + +Roles make use of [Molecule](https://molecule.readthedocs.io/en/latest/) to verify and test the execution of each role. In order to start testing with Molecule, you need to install the required dependencies. Requirements file can be found in the root of the [dj-wasabi/ansible-ci-base](https://github.com/dj-wasabi/ansible-ci-base) repository. + +It is recommended to create a [new Python virtual environment](#virtualenv) for this to not clutter your global Python installation. First, install the dependencies: + +```bash +pip install -r requirements.txt +``` + +Note that Docker is required when testing roles as Molecule is configured to use it. Once everything is installed, validate your role changes with: + +```bash +molecule test +``` + +### Testing Zabbix modules + +Modules are tested via `ansible-test` command. Configurations for integration and sanity tests for the command are contained within `tests` directory. Refer to the [official documentation](https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html) for introduction to module integration testing within Ansible. Please note that this may fail if you get your directory structure wrong. If this happens, please see the start of [Testing and Development](#testing-and-development) regarding the placement of the collection. + +Running test suites locally requires a few dependencies to be installed. Same as for the roles, it is recommended to use [Python virtual environment](#virtualenv): + +```bash +pip install docker-compose zabbix-api +``` + +Integration test suite for modules can be run with the commands below: + +```bash +export zabbix_version=X.Y +docker-compose up -d +ansible-test integration -v --color --retry-on-error --continue-on-error --diff +docker-compose down +``` +*Notes*: +* `zabbix_version=X.Y` will be expanded to Docker image `ubuntu-X.Y-latest` +* Details for both variables and values that are in use can be read from [ansible-test.yml](.github/workflows/ansible-test.yml). + +Sanity test suite for the modules can be run with the commands: + +```bash +ansible-test sanity -v --color --docker --python 3.6 +``` + +# Additional information + +## Virtualenv + +It is recommended to use virtualenv for development and testing work to prevent any conflicting dependencies with other projects. + +A few resources describing virtualenvs: + +* http://thepythonguru.com/python-virtualenv-guide/ +* https://realpython.com/python-virtual-environments-a-primer/ +* https://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/ + +## Links + +* [Ansible](https://www.ansible.com/) +* [Ansible style guide](http://docs.ansible.com/ansible/latest/dev_guide/style_guide/) +* [Ansible module best practices](https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_best_practices.html) +* [Integration testing with `ansible-test`](https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html) +* [Docker installation guide](https://docs.docker.com/install/) +* [Molecule](https://molecule.readthedocs.io/) +* [Molecule V2 with your own role](https://werner-dijkerman.nl/2017/09/05/using-molecule-v2-to-test-ansible-roles/) +* [dj-wasabi/ansible-ci-base](https://github.com/dj-wasabi/ansible-ci-base) +* [Current Zabbix releases](https://www.zabbix.com/life_cycle_and_release_policy) + +**End note**: Have fun making changes. If a feature helps you, others may find it useful as well and we will be happy to merge it. diff --git a/collections-debian-merged/ansible_collections/community/zabbix/FILES.json b/collections-debian-merged/ansible_collections/community/zabbix/FILES.json new file mode 100644 index 00000000..be0ab609 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/FILES.json @@ -0,0 +1,2714 @@ +{ + "files": [ + { + "name": ".", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows/plugins-integration.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a69cee55ffbbee2725ce8cdae1d950e3dd0bc259ea230ac166503333f4734652", + "format": 1 + }, + { + "name": ".github/workflows/agent.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "674088380d5fca2776f67e464eb81d9e932d69c73c82ef3ef55b26af0b92062c", + "format": 1 + }, + { + "name": ".github/workflows/javagateway.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c45085cfd864a2fd71922e78cfe79aabaaab3260d5bc67019cab1188ae429a0a", + "format": 1 + }, + { + "name": ".github/workflows/server.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b575dab6a5328189a06bd2a8e49bddfb5a2a0f405176848e90d1808952da4186", + "format": 1 + }, + { + "name": ".github/workflows/proxy.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c18a06ec4cdb95f6cde58778839b0799e023630321db927eab292351df972a77", + "format": 1 + }, + { + "name": ".github/workflows/web.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e2c68fba6acb48ce1c8d8273fe0e8dfc53f12fdfb3240f21cb80ced579fd516e", + "format": 1 + }, + { + "name": ".github/workflows/repo-sanity.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ec06a98679a41ffb9054fdfa0b004250d51c6b1fb006295e63928a309679b651", + "format": 1 + }, + { + "name": ".github/ISSUE_TEMPLATE", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/ISSUE_TEMPLATE/feature_request.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d07bd877d38e16657c68cbd89c1c79eeda6debe008cb82745de6a705f984e442", + "format": 1 + }, + { + "name": ".github/ISSUE_TEMPLATE/bug_report.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2198c3a25f580fb743064df8a8fc34fe8a6bbc9a1ad4466b37d1857d53746a88", + "format": 1 + }, + { + "name": "molecule", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_agent", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_agent/molecule.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7acae38dd3704d32b983e67c5add1d101a16399868d079a65a1c0346f73d711e", + "format": 1 + }, + { + "name": "molecule/zabbix_agent/converge.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6081b72ff03c46e191faea23fbda8f7709be3c7c12f40efac22fb72c4c159b28", + "format": 1 + }, + { + "name": "molecule/zabbix_agent/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_agent/tests/test_docker.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bcbc33a5ef1e281649d0770940c19efa526f034835e7f39f64a640d7f6ec9a07", + "format": 1 + }, + { + "name": "molecule/zabbix_agent/tests/test_agent2.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "89ff82614dec7fb32ebedc37df0417ef029b93607625e5ca81c652c08d44c2be", + "format": 1 + }, + { + "name": "molecule/zabbix_agent/tests/test_agent.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2ac7fca638b4dad12ee85ed808710b71a6c70093c2630061c01536d738333c74", + "format": 1 + }, + { + "name": "molecule/zabbix_agent/prepare.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "762fbba8659bfd5a5bc88e56824a276c819ab9647b1a1ed50a733dfb267d31e8", + "format": 1 + }, + { + "name": "molecule/zabbix_server", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_server/molecule.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "495c1b75667057e6a05fd818ee91f108b71c84c2fb6e6c5dea921df1addf28bf", + "format": 1 + }, + { + "name": "molecule/zabbix_server/destroy.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7b792640d76895ee13fe818c28d20b06c93d5783d71cc85bf4bebd233ffcf640", + "format": 1 + }, + { + "name": "molecule/zabbix_server/converge.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5e1dc7dd2f64221e68e0c06f051226df74626042d10de6570f733dcc96455816", + "format": 1 + }, + { + "name": "molecule/zabbix_server/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_server/tests/test_default.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4eae4030c95e0f56701be42e0003b3c2ed377f1425622fe3d15d3a693d337042", + "format": 1 + }, + { + "name": "molecule/zabbix_server/prepare.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "75c7524a4ab9966c7d409f9fae389bc0a68babcf98e241d58569184cea558983", + "format": 1 + }, + { + "name": "molecule/zabbix_proxy", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_proxy/molecule.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4170b3d29f93ca1ed50766e575fef3f91570ca5b6ab1c2087b60bf16112b2b2a", + "format": 1 + }, + { + "name": "molecule/zabbix_proxy/destroy.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7b792640d76895ee13fe818c28d20b06c93d5783d71cc85bf4bebd233ffcf640", + "format": 1 + }, + { + "name": "molecule/zabbix_proxy/converge.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "82b284a5ec5707b2a2ea3bb7c7e41fb8f2f583eb255b60e25b61935de3e09236", + "format": 1 + }, + { + "name": "molecule/zabbix_proxy/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_proxy/tests/test_default.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a15b6fdf1545fd3d2298241bf9e62c7a4eda1f46c03c382fa61c28215e67a54e", + "format": 1 + }, + { + "name": "molecule/zabbix_proxy/prepare.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d31790d1c5631f2d281b33c742233ab1ab6e95392b818367d2d6b4fe4f0ca7b4", + "format": 1 + }, + { + "name": "molecule/zabbix_web", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_web/molecule.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bfa60180b552f3bc6815e04536a12519db2a4820b476a36936379e77092da1b3", + "format": 1 + }, + { + "name": "molecule/zabbix_web/requirements.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "595b39f9e746996afa76a18b9fdc4bed710cd7e016e76cffc5b8587dc7501542", + "format": 1 + }, + { + "name": "molecule/zabbix_web/destroy.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7b792640d76895ee13fe818c28d20b06c93d5783d71cc85bf4bebd233ffcf640", + "format": 1 + }, + { + "name": "molecule/zabbix_web/converge.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "342a9bd906308c1ad2b4c68efbe16ba8e66ad0658fc7e1f584947f3d817fbdd3", + "format": 1 + }, + { + "name": "molecule/zabbix_web/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_web/tests/test_default.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e5d982d846ef5eefad1dcf98053a848f7b4077993de52386463dc80e5567b3e5", + "format": 1 + }, + { + "name": "molecule/zabbix_web/prepare.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cf68a5c1bcb1a5f7d951951d90294ce95b5818136642a015d5baff05aabe7100", + "format": 1 + }, + { + "name": "molecule/zabbix_javagateway", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_javagateway/molecule.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e1b6fa1a512f0c48d3059d1c7b36e841b22645e440d4c0a794ae424fa23df0de", + "format": 1 + }, + { + "name": "molecule/zabbix_javagateway/converge.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c41ec5d85027442c2d6eb2ad88245e313a507cdb669f1b89ec3c7eb98d6d0d6b", + "format": 1 + }, + { + "name": "molecule/zabbix_javagateway/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "molecule/zabbix_javagateway/tests/test_default.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "42216040435b108d772efea497ef5f03e13d6d9c36358df9959d587902ed4140", + "format": 1 + }, + { + "name": "molecule/zabbix_javagateway/prepare.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c788319bd98aaa4ba8ed5e673edb8944b36c6df2483056a24f4b6ed4b1cd7714", + "format": 1 + }, + { + "name": "molecule/requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fdfd5ce77c3d3f941e735557aae84f8ed8c6ab338908307a94de10bb9c859515", + "format": 1 + }, + { + "name": "meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "meta/runtime.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "df18179bb2f5447a56ac92261a911649b96821c0b2c08eea62d5cc6b0195203f", + "format": 1 + }, + { + "name": "CONTRIBUTING.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5f3ffa0214dfe5407caa03a951bf939c320c403dde1df3671926dc2d4940e718", + "format": 1 + }, + { + "name": "plugins", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments/zabbix.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7220e6dd6276890d86203e2506db12eff05edec76493af937026109b0aa1d2dc", + "format": 1 + }, + { + "name": "plugins/modules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/modules/zabbix_discovery_rule.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ca617e55b398ac56081df9c68ad6b1349f2bcdba5aa2622a5016e263c142d618", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_group_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2668ee55e1b7486949420e779317c762f6459c9af7b7e98772f06bd074a5d01b", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_maintenance.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9a17366c91a338260a2e88ecbd66ec4f7c5ff48a51a330bb746371991f36718e", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_group.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1e39ba43984fb6486813f3c4a0450c626e574a0ea459b1380e9013769cdd4b7f", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_mediatype.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1efb886dd4f376f41ef4457ed7d00175fe33f45568f136051b4a08d454e9d42c", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_host_events_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b6eb1a12e71834c531458b41966aaac1bb95e71b504d2afaf726b62233b0a9c3", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_screen.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9e5cdafc3d7c134e82a119f6ef5635f589504c39d9fed4918cc76a9c6f1f7ee4", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_usergroup.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e1ee36b469d6400a9e932140bc8eb33b480f9a2ef0b31800df87097837997aa9", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_valuemap.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6cbee4de8084d6bd3db832e67863433c927c3956478431ba2e7777c4edd9bdc2", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_action.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e7980f2b2e03c05043ebec2af2038e7cca3a80d22eb42f5016ec0f2d8a0bf612", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_host_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e294dbed261ce474e03bf20280139455352f68c4b8a7e866ff588f7fb0122741", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_host_facts.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e294dbed261ce474e03bf20280139455352f68c4b8a7e866ff588f7fb0122741", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_template_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f747a03a06a76f6c0d34fbcb318a4e90aa4474a91bb8212b6d4ee8a08f441629", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_service.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "21088e9932f6b4f59bc685e5921ba13c5e93c6c4099b382adde8175745297cf6", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_user.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "736fcc1ad312787add034d23b8f047acd95916539a92832675dc94548e02f47c", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_map.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1cb552840846a4e2eb7fda91bf20dadd43a5ae8be600f00a22bb60a4ed452d22", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_user_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3855f9ba15f077d1953bce0d3703308e2a0e1422739947c7ec4244d829e685e3", + "format": 1 + }, + { + "name": "plugins/modules/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_template.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "451615ae0c2789d95494bc7eb2af9519150aed372d165e18c13e4e1d80b86485", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_group_facts.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2668ee55e1b7486949420e779317c762f6459c9af7b7e98772f06bd074a5d01b", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_host.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "82197c2ae987e4b07ab847fcdb3f059ca034341624f985b935b20882f52d1e79", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_proxy.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "643090343af22b4a0ea4daae9e39de6ef3568354afb8696fe872b603680c5998", + "format": 1 + }, + { + "name": "plugins/modules/zabbix_hostmacro.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9f4b1ed351467606cee74d927bad59026e2e782405e09604db86ad42123b3bc3", + "format": 1 + }, + { + "name": "plugins/module_utils", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/wrappers.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0cad53b29c79d31df0563db1f3a3eaa3ceca2f9768a8581588f7e89f20f0a5dd", + "format": 1 + }, + { + "name": "plugins/module_utils/helpers.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6882bfa93d8779f4c7befb0350c4fd1b21fe951dbf9db4ce62d02df6dab24b68", + "format": 1 + }, + { + "name": "plugins/module_utils/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/base.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "77f2fd7a7327b5f256afb99eb4c9f44f7dbfd38432b1ccb0a3be393f8aa8e06d", + "format": 1 + }, + { + "name": ".gitignore", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4442037a96f6c5883feb22e2bbf2d8e4cb5d6e0ff6064e15b1e7e0e6cfc0ba99", + "format": 1 + }, + { + "name": "tox.ini", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a021473b5d2ddd01c9a3e09a88c5da88c5e32d34847f2606a10237d62416746c", + "format": 1 + }, + { + "name": "CODE_OF_CONDUCT.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5c18a80f7f461c2fb2ed69961a1c918eb3653f86ecf0506e79ef74200836f38a", + "format": 1 + }, + { + "name": "tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user_info", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user_info/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user_info/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user_info/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user_info/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7145f82cd66f3ec44f59895cdc60d13b18b6437f2a26824a48fcb2bbeb1ae6fc", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/files", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/files/template1-changed_52_higher.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7dbca94edf08419603710f20aab3e38afdc7ebf9c532b3ead6cba732d67df1bc", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/files/template1_50_lower.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "50f73e7b67dbfae0172e8d6e5eb247bd233f2806f0cb06c315862e3969183990", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13449759abe3ea35ff1c046f21a03961d1e64c76482bda4d7a17df2a93e5d828", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/files/template1_52_higher.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ba19425c04d8c2c87a0f54f43dc4e46b0454a616f6be0e82cd7ea7c5bb734b5f", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/files/template1-changed_50_lower.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b36c50bed75503fd6bf60504e6ab82495f175638e9e766b16f09ec02f88a7a03", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/files/template2_52_higher.xml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126cf0cd9ffe53e63ab0eb675d4413d85a2b1ddb2ca728b791ecac0c6e88200a", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c4f833523a6a599a624cecf3560f4a5a988913fa3f2104c65cd67a98db64a697", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_service", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_service/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_service/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_service/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_service/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "df3656394d089e85d896badf406e884eac1367f4faecfb9066d0a3913200b24f", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_screen", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_screen/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_screen/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_screen/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_screen/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "90a04108edc97153116364cd2aac80ad5dcdd92e84bd0afc5569646703e0ff9b", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_hostmacro", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_hostmacro/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_hostmacro/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_hostmacro/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "199e7c905b98677013b75e6b7dc052cf022e216b2b0b8fb9034554e8aeef4d18", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9dfdc277ac7400e703b784eeaed1c5fbc18ce218f7a170ba2f3e7db86563583c", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2ef74640b439dedd9e870b3605b5ab1eaf60b8735d6dac178abc79dc98518032", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_user/tasks/for_zabbix_52_higher.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "67f9e81b633997ffcb97d15f9ae505092820535fcea1ac6b8f22de8856c07a55", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host_info", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host_info/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host_info/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host_info/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host_info/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3d56ea3ad07b29f4ed524f765d628cb68be1c2413f986c0aafd34272c96e4a1b", + "format": 1 + }, + { + "name": "tests/integration/targets/setup_zabbix", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/setup_zabbix/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/setup_zabbix/defaults/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ba7cac88b31a6122cf87bedc0e343dfbbb7fb1450261c8f95b9bdab44d82b977", + "format": 1 + }, + { + "name": "tests/integration/targets/setup_zabbix/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/setup_zabbix/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eb40a2d1f99fd46023892360c6a96e8048d74dc55c9bd7ca71c253acd3e71b46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_discovery_rule", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_discovery_rule/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_discovery_rule/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_discovery_rule/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "30251428bb3006937adc9c6d6bed91048c25c3bf6bf0ea904fb1c290e6a38b06", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_usergroup", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_usergroup/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_usergroup/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_usergroup/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_usergroup/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2f3b9e8e4cb7365ca0a60c406cd2d3b805957ab889602fefbbb230f86918720d", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_mediatype", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_mediatype/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_mediatype/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_mediatype/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_mediatype/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b05223bab4113b8ac07cbee8c40180f7729de34b720362747bbaeece58c7dd2f", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_action", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_action/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_action/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_action/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_action/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "220e04c961060490f14ffe273f8f9f1fdaa766015e6ea4e0dd243518b869197b", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template_info", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template_info/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template_info/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template_info/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template_info/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a42f244d409a547c192a32eb62a1a2655a85779d8d2b011ebb88b1760a140c4b", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_proxy", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_proxy/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_proxy/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_proxy/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b5ea375becd3088862c16fc97fe379532c583079829fcf1fdcb549e6808262fb", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_proxy/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_proxy/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e85349c2e70ae77e7c7c49c1de65565fd591f1eab4d20413044e24ea29af2f08", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0dc70adf87d5997dd3d3636c69b0646ab9eb45f10e33d7707fae5ac33ce71b84", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "629aec4c942ac89f8bd777843bb9008a98bff4b59ae70b8faa7e3c258ac0c09e", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5aeb80d775ecc2c7a3bf3d5f039a917a2a54b8e34a4a94cde0b402d9306682d6", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f7775bea9aac4273117b513442079f23d055eef64580086a84559dd67ac28d3b", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_host/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a4feceef8e304f463e9b16d4ed45e45fc3f3d9a3040cc8f9fda8d2f30f39da17", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group_info", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group_info/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group_info/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group_info/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group_info/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e7c8e9e0b9f440ebd1c98bbb3fd75b357b4ab8b98d9cc303fb94ac2e230caae1", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_group/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13b100c0ffe867ca7641c82bbb850f9f924898e0150477548730caea2bd0e58e", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_maintenance", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_maintenance/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_maintenance/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "874d1d403ddac469717f022bd79e891d4332f2460d97ff80e9b8602f2bcc2a46", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_maintenance/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b5ea375becd3088862c16fc97fe379532c583079829fcf1fdcb549e6808262fb", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_maintenance/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_maintenance/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4c59513254c196f804b6a5d2c9cd6a7c3791d9526c1b39b4da001575d7d74373", + "format": 1 + }, + { + "name": "tests/sanity", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/sanity/ignore-2.9.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "620f5d8493316aaa59a60b0977cd85abba84ee24979771d11bc5d0034cdb6d7e", + "format": 1 + }, + { + "name": "tests/sanity/ignore-2.10.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "812ffc700c0583369950e3445462711a9e30b584249a2dc3f5430836d205b2e3", + "format": 1 + }, + { + "name": "tests/sanity/ignore-2.11.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5eb5f30b6cd1c35495bb61cd6e20f25d9db1f5a6ce188594ff3b3fe10986643c", + "format": 1 + }, + { + "name": "tests/sanity/requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c8a4ac4bfdef88e75d6e748e35a42fb4915947dfa2b7dd788626fd829600e014", + "format": 1 + }, + { + "name": "docs", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "docs/ZABBIX_WEB_ROLE.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "db1f289a58dbb8c794272ccc3269c6c53b788b4a46b2df3cd2ed6a8fe02c215f", + "format": 1 + }, + { + "name": "docs/UPGRADE.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2d4269c3df6c64c492e1466efb65fc87bb821befdadde9c942a2e73f3b92bc5d", + "format": 1 + }, + { + "name": "docs/PUBLISHING_TO_GALAXY.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c07ee2f57209bde4c62062b0e1e8f96ac3481e35ffa72d785fb29d4f02b75046", + "format": 1 + }, + { + "name": "docs/RELEASE.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e6e82418946c80ed2d063090f5444132de3973d16116bc1c7a484b92ac9fb15a", + "format": 1 + }, + { + "name": "docs/ZABBIX_JAVAGATEWAY_ROLE.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5e1b1e054bac24cbfcb763b08601281bb532880c2aab8e9105d103680c5625d8", + "format": 1 + }, + { + "name": "docs/ZABBIX_AGENT_ROLE.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5da9b3514cb01b30961a925931199aea6cc14e293245552e3fcd5d2c4eee08dd", + "format": 1 + }, + { + "name": "docs/ZABBIX_SERVER_ROLE.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b13077c71b48ceeaeb8bbb2d342015caecc5c55551e095fde9e36de64adfbb9c", + "format": 1 + }, + { + "name": "docs/ZABBIX_PROXY_ROLE.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e15bf956b8329e1bd4794a286dcd6cfd32a801ce0e720b04ed7c4cadae7651bc", + "format": 1 + }, + { + "name": "docker-compose.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "11bad78cb08f6852cfaee1617b195bc3791afd9db98b2ff544933af31c3e5f79", + "format": 1 + }, + { + "name": "scripts", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "scripts/inventory", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "scripts/inventory/zabbix.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ec4257fd991f789e540373445c4f607cb7dc631bc4868d83d104540d248a78c5", + "format": 1 + }, + { + "name": "scripts/inventory/zabbix.ini", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "be08243c8bdc7c88f8fef16108e10face4d04d03764cb569718a241c181c5515", + "format": 1 + }, + { + "name": "changelogs", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "changelogs/.plugin-cache.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eafd3ae1882152b642739da2826e295898cfa34cfef56ada6da5a9e510a15fa1", + "format": 1 + }, + { + "name": "changelogs/changelog.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "047947a47db7ee2a85c52bd15a96c1ff71f836a1c332bc7cbad18d081b687028", + "format": 1 + }, + { + "name": "changelogs/config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d0f179f6e8774045903750ecbce85f3c9fa33c9813b527bc96ca48012ad101f7", + "format": 1 + }, + { + "name": "changelogs/fragments", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "changelogs/fragments/.gitkeep", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "701df650f2fe94806a6391b9a3cb92e2a4ce85f0000b15c5e2e5884df8eccd17", + "format": 1 + }, + { + "name": "roles", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/files", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/files/win_sample", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/files/win_sample/doSomething.ps1", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "roles/zabbix_agent/files/sample.conf", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3aa3b604a215baf40d9d4318ba4f7197a1c58df7277fa349fbafd7666ed2d941", + "format": 1 + }, + { + "name": "roles/zabbix_agent/templates", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/templates/userparameters", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/templates/userparameters/win_sample.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "97f7f02ba1bdf4c130838aea75f1246232b2b4cc00a36cea4bfc9123df1698c0", + "format": 1 + }, + { + "name": "roles/zabbix_agent/templates/userparameters/mysql.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3aa3b604a215baf40d9d4318ba4f7197a1c58df7277fa349fbafd7666ed2d941", + "format": 1 + }, + { + "name": "roles/zabbix_agent/templates/zabbix_agent2.conf.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e72f7115c96b272d7310d1ca325ab5a7d8f8d4e7d907b9326bfda8e504b8612c", + "format": 1 + }, + { + "name": "roles/zabbix_agent/templates/zabbix_agentd.conf.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ef03e1b7f9b73af2fbc22413c22cad0272e66a391d68d40751f68901f0234f08", + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server/INSTALL.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "61ec9005b35344df43db785d54f69a5fe87cc1783014e404e068497f6773f924", + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server/molecule.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "96ab648092971515942732bdaa0f6e04b3861bb43163b7fe08153f027e9600c3", + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server/requirements.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7cb18ed88555380f82e4f37d4cfae43303cf2071ac8b407aaa32d37aec0be804", + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server/playbook.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13a4ad0b1d0255ea9334120da7dd76ced70f7abb9eb32cd57f2a97de4fb8f8ec", + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server/tests/test_default.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c7cc3d29745b0c8bc7730858de639184b8125d481511130023ed1c5dcc64c32b", + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server/tests/test_agent.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "12fbdb469e65f0db8195e61c0dad1bf924bcda267e14d2bbb6006392e2df52db", + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server/Dockerfile.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "45fcdc65bf0c38188ae34f4db3ddf66a0fc572ffb1c3fe66055edab399d53f09", + "format": 1 + }, + { + "name": "roles/zabbix_agent/molecule/with-server/prepare.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "63f6b966ce1f98098750392194d953d07ffaae772d468c68a7f74d32f4ca4ff1", + "format": 1 + }, + { + "name": "roles/zabbix_agent/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "711e51291c34046ab48ab02e04d12dc475a366574d3a9a74b766087e94a5833b", + "format": 1 + }, + { + "name": "roles/zabbix_agent/handlers", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/handlers/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fe0a8a22421adcb6fd0cbfd89f3104d352c81af0ba9641c0498d447e7a50cc6e", + "format": 1 + }, + { + "name": "roles/zabbix_agent/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/vars/Sangoma.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a28d32329090b98ec9357c04e4ca04c67739e51e8dc6d1b7ebfd3bb21abad1d8", + "format": 1 + }, + { + "name": "roles/zabbix_agent/vars/Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "235b0f303d48a27d73b3534184bb7bee6880a461d7d77156a8f08ff59f4ef6cb", + "format": 1 + }, + { + "name": "roles/zabbix_agent/vars/zabbix.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ea6889692ab5938f1045cce02ac6a51e7377980979b1fd17d6ec396461cca0fa", + "format": 1 + }, + { + "name": "roles/zabbix_agent/vars/Darwin.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "00a2774a3bc0ffa0716bc266bd5823bad22ebbc77e0468a661296c0832f506eb", + "format": 1 + }, + { + "name": "roles/zabbix_agent/vars/Suse.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fff21c57807eff2ad55d06fea1e5f8276d3ca5f8c4ef28cf7a217014190e2831", + "format": 1 + }, + { + "name": "roles/zabbix_agent/vars/Windows.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7b4615ecab46eb48ba74fd4e76d127c4412dcecc944209e9c8e7d1ae8f0dade2", + "format": 1 + }, + { + "name": "roles/zabbix_agent/vars/RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5ac397362954bc7ddc737070186915854cc930facdd9c54f6396612a921bbd11", + "format": 1 + }, + { + "name": "roles/zabbix_agent/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/defaults/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "28ff822c617884ad64a5eb60e4dff57ff5131baaa7ce5d94b153d55674714b90", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/userparameter.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eff5868ecf7ee76d9e570abbc5f4acb4a9146d60da07af79a04246f909f7dc39", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c5ab1a9260f87a7bceb57ee3cb2880b8d859f6070b12949cd23fefcc2992127c", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/selinux.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cfee91bcabc64aad09babbd3f4aec611c9721d83f80a1cf9099e6d2b3879197a", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7eba5e3599f6cde87b8def7f0591297cf61597f57c7796a6ff0fd9b407f231f7", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/Linux.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3f6c8814d150591ce934a00376cebd8ee3ec447e640683f01d33ef11ee24fa86", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/Darwin.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "90c735cf2dc14e44fd72906c8172b69f5d8069a4f25280244e483ad662c9ac3f", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/remove.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "97606e8390eb36278e7aabf090cefdc33c9d7dfde71d90f7a0c956d7048fd698", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/Suse.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0c0581b96ee921b74d678302975c58834eb3c90475045e544bd40b83b2cb3aef", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/Windows.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4719f1c12efb8877c070a147029aac5d0930800c0ea20311ea57188c9c291d31", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/firewall.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9e140522e2aa25ce45ccbb9b9ebd70a8d39ce6198ab6d1b6f25f9ff10db30189", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/api.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e09947bfa904595635bbadb8cfc27daac03fe7184410233a00b5d8f4fe76f158", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fdfa91421477b454dd33c11c9fdd455bf2659e5d0e589050d39d6b7277097831", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/tlspsk_auto.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2949f2485c3b42fcb27c0509e49c2c9e2a6bc9982ddf3fd706464d18b9338d67", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cb1a3a6f71e8726f80f179bc8031c4955d097742836b7dc7fc0515b4bbb16c6a", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/macOS.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9ead1d6ce6c3b1d3c9803200ff826c8ef1845e892947b4358c8587cda3b79cea", + "format": 1 + }, + { + "name": "roles/zabbix_agent/tasks/Docker.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0ccd85e3d876df33562e6d7585bf54ef911b5704134907bdf4f6edec38135f64", + "format": 1 + }, + { + "name": "roles/zabbix_agent/README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5da9b3514cb01b30961a925931199aea6cc14e293245552e3fcd5d2c4eee08dd", + "format": 1 + }, + { + "name": "roles/zabbix_server", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_server/files", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_server/files/install_semodule.bsx", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "729d5b564427618c3acad7c499736930070ed3c7cbd542dedf341722db68cfa0", + "format": 1 + }, + { + "name": "roles/zabbix_server/templates", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_server/templates/zabbix_server.conf.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1125c463a33ab2cd5a33377e85b334efa6ca78ea33775cac91890ac3f7a6dd81", + "format": 1 + }, + { + "name": "roles/zabbix_server/requirements.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "611752d0deb2ca1b709decc428840850cfeec930c4963051040b9ba1d675f18e", + "format": 1 + }, + { + "name": "roles/zabbix_server/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_server/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0487f93463794453a72406f64a054fefeec900959fc97293b38282fd3c59a201", + "format": 1 + }, + { + "name": "roles/zabbix_server/handlers", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_server/handlers/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "03d7e9de7d58a7baae66d49e54434bb2c6b3d11de06d9670edf131b36747d0d8", + "format": 1 + }, + { + "name": "roles/zabbix_server/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_server/vars/Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f4eb8a4a848b0eae37caae62c36ae4d1e35dabe5aab2357203f1427b5ad55491", + "format": 1 + }, + { + "name": "roles/zabbix_server/vars/zabbix.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ea5e53c05e15c30729a25ddccf320789c2fdf8afc8c892f7a3506799bb22ce4a", + "format": 1 + }, + { + "name": "roles/zabbix_server/vars/RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ee454bd3e000b6cb6bf752ecbd4a29f6a10a2773a148f945220ea91076450493", + "format": 1 + }, + { + "name": "roles/zabbix_server/vars/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e5af1c5728104c6e27de937da6999ba759c8de4d6df2ee48db5366a92ef375ad", + "format": 1 + }, + { + "name": "roles/zabbix_server/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_server/defaults/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "37c4a9a8b15ca39b66da9812e061cc8b5227829e1f36639e9c84857022945e82", + "format": 1 + }, + { + "name": "roles/zabbix_server/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_server/tasks/selinux.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "20c4d575b682bcaf7a050420ea189616968c6e77dd6366e9dc3dd2600b2149eb", + "format": 1 + }, + { + "name": "roles/zabbix_server/tasks/postgresql.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0edd8c5fb10cc7143ba2abf70a5de9ef9934bf7e757682b9f9d0f9db77ff2a98", + "format": 1 + }, + { + "name": "roles/zabbix_server/tasks/Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "48369dfdbdea0031c6a58193bf0c6f9b5f616f42205b7522579599d005a24290", + "format": 1 + }, + { + "name": "roles/zabbix_server/tasks/mysql.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2d7a4e0cdb8bb065972328e7534069733dadbfe7b2eabf78b9e9f3e326c91173", + "format": 1 + }, + { + "name": "roles/zabbix_server/tasks/RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "628a40318e9248567ebef85632a177541e634e57c44f97ab0a36b74d04c6333c", + "format": 1 + }, + { + "name": "roles/zabbix_server/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f0d21cdd7c2c77fdc8609e3441aa3bfd7eb90c07dfc1a5628afd2ebdfb5597ba", + "format": 1 + }, + { + "name": "roles/zabbix_server/tasks/scripts.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ae57630fcbe0bbb4c702a2a173bc0e8f746c5d2ab5ff107074ee86c8329b56d2", + "format": 1 + }, + { + "name": "roles/zabbix_server/README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b13077c71b48ceeaeb8bbb2d342015caecc5c55551e095fde9e36de64adfbb9c", + "format": 1 + }, + { + "name": "roles/zabbix_proxy", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_proxy/files", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_proxy/files/install_semodule.bsx", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "729d5b564427618c3acad7c499736930070ed3c7cbd542dedf341722db68cfa0", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/templates", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_proxy/templates/zabbix_proxy.conf.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d0278a1926c38f0a9576e3f8fddec08d679dbdd123eeac9ee59ca3680fe331d0", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/requirements.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f669210dc6814ed6c193a746cd8bfd1eb13448269b3d8f6b2d209f9418b907cb", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_proxy/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1b6248de4d50ab09df5f595799aa31a4f9b10ff17a7e2a45a96fe799e41bd52a", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/handlers", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_proxy/handlers/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8741464bdb772cc2fde80d4f83f14cae718f8752ef1e88dca1348bbe0eaef717", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_proxy/vars/zabbix.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ea5e53c05e15c30729a25ddccf320789c2fdf8afc8c892f7a3506799bb22ce4a", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/vars/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d923300ab46156cf73c991af83f1497010a57f7c80e4a10fb87b72613e9110b8", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/vars/Amazon.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7d87cd61d18e6d90032bfe0a42d18cb1bf651001280e06ac60a7850e7be5e733", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_proxy/defaults/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1fec5e54c4befefd623595476777c1bd79e9e2ad8647021c1879e01940fd28a2", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_proxy/tasks/selinux.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "df20b0510f210de41e4126943b3f70f0886577e7745c2af64c2084c2eba7f1fa", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/tasks/sqlite3.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "19f6fa253179b51e62d7be2f49ac6893e7f927f06dd7471c55e2331e2c95b5d8", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/tasks/postgresql.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6fa2fa8913b54f214e633d69ce6b4b0514a076231977649ed088d9af565bbcac", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/tasks/Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "099800b16ee76a52cd0a83f19326bc76de211b09a044a4b58b8e076016f1fe28", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/tasks/mysql.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "076de80c1b1f968d1728e0b5c9d07b3a0f78131e00b207ace4dfca97a3be0ef0", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/tasks/RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "104d4459a996690cf4230b379c267c0a2942e41db0054c156c0345212c3be151", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b9621fcff0beeb1442146f765d5794e7dcd9fe6ce1bed26fe39792ab9841d3e1", + "format": 1 + }, + { + "name": "roles/zabbix_proxy/README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e15bf956b8329e1bd4794a286dcd6cfd32a801ce0e720b04ed7c4cadae7651bc", + "format": 1 + }, + { + "name": "roles/zabbix_web", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_web/templates", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_web/templates/nginx_vhost.conf.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0ad2ff4602b1d6d048c9d0217dcd4d3427a13ae93f3a1ea58972c8ccc87e1284", + "format": 1 + }, + { + "name": "roles/zabbix_web/templates/php-fpm.conf.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "250e0fe3ab6eb0d67e20751e852775e6d4927f473aec1c8b671e773277edff3b", + "format": 1 + }, + { + "name": "roles/zabbix_web/templates/apache_vhost.conf.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d5f2824024f3dce38bf3d23d42f9575c7301d6bf62c9212cca72e125f88ec2a1", + "format": 1 + }, + { + "name": "roles/zabbix_web/templates/zabbix.conf.php.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a7c7f1f352c31396cb2515bf91b9be23a09ea1dc243546b53dcb1021d96d527f", + "format": 1 + }, + { + "name": "roles/zabbix_web/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_web/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a4323c1de12142fd1f613a272f51a471e0f94aee30035cc554bf6fdc2bff13fc", + "format": 1 + }, + { + "name": "roles/zabbix_web/handlers", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_web/handlers/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "17ae10ff140a1e0424d652d9b1898baa1e6667e706d85bb98c2c01cee8c25c60", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/RedHat-8.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "87c0942832efd38895ea0e111ee14b59c16f2599ba5a1ad18f9d0b186d382dcb", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "76b26052bf10e4ad94388272f3e8af9aa2bdc34257b12af6c471139407b595be", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/zabbix.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ea5e53c05e15c30729a25ddccf320789c2fdf8afc8c892f7a3506799bb22ce4a", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/Debian-9.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a80f687d7a145445cc9d3ece5f075047ad0b8419c162dee68d4d7e1d64c97b7c", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/Ubuntu-18.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a80f687d7a145445cc9d3ece5f075047ad0b8419c162dee68d4d7e1d64c97b7c", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3962e72fb4a421c31827b41ba4a505af9585f53c1c188d980f413629254fa42c", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/Debian-10.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a80f687d7a145445cc9d3ece5f075047ad0b8419c162dee68d4d7e1d64c97b7c", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/Ubuntu-20.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a80f687d7a145445cc9d3ece5f075047ad0b8419c162dee68d4d7e1d64c97b7c", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/Debian-8.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "329443560941bda266833e38ba4139ac070b477db817db61728ed18817b8131d", + "format": 1 + }, + { + "name": "roles/zabbix_web/vars/RedHat-7.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "223efa6596a21b785b397b63542cf1b244078b789977e72ac6b7e60eff2722ba", + "format": 1 + }, + { + "name": "roles/zabbix_web/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_web/defaults/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ce98b81effc6b20f5ca5801672c33c080d960676a0eeb8dc75d8f19bc945f77e", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/selinux.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6790cfdf4ebf395ed45ebee2a5d737afcc2a438be8247823550b3e416c7d0b3e", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/apache_Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cff8b595878f48de200d54dc9ae0f2ab7281b7b1606baa29e214d5e4c2faddbf", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "708d1ab8aadbbce1aa2769d1e4bca4d9427afe5ef15e129eef3cb8d8eda1ce9e", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/nginx.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "37d80f31f34be979d008283fae528a96a3250eaf62d4966a90ec5ef8cb6ea6aa", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/apache_RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b58d98a87e46d72cf7e4f127943201a2e5042677e90090b52d1fcdcd9dd9bd16", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/php_Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3276e0de75d31e75298cf6fbaa2a60e88aff4b1f7a03a6bccbf2ea39c315683b", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8fc405ccf243a00abe7d6dd5a619ab99eb29177d8bb6a3f538082a60c0bd4d6f", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/apache.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "586db8f2a1aee9be84b5cb2c0b850268f14699b5ef3c11be4bd0c54d71a12024", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cd01a75811703ae583e50ac5b6941deb608a06f4ff803b13594982bfa7021c66", + "format": 1 + }, + { + "name": "roles/zabbix_web/tasks/access.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7f4e54527c9aea2edb2b7224a9d1166620b2abc3500fbc6175d790e0c36a507d", + "format": 1 + }, + { + "name": "roles/zabbix_web/README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "db1f289a58dbb8c794272ccc3269c6c53b788b4a46b2df3cd2ed6a8fe02c215f", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/files", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/files/systemd.service", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "df08ce5450891ea88a7fec5a1c56c5d4c243e1b3ef128dcb26e37714b48e88c9", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/templates", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/templates/zabbix_java_gateway.conf.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "36432a6d2a07ac10daefd1af7fc9bfe50b21fcb6a04e1cad1ce0cd74eae9deea", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eefd2527d9e1e50e0dbf2905a46dc29eb8fe677b54ffed00d8f6f4260480df30", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/handlers", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/handlers/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "50f97ddf507499869d667aafeafb93fbb749a5097e74a6e0ac1e00ad95517a0c", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/vars/Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f4eb8a4a848b0eae37caae62c36ae4d1e35dabe5aab2357203f1427b5ad55491", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/vars/zabbix.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ea5e53c05e15c30729a25ddccf320789c2fdf8afc8c892f7a3506799bb22ce4a", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/vars/RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ee454bd3e000b6cb6bf752ecbd4a29f6a10a2773a148f945220ea91076450493", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/vars/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e5af1c5728104c6e27de937da6999ba759c8de4d6df2ee48db5366a92ef375ad", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/defaults/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "86cad7b7a9560a91bbf96f20f7c82e476101a3cb0f67f786bb1d9de1c9d7d3bf", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/tasks/Debian.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0a6111657b6f37f8e36eba3724fab4188a187bc4d30ba1ec2d4213e77b270ae0", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/tasks/RedHat.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "65646adfe41274f2bc3a9016edcd374159e2c94aa2c64beec567ff65d6a86317", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a044a5474bced67966c4e679dff3993c0c978a2e9d880e74fead6d8ab2b6a408", + "format": 1 + }, + { + "name": "roles/zabbix_javagateway/README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5e1b1e054bac24cbfcb763b08601281bb532880c2aab8e9105d103680c5625d8", + "format": 1 + }, + { + "name": "CHANGELOG.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b0b68f71ee274ae41e9102a9e50a86ab4a5785e04937d767755461d3c1edb746", + "format": 1 + }, + { + "name": "LICENSE", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986", + "format": 1 + } + ], + "format": 1 +} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/LICENSE b/collections-debian-merged/ansible_collections/community/zabbix/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/collections-debian-merged/ansible_collections/community/zabbix/MANIFEST.json b/collections-debian-merged/ansible_collections/community/zabbix/MANIFEST.json new file mode 100644 index 00000000..59d5d4ee --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/MANIFEST.json @@ -0,0 +1,33 @@ +{ + "collection_info": { + "namespace": "community", + "name": "zabbix", + "version": "1.2.0", + "authors": [ + "Dusan Matejka (@D3DeFi)", + "sky-joker (@sky-joker)", + "Werner Dijkerman (@dj-wasabi)" + ], + "readme": "README.md", + "tags": [ + "monitoring", + "zabbix" + ], + "description": "Collection allowing to configure resources in Zabbix monitoring system", + "license": [], + "license_file": "LICENSE", + "dependencies": {}, + "repository": "https://github.com/ansible-collections/community.zabbix.git", + "documentation": "https://github.com/ansible-collections/community.zabbix.git", + "homepage": "https://github.com/ansible-collections/community.zabbix", + "issues": "https://github.com/ansible-collections/community.zabbix/issues" + }, + "file_manifest_file": { + "name": "FILES.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a54057785041801ee9a89a0858df8ac0f737bf8bba4adfb733c04f296ba355c8", + "format": 1 + }, + "format": 1 +} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/README.md b/collections-debian-merged/ansible_collections/community/zabbix/README.md new file mode 100644 index 00000000..0941dd24 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/README.md @@ -0,0 +1,166 @@ +# Zabbix collection for Ansible + +Plugins: + +![plugins](https://github.com/ansible-collections/community.zabbix/workflows/plugins-integration/badge.svg) ![repo-sanity](https://github.com/ansible-collections/community.zabbix/workflows/repo-sanity/badge.svg) + +Roles: + +![Zabbix Agent](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_agent/badge.svg) ![Zabbix Server](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_server/badge.svg) ![Zabbix Proxy](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_proxy/badge.svg) ![Zabbix Web](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_web/badge.svg) ![Zabbix Javagateway](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_javagateway/badge.svg) + +**Table of Contents** + +- [Zabbix collection for Ansible](#zabbix-collection-for-ansible) + * [Introduction](#introduction) + * [Included content](#included-content) + * [Installation](#installation) + + [Requirements](#requirements) + + [Installing the Collection from Ansible Galaxy](#installing-the-collection-from-ansible-galaxy) + + [Upgrading collection](#upgrading-collection) + * [Usage](#usage) + * [Supported Zabbix versions](#supported-zabbix-versions) + * [Collection life cycle and support](#collection-life-cycle-and-support) + * [Contributing](#contributing) + * [License](#license) + +## Introduction + +This repo hosts the `community.zabbix` Ansible Collection. + +The collection includes a variety of Ansible content to help automate the management of resources in Zabbix. + +## Included content + +Click on the name of a plugin or module to view that content's documentation: + + - **Inventory Source**: + - [zabbix](scripts/inventory/zabbix.py) + - **Modules**: + - [zabbix_action](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_action_module.html) + - [zabbix_group_info](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_group_info_module.html) + - [zabbix_discovery_rule](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_discovery_rule_module.html) + - [zabbix_group](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_group_module.html) + - [zabbix_host_events_info](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_host_events_info_module.html) + - [zabbix_host_info](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_host_info_module.html) + - [zabbix_hostmacro](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_hostmacro_module.html) + - [zabbix_host](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_host_module.html) + - [zabbix_maintenance](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_maintenance_module.html) + - [zabbix_map](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_map_module.html) + - [zabbix_mediatype](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_mediatype_module.html) + - [zabbix_proxy](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_proxy_module.html) + - [zabbix_screen](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_screen_module.html) + - [zabbix_service](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_service_module.html) + - [zabbix_template_info](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_template_info_module.html) + - [zabbix_template](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_template_module.html) + - [zabbix_user_info](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_user_info_module.html) + - [zabbix_user](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_user_module.html) + - [zabbix_usergroup](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_usergroup_module.html) + - [zabbix_valuemap](https://docs.ansible.com/ansible/2.10/collections/community/zabbix/zabbix_valuemap_module.html) + - **Roles**: + - [zabbix_agent](docs/ZABBIX_AGENT_ROLE.md) + - [zabbix_javagateway](docs/ZABBIX_JAVAGATEWAY_ROLE.md) + - [zabbix_proxy](docs/ZABBIX_PROXY_ROLE.md) + - [zabbix_server](docs/ZABBIX_SERVER_ROLE.md) + - [zabbix_web](docs/ZABBIX_WEB_ROLE.md) + +## Installation + +### Requirements + +Each component in this collection requires additional dependencies. Review components you are interested in by visiting links present in the [Included content](#included-content) section. + +This is especially important for some of the Zabbix roles that require you to **install additional standalone roles** from Ansible Galaxy. + +For the majority of modules, however, you can get away with just: + +```bash +pip install zabbix-api +``` + +### Installing the Collection from Ansible Galaxy + +Before using the Zabbix collection, you need to install it with the Ansible Galaxy CLI: + +```bash +ansible-galaxy collection install community.zabbix +``` + +You can also include it in a `requirements.yml` file and install it via `ansible-galaxy collection install -r requirements.yml`, using the format: + +```yaml +--- +collections: + - name: community.zabbix + version: 1.2.0 +``` + +### Upgrading collection + +Make sure to read [UPGRADE](docs/UPGRADE.md) document before installing newer version of this collection. + +## Usage + +*Please note that these are not working examples. For documentation on how to use content included in this collection, refer to the links in the [Included content](#included-content) section.* + +To use a module or role from this collection, reference them with their Fully Qualified Collection Namespace (FQCN) like so: + +```yaml +--- +- name: Using Zabbix collection + hosts: localhost + roles: + - role: community.zabbix.zabbix_agent + zabbix_agent_server: zabbix.example.com + ... + + tasks: + - name: Ensure host is monitored by Zabbix + community.zabbix.zabbix_host: + server_url: https://zabbix.example.com + ... +``` + +Or you include collection name `community.zabbix` in the playbook's `collections` element, like this: + +```yaml +--- +- name: Using Zabbix collection + hosts: localhost + collections: + - community.zabbix + + roles: + - role: zabbix_agent + zabbix_agent_server: zabbix.example.com + ... + + tasks: + - name: Ensure host is monitored by Zabbix + zabbix_host: + server_url: https://zabbix.example.com + ... +``` + +## Supported Zabbix versions + +Main priority is to support Zabbix releases which have official full support from Zabbix LLC. Please checkout the versions at [Zabbix Life Cycle & Release Policy](https://www.zabbix.com/life_cycle_and_release_policy) page. + +Support for Zabbix versions will be dropped with Major releases of the collection and mostly affect modules. Each role is following its unique support matrix. You should always consult documentation of roles in *docs/* directory. + +If you find any inconsistencies with the version of Zabbix you are using, feel free to open a pull request or an issue and we will try to address it as soon as possible. In case of pull requests, please make sure that your changes will not break any existing functionality for currently supported Zabbix releases. + +## Collection life cycle and support + +See [RELEASE](docs/RELEASE.md) document for more information regarding life cycle and support for the collection. + +## Contributing + +See [CONTRIBUTING](CONTRIBUTING.md) for more information about how to contribute to this repository. + +Please also feel free to stop by our [Gitter community](https://gitter.im/community-zabbix/community). + +## License + +GNU General Public License v3.0 or later + +See [LICENSE](LICENSE) to see the full text. diff --git a/collections-debian-merged/ansible_collections/community/zabbix/changelogs/.plugin-cache.yaml b/collections-debian-merged/ansible_collections/community/zabbix/changelogs/.plugin-cache.yaml new file mode 100644 index 00000000..0162ec0c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/changelogs/.plugin-cache.yaml @@ -0,0 +1,115 @@ +plugins: + become: {} + cache: {} + callback: {} + cliconf: {} + connection: {} + httpapi: {} + inventory: {} + lookup: {} + module: + zabbix_action: + description: Create/Delete/Update Zabbix actions + name: zabbix_action + namespace: '' + version_added: null + zabbix_discovery_rule: + description: Create/delete/update Zabbix discovery rules + name: zabbix_discovery_rule + namespace: '' + version_added: null + zabbix_group: + description: Create/delete Zabbix host groups + name: zabbix_group + namespace: '' + version_added: null + zabbix_group_info: + description: Gather information about Zabbix hostgroup + name: zabbix_group_info + namespace: '' + version_added: null + zabbix_host: + description: Create/update/delete Zabbix hosts + name: zabbix_host + namespace: '' + version_added: null + zabbix_host_events_info: + description: Get all triggers about a Zabbix host + name: zabbix_host_events_info + namespace: '' + version_added: null + zabbix_host_info: + description: Gather information about Zabbix host + name: zabbix_host_info + namespace: '' + version_added: null + zabbix_hostmacro: + description: Create/update/delete Zabbix host macros + name: zabbix_hostmacro + namespace: '' + version_added: null + zabbix_maintenance: + description: Create Zabbix maintenance windows + name: zabbix_maintenance + namespace: '' + version_added: null + zabbix_map: + description: Create/update/delete Zabbix maps + name: zabbix_map + namespace: '' + version_added: null + zabbix_mediatype: + description: Create/Update/Delete Zabbix media types + name: zabbix_mediatype + namespace: '' + version_added: null + zabbix_proxy: + description: Create/delete/get/update Zabbix proxies + name: zabbix_proxy + namespace: '' + version_added: null + zabbix_screen: + description: Create/update/delete Zabbix screens + name: zabbix_screen + namespace: '' + version_added: null + zabbix_service: + description: Create/update/delete Zabbix service + name: zabbix_service + namespace: '' + version_added: null + zabbix_template: + description: Create/update/delete/dump Zabbix template + name: zabbix_template + namespace: '' + version_added: null + zabbix_template_info: + description: Gather information about Zabbix template + name: zabbix_template_info + namespace: '' + version_added: null + zabbix_user: + description: Create/update/delete Zabbix users + name: zabbix_user + namespace: '' + version_added: null + zabbix_user_info: + description: Gather information about Zabbix user + name: zabbix_user_info + namespace: '' + version_added: null + zabbix_usergroup: + description: Create/delete/update Zabbix user groups + name: zabbix_usergroup + namespace: '' + version_added: null + zabbix_valuemap: + description: Create/update/delete Zabbix value maps + name: zabbix_valuemap + namespace: '' + version_added: null + netconf: {} + shell: {} + strategy: {} + vars: {} +version: 1.2.0 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/changelogs/changelog.yaml b/collections-debian-merged/ansible_collections/community/zabbix/changelogs/changelog.yaml new file mode 100644 index 00000000..a8b036db --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/changelogs/changelog.yaml @@ -0,0 +1,316 @@ +ancestor: null +releases: + 0.1.0: + changes: + bugfixes: + - zabbix_action - allow str values for ``esc_period`` options (see `#66841 `_). + - zabbix_action - no longer requires ``esc_period`` and ``event_source`` arguments + when ``state=absent``. + - zabbix_host - now supports configuring user macros and host tags on the managed + host (see `#66777 `_). + - zabbix_host_info - ``host_name`` based search results now include host groups. + - zabbix_hostmacro - ``macro_name`` now accepts macros in zabbix native format + as well (e.g. ``{$MACRO}``). + - zabbix_hostmacro - ``macro_value`` is no longer required when ``state=absent``. + - zabbix_proxy (module) - ``interface`` sub-options ``type`` and ``main`` are + now deprecated and will be removed in community.general 3.0.0. Also, the values + passed to ``interface`` are now checked for correct types and unexpected keys. + - zabbix_proxy (module) - added option proxy_address for comma-delimited list + of IP/CIDR addresses or DNS names to accept active proxy requests from. + - zabbix_template - add new option omit_date to remove date from exported/dumped + template (see `#67302 `_). + - zabbix_template - adding new update rule templateLinkage.deleteMissing for + newer zabbix versions (see `#66747 `_). + - zabbix_template_info - add new option omit_date to remove date from exported/dumped + template (see `#67302 `_). + deprecated_features: + - zabbix_proxy (module) - deprecates ``interface`` sub-options ``type`` and + ``main`` when proxy type is set to passive via ``status=passive``. Make sure + these suboptions are removed from your playbook as they were never supported + by Zabbix in the first place. + minor_changes: + - zabbix inventory plugin now no longer prints DeprecationWarning when used + with Python3 due to SafeConfigParser. + - zabbix_action - arguments ``event_source`` and ``esc_period`` no longer required + when ``state=absent``. + - zabbix_host - fixed inventory_mode key error, which occurs with Zabbix 4.4.1 + or more (see `#65304 `_). + - zabbix_host - was not possible to update a host where visible_name was not + set in zabbix. + - zabbix_mediatype - Fixed to support zabbix 4.4 or more and python3 (see `#67693 + `_). + - zabbix_template - fixed error when providing empty ``link_templates`` to the + module (see `#66417 `_). + - zabbix_template - fixed invalid (non-importable) output provided by exporting + XML (see `#66466 `_). + - zabbix_user - Fixed an issue where module failed with zabbix 4.4 or above + (see `#67475 `_). + release_summary: '| Release date: 2020-06-15 + + ' + fragments: + - 010release.yml + release_date: '2020-06-15' + 0.2.0: + changes: + bugfixes: + - zabbix_action - documented ``value2`` parameter and ``notify_all_involved`` + option. + - zabbix_maintenance - changing value of ``description`` parameter now actually + updates maintenance's description. + - zabbix_template - is now able to perform ``state=dump`` when using ``ansible-playbook + --check``. + - zabbix_template - no longer imports template from ``template_json`` or ``template_xml`` + when using ``ansible-playbook --check``. + minor_changes: + - Documentation for roles moved to ``docs/`` sub-directory in the collection. + - New **role zabbix_agent** - previously known as dj-wasabi/zabbix-agent (also + see `UPGRADE.md `_ + for each role). + - New **role zabbix_javagateway** - previously known as dj-wasabi/zabbix-javagateway. + - New **role zabbix_proxy** - previously known as dj-wasabi/zabbix-proxy. + - New **role zabbix_server** - previously known as dj-wasabi/zabbix-server. + - New **role zabbix_web** - previously known as dj-wasabi/zabbix-web. + - zabbix_action - new alias ``update_operations`` for ``acknowledge_operations`` + parameter. + - zabbix_host - ``macros`` now support new macro types ``text`` and ``secret``. + - zabbix_host - new option ``details`` (additional SNMP details) for ``interfaces`` + parameter. + - zabbix_host - now supports Zabbix 5.0. + - zabbix_proxy (module) - now supports Zabbix 5.0. + - zabbix_screen - ``host_group`` parameter now accepts multiple groups. + release_summary: '| Release date: 2020-06-15 ' + fragments: + - 020release.yml + release_date: '2020-06-15' + 0.3.0: + changes: + bugfixes: + - zabbix_action - choices for the ``inventory`` paramter sub option in ``*operations`` + arguments have been clarified to ``manual`` and ``automatic``. + - zabbix_action - fixed error on changed API fields ``*default_message`` and + ``*default_subject`` for Zabbix 5.0 (see `#92 `_). + - zabbix_action - module will no longer fail when searching for global script + provided to ``script_name`` parameter. + - zabbix_action - now correctly selects mediatype for the (normal|recovery|update) + operations with Zabbix 4.4 and newer. + - zabbix_agent - fixed installation of agent on Windows to directories with + spaces. + - zabbix_agent - role should no longer fail when looking for ``getenforce`` + binary. + - zabbix_host - module will no longer convert context part of user macro to + upper case. + - zabbix_proxy (role) - will now correctly install python3-libsemanage on RHEL + OS family. + - zabbix_service - fixed the zabbix_service has no idempotency with Zabbix 5.0. + - zabbix_web - now no longer fails when rendering apache vhost template. + minor_changes: + - All roles now **support Zabbix 5.0** and by default install this version (see + `#131 `_ + and `#121 `_). + - Roles will now install gnupg on Debian OS family if not present. + - zabbix_action - no longer requires ``password`` and ``ssh_*key_file`` parameters + at the same time for ``remote_command`` operations of type SSH. + - zabbix_action - parameter ``ssh_auth_type`` for SSH ``remote_command`` operation + now correctly identifies which other parameters are required. + - zabbix_discovery_rule - refactoring module to use ``module_utils`` classes + and functions, adjust return values on success, add documentation for return + values. + - zabbix_discovery_rule - refactoring the module to remove unnecessary variables + and fix a variable typo. + - zabbix_mediatype - new options ``message_templates``, ``description`` and + many more related to ``type=webhook``. + - zabbix_mediatype - now supports new ``webhook`` media type. + release_summary: '| Release date: 2020-07-26 + + ' + fragments: + - 030release.yml + modules: + - description: Create/delete/update Zabbix discovery rules + name: zabbix_discovery_rule + namespace: '' + - description: Create/delete/update Zabbix user groups + name: zabbix_usergroup + namespace: '' + release_date: '2020-07-26' + 1.0.0: + changes: + breaking_changes: + - zabbix_javagateway - options ``javagateway_pidfile``, ``javagateway_listenip``, + ``javagateway_listenport`` and ``javagateway_startpollers`` renamed to ``zabbix_javagateway_xyz`` + (see `UPGRADE.md `_). + bugfixes: + - all roles - a ``handler`` is configured when ``zabbix_http(s)_proxy`` is defined + which will remove the proxy line from the repository files. This results that + execution of the roles are not idempotent anymore. + - zabbix_proxy (role) - ``StartPreprocessors`` only works with version 4.2 or + higher. When a lower version is used, it will not be added to the configuration. + - zabbix_proxy (role) - only install the sql files that needs to be executed + for when ``zabbix_repo`` is set to ``epel``. + - zabbix_server - ``StartPreprocessors`` only works with version 4.2 or higher. + When a lower version is used, it will not be added to the configuration. + - zabbix_server - only install the sql files that needs to be executed for when + ``zabbix_repo`` is set to ``epel``. + minor_changes: + - Added the possibility to configure the ``mode`` for the ``zabbix_{agent,server,proxy}_include`` + directories. + - all roles - added the possibility to configure the ``mode`` for the ``yum`` + repositories files in case it contains credentials. + - zabbix_agent - ``zabbix-sender`` and ``zabbix-get`` will not be installed + when ``zabbix_repo`` is set to ``epel``, as they are not part of the repository. + - zabbix_agent - added option to change between HTTP/HTTPS with ``zabbix_repo_yum_schema``. + - zabbix_agent - can also install the zabbix-agent2 application when ``zabbix_agent2`` + is set to ``true``. + - zabbix_proxy (role) - a user and group are created on the host when ``zabbix_repo`` + is set to ``epel``. + - zabbix_proxy (role) - now supports ``startpreprocessors`` setting and encryption + when connecting to database (see `#164 `_). + - zabbix_server - a user and group are created on the host when ``zabbix_repo`` + is set to ``epel``. + - zabbix_server - added option to change between HTTP/HTTPS with ``zabbix_repo_yum_schema``. + - zabbix_server - now supports ``startpreprocessors`` setting and encryption + when connecting to database (see `#164 `_). + - zabbix_web - a property is added ``zabbix_web_doubleprecision`` which currently + is set to ``false`` for default installations. For new installations this + should be set to ``True``. For upgraded installations, please read database + `upgrade notes `_ + (Paragraph "Enabling extended range of numeric (float) values") before enabling + this option. + - zabbix_web - added option to change between HTTP/HTTPS with ``zabbix_repo_yum_schema``. + - zabbix_web - don't remove the files that Zabbix will install during installation + when you don't want to configure a virtual host configuration. + release_summary: '| Release date: 2020-08-16 + + ' + fragments: + - 100-release-prep.yaml + - role-agent-supports-zabbix-agent2.yaml + - role-all-configure-mode-include.yaml + - role-all-configure-mode-with-handlers.yaml + - role-all-fix-epel-installations.yaml + - role-web-add-doubleprecision.yaml + - role-web-zabbix_vhost-dont-remove-files.yaml + release_date: '2020-08-16' + 1.1.0: + changes: + bugfixes: + - all roles - missing ``become`` set to ``true`` was added to each task that + requires admin privleges. + - zabbix_agent - added new properties and updated documentation to allow for + correct Zabbix Agent2 configuration. + - zabbix_agent - fixed bug where Nginx prevented Apache from working as it was + part of the FPM configuration. + minor_changes: + - all roles - added ``zabbix_{agent,web,server,proxy,javagateway}_conf_mode`` + option for configuring a mode of the configuration file for each Zabbix service. + - zabbix_proxy (role) - added an option ``innodb_default_row_format`` for MariaDB/MySQL + if it isn't set to ``dynamic``. + - zabbix_server - fixed installation output when using MySQL database to not + print PostgreSQL. + - zabbix_user - ``passwd`` no longer required when ALL groups in ``usrgrps`` + use LDAP as ``gui_access`` (see `#240 `_). + - zabbix_user - no longer requires ``usrgrps`` when ``state=absent`` (see `#240 + `_). + - zabbix_web - added several configuration options for the PHP-FPM setup to + configure the listen (socket) file. + - zabbix_web - added support for configuring Zabbix Web with Nginx, same way + as with Apache. + release_summary: '| Release date: 2020-10-22 + + ' + fragments: + - 240-zabbix-user-nopass-ldap.yaml + - role-agent-correct-usage-acl.yaml + - role-agent-zabbix-agent2-props.yaml + - role-server-screen-output.yaml + - role-web-add-support-for-nginx.yaml + - role-web-added-some-properties.yaml + - roles-all-add-become.yaml + - roles-all-configure-conf-mode.yaml + - roles-server-proxy-add-innodb-check.yaml + release_date: '2020-10-22' + 1.2.0: + changes: + bugfixes: + - When installing the Zabbix packages, we disable all other yum repositories + except the one for the Zabbix. + - zabbix_agent - Agent 2 also be able to use userparameters file. + - zabbix_agent - Also work on SLES 12 sp5 + - zabbix_agent - Documented the property 'zabbix_proxy_ip' in the documentation. + - zabbix_agent - There was an task that wasn't able to use an http(s)_proxy + environment while installing an package. + - zabbix_agent - Windows - Able to create PSK file + - zabbix_agent - Windows - Fixing download links to proper version/url + - zabbix_agent - Windows - Removal of not working property + - zabbix_agent - Zabbix packages were not able to install properly on Fedora. + When the packages are installed, the version will be appended to the package + name. This is eofr all RedHat related OS'es. + - zabbix_agent - fixed issue with zabbix_agent2_tlspsk_auto having no effect + when using zabbix_agent2 + - zabbix_agent - fixed issue with zabbix_api_create_hosts and TLS configuration + when using zabbix_agent2, where zabbix_agent_tls* settings were used instead + of zabbix_agent2_tls* + - zabbix_host - module will no longer require ``interfaces`` to be present when + creating host with Zabbix 5.2 (https://github.com/ansible-collections/community.zabbix/pull/291). + - zabbix_host - should no longer fail with 'host cannot have more than one default + interface' error (https://github.com/ansible-collections/community.zabbix/pull/309). + - zabbix_proxy (role) - Added missing paragraph for the SQLite3 as database. + - zabbix_proxy (role) - The become option was missing in some essential tasks + when installing the Zabbix Proxy with SQLite3 as database. + - zabbix_proxy (role) - Various documentation fixes removing the Zabbix Server + and replaced it with actual Zabbix Proxy information. + - zabbix_proxy - Added new property 'zabbix_proxy_ip' to determine ip for host + running the Zabbix Proxy. + - zabbix_proxy - The 'interface' option was missing when creating an Proxy via + the API. + - zabbix_template - fixed documentation for ``macros`` argument (https://github.com/ansible-collections/community.zabbix/pull/296). + - zabbix_template - fixed encode error when using Python2 (https://github.com/ansible-collections/community.zabbix/pull/297). + - zabbix_template - fixed issue when importing templates to zabbix version. + >= 5.2 + - zabbix_template_info - fixed encode error when using Python2 (https://github.com/ansible-collections/community.zabbix/pull/297). + - zabbix_user - disable no_log warning for option override_password. + - zabbix_user - fixed issue where module couldn't create a user since Zabbix + 5.2 (https://github.com/ansible-collections/community.zabbix/pull/260). + - zabbix_web - fixed issue Role cannot install Zabbix web 5.0 on RHEL 7 (https://github.com/ansible-collections/community.zabbix/issues/202). + minor_changes: + - Updated the roles to support Zabbix 5.2. + - zabbix_agent - Added a new property `zabbix_agent_dont_detect_ip` when set + to true, it won't detect the ips and no need to install the python module + `netaddr`. + - zabbix_agent - Added parameter `zabbix_agent_package_remove` when set to `true` + and `zabbix_agent2` is set to `true` it will uninstall the `zabbix-agent` + service and package. + - zabbix_agent - added `zabbix_agent_install_agent_only` Will only install the + Zabbix Agent package and not the `zabbix-sender` or `zabbix-get` packages. + - zabbix_template - Fixed to decode Unicode Escape of multibyte strings in an + importing template data(https://github.com/ansible-collections/community.zabbix/pull/226). + - zabbix_user - added new parameters to set timezone and role_name for users + (https://github.com/ansible-collections/community.zabbix/pull/260). + - zabbix_user - user_medias now defaults to None and is optional (https://github.com/ansible-collections/community.zabbix/pull/264). + - zabbix_web - added `zabbix_web_rhel_release` which enable scl on RHEL (https://github.com/ansible-collections/community.zabbix/pull/266). + - zabbix_web - quality of life improvements when using Nginx (https://github.com/ansible-collections/community.zabbix/pull/304). + fragments: + - 226-zabbix_template.yaml + - 254-disable-no-log-warning.yml + - 260-zabbix_user.yml + - 264-allow-user_medias-to-be-optional.yaml + - 266-zabbix_web.yml + - 297-zabbix_template_modules.yml + - 309-host-interfaces.yaml + - agent-missing-proxy-task.yaml + - agent-not-detect-ips.yml + - agent-use-version-for-rh.yml + - agent2-psk-fixes.yml + - module-zabbix_host-interfaces-not-required.yaml + - module-zabbix_template-argspec-doc.yaml + - proxy-able-to-use-interface.yaml + - role-agent-allow-uninstall-agent.yaml + - role-agent-userparameter.yaml + - role-agent-windows-service-handling.yaml + - role-agent-work-with-sles.yaml + - role-proxy-sqlite3-zabbix-proxy.yaml + - roles-all-enable-zabbix-disable-rest.yaml + - roles-all-update-to-zabbix-52.yml + - templatescreens-fix.yml + release_date: '2021-01-04' diff --git a/collections-debian-merged/ansible_collections/community/zabbix/changelogs/config.yaml b/collections-debian-merged/ansible_collections/community/zabbix/changelogs/config.yaml new file mode 100644 index 00000000..f5547716 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/changelogs/config.yaml @@ -0,0 +1,31 @@ +changelog_filename_template: ../CHANGELOG.rst +changelog_filename_version_depth: 0 +changes_file: changelog.yaml +changes_format: combined +ignore_other_fragment_extensions: true +keep_fragments: false +mention_ancestor: true +new_plugins_after_name: removed_features +notesdir: fragments +prelude_section_name: release_summary +prelude_section_title: Release Summary +sections: +- - major_changes + - Major Changes +- - minor_changes + - Minor Changes +- - breaking_changes + - Breaking Changes / Porting Guide +- - deprecated_features + - Deprecated Features +- - removed_features + - Removed Features (previously deprecated) +- - security_fixes + - Security Fixes +- - bugfixes + - Bugfixes +- - known_issues + - Known Issues +title: community.zabbix +trivial_section_name: trivial +use_fqcn: true diff --git a/collections-debian-merged/ansible_collections/community/zabbix/changelogs/fragments/.gitkeep b/collections-debian-merged/ansible_collections/community/zabbix/changelogs/fragments/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/collections-debian-merged/ansible_collections/community/zabbix/docker-compose.yml b/collections-debian-merged/ansible_collections/community/zabbix/docker-compose.yml new file mode 100644 index 00000000..719a3574 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/docker-compose.yml @@ -0,0 +1,37 @@ +--- +version: '3.7' +services: + zabbix-db: + image: postgres:latest + environment: + POSTGRES_DB: "zabbix" + POSTGRES_USER: "zabbix" + POSTGRES_PASSWORD: "zabbix" + zabbix-server: + image: zabbix/zabbix-server-pgsql:ubuntu-${zabbix_version}-latest + environment: + DB_SERVER_HOST: "zabbix-db" + POSTGRES_USER: "zabbix" + POSTGRES_PASSWORD: "zabbix" + POSTGRES_DB: "zabbix" + depends_on: + - "zabbix-db" + links: + - "zabbix-db" + zabbix-web: + image: zabbix/zabbix-web-nginx-pgsql:ubuntu-${zabbix_version}-latest + environment: + DB_SERVER_HOST: "zabbix-db" + POSTGRES_USER: "zabbix" + POSTGRES_PASSWORD: "zabbix" + POSTGRES_DB: "zabbix" + ZBX_SERVER_HOST: "zabbix-server" + PHP_TZ: "Asia/Tokyo" + depends_on: + - "zabbix-db" + - "zabbix-server" + links: + - "zabbix-db" + - "zabbix-server" + ports: + - "8080:8080" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/docs/PUBLISHING_TO_GALAXY.md b/collections-debian-merged/ansible_collections/community/zabbix/docs/PUBLISHING_TO_GALAXY.md new file mode 100644 index 00000000..222b22ec --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/docs/PUBLISHING_TO_GALAXY.md @@ -0,0 +1,24 @@ +# Publishing New Versions + + 1. Ensure all relevant PRs have provided changelog fragments, then generate a changelog entries for new version: + ``` + antsibull-changelog release --version X.Y.Z --date YYYY-MM-DD + ``` + 2. Update `galaxy.yml` file and `requirements.yml` example in `README.md` with the new `version` for the collection. + 3. Tag the version in Git and push to GitHub: + ``` + git tag -a X.Y.Z + git push origin X.Y.Z + ``` + +Additional manual steps are required when automatic publish to Ansible Galaxy is not enabled in the repository. This +requires a user who has access to the `community.zabbix` namespace on Ansible Galaxy to publish the build artifact. + + 4. Run the following commands to build and release the new version on Galaxy: + + ``` + ansible-galaxy collection build + ansible-galaxy collection publish ./community-zabbix-$VERSION_HERE.tar.gz + ``` + +After the version is published, verify it exists on the [Zabbix Collection Galaxy page](https://galaxy.ansible.com/community/zabbix). diff --git a/collections-debian-merged/ansible_collections/community/zabbix/docs/RELEASE.md b/collections-debian-merged/ansible_collections/community/zabbix/docs/RELEASE.md new file mode 100644 index 00000000..0c6cc2e8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/docs/RELEASE.md @@ -0,0 +1,46 @@ +# Release cycle and versioning + +## Versioning +Versioning is using SemVer (X.Y.Z): +- The X is a **major version** and is incremented when: + - Support for older Zabbix versions is removed. + - Support for older Ansible versions is removed. + - Support for older Python versions is removed. + - Modules, roles or plugins are removed. + - Module or role functionality is removed. + - Other breaking changes or backward-incompatible changes are introduced. + +- The Y is a **minor version** and is incremented when: + - Support for new Zabbix versions is added. + - Support for new Ansible versions is added. + - Support for new Python versions is added. + - A new module, role, plugin, etc., is added. + - New features are introduced to modules, roles, plugins. + - A functionality of components is adjusted in a backward-compatible way. + +- The Z is a **patch version** and is incremented when: + - Bugs are fixed in a backward-compatible way. + - Documentation fixes and smaller changes are introduced. +## Releases +Release dates are not fixed. Instead, they will be discussed at the beginning of each month following this guideline: +- The version increment will depend on the content that will be included in the release, as discussed in the *Versioning* section. +- New collection releases may be a result of this discussion if necessary. +- There may be several releases during the month if needed. +## Collection support +The latest release of the community.zabbix is always supported. +Older releases, which are included in the still supported Ansible versions, may obtain occasional backports or bug fixes when necessary. [1] + +[1] [Collection versioning requirements](https://github.com/ansible-collections/overview/blob/main/collection_requirements.rst#versioning-and-deprecation) +## Branches +Branch *main* always holds the code for the latest supported release. +New branch *stable-X.Y* is pushed before starting a new *major (X+1)* version development in the main branch. + +The *stable-X.Y* branch provides a way to merge any necessary backports and release bug fixes for older major versions of this collection while they are still included in currently supported ansible releases. +> For example, if the current version of the collection is *1.3.2* and a new version *2.0.0* is being released, the branch *stable-1.Y* should be pushed prior to the release, matching the last commit that was included with the *1.3.2* release. + +## Merging +Merging follows this guideline: +- *Main branch* (previously master branch) is the current branch. +- *stable-X.Y* is a separate branch used to fix issues in older supported collection releases. +- There should be a separate branch for each contribution. +- There should be a separate pull request for each version increment. diff --git a/collections-debian-merged/ansible_collections/community/zabbix/docs/UPGRADE.md b/collections-debian-merged/ansible_collections/community/zabbix/docs/UPGRADE.md new file mode 100644 index 00000000..557dcce2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/docs/UPGRADE.md @@ -0,0 +1,126 @@ +__Upgrade__ + +Table of content + +- [1.0.0](#100) + * [Roles](#roles) + + [Proxy](#proxy) + + [Java Gateway](#java-gateway) +- [0.2.0](#020) + * [Roles](#roles-1) + + [Agent](#agent) + + [Server](#server) + + [Proxy](#proxy-1) + + [Web](#web) + + [Java Gateway](#java-gateway-1) + +This document provides an overview of all the changes that are needed to be applied to have a correctly working environment per version. If a version is not part of this document, then there are no changes needed to apply. + +## 1.0.0 + +### Roles + +#### Proxy + +The following property is renamed in the `zabbix_proxy` role. + +|From|To| +|----|--| +|`zabbix_version`|`zabbix_proxy_version`| + +NOTE: The `zabbix_version` can still be used, but will be deprecated in later releases. + +#### Java Gateway + +The following properties are renamed in the `zabbix_javagateway` role. + +|From|To| +|----|--| +|`zabbix_version`|`zabbix_javagateway_version`| +|`javagateway_package_state`|`zabbix_javagateway_package_state`| +|`javagateway_pidfile`|`zabbix_javagateway_pidfile`| +|`javagateway_listenip`|`zabbix_javagateway_listenip`| +|`javagateway_listenport`|`zabbix_javagateway_listenport`| +|`javagateway_startpollers`|`zabbix_javagateway_startpollers`| + +NOTE: The `zabbix_version` can still be used, but will be deprecated in later releases. + +## 0.2.0 + +### Roles + +#### Agent + +A 1-on-1 copy of the Ansible role `dj-wasabi.zabbix-agent` to this collection. Due to naming of roles as part of a collection, some characters (Like the `-`) are not allowed anymore. This role is therefore renamed from `zabbix-agent` to `zabbix_agent`. + +Example of using the role in this collection: +```yaml +- hosts: all + roles: + - role: community.zabbix.zabbix_agent + zabbix_agent_server: 192.168.33.30 + zabbix_agent_serveractive: 192.168.33.30 +``` + +#### Server + +A 1-on-1 copy of the Ansible role `dj-wasabi.zabbix-server` to this collection. Due to naming of roles as part of a collection, some characters (Like the `-`) are not allowed anymore. This role is therefore renamed from `zabbix-server` to `zabbix_server`. + +Example of using the role in this collection:: +```yaml +- hosts: zabbix-server + roles: + - role: community.zabbix.zabbix_server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 +``` + +#### Proxy + +A 1-on-1 copy of the Ansible role `dj-wasabi.zabbix-proxy` to this collection. Due to naming of roles as part of a collection, some characters (Like the `-`) are not allowed anymore. This role is therefore renamed from `zabbix-proxy` to `zabbix_proxy`. + +Example of using the role in this collection:: +```yaml +- hosts: zabbix-proxy + roles: + - role: community.zabbix.zabbix_proxy + zabbix_server_host: 192.168.1.1 + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 +``` + +#### Web + +A 1-on-1 copy of the Ansible role `dj-wasabi.zabbix-web` to this collection. Due to naming of roles as part of a collection, some characters (Like the `-`) are not allowed anymore. This role is therefore renamed from `zabbix-web` to `zabbix_web`. + +Example of using the role in this collection:: +```yaml +- hosts: zabbix-web + become: yes + roles: + - role: geerlingguy.apache + - role: community.zabbix.zabbix_web + zabbix_url: zabbix.mydomain.com + zabbix_server_hostname: zabbix-server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 +``` + +#### Java Gateway + +A 1-on-1 copy of the Ansible role `dj-wasabi.zabbix-javagateway` to this collection. Due to naming of roles as part of a collection, some characters (Like the `-`) are not allowed anymore. This role is therefore renamed from `zabbix-javagateway` to `zabbix_javagateway`. + +Example of using the role in this collection:: +```yaml +- hosts: zabbix-server + roles: + - role: community.zabbix.zabbix_server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + zabbix_server_javagateway: 192.168.1.1 + - role: community.zabbix.zabbix_javagateway +``` diff --git a/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_AGENT_ROLE.md b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_AGENT_ROLE.md new file mode 100644 index 00000000..f13b7e4c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_AGENT_ROLE.md @@ -0,0 +1,509 @@ +# community.zabbix.zabbix_agent role + +![Zabbix Agent](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_agent/badge.svg) + +**Table of Contents** + +- [Requirements](#requirements) + * [Operating systems](#operating-systems) + + [Windows](#windows) + * [Local system access](#local-system-access) + * [Zabbix Versions](#zabbix-versions) +- [Getting started](#getting-started) + * [Minimal Configuration](#minimal-configuration) + * [Issues](#issues) +- [Role Variables](#role-variables) + * [Main variables](#main-variables) + + [Overall Zabbix](#overall-zabbix) + + [SElinux](#selinux) + + [Zabbix Agent](#zabbix-agent) + + [Zabbix Agent vs Zabbix Agent 2 configuration](#zabbix-agent-vs-zabbix-agent-2-configuration) + * [TLS Specific configuration](#tls-specific-configuration) + * [Zabbix API variables](#zabbix-api-variables) + * [Windows Variables](#windows-variables) + * [macOS Variables](#macos-variables) + * [Docker Variables](#docker-variables) + * [FirewallD/Iptables](#firewalld-iptables) + * [IPMI variables](#ipmi-variables) + * [proxy](#proxy) +- [Dependencies](#dependencies) +- [Example Playbook](#example-playbook) + * [zabbix_agent2_plugins](#zabbix-agent2-plugins) + * [agent_interfaces](#agent-interfaces) + * [Other interfaces](#other-interfaces) + * [Vars in role configuration](#vars-in-role-configuration) + * [Combination of group_vars and playbook](#combination-of-group-vars-and-playbook) + * [Example for TLS PSK encrypted agent communication](#example-for-tls-psk-encrypted-agent-communication) +- [Molecule](#molecule) +- [Deploying Userparameters](#deploying-userparameters) +- [License](#license) +- [Author Information](#author-information) + +# Requirements +## Operating systems +This role will work on the following operating systems: + + * Red Hat + * Fedora + * Debian + * Ubuntu + * opensuse + * Windows (Best effort) + * macOS + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +### Windows + +When you are a Windows user and using Ansible 2.10 or newer, then there is a dependency on a collection named `ansible.windows`. This collection is needed as the `win_service` is part of this collection and not standard in Ansible anymmore. Installing the collection: + +```sh +ansible-galaxy collection install ansible.windows +``` + +For more information, see: https://github.com/ansible-collections/community.zabbix/issues/236 + +## Local system access + +To successfully complete the install the role requires `python-netaddr` on the controller to be able to manage IP addresses. This requires that the library is available on your local machine (or that `pip` is installed to be able to run). This will likely mean that running the role will require `sudo` access to your local machine and therefore you may need the `-K` flag to be able to enter your local machine password if you are not running under root. + +## Zabbix Versions + +See the following list of supported Operating systems with the Zabbix releases: + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | V | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +# Getting started + +## Minimal Configuration + +In order to get the Zabbix Agent running, you'll have to define the following properties before executing the role: + +* `zabbix_agent_version` +* `zabbix_agent_server` +* `zabbix_agent_serveractive` (When using active checks) + +The `zabbix_agent_version` is optional. The latest available major.minor version of Zabbix will be installed on the host(s). If you want to use an older version, please specify this in the major.minor format. Example: `zabbix_agent_version: 4.0`, `zabbix_agent_version: 3.4` or `zabbix_agent_version: 2.2`. + +The `zabbix_agent_server` (and `zabbix_agent_serveractive`) should contain the ip or fqdn of the host running the Zabbix Server. + +## Issues + +Due to issue discussed on [#291](https://github.com/dj-wasabi/ansible-zabbix-agent/issues/291), the Ansible Version 2.9.{0,1,2} isn't working correctly on Windows related targets. + +# Role Variables + +## Main variables + +The following is an overview of all available configuration default for this role. + +### Overall Zabbix + +* `zabbix_agent_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. + +### SElinux + +* `zabbix_selinux`: Default: `False`. Enables an SELinux policy so that the server will run. + +### Zabbix Agent + +* `zabbix_agent_ip`: The IP address of the host. When not provided, it will be determined via the `ansible_default_ipv4` fact. +* `zabbix_agent2`: Default: `False`. When you want to install the `Zabbix Agent2` instead of the "old" `Zabbix Agent`. +* `zabbix_agent_server`: The ip address for the zabbix-server or zabbix-proxy. +* `zabbix_agent_serveractive`: The ip address for the zabbix-server or zabbix-proxy for active checks. +* `zabbix_agent_listeninterface`: Interface zabbix-agent listens on. Leave blank for all. +* `zabbix_agent_package_remove`: If `zabbix_agent2: True` and you want to remove the old installation. Default: `False`. +* `zabbix_agent_package`: The name of the zabbix-agent package. Default: `zabbix-agent`. In case for EPEL, it is automatically renamed. +* `zabbix_sender_package`: The name of the zabbix-sender package. Default: `zabbix-sender`. In case for EPEL, it is automatically renamed. +* `zabbix_get_package`: The name of the zabbix-get package. Default: `zabbix-get`. In case for EPEL, it is automatically renamed. +* `zabbix_agent_package_state`: If Zabbix-agent needs to be `present` or `latest`. +* `zabbix_agent_interfaces`: A list that configured the interfaces you can use when configuring via API. +* `zabbix_agent_install_agent_only`: Only install the Zabbix Agent and not the `zabbix-sender` and `zabbix-get` packages. Default: `False` +* `zabbix_agent_userparameters`: Default: `[]]`. List of userparameter names and scripts (if any). Detailed description is given in the [Deploying Userparameters](#deploying-userparameters) section. + * `name`: Userparameter name (should be the same with userparameter template file name) + * `scripts_dir`: Directory name of the custom scripts needed for userparameters +* `zabbix_agent_userparameters_templates_src`: indicates the relative path (from `templates/`) where userparameter templates are searched +* `zabbix_agent_userparameters_scripts_src`: indicates the relative path (from `files/`) where userparameter scripts are searched +* `zabbix_agent_runas_user`: Drop privileges to a specific, existing user on the system. Only has effect if run as 'root' and AllowRoot is disabled. +* `zabbix_agent_become_on_localhost`: Default: `True`. Set to `False` if you don't need to elevate privileges on localhost to install packages locally with pip. +* `zabbix_install_pip_packages`: Default: `True`. Set to `False` if you don't want to install the required pip packages. Useful when you control your environment completely. +* `zabbix_agent_apt_priority`: Add a weight (`Pin-Priority`) for the APT repository. +* `zabbix_agent_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. +* `zabbix_agent_dont_detect_ip`: Default `false`. When set to `true`, it won't detect available ip addresses on the host and no need for the Python module `netaddr` to be installed. + +### Zabbix Agent vs Zabbix Agent 2 configuration + +The following provides an overview of all the properties that can be set in the Zabbix Agent configuration file. When `(2)` is used in the name of the property, like `zabbix_agent(2)_pidfile`, it will show that you can configure `zabbix_agent_pidfile` for the Zabbix Agent configuration file and `zabbix_agent2_pidfile` for the Zabbix Agent 2 configuration file. + +Otherwise it just for the Zabbix Agent or for the Zabbix Agent 2. + +* `zabbix_agent(2)_pidfile`: name of pid file. +* `zabbix_agent(2)_logfile`: name of log file. +* `zabbix_agent(2)_logfilesize`: maximum size of log file in mb. +* `zabbix_agent2_logtype`: Specifies where log messages are written to +* `zabbix_agent(2)_debuglevel`: specifies debug level +* `zabbix_agent(2)_sourceip`: source ip address for outgoing connections. +* `zabbix_agent_enableremotecommands`: whether remote commands from zabbix server are allowed. +* `zabbix_agent_logremotecommands`: enable logging of executed shell commands as warnings. +* `zabbix_agent(2)_listenport`: agent will listen on this port for connections from the server. +* `zabbix_agent2_statusport`: Agent will listen on this port for HTTP status requests. +* `zabbix_agent_listenip`: list of comma delimited ip addresses that the agent should listen on. +* `zabbix_agent_startagents`: number of pre-forked instances of zabbix_agentd that process passive checks. +* `zabbix_agent(2)_hostname`: unique, case sensitive hostname. +* `zabbix_agent(2)_hostnameitem`: item used for generating hostname if it is undefined. +* `zabbix_agent(2)_hostmetadata`: optional parameter that defines host metadata. +* `zabbix_agent(2)_hostmetadataitem`: optional parameter that defines an item used for getting the metadata. +* `zabbix_agent(2)_refreshactivechecks`: how often list of active checks is refreshed, in seconds. +* `zabbix_agent(2)_buffersend`: do not keep data longer than n seconds in buffer. +* `zabbix_agent(2)_buffersize`: maximum number of values in a memory buffer. the agent will send all collected data to zabbix server or proxy if the buffer is full. +* `zabbix_agent2_enablepersistentbuffer`: 0 - disabled, in-memory buffer is used (default); 1 - use persistent buffer +* `zabbix_agent2_persistentbufferperiod`: Zabbix Agent2 will keep data for this time period in case of no connectivity with Zabbix server or proxy. Older data will be lost. Log data will be preserved. +* `zabbix_agent2_persistentbufferfile`: Zabbix Agent2 will keep SQLite database in this file * n is valid if `EnablePersistentBuffer=1` +* `zabbix_agent_maxlinespersecond`: maximum number of new lines the agent will send per second to zabbix server or proxy processing 'log' and 'logrt' active checks. +* `zabbix_agent_allowroot`: allow the agent to run as 'root'. if disabled and the agent is started by 'root', the agent will try to switch to user 'zabbix' instead. has no effect if started under a regular user. +* `zabbix_agent(2)_zabbix_alias`: sets an alias for parameter. it can be useful to substitute long and complex parameter name with a smaller and simpler one. +* `zabbix_agent(2)_timeout`: spend no more than timeout seconds on processing +* `zabbix_agent(2)_include`: you may include individual files or all files in a directory in the configuration file. +* `zabbix_agent(2)_include_mode`: The mode for the directory mentioned above. +* `zabbix_agent(2)_unsafeuserparameters`: allow all characters to be passed in arguments to user-defined parameters. +* `zabbix_agent_loadmodulepath`: Full path to location of agent modules. +* `zabbix_agent_loadmodule`: Module to load at agent startup. Modules are used to extend functionality of the agent. +* `zabbix_agent2_controlsocket`: The control socket, used to send runtime commands with '-R' option. +* `zabbix_agent_allowroot`: Allow the agent to run as 'root'. 0 - do not allow, 1 - allow +* `zabbix_agent2_plugins`: A list containing plugin configuration. + +## TLS Specific configuration + +These variables are specific for Zabbix 3.0 and higher. When `(2)` is used in the name of the property, like `zabbix_agent(2)_tlsconnect`, it will show that you can configure `zabbix_agent_tlsconnect` for the Zabbix Agent configuration file and `zabbix_agent2_tlsconnect` for the Zabbix Agent 2 configuration file. + +* `zabbix_agent(2)_tlsconnect`: How the agent should connect to server or proxy. Used for active checks. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_agent(2)_tlsaccept`: What incoming connections to accept. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_agent(2)_tlscafile`: Full pathname of a file containing the top-level CA(s) certificates for peer certificate verification. +* `zabbix_agent(2)_tlscrlfile`: Full pathname of a file containing revoked certificates. +* `zabbix_agent(2)_tlsservercertissuer`: Allowed server certificate issuer. +* `zabbix_agent(2)_tlsservercertsubject`: Allowed server certificate subject. +* `zabbix_agent(2)_tlscertfile`: Full pathname of a file containing the agent certificate or certificate chain. +* `zabbix_agent(2)_tlskeyfile`: Full pathname of a file containing the agent private key. +* `zabbix_agent(2)_tlspskidentity`: Unique, case sensitive string used to identify the pre-shared key. +* `zabbix_agent(2)_tlspskidentity_file`: Full pathname of a file containing the pre-shared key identity. +* `zabbix_agent(2)_tlspskfile`: Full pathname of a file containing the pre-shared key. +* `zabbix_agent(2)_tlspsk_secret`: The pre-shared secret key that should be placed in the file configured with `agent_tlspskfile`. +* `zabbix_agent(2)_tlspsk_auto`: Enables auto generation and storing of individual pre-shared keys and identities on clients. + +## Zabbix API variables + +These variables need to be overridden when you want to make use of the zabbix-api for automatically creating and or updating hosts. + +Host encryption configuration will be set to match agent configuration. + +When `zabbix_api_create_hostgroup` or `zabbix_api_create_hosts` is set to `True`, it will install on the host executing the Ansible playbook the `zabbix-api` python module. + +* `zabbix_url`: The url on which the Zabbix webpage is available. Example: http://zabbix.example.com +* `zabbix_api_http_user`: The http user to access zabbix url with Basic Auth +* `zabbix_api_http_password`: The http password to access zabbix url with Basic Auth +* `zabbix_api_create_hosts`: Default: `False`. When you want to enable the Zabbix API to create/delete the host. This has to be set to `True` if you want to make use of `zabbix_create_host`. +* `zabbix_api_create_hostgroup`: When you want to enable the Zabbix API to create/delete the hostgroups. This has to be set to `True` if you want to make use of `zabbix_create_hostgroup`.Default: `False` +* `zabbix_api_user`: Username of user which has API access. +* `zabbix_api_pass`: Password for the user which has API access. +* `zabbix_create_hostgroup`: present (Default) if the hostgroup needs to be created or absent if you want to delete it. This only works when `zabbix_api_create_hostgroup` is set to `True`. +* `zabbix_host_status`: enabled (Default) when host in monitored, disabled when host is disabled for monitoring. +* `zabbix_create_host`: present (Default) if the host needs to be created or absent is you want to delete it. This only works when `zabbix_api_create_hosts` is set to `True`. +* `zabbix_update_host`: yes (Default) if the host should be updated if already present. This only works when `zabbix_api_create_hosts` is set to `True`. +* `zabbix_useuip`: 1 if connection to zabbix-agent is made via ip, 0 for fqdn. +* `zabbix_host_groups`: A list of hostgroups which this host belongs to. +* `zabbix_link_templates`: A list of templates which needs to be link to this host. The templates should exist. +* `zabbix_macros`: A list with macro_key and macro_value for creating hostmacro's. +* `zabbix_inventory_mode`: Configure Zabbix inventory mode. Needed for building inventory data, manually when configuring a host or automatically by using some automatic population options. This has to be set to `automatic` if you want to make automatically building inventory data. +* `zabbix_visible_hostname` : Configure Zabbix visible name inside Zabbix web UI for the node. +* `zabbix_validate_certs` : yes (Default) if we need to validate tls certificates of the API. Use `no` in case self-signed certificates are used +* `zabbix_agent_description`: Description of the host in Zabbix. +* `zabbix_agent_inventory_zabbix`: Adds Facts for a zabbix inventory + +## Windows Variables + +**NOTE** + +_Supporting Windows is a best effort (I don't have the possibility to either test/verify changes on the various amount of available Windows instances). PRs specific to Windows will almost immediately be merged, unless someone is able to provide a Windows test mechanism via Travis for Pull Requests._ + +* `zabbix_version_long`: The long (major.minor.patch) version of the Zabbix Agent. This will be used to generate the `zabbix_win_download_link` link and for Zabbix Agent update if `zabbix_agent_package_state: latest`. +* `zabbix_win_download_link`: The download url to the `win.zip` file. +* `zabbix_win_install_dir`: The directory where Zabbix needs to be installed. +* `zabbix_agent_win_logfile`: The full path to the logfile for the Zabbix Agent. +* `zabbix_agent_win_include`: The directory in which the Zabbix specific configuration files are stored. +* `zabbix_agent_win_svc_recovery`: Enable Zabbix Agent service auto-recovery settings. + +## macOS Variables + +* `zabbix_version_long`: The long (major.minor.patch) version of the Zabbix Agent. This will be used to generate the `zabbix_mac_download_link` link. +* `zabbix_mac_download_link`: The download url to the `pkg` file. + +## Docker Variables + +When you don't want to install the Zabbix Agent on the host, but would like to run it in a container then these properties are useful. When `zabbix_agent_docker` is set to `True`, then a +Docker image will be downloaded and a Container will be started. No other installations will be done on the host, with the exception of the PSK file and the "Zabbix Include Directory". + +The following directories are mounted in the Container: + +``` + - /etc/zabbix/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d + - /:/hostfs:ro + - /etc:/hostfs/etc:ro + - /proc:/hostfs/proc:ro + - /sys:/hostfs/sys:ro + - /var/run:/var/run +``` + +Keep in mind that using the Zabbix Agent in a Container requires changes to the Zabbix Template for Linux as `/proc`, `/sys` and `/etc` are mounted in a directory `/hostfs`. + +* `zabbix_agent_docker`: Default: `False`. When set to `True`, it will install a Docker container on the target host instead of installation on the target. +* `zabbix_agent_docker_state`: Default: `started` +* `zabbix_agent_docker_name`: The name of the Container. Default: `zabbix-agent` +* `zabbix_agent_docker_image`: The name of the Docker image. Default: `zabbix/zabbix-agent` +* `zabbix_agent_docker_image_tag`: The tag of the Docker image. +* `zabbix_agent_docker_user_gid`: The group id of the zabbix user in the Container. +* `zabbix_agent_docker_user_uid`: The user id of the zabbix user in the Container. +* `zabbix_agent_docker_network_mode`: The name of the (Docker) network that should be used for the Container. Default `host`. +* `zabbix_agent_docker_restart_policy`: Default: `unless-stopped`. The restart policy of the Container. +* `zabbix_agent_docker_privileged`: When set to `True`, the container is running in privileged mode. +* `zabbix_agent_docker_ports`: A list with `:` values to open ports to the container. +* `zabbix_agent_docker_security_opts`: A list with available security options. +* `zabbix_agent_docker_volumes`: A list with all directories that needs to be available in the Container. +* `zabbix_agent_docker_env`: A dict with all environment variables that needs to be set for the Container. + +## FirewallD/Iptables + +* `zabbix_agent_firewall_enable`: If IPtables needs to be updated by opening an TCP port for port configured in `zabbix_agent_listenport`. +* `zabbix_agent_firewall_source`: When provided, IPtables will be configuring to only allow traffic from this IP address/range. +* `zabbix_agent_firewalld_enable`: If firewalld needs to be updated by opening an TCP port for port configured in `zabbix_agent_listenport` and `zabbix_agent_jmx_listenport` if defined. +* `zabbix_agent_firewalld_source`: When provided, firewalld will be configuring to only allow traffic for IP configured in `zabbix_agent_server`. +* `zabbix_agent_firewalld_zone`: When provided, the firewalld rule will be attached to this zone (only if zabbix_agent_firewalld_enable is set to true). The default behavior is to use the default zone define by the remote host firewalld configuration. +* `zabbix_agent_firewall_action`: Default: `insert`. When to `insert` the rule or to `append` to IPTables. +* `zabbix_agent_firewall_chain`: Default `INPUT`. Which `chain` to add the rule to IPTables. + + +## IPMI variables + +* `zabbix_agent_ipmi_authtype`: IPMI authentication algorithm. Possible values are 1 (callback), 2 (user), 3 (operator), 4 (admin), 5 (OEM), with 2 being the API default. +* `zabbix_agent_ipmi_password`: IPMI password. +* `zabbix_agent_ipmi_privilege`: IPMI privilege level. Possible values are 1 (callback), 2 (user), 3 (operator), 4 (admin), 5 (OEM), with 2 being the API default. +* `zabbix_agent_ipmi_username`: IPMI username. + +## proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +# Dependencies + +There are no dependencies on other roles. + +# Example Playbook + +## zabbix_agent2_plugins + +Specifically for the Zabbix Agent 2, a list of extra plugins can be configured. The following provides an overview of configuring the `SystemRun` plugin by setting the `LogRemoteCommands` to `0`: + +```yaml +zabbix_agent2_plugins: + - name: SystemRun + options: + - parameter: LogRemoteCommands + value: 0 +``` + +In the `zabbix_agent2.conf` an entry will be created with the following content: + +``` +Plugins.SystemRun.LogRemoteCommands=0 +``` + +## agent_interfaces + +This will configure the Zabbix Agent interface on the host. +```yaml +zabbix_agent_interfaces: + - type: 1 + main: 1 + useip: "{{ zabbix_useuip }}" + ip: "{{ zabbix_agent_ip }}" + dns: "{{ ansible_fqdn }}" + port: "{{ zabbix_agent_listenport }}" +``` + +## Other interfaces + +You can also configure the `zabbix_agent_interfaces` to add/configure snmp, jmx and ipmi interfaces. + +You'll have to use one of the following type numbers when configuring it: + +| Type Interface | Nr | +|-----------------|-------| +| Zabbix Agent | 1 | +| snmp | 2 | +| ipmi | 3 | +| jmx | 4 | + +Configuring a snmp interface will look like this: + +``` +zabbix_agent_interfaces: + - type: 2 + main: 1 + useip: "{{ zabbix_useuip }}" + ip: "{{ agent_ip }}" + dns: "{{ ansible_fqdn }}" + port: "{{ agent_listenport }}" +``` + +## Vars in role configuration +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + +```yaml + - hosts: all + roles: + - role: community.zabbix.zabbix_agent + zabbix_agent_server: 192.168.33.30 + zabbix_agent_serveractive: 192.168.33.30 + zabbix_url: http://zabbix.example.com + zabbix_api_use: true # use zabbix_api_create_hosts and/or zabbix_api_create_hostgroup from 0.8.0 + zabbix_api_user: Admin + zabbix_api_pass: zabbix + zabbix_create_host: present + zabbix_host_groups: + - Linux Servers + zabbix_link_templates: + - Template OS Linux + - Apache APP Template + zabbix_macros: + - macro_key: apache_type + macro_value: reverse_proxy +``` + +## Combination of group_vars and playbook +You can also use the group_vars or the host_vars files for setting the variables needed for this role. File you should change: `group_vars/all` or `host_vars/` (Where is the hostname of the machine running Zabbix Server) + +```yaml + zabbix_agent_server: 192.168.33.30 + zabbix_agent_serveractive: 192.168.33.30 + zabbix_url: http://zabbix.example.com + zabbix_api_use: true # use zabbix_api_create_hosts and/or zabbix_api_create_hostgroup from 0.8.0 + zabbix_api_user: Admin + zabbix_api_pass: zabbix + zabbix_create_host: present + zabbix_host_groups: + - Linux Servers + zabbix_link_templates: + - Template OS Linux + - Apache APP Template + zabbix_macros: + - macro_key: apache_type + macro_value: reverse_proxy +``` + +and in the playbook only specifying: + +```yaml + - hosts: all + roles: + - role: community.zabbix.zabbix_agent +``` + +## Example for TLS PSK encrypted agent communication + +Variables e.g. in the playbook or in `host_vars/myhost`: + +```yaml + zabbix_agent_tlsaccept: psk + zabbix_agent_tlsconnect: psk + zabbix_agent_tlspskidentity: "myhost PSK" + zabbix_agent_tlspsk_secret: b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d + zabbix_agent_tlspskfile: /etc/zabbix/zabbix_agent_pskfile.psk +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully. + +# Deploying Userparameters + +The following steps are required to install custom userparameters and/or scripts: + +* Put the desired userparameter file in the `templates/userparameters` directory and name it as `.j2`. For example: `templates/userparameters/mysql.j2`. You can change the default directory to a custom one modifying `zabbix_agent_userparameters_templates_src` variable. +* Put the scripts directory (if any) in the `files/scripts` directory. For example: `files/scripts/mysql`. You can change the default directory to a custom one modifying `zabbix_agent_userparameters_scripts_src` variable. +* Add `zabbix_agent_userparameters` variable to the playbook as a list of dictionaries and define userparameter name and scripts directory name (if there are no scripts just no not specify the `scripts_dir` variable). + +Example: + +```yaml +- hosts: mysql_servers + tasks: + - include_role: + name: community.zabbix.zabbix_agent + vars: + zabbix_agent_server: zabbix.mydomain.com + zabbix_agent_userparameters: + - name: mysql + scripts_dir: mysql + - name: galera + +``` + +Example of the "templates/userparameters/mysql.j2" file: + +``` +UserParameter=mysql.ping_to,mysqladmin -uroot ping | grep -c alive +``` + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_JAVAGATEWAY_ROLE.md b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_JAVAGATEWAY_ROLE.md new file mode 100644 index 00000000..530a663e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_JAVAGATEWAY_ROLE.md @@ -0,0 +1,143 @@ +# community.zabbix.zabbix_javagateway role + +![Zabbix Javagateway](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_javagateway/badge.svg) + +**Table of Contents** + +- [Overview](#overview) + * [Operating systems](#operating-systems) + * [Zabbix Versions](#zabbix-versions) +- [Role Variables](#role-variables) + * [Main variables](#main-variables) + + [Overall Zabbix](#overall-zabbix) + + [Java Gatewaty](#java-gatewaty) + + [proxy](#proxy) +- [Dependencies](#dependencies) +- [Example Playbook](#example-playbook) +- [Molecule](#molecule) +- [License](#license) +- [Author Information](#author-information) + +# Overview + +## Operating systems + +This role will work on the following operating systems: + + * Red Hat + * Debian + * Ubuntu + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +## Zabbix Versions + +See the following list of supported Operating systems with the Zabbix releases. + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | V | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +# Role Variables + +## Main variables + +The following is an overview of all available configuration default for this role. + +### Overall Zabbix + +* `zabbix_javagateway_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. +* `zabbix_javagateway_package_state`: Default: `present`. Can be overridden to `latest` to update packages when needed. +* `zabbix_javagateway_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. + +### Java Gatewaty + +* `zabbix_javagateway_pidfile`: Default: `/run/zabbix/zabbix_java_gateway.pid`. The location for the pid file. +* `zabbix_javagateway_listenip`: Default: `0.0.0.0`. The IP address to listen on. +* `zabbix_javagateway_listenport`: Default: `10052`. The port on which Java Gateway is listening on. +* `zabbix_javagateway_startpollers`: Default: `5`. The amount of pollers to start. + +### proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +# Dependencies + +The java gateway can be installed on either the zabbix-server or the zabbix-proxy machine. So one of these should be installed. You'll need to provide an parameter in your playbook for using the javagateway. + +When using the zabbix-server: +```yaml + roles: + - role: community.zabbix.zabbix_server + zabbix_server_javagateway: 192.168.1.2 +``` + +or when using the zabbix-proxy: +```yaml + roles: + - role: community.zabbix.zabbix_proxy + zabbix_server_host: 192.168.1.1 + zabbix_proxy_javagateway: 192.168.1.2 +``` + +# Example Playbook + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + +```yaml + - hosts: zabbix-server + sudo: yes + roles: + - role: community.zabbix.zabbix_server + zabbix_server_javagateway: 192.168.1.2 + - role: community.zabbix.zabbix_javagateway +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully. + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_PROXY_ROLE.md b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_PROXY_ROLE.md new file mode 100644 index 00000000..29cbbf9f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_PROXY_ROLE.md @@ -0,0 +1,342 @@ +# community.zabbix.zabbix_proxy role + +![Zabbix Proxy](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_proxy/badge.svg) + +**Table of Contents** + +- [Overview](#overview) + * [Operating systems](#operating-systems) + * [Zabbix Versions](#zabbix-versions) +- [Role Variables](#role-variables) + * [Main variables](#main-variables) + + [Overall Zabbix](#overall-zabbix) + + [SElinux](#selinux) + + [Zabbix Proxy](#zabbix-proxy) + + [Database specific](#database-specific) + + [TLS Specific configuration](#tls-specific-configuration) + * [proxy](#proxy) + * [Database](#database) + + [MySQL](#mysql) + - [Local Setup](#local-setup) + - [Separate Setup](#separate-setup) + + [PostgreSQL](#postgresql) + - [Local Setup](#local-setup-1) + - [Separate Setup](#separate-setup-1) + + [SQLite3](#sqlite3) + * [Zabbix API variables](#zabbix-api-variables) +- [Example Playbook](#example-playbook) +- [Molecule](#molecule) +- [License](#license) +- [Author Information](#author-information) + +# Overview + +## Operating systems + +This role will work on the following operating systems: + + * Red Hat + * Debian + * Ubuntu + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +## Zabbix Versions + +See the following list of supported Operating systems with the Zabbix releases. + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | V | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +# Role Variables + +## Main variables + +The following is an overview of all available configuration default for this role. + +### Overall Zabbix + +* `zabbix_proxy_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. + +### SElinux + +* `zabbix_selinux`: Default: `False`. Enables an SELinux policy so that the Proxy will run. + +### Zabbix Proxy + +* `zabbix_proxy_ip`: The IP address of the host. When not provided, it will be determined via the `ansible_default_ipv4` fact. +* `zabbix_server_host`: The ip or dns name for the zabbix-server machine. +* `zabbix_server_port`: The port on which the zabbix-server is running. Default: 10051 +* `*zabbix_proxy_package_state`: Default: `present`. Can be overridden to `latest` to update packages +* `zabbix_proxy_install_database_client`: Default: `True`. False does not install database client. +* `zabbix_proxy_become_on_localhost`: Default: `True`. Set to `False` if you don't need to elevate privileges on localhost to install packages locally with pip. +* `zabbix_proxy_manage_service`: Default: `True`. When you run multiple Zabbix proxies in a High Available cluster setup (e.g. pacemaker), you don't want Ansible to manage the zabbix-proxy service, because Pacemaker is in control of zabbix-proxy service. +* `zabbix_install_pip_packages`: Default: `True`. Set to `False` if you don't want to install the required pip packages. Useful when you control your environment completely. +* `zabbix_proxy_startpreprocessors`: Number of pre-forked instances of preprocessing workers. The preprocessing manager process is automatically started when a preprocessor worker is started.This parameter is supported since Zabbix 4.2.0. +* `zabbix_proxy_username`: Default: `zabbix`. The name of the account on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_proxy_userid`: The UID of the account on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_proxy_groupname`: Default: `zabbix`. The name of the group of the user on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_proxy_groupid`: The GID of the group on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_proxy_include_mode`: Default: `0755`. The "mode" for the directory configured with `zabbix_proxy_include`. +* `zabbix_proxy_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. + +### Database specific + +* `zabbix_proxy_dbhost_run_install`: Default: `True`. When set to `True`, sql files will be executed on the host running the database. +* `zabbix_proxy_database`: Default: `pgsql`. The type of database used. Can be: `mysql`, `pgsql` or `sqlite3` +* `zabbix_proxy_database_long`: Default: `postgresql`. The type of database used, but long name. Can be: `mysql`, `postgresql` or `sqlite3` +* `zabbix_proxy_dbhost`: The hostname on which the database is running. Will be ignored when `sqlite3` is used as database. +* `zabbix_proxy_real_dbhost`: The hostname of the dbhost that is running behind a loadbalancer/VIP (loadbalancers doesn't accept ssh connections) Will be ignored when `sqlite3` is used as database. +* `zabbix_proxy_dbname`: The database name which is used by the Zabbix Proxy. +* `zabbix_proxy_dbuser`: The database username which is used by the Zabbix Proxy. Will be ignored when `sqlite3` is used as database. +* `zabbix_proxy_dbpassword`: The database user password which is used by the Zabbix Proxy. Will be ignored when `sqlite3` is used as database. +* `zabbix_proxy_dbport`: The database port which is used by the Zabbix Proxy. Will be ignored when `sqlite3` is used as database. +* `zabbix_database_creation`: Default: `True`. When you don't want to create the database including user, you can set it to False. +* `zabbix_proxy_install_database_client`: Default: `True`. False does not install database client. Default true +* `zabbix_database_sqlload`:True / False. When you don't want to load the sql files into the database, you can set it to False. +* `zabbix_proxy_dbencoding`: Default: `utf8`. The encoding for the MySQL database. +* `zabbix_proxy_dbcollation`: Default: `utf8_bin`. The collation for the MySQL database.zabbix_proxy_ + +### TLS Specific configuration + +These variables are specific for Zabbix 3.0 and higher: + +* `zabbix_proxy_tlsconnect`: How the agent should connect to server or proxy. Used for active checks. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_proxy_tlsaccept`: What incoming connections to accept. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_proxy_tlscafile`: Full pathname of a file containing the top-level CA(s) certificates for peer certificate verification. +* `zabbix_proxy_tlscrlfile`: Full pathname of a file containing revoked certificates. +* `zabbix_proxy_tlsservercertissuer`: Allowed server certificate issuer. +* `zabbix_proxy_tlsservercertsubject`: Allowed server certificate subject. +* `zabbix_proxy_tlscertfile`: Full pathname of a file containing the agent certificate or certificate chain. +* `zabbix_proxy_tlskeyfile`: Full pathname of a file containing the agent private key. +* `zabbix_proxy_dbtlsconnect`: Setting this option enforces to use TLS connection to database: + +`required` - connect using TLS +`verify_ca` - connect using TLS and verify certificate +`verify_full` - connect using TLS, verify certificate and verify that database identity specified by DBHost matches its certificate + +On `MySQL` starting from 5.7.11 and `PostgreSQL` the following values are supported: `required`, `verify`, `verify_full`. On MariaDB starting from version 10.2.6 `required` and `verify_full` values are supported. +By default not set to any option and the behaviour depends on database configuration. +This parameter is supported since Zabbix 5.0.0. + +* `zabbix_proxy_dbtlscafile`: Full pathname of a file containing the top-level CA(s) certificates for database certificate verification. This parameter is supported since Zabbix 5.0.0. +* `zabbix_proxy_dbtlscertfile`: Full pathname of file containing Zabbix Proxy certificate for authenticating to database. This parameter is supported since Zabbix 5.0.0. +* `zabbix_proxy_dbtlskeyfile`: Full pathname of file containing the private key for authenticating to database. This parameter is supported since Zabbix 5.0.0. +* `zabbix_proxy_dbtlscipher`: The list of encryption ciphers that Zabbix Proxy permits for TLS protocols up through TLSv1.2. Supported only for MySQL.This parameter is supported since Zabbix 5.0.0. +* `zabbix_proxy_dbtlscipher13`: The list of encryption ciphersuites that Zabbix Proxy permits for TLSv1.3 protocol. Supported only for MySQL, starting from version 8.0.16. This parameter is supported since Zabbix 5.0.0. + +## proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +## Database + +With Zabbix Proxy you can make use of 2 different databases: + +* `mysql` +* `postgresql` +* `SQLite3` + +In the following paragraphs we dive into both setups. + +### MySQL + +To make the Zabbix Proxy work with a `MySQL` database, there are 2 types on setup: + +1. Local setup, `MySQL` running on same host as the Zabbix Proxy; +2. Separate setup, `MySQL` running on a different host than the Zabbix Proxy. + +#### Local Setup + +We need to have the following dependencies met: + +1. Find an (Ansible) role that will install a `MySQL` instance on the host. Example: `geerlingguy.mysql` can be used, but also others can be used. Please make sure that before installing the Zabbix Proxy, you have a fully functional `MySQL` instance running. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_proxy_database: mysql +zabbix_proxy_database_long: mysql +zabbix_proxy_dbport: 3306 +zabbix_proxy_dbpassword: +``` + +Please generate a value for the `zabbix_proxy_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-proxy role will create an database and username (With the provided value for the password) in `MySQL`. +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Proxy with `MySQL` will be running. + +#### Separate Setup + +We need to have the following dependencies met: + +1. We need to either have a `MySQL` instance running somewhere in the environment. If this is the case, we need to have a username/password combination that is allowed to create a database and an user account. If there isn't one, please make sure there is one. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_proxy_database: mysql +zabbix_proxy_database_long: mysql +zabbix_proxy_dbport: 3306 +zabbix_proxy_dbhost: mysql-host +zabbix_proxy_dbhost_run_install: false +zabbix_proxy_dbpassword: +zabbix_proxy_privileged_host: '%' +zabbix_proxy_mysql_login_host: mysql-host +zabbix_proxy_mysql_login_user: root +zabbix_proxy_mysql_login_password: changeme +zabbix_proxy_mysql_login_port: 3306 +``` + +Please generate a value for the `zabbix_proxy_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-proxy role will create an database and username (With the provided value for the password) in `MySQL`. + +The `zabbix_proxy_privileged_host` can be set to the hostname/ip of the host running Zabbix Proxy for security related purposes. Also make sure that `zabbix_proxy_mysql_login_password` is set to the correct password for the user provided with `zabbix_proxy_mysql_login_host` to create a database and user in the `MySQL` instance. + +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Proxy with `MySQL` on a different host will be running. + +### PostgreSQL + +To make the Zabbix Proxy work with a `PgSQL` database, there are 2 types on setup: + +1. Local setup, `PgSQL` running on same host as the Zabbix Proxy; +2. Separate setup, `PgSQL` running on a different host than the Zabbix Proxy. + +#### Local Setup + +We need to have the following dependencies met: + +1. Find an (Ansible) role that will install a `PgSQL` instance on the host. Example: `geerlingguy.postgresql` can be used, but also others can be used. Please make sure that before installing the Zabbix Proxy, you have a fully functional `PgSQL` instance running. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_proxy_database: pgsql +zabbix_proxy_database_long: postgresql +zabbix_proxy_dbport: 5432 +zabbix_proxy_dbpassword: +``` + +Please generate a value for the `zabbix_proxy_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-proxy role will create an database and username (With the provided value for the password) in `PgSQL`. +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Proxy with `PgSQL` will be running. + +#### Separate Setup + +We need to have the following dependencies met: + +1. We need to either have a `PgSQL` instance running somewhere in the environment. If this is the case, we need to have a username/password combination that is allowed to create a database and an user account. If there isn't one, please make sure there is one. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_proxy_database: pgsql +zabbix_proxy_database_long: postgresql +zabbix_proxy_dbport: 5432 +zabbix_proxy_dbhost: pgsql-host +zabbix_proxy_dbhost_run_install: false +zabbix_proxy_dbpassword: +zabbix_proxy_privileged_host: '%' +zabbix_proxy_pgsql_login_host: pgsql-host +zabbix_proxy_pgsql_login_user: postgres +zabbix_proxy_pgsql_login_password: changeme +zabbix_proxy_pgsql_login_port: 5432 +``` + +Please generate a value for the `zabbix_proxy_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-proxy role will create an database and username (With the provided value for the password) in `PgSQL`. + +The `zabbix_proxy_privileged_host` can be set to the hostname/ip of the host running Zabbix Proxy for security related purposes. Also make sure that `zabbix_proxy_mysql_login_password` is set to the correct password for the user provided with `zabbix_proxy_mysql_login_host` to create a database and user in the `PgSQL` instance. + +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Proxy with `PgSQL` on a different host will be running.zabbix_proxy_ + +### SQLite3 + +The SQLite3 can only be used on the same host as on which the Zabbix Proxy is running. If you want to use a seperate host for running the database for the proxy, please consider going for MySQL or PostGreSQL. + +The following properties needs to be set when using `SQLite3` as the database: + +```yaml +zabbix_proxy_database: sqlite3 +zabbix_proxy_database_long: sqlite3 +zabbix_proxy_dbname: /path/to/sqlite3.db +``` + +NOTE: When using `zabbix_proxy_dbname: zabbix_proxy` (Which is default with this role), it will automatically be stored on `/var/lib/zabbix/zabbix_proxy.db` + +## Zabbix API variables + +These variables need to be overridden when you want to make use of the zabbix-api for automatically creating and or updating hosts. Host encryption configuration will be set to match agent configuration. + +When `zabbix_api_create_proxy` is set to `True`, it will install on the host executing the Ansible playbook the `zabbix-api` python module. + +* `zabbix_url`: The url on which the Zabbix webpage is available. Example: http://zabbix.example.com +* `zabbix_api_http_user`: The http user to access zabbix url with Basic Auth +* `zabbix_api_http_password`: The http password to access zabbix url with Basic Auth +* `zabbix_api_create_proxy`: When you want to enable the Zabbix API to create/delete the proxy. This has to be set to `True` if you want to make use of `zabbix_create_proxy`. Default: `False` +* `zabbix_api_user`: Username of user which has API access. +* `zabbix_api_pass`: Password for the user which has API access. +* `zabbix_create_proxy`: present (Default) if the proxy needs to be created or absent if you want to delete it. This only works when `zabbix_api_create_proxy` is set to `True`. +* `zabbix_proxy_status`: active (Default) if the proxy needs to be active or passive. + +# Example Playbook + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + +```yaml + - hosts: zabbix-proxy + roles: + - role: community.zabbix.zabbix_proxy + zabbix_server_host: 192.168.1.1 + zabbix_proxy_database: mysql + zabbix_proxy_database_long: mysql +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully. + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_SERVER_ROLE.md b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_SERVER_ROLE.md new file mode 100644 index 00000000..61808c7c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_SERVER_ROLE.md @@ -0,0 +1,339 @@ +# community.zabbix.zabbix_server role + +![Zabbix Server](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_server/badge.svg) + +**Table of Contents** + +- [Overview](#overview) +- [Requirements](#requirements) + * [Operating systems](#operating-systems) + * [Zabbix Versions](#zabbix-versions) +- [Installation](#installation) +- [Role Variables](#role-variables) + * [Main variables](#main-variables) + + [Overall Zabbix](#overall-zabbix) + + [SElinux](#selinux) + + [Zabbix Server](#zabbix-server) + + [Database specific](#database-specific) + + [TLS Specific configuration](#tls-specific-configuration) + + [Custom Zabbix Scripts](#custom-zabbix-scripts) + * [proxy](#proxy) + * [Database](#database) + + [MySQL](#mysql) + - [Local Setup](#local-setup) + - [Separate Setup](#separate-setup) + + [PostgreSQL](#postgresql) + - [Local Setup](#local-setup-1) + - [Separate Setup](#separate-setup-1) +- [Example Playbook](#example-playbook) +- [Molecule](#molecule) +- [License](#license) +- [Author Information](#author-information) + +# Overview + +This is a Ansible role for installing and maintaining the zabbix-server. This will only install the Zabbix Server component and not the Zabbix Web. + +# Requirements + +## Operating systems + +This role will work on the following operating systems: + + * Red Hat + * Debian + * Ubuntu + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +## Zabbix Versions + +See the following list of supported Operating systems with the Zabbix releases: + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +See https://support.zabbix.com/browse/ZBX-18790 why RHEL7 is not supported anymore. + +# Installation + +Installing this role is very simple: `ansible-galaxy install community.zabbix.zabbix_server` + +Please be aware that this role only installs the Zabbix Server and not the Zabbix Web. If you do want to have a Zabbix Web, please execute the following command: `ansible-galaxy install community.zabbix.zabbix_web` + +# Role Variables + +## Main variables + +The following is an overview of all available configuration default for this role. + +### Overall Zabbix + +* `zabbix_server_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. +* `zabbix_service_state`: Default: `started`. Can be overridden to stopped if needed +* `zabbix_service_enabled`: Default: `True` Can be overridden to `False` if needed + +### SElinux + +* `zabbix_selinux`: Default: `False`. Enables an SELinux policy so that the server will run. +* `selinux_allow_zabbix_can_network`: Default: `False`. +* `selinux_allow_zabbix_can_http`: Default: `False`. + +### Zabbix Server + +* `zabbix_server_package_state`: Default: `present`. Can be overridden to `latest` to update packages when needed. +* `zabbix_server_listenport`: Default: `10051`. On which port the Zabbix Server is available. +* `zabbix_server_install_recommends`: Default: `True`. `False` does not install the recommended packages that come with the zabbix-server install. +* `zabbix_server_manage_service`: Default: `True`. When you run multiple Zabbix servers in a High Available cluster setup (e.g. pacemaker), you don't want Ansible to manage the zabbix-server service, because Pacemaker is in control of zabbix-server service and in this case, it needs to be set to `False`. +* `zabbix_proxy_startpreprocessors`: Number of pre-forked instances of preprocessing workers. The preprocessing manager process is automatically started when a preprocessor worker is started. This parameter is supported since Zabbix 4.2.0. +* `zabbix_server_username`: Default: `zabbix`. The name of the account on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_server_userid`: The UID of the account on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_server_groupname`: Default: `zabbix`. The name of the group of the user on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_server_groupid`: The GID of the group on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_server_include_mode`: Default: `0755`. The "mode" for the directory configured with `zabbix_server_include`. +* `zabbix_server_conf_mode`: Default: `0640`. The "mode" for the Zabbix configuration file. + +### Database specific + +* `zabbix_server_dbhost_run_install`: Default: `True`. When set to `True`, sql files will be executed on the host running the database. +* `zabbix_server_database`: Default: `pgsql`. The type of database used. Can be: `mysql` or `pgsql` +* `zabbix_server_database_long`: Default: `postgresql`. The type of database used, but long name. Can be: `mysql` or `postgresql` +* `zabbix_server_dbhost`: The hostname on which the database is running. +* `zabbix_server_real_dbhost`: The hostname of the dbhost that is running behind a loadbalancer/VIP (loadbalancers doesn't accept ssh connections) +* `zabbix_server_dbname`: The database name which is used by the Zabbix Server. +* `zabbix_server_dbuser`: The database username which is used by the Zabbix Server. +* `zabbix_server_dbpassword`: The database user password which is used by the Zabbix Server. +* `zabbix_server_dbport`: The database port which is used by the Zabbix Server. +* `zabbix_database_creation`: Default: `True`. When you don't want to create the database including user, you can set it to False. +* `zabbix_server_install_database_client`: Default: `True`. False does not install database client. Default true +* `zabbix_database_sqlload`:True / False. When you don't want to load the sql files into the database, you can set it to False. +* `zabbix_server_dbencoding`: Default: `utf8`. The encoding for the MySQL database. +* `zabbix_server_dbcollation`: Default: `utf8_bin`. The collation for the MySQL database. + +### TLS Specific configuration + +These variables are specific for Zabbix 3.0 and higher: + +* `zabbix_server_tlsconnect`: How the agent should connect to server or proxy. Used for active checks. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_server_tlsaccept`: What incoming connections to accept. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_server_tlscafile`: Full pathname of a file containing the top-level CA(s) certificates for peer certificate verification. +* `zabbix_server_tlscrlfile`: Full pathname of a file containing revoked certificates. +* `zabbix_server_tlsservercertissuer`: Allowed server certificate issuer. +* `zabbix_server_tlsservercertsubject`: Allowed server certificate subject. +* `zabbix_server_tlscertfile`: Full pathname of a file containing the agent certificate or certificate chain. +* `zabbix_server_tlskeyfile`: Full pathname of a file containing the agent private key. +* `zabbix_server_dbtlsconnect`: Setting this option enforces to use TLS connection to database: + +`required` - connect using TLS +`verify_ca` - connect using TLS and verify certificate +`verify_full` - connect using TLS, verify certificate and verify that database identity specified by DBHost matches its certificate + +On `MySQL` starting from 5.7.11 and `PostgreSQL` the following values are supported: `required`, `verify`, `verify_full`. On MariaDB starting from version 10.2.6 `required` and `verify_full` values are supported. +By default not set to any option and the behaviour depends on database configuration. +This parameter is supported since Zabbix 5.0.0. + +* `zabbix_server_dbtlscafile`: Full pathname of a file containing the top-level CA(s) certificates for database certificate verification. This parameter is supported since Zabbix 5.0.0. +* `zabbix_server_dbtlscertfile`: Full pathname of file containing Zabbix server certificate for authenticating to database. This parameter is supported since Zabbix 5.0.0. +* `zabbix_server_dbtlskeyfile`: Full pathname of file containing the private key for authenticating to database. This parameter is supported since Zabbix 5.0.0. +* `zabbix_server_dbtlscipher`: The list of encryption ciphers that Zabbix server permits for TLS protocols up through TLSv1.2. Supported only for MySQL.This parameter is supported since Zabbix 5.0.0. +* `zabbix_server_dbtlscipher13`: The list of encryption ciphersuites that Zabbix server permits for TLSv1.3 protocol. Supported only for MySQL, starting from version 8.0.16. This parameter is supported since Zabbix 5.0.0. + +### Custom Zabbix Scripts + +Define these variables to copy scripts to your respective scripts path. + +* `zabbix_server_alertscripts`: List of alertscripts to be added to `zabbix_server_alertscriptspath` +* `zabbix_server_externalscripts`: List of alertscripts to be added to `zabbix_server_externalscriptspath` + +Example: + +```yaml + zabbix_server_alertscripts: + - path: "{{ lookup('first_found', 'zabbix-scripts/somescript.php') }}" + name: "somescript.php" +``` + +## proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +## Database + +With Zabbix Server you can make use of 2 different databases: + +* `mysql` +* `postgresql` + +In the following paragraphs we dive into both setups. + +### MySQL + +To make the Zabbix Server work with a `MySQL` database, there are 2 types on setup: + +1. Local setup, `MySQL` running on same host as the Zabbix Server; +2. Separate setup, `MySQL` running on a different host than the Zabbix Server. + +#### Local Setup + +We need to have the following dependencies met: + +1. Find an (Ansible) role that will install a `MySQL` instance on the host. Example: `geerlingguy.mysql` can be used, but also others can be used. Please make sure that before installing the Zabbix Server, you have a fully functional `MySQL` instance running. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_server_database: mysql +zabbix_server_database_long: mysql +zabbix_server_dbport: 3306 +zabbix_server_dbpassword: +``` + +Please generate a value for the `zabbix_server_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-server role will create an database and username (With the provided value for the password) in `MySQL`. +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Server with `MySQL` will be running. + +#### Separate Setup + +We need to have the following dependencies met: + +1. We need to either have a `MySQL` instance running somewhere in the environment. If this is the case, we need to have a username/password combination that is allowed to create a database and an user account. If there isn't one, please make sure there is one. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_server_database: mysql +zabbix_server_database_long: mysql +zabbix_server_dbport: 3306 +zabbix_server_dbhost: mysql-host +zabbix_server_dbhost_run_install: false +zabbix_server_dbpassword: +zabbix_server_privileged_host: '%' +zabbix_server_mysql_login_host: mysql-host +zabbix_server_mysql_login_user: root +zabbix_server_mysql_login_password: changeme +zabbix_server_mysql_login_port: 3306 +``` + +Please generate a value for the `zabbix_server_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-server role will create an database and username (With the provided value for the password) in `MySQL`. + +The `zabbix_server_privileged_host` can be set to the hostname/ip of the host running Zabbix Server for security related purposes. Also make sure that `zabbix_server_mysql_login_password` is set to the correct password for the user provided with `zabbix_server_mysql_login_host` to create a database and user in the `MySQL` instance. + +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Server with `MySQL` on a different host will be running. + +### PostgreSQL + +To make the Zabbix Server work with a `PgSQL` database, there are 2 types on setup: + +1. Local setup, `PgSQL` running on same host as the Zabbix Server; +2. Separate setup, `PgSQL` running on a different host than the Zabbix Server. + +#### Local Setup + +We need to have the following dependencies met: + +1. Find an (Ansible) role that will install a `PgSQL` instance on the host. Example: `geerlingguy.postgresql` can be used, but also others can be used. Please make sure that before installing the Zabbix Server, you have a fully functional `PgSQL` instance running. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_server_database: pgsql +zabbix_server_database_long: postgresql +zabbix_server_dbport: 5432 +zabbix_server_dbpassword: +``` + +Please generate a value for the `zabbix_server_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-server role will create an database and username (With the provided value for the password) in `PgSQL`. +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Server with `PgSQL` will be running. + +#### Separate Setup + +We need to have the following dependencies met: + +1. We need to either have a `PgSQL` instance running somewhere in the environment. If this is the case, we need to have a username/password combination that is allowed to create a database and an user account. If there isn't one, please make sure there is one. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_server_database: pgsq; +zabbix_server_database_long: postgresql +zabbix_server_dbport: 5432 +zabbix_server_dbhost: pgsql-host +zabbix_server_dbhost_run_install: false +zabbix_server_dbpassword: +zabbix_server_privileged_host: '%' +zabbix_server_pgsql_login_host: pgsql-host +zabbix_server_pgsql_login_user: postgres +zabbix_server_pgsql_login_password: changeme +zabbix_server_pgsql_login_port: 5432 +``` + +Please generate a value for the `zabbix_server_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-server role will create an database and username (With the provided value for the password) in `PgSQL`. + +The `zabbix_server_privileged_host` can be set to the hostname/ip of the host running Zabbix Server for security related purposes. Also make sure that `zabbix_server_mysql_login_password` is set to the correct password for the user provided with `zabbix_server_mysql_login_host` to create a database and user in the `PgSQL` instance. + +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Server with `PgSQL` on a different host will be running. + +# Example Playbook + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + +```yaml + - hosts: zabbix-server + roles: + - role: community.zabbix.zabbix_server + zabbix_server_database: mysql + zabbix_server_database_long: mysql +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via Github Actions to validate the change on a new installation. Each PR should result into a correct working Zabbix Server installation and PR's will not be merged once this process fails. + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_WEB_ROLE.md b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_WEB_ROLE.md new file mode 100644 index 00000000..fab07dc1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/docs/ZABBIX_WEB_ROLE.md @@ -0,0 +1,322 @@ +# community.zabbix.zabbix_web role + +![Zabbix Web](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_web/badge.svg) + +**Table of Contents** + +- [Overview](#overview) +- [Requirements](#requirements) + - [Operating Systems](#operating-systems) + - [Zabbix Versions](#zabbix-versions) +- [Installation](#installation) +- [Role Variables](#role-variables) + - [Main variables](#main-variables) + - [Overall Zabbix](#overall-zabbix) + - [Zabbix Web specific](#zabbix-web-specific) + - [Apache configuration](#apache-configuration) + - [Nginx configuration](#nginx-configuration) + - [PHP-FPM](#php-fpm) + - [Zabbix Server](#zabbix-server) + * [proxy](#proxy) +- [Example Playbook](#example-playbook) + - [Single instance](#single-instance) + - [Multi host setup](#multi-host-setup) + - [Adding Environment Variables for zabbix_web](#adding-environment-variables-for-zabbixweb) + - [Using Elasticsearch for history storage](#using-elasticsearch-for-history-storage) +- [Molecule](#molecule) +- [License](#license) +- [Author Information](#author-information) + +# Overview + +# Requirements +## Operating Systems + +This role will work on the following operating systems: + + * RedHat + * Debian + * Ubuntu + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +## Zabbix Versions + +See the following list of supported Operating Systems with the Zabbix releases. + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | V | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +# Installation + +Installing this role is very simple: `ansible-galaxy install community.zabbix.zabbix_web` + +When the Zabbix Web needs to be running on the same host as the Zabbix Server, please also install the Zabbix Server by executing the following command: `ansible-galaxy install community.zabbix.zabbix_server` + +Default username/password for the Zabbix Web interface is the default. + +Username: Admin +Password: zabbix + +# Role Variables + +## Main variables + +The following is an overview of all available configuration defaults for this role. + +### Overall Zabbix + +* `zabbix_web_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. + +* `zabbix_web_package_state`: Default: `present`. Can be overridden to `latest` to update packages when needed. +* `zabbix_web_centos_release`: Default: True. When the `centos-release-scl` repository needs to be enabled. This is required when using Zabbix 5.0 due to installation of a recent version of `PHP`. +* `zabbix_web_rhel_release`: Default: True. When the `scl-utils` repository needs to be enabled. This is required when using Zabbix 5.0 due to installation of a recent version of `PHP`. +* `zabbix_web_doubleprecision`: Default: `False`. For upgraded installations, please read database [upgrade notes](https://www.zabbix.com/documentation/current/manual/installation/upgrade_notes_500) (Paragraph "Enabling extended range of numeric (float) values") before enabling this option. +* `zabbix_web_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. + +### Zabbix Web specific + +* `zabbix_url`: This is the url on which the zabbix web interface is available. Default is zabbix.example.com, you should override it. For example, see "Example Playbook" +* `zabbix_url_aliases`: A list with Aliases for the Apache Virtual Host configuration. +* `zabbix_timezone`: Default: `Europe/Amsterdam`. This is the timezone. The Apache Virtual Host needs this parameter. +* `zabbix_vhost`: Default: `true`. When you don't want to create an Apache Virtual Host configuration, you can set it to False. +* `zabbix_web_env`: (Optional) A Dictionary of PHP Environments settings. +* `zabbix_web_conf_web_user`: When provided, the user (which should already exist on the host) will be used for ownership for web/php related processes. (Default set to either `apache` (`www-data` for Debian) or `nginx`). +* `zabbix_web_conf_web_group`: When provided, the group (which should already exist on the host) will be used for ownership for web/php related processes. (Default set to either `apache` (`www-data` for Debian) or `nginx`). +* `zabbix_web_htpasswd`: (Optional) Allow HTTP authentication at the webserver level via a htpasswd file. +* `zabbix_web_htpasswd_file`: Default: `/etc/zabbix/web/htpasswd`. Allows the change the default path to the htpasswd file. +* `zabbix_web_htpasswd_users`: (Optional) Dictionary for creating users via `htpasswd_user` and passphrases via `htpasswd_pass` in htpasswd file. +* `zabbix_web_allowlist_ips`: (Optional) Allow web access at webserver level to a list of defined IPs or CIDR. + +#### Apache configuration + +* `zabbix_apache_vhost_port`: The port on which Zabbix HTTP vhost is running. +* `zabbix_apache_vhost_tls_port`: The port on which Zabbix HTTPS vhost is running. +* `zabbix_apache_vhost_listen_ip`: On which interface the Apache Virtual Host is available. +* `zabbix_apache_can_connect_ldap`: Default: `false`. Set SELinux boolean to allow httpd to connect to LDAP. +* `zabbix_php_install`: Default: `true`. True / False. Switch for extra install of packages for PHP, currently on for Debian/Ubuntu. +* `zabbix_web_max_execution_time`: +* `zabbix_web_memory_limit`: +* `zabbix_web_post_max_size`: +* `zabbix_web_upload_max_filesize`: +* `zabbix_web_max_input_time`: +* `zabbix_apache_include_custom_fragment`: Default: `true`. Includes php_value vars max_execution_time, memory_limit, post_max_size, upload_max_filesize, max_input_time and date.timezone in vhost file.. place those in php-fpm configuration. +* `zabbix_apache_tls`: If the Apache vhost should be configured with TLS encryption or not. +* `zabbix_apache_redirect`: If a redirect should take place from HTTP to HTTPS +* `zabbix_apache_tls_crt`: The path to the TLS certificate file. +* `zabbix_apache_tls_key`: The path to the TLS key file. +* `zabbix_apache_tls_chain`: The path to the TLS certificate chain file. +* `zabbix_apache_SSLPassPhraseDialog`: Type of pass phrase dialog for encrypted private keys. +* `zabbix_apache_SSLSessionCache`: Type of the global/inter-process SSL Session Cache +* `zabbix_apache_SSLSessionCacheTimeout`: Number of seconds before an SSL session expires in the Session Cache +* `zabbix_apache_SSLCryptoDevice`: Enable use of a cryptographic hardware accelerator + +When `zabbix_apache_tls_crt`, `zabbix_apache_tls_key` and/or `zabbix_apache_tls_chain` are used, make sure that these files exists before executing this role. The Zabbix-Web role will not install the mentioned files. + +See https://httpd.apache.org/docs/current/mod/mod_ssl.html for SSL* configuration options for Apache HTTPD. + +#### Nginx configuration + +* `zabbix_nginx_vhost_port`: The port on which Zabbix HTTP vhost is running. +* `zabbix_nginx_vhost_tls_port`: The port on which Zabbix HTTPS vhost is running. +* `zabbix_nginx_tls`: If the Nginx vhost should be configured with TLS encryption or not. +* `zabbix_nginx_tls_crt`: The path to the TLS certificate file. +* `zabbix_nginx_tls_key`: The path to the TLS key file. +* `zabbix_nginx_tls_dhparam`: The path to the TLS DHParam file. +* `zabbix_nginx_tls_session_cache`: Type of the global/inter-process SSL Session Cache +* `zabbix_nginx_tls_session_timeout`: +* `zabbix_nginx_tls_session_tickets`: +* `zabbix_nginx_tls_protocols`: The TLS Protocols to accept. +* `zabbix_nginx_tls_ciphers`: The TLS Ciphers to be allowed. + +When `zabbix_nginx_tls_crt` and `zabbix_nginx_tls_key` are used, make sure that these files exists before executing this role. The Zabbix-Web role will not install the mentioned files. + +#### PHP-FPM + +The following properties are specific to Zabbix 5.0 and for the PHP(-FPM) configuration: + +* `zabbix_php_version`: Either `7.3` or `7.4` (Based on the OS Family). When you want to override the PHP Version. +* `zabbix_php_fpm_session`: The directory where sessions will be stored. If none are provided, defaults are used. +* `zabbix_php_fpm_listen`: The path to a socket file or ipaddress:port combination on which PHP-FPM needs to listen. If none are provided, defaults are used. +* `zabbix_php_fpm_conf_listen`: Default: `true`. If we want to configure the `zabbix_php_fpm_listen` in the PHP-FPM configuration file. +* `zabbix_php_fpm_conf_user`: The owner of the socket file (When `zabbix_php_fpm_listen` contains a patch to a socket file). +* `zabbix_php_fpm_conf_enable_user`: Default: `true`. If we want to configure the owner of the `zabbix_php_fpm_listen` in the PHP-FPM configuration file. +* `zabbix_php_fpm_conf_group`: The group of the owner of the socket file (When `zabbix_php_fpm_listen` contains a patch to a socket file). +* `zabbix_php_fpm_conf_enable_group`: Default: `true`. If we want to configure the group of the `zabbix_php_fpm_listen` in the PHP-FPM configuration file. +* `zabbix_php_fpm_conf_mode`: The mode for the socket file (When `zabbix_php_fpm_listen` contains a patch to a socket file). +* `zabbix_php_fpm_conf_enable_mode`: Default: `true`. If we want to configure the mode of the `zabbix_php_fpm_listen` in the PHP-FPM configuration file. +* `zabbix_php_fpm_dir_etc`: etc HOME root directory of PHP-FPM setup. +* `zabbix_php_fpm_dir_var`: Var HOME root directory of PHP-FPM setup. + +### Zabbix Server + +* `zabbix_server_name`: The name of the Zabbix Server. +* `zabbix_server_database`: The type of database used. Can be: mysql or pgsql +* `zabbix_server_database_long`: The type of database used, but long name. Can be: mysql or postgresql +* `zabbix_server_hostname`: The hostname on which the zabbix-server is running. Default set to: {{ inventory_hostname }} +* `zabbix_server_listenport`: On which port the Zabbix Server is available. Default: 10051 +* `zabbix_server_dbhost`: The hostname on which the database is running. +* `zabbix_server_dbname`: The database name which is used by the Zabbix Server. +* `zabbix_server_dbuser`: The database username which is used by the Zabbix Server. +* `zabbix_server_dbpassword`: The database user password which is used by the Zabbix Server. +* `zabbix_server_dbport`: The database port which is used by the Zabbix Server. + +The following properties are related when using Elasticsearch for history storage: + +* `zabbix_server_history_url`: String with url to the Elasticsearch server or a list if the types are stored on different Elasticsearch URLs. +* `zabbix_server_history_types`: List of history types to store in Elasticsearch. + +See the following links for more information regarding Zabbix and Elasticsearch +https://www.zabbix.com/documentation/3.4/manual/appendix/install/elastic_search_setup +https://www.zabbix.com/documentation/4.0/manual/appendix/install/elastic_search_setup + +## proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +# Example Playbook + +There are two ways of using the zabbix-web: + +* Single instance +* Multi host setup + +## Single instance + +When there is one host running both Zabbix Server and the Zabbix Web (Running MySQL as database): + +```yaml +- hosts: zabbix-server + become: yes + roles: + - role: geerlingguy.apache + - role: community.zabbix.zabbix_server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + - role: community.zabbix.zabbix_web + zabbix_url: zabbix.mydomain.com + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 +``` + +## Multi host setup + +This is a two host setup. On one host (Named: "zabbix-server") the Zabbix Server is running, and the other host (Named: zabbix-web) runs Zabbix Web (with MySQL as database): + +```yaml +- hosts: zabbix-server + become: yes + roles: + - role: community.zabbix.zabbix_server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + +- hosts: zabbix-web + become: yes + roles: + - role: geerlingguy.apache + - role: community.zabbix.zabbix_web + zabbix_url: zabbix.mydomain.com + zabbix_server_hostname: zabbix-server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 +``` + +## Adding Environment Variables for zabbix_web + +Sometimes you need to add environment variables to your +zabbix.conf.php, for example to add LDAP CA certificates. To do this add a `zabbix_web_env` dictionary: + +```yaml +- hosts: zabbix-web + become: yes + roles: + - role: geerlingguy.apache + - role: community.zabbix.zabbix_web + zabbix_url: zabbix.mydomain.com + zabbix_server_hostname: zabbix-server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + zabbix_web_env: + LDAPTLS_CACERT: /etc/ssl/certs/ourcert.pem +``` + +## Using Elasticsearch for history storage + +To use Elasticsearch for history storage you need to configure the `zabbix_server_history_url` and `zabbix_server_history_types`. You will also need to configure Elasticsearch +in the zabbix_server role. + +Zabbix can store the following history types +in Elasticsearch: +* Numeric (unsigned) - `uint` +* Numeric (float) - `dbl` +* Character - `str` +* Log - `log` +* Text - `text` + +To store all history types in the same history URL the following variables should be set (make sure history url points to your Elasticsearch cluster): + +``` +zabbix_server_history_url: "http://localhost:9200" +zabbix_server_history_types: + - 'str' + - 'text' + - 'log' + - 'uint' + - 'dbl' +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully. + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/meta/runtime.yml b/collections-debian-merged/ansible_collections/community/zabbix/meta/runtime.yml new file mode 100644 index 00000000..2ee3c9fa --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/meta/runtime.yml @@ -0,0 +1,2 @@ +--- +requires_ansible: '>=2.9.10' diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/requirements.txt b/collections-debian-merged/ansible_collections/community/zabbix/molecule/requirements.txt new file mode 100644 index 00000000..8ed19f2d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/requirements.txt @@ -0,0 +1,11 @@ +# Install CI dependencies for the Zabbix Roles +ansible==2.10.4 +ansible-lint==4.3.7 +docker==4.3.1 +molecule==3.2.1 +molecule-docker==0.2.4 +netaddr==0.8.0 +pytest-testinfra==6.1.0 +zabbix-api==0.5.4 +ipaddr==2.2.0 +ipaddress==1.0.23 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/converge.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/converge.yml new file mode 100644 index 00000000..7ce55d49 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/converge.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: zabbix_agent diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/molecule.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/molecule.yml new file mode 100644 index 00000000..865333b9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/molecule.yml @@ -0,0 +1,71 @@ +--- +driver: + name: docker + +platforms: + - name: zabbix-agent-${MY_MOLECULE_CONTAINER:-centos} + image: ${MY_MOLECULE_IMAGE:-"geerlingguy/docker-centos8-ansible"} + command: ${MY_MOLECULE_DOCKER_COMMAND:-""} + privileged: True + pre_build_image: True + networks: + - name: zabbix + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - ${MY_MOLECULE_GROUP:-agent} + +provisioner: + name: ansible + lint: + name: ansible-lint + env: + ANSIBLE_REMOTE_TMP: /tmp/ + ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix + ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + inventory: + host_vars: + zabbix-agent-centos2: + zabbix_agent2: true + zabbix_agent2_tlsconnect: psk + zabbix_agent2_tlsaccept: psk + zabbix_agent2_tlspskidentity: my_Identity + zabbix_agent2_tlspskfile: /data/certs/zabbix.psk + zabbix_agent2_tlspsk_secret: 97defd6bd126d5ba7fa5f296595f82eac905d5eda270207a580ab7c0cb9e8eab + zabbix_agent2_plugins: + - name: SystemRun + options: + - parameter: LogRemoteCommands + value: 0 + group_vars: + all: + zabbix_agent_src_reinstall: False + zabbix_install_pip_packages: False + zabbix_agent_server: 192.168.3.33 + zabbix_agent_serveractive: 192.168.3.33 + zabbix_agent_listenip: 0.0.0.0 + zabbix_agent_tlsconnect: psk + zabbix_agent_tlsaccept: psk + zabbix_agent_tlspskidentity: my_Identity + zabbix_agent_tlspskfile: /data/certs/zabbix.psk + zabbix_agent_tlspsk_secret: 97defd6bd126d5ba7fa5f296595f82eac905d5eda270207a580ab7c0cb9e8eab + +scenario: + test_sequence: + - dependency + - lint + - cleanup + - destroy + - syntax + - create + - prepare + - converge + # - idempotence + - side_effect + - verify + - cleanup + - destroy +verifier: + name: testinfra + lint: + name: flake8 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/prepare.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/prepare.yml new file mode 100644 index 00000000..73a3385c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/prepare.yml @@ -0,0 +1,86 @@ +--- + +- name: Prepare + hosts: all + tasks: + - name: "Installing packages on CentOS family" + package: + pkg: + - net-tools + - which + state: present + register: zabbix_agent_prepare_packages_install + until: zabbix_agent_prepare_packages_install is succeeded + when: + - ansible_os_family == 'RedHat' + + - name: "Installing packages on CentOS (Sangoma) family" + package: + pkg: + - net-tools + - which + state: present + register: zabbix_agent_prepare_packages_install + until: zabbix_agent_prepare_packages_install is succeeded + when: + - ansible_os_family == 'Sangoma' + + - name: "Installing packages on Debian family" + apt: + name: + - "{{ 'net-tools' if ansible_distribution_major_version not in ['18', '20'] else 'iproute2' }}" + state: present + register: zabbix_agent_prepare_packages_install + until: zabbix_agent_prepare_packages_install is succeeded + when: + - ansible_os_family == 'Debian' + + - name: "Installing packages on Suse family" + shell: zypper install -y python-xml python-libxml2 net-tools which + register: zabbix_agent_prepare_packages_install + until: zabbix_agent_prepare_packages_install is succeeded + when: ansible_os_family == 'Suse' + tags: + - skip_ansible_lint + +- name: Prepare + hosts: docker + tasks: + - name: "Download Docker CE repo file" + get_url: + url: https://download.docker.com/linux/centos/docker-ce.repo + dest: /etc/yum.repos.d/docker-ce.repo + mode: 0644 + register: zabbix_agent_prepare_docker_repo + until: zabbix_agent_prepare_docker_repo is succeeded + + - name: "Installing Epel" + package: + pkg: + - epel-release + state: present + register: zabbix_agent_prepare_docker_install + until: zabbix_agent_prepare_docker_install is succeeded + + - name: "Installing Docker" + package: + pkg: + - docker-ce + - python-pip + - python-setuptools + state: present + register: zabbix_agent_prepare_docker_install + until: zabbix_agent_prepare_docker_install is succeeded + + - name: "Installing Docker Python" + pip: + name: + - docker + state: present + register: zabbix_agent_prepare_docker_install + until: zabbix_agent_prepare_docker_install is succeeded + + - name: "Starting Docker service" + service: + name: docker + state: started diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_agent.py b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_agent.py new file mode 100644 index 00000000..bb4a8586 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_agent.py @@ -0,0 +1,66 @@ +import os +import pytest + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('agent') + + +def test_zabbixagent_running_and_enabled(host): + zabbixagent = host.service("zabbix-agent") + # Find out why this is not working for linuxmint and opensuse + if host.system_info.distribution not in ['linuxmint', 'opensuse', 'ubuntu']: + assert zabbixagent.is_running + assert zabbixagent.is_enabled + + +def test_zabbix_agent_dot_conf(host): + if host.system_info.distribution in ['opensuse']: + passwd = host.file("/etc/zabbix/zabbix-agentd.conf") + else: + passwd = host.file("/etc/zabbix/zabbix_agentd.conf") + assert passwd.user == "root" + assert passwd.group == "root" + assert passwd.mode == 0o644 + + assert passwd.contains("Server=192.168.3.33") + assert passwd.contains("ServerActive=192.168.3.33") + assert passwd.contains("DebugLevel=3") + assert passwd.contains("TLSAccept=psk") + assert passwd.contains("TLSPSKIdentity=my_Identity") + assert passwd.contains("TLSPSKFile=/data/certs/zabbix.psk") + + +def test_zabbix_agent_psk(host): + psk_file = host.file("/data/certs/zabbix.psk") + assert psk_file.user == "zabbix" + assert psk_file.group == "zabbix" + assert psk_file.mode == 0o400 + assert psk_file.contains("97defd6bd126d5ba7fa5f296595f82eac905d5eda270207a580ab7c0cb9e8eab") + + +def test_zabbix_include_dir(host): + zabbixagent = host.file("/etc/zabbix/zabbix_agentd.d") + assert zabbixagent.is_directory + assert zabbixagent.user == "root" + assert zabbixagent.group == "zabbix" + + +def test_socket(host): + # Find out why this is not working for linuxmint and opensus + if host.system_info.distribution not in ['linuxmint', 'opensuse']: + assert host.socket("tcp://0.0.0.0:10050").is_listening + + +@pytest.mark.parametrize("zabbix_packages", [ + ("zabbix-agent"), +]) +def test_zabbix_package(host, zabbix_packages): + zabbixagent = host.package(zabbix_packages) + assert zabbixagent.is_installed + + if host.system_info.distribution == 'debian': + assert zabbixagent.version.startswith("1:5.2") + if host.system_info.distribution == 'centos': + assert zabbixagent.version.startswith("5.2") diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_agent2.py b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_agent2.py new file mode 100644 index 00000000..156304bf --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_agent2.py @@ -0,0 +1,67 @@ +import os +import pytest + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('agent2') + + +def test_zabbixagent_running_and_enabled(host): + zabbixagent = host.service("zabbix-agent2") + # Find out why this is not working for linuxmint and opensuse + if host.system_info.distribution not in ['linuxmint', 'opensuse', 'ubuntu']: + assert zabbixagent.is_running + assert zabbixagent.is_enabled + + +def test_zabbix_agent_dot_conf(host): + if host.system_info.distribution in ['opensuse']: + passwd = host.file("/etc/zabbix/zabbix-agentd.conf") + else: + passwd = host.file("/etc/zabbix/zabbix_agent2.conf") + assert passwd.user == "root" + assert passwd.group == "root" + assert passwd.mode == 0o644 + + assert passwd.contains("Server=192.168.3.33") + assert passwd.contains("ServerActive=192.168.3.33") + assert passwd.contains("DebugLevel=3") + assert passwd.contains("TLSAccept=psk") + assert passwd.contains("TLSPSKIdentity=my_Identity") + assert passwd.contains("TLSPSKFile=/data/certs/zabbix.psk") + assert passwd.contains("Plugins.SystemRun.LogRemoteCommands=0") + + +def test_zabbix_agent_psk(host): + psk_file = host.file("/data/certs/zabbix.psk") + assert psk_file.user == "zabbix" + assert psk_file.group == "zabbix" + assert psk_file.mode == 0o400 + assert psk_file.contains("97defd6bd126d5ba7fa5f296595f82eac905d5eda270207a580ab7c0cb9e8eab") + + +def test_zabbix_include_dir(host): + zabbixagent = host.file("/etc/zabbix/zabbix_agent2.d") + assert zabbixagent.is_directory + assert zabbixagent.user == "root" + assert zabbixagent.group == "zabbix" + + +def test_socket(host): + # Find out why this is not working for linuxmint and opensus + if host.system_info.distribution not in ['linuxmint', 'opensuse']: + assert host.socket("tcp://0.0.0.0:10050").is_listening + + +@pytest.mark.parametrize("zabbix_packages", [ + ("zabbix-agent2"), +]) +def test_zabbix_package(host, zabbix_packages): + zabbixagent = host.package(zabbix_packages) + assert zabbixagent.is_installed + + if host.system_info.distribution == 'debian': + assert zabbixagent.version.startswith("1:5.2") + if host.system_info.distribution == 'centos': + assert zabbixagent.version.startswith("5.2") diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_docker.py b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_docker.py new file mode 100644 index 00000000..a3b96d0b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_agent/tests/test_docker.py @@ -0,0 +1,22 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('docker') + + +def test_docker_running(host): + zabbixagent = host.docker("zabbix-agent") + zabbixagent.is_running + + +def test_zabbix_include_dir(host): + zabbixagent = host.file("/etc/zabbix/zabbix_agentd.d") + assert zabbixagent.is_directory + assert zabbixagent.user == "root" + assert zabbixagent.group == "zabbix" + + +def test_socket(host): + assert host.socket("tcp://0.0.0.0:10050").is_listening diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/converge.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/converge.yml new file mode 100644 index 00000000..ae76d6ee --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/converge.yml @@ -0,0 +1,6 @@ +--- +- name: Converge + hosts: all + roles: + - role: zabbix_javagateway + javagateway_pidfile: /tmp/zabbix_java.pid diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/molecule.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/molecule.yml new file mode 100644 index 00000000..6d5c97c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/molecule.yml @@ -0,0 +1,27 @@ +--- +driver: + name: docker + +platforms: + - name: zabbix-javagateway-${MY_MOLECULE_CONTAINER:-centos} + image: ${MY_MOLECULE_IMAGE:-"geerlingguy/docker-centos8-ansible"} + command: ${MY_MOLECULE_DOCKER_COMMAND:-""} + privileged: True + pre_build_image: True + networks: + - name: zabbix + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + +provisioner: + name: ansible + lint: + name: ansible-lint + env: + ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix + ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/prepare.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/prepare.yml new file mode 100644 index 00000000..9852d377 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/prepare.yml @@ -0,0 +1,57 @@ +--- +- name: Prepare + hosts: all + pre_tasks: + + - name: "Set short version name" + set_fact: + zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}" + + - name: "Installing packages on CentOS" + yum: + name: + - net-tools + - which + - sudo + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family == 'RedHat' + + - name: "Make sure the docs can be installed. (Debian)" + lineinfile: + path: /etc/dpkg/dpkg.cfg.d/excludes + state: absent + regexp: 'path-exclude=/usr/share/doc/*' + when: + - ansible_os_family != 'RedHat' + + # https://github.com/geerlingguy/ansible-role-java/issues/64 + - name: "Apt update" + shell: "apt-get update && mkdir -p /usr/share/man/man1" + args: + warn: False + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family != 'RedHat' + + - name: "Installing packages on NON-CentOS" + apt: + name: + - net-tools + - apt-utils + - procps + - "{{ zabbix_python_prefix }}-pip" + - gpg-agent + - "{{ zabbix_python_prefix }}-apt" + - sudo + - software-properties-common + - openjdk-11-jdk + update_cache: True + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family != 'RedHat' diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/tests/test_default.py b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/tests/test_default.py new file mode 100644 index 00000000..57ff0e12 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_javagateway/tests/test_default.py @@ -0,0 +1,23 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_zabbix_running_and_enabled(host): + zabbix = host.service("zabbix-java-gateway") + assert zabbix.is_running + + +def test_zabbix_java_gateway_dot_conf(host): + zabbix_proxy_conf = host.file("/etc/zabbix/zabbix_java_gateway.conf") + assert zabbix_proxy_conf.user == "zabbix" + assert zabbix_proxy_conf.group == "zabbix" + assert zabbix_proxy_conf.mode == 0o644 + + assert zabbix_proxy_conf.contains("LISTEN_IP=0.0.0.0") + assert zabbix_proxy_conf.contains("LISTEN_PORT=10052") + assert zabbix_proxy_conf.contains("PID_FILE=/run/zabbix/zabbix_java_gateway.pid") + assert zabbix_proxy_conf.contains("START_POLLERS=5") diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/converge.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/converge.yml new file mode 100644 index 00000000..d5413e2a --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/converge.yml @@ -0,0 +1,4 @@ +--- +- hosts: all + roles: + - role: zabbix_proxy diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/destroy.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/destroy.yml new file mode 100644 index 00000000..1a487480 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/destroy.yml @@ -0,0 +1,25 @@ +--- +- name: Destroy + hosts: localhost + connection: local + gather_facts: False + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}" + tasks: + - name: Destroy molecule instance(s) + docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(True) }}" + with_items: "{{ molecule_yml.platforms }}" + + - name: Destroy 3rd party instance(s) + docker_container: + name: '{{ item }}' + state: absent + force_kill: True + with_items: + - mysql-host + - postgresql-host diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml new file mode 100644 index 00000000..7fcb7015 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml @@ -0,0 +1,56 @@ +--- + +driver: + name: docker +platforms: + - name: zabbix-proxy-${MY_MOLECULE_CONTAINER:-mysql-centos} + image: ${MY_MOLECULE_IMAGE:-"geerlingguy/docker-centos8-ansible"} + command: ${MY_MOLECULE_DOCKER_COMMAND:-""} + privileged: True + pre_build_image: True + networks: + - name: zabbix + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - ${MY_MOLECULE_GROUP:-mysql} + +provisioner: + name: ansible + lint: + name: ansible-lint + env: + ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix + ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + inventory: + group_vars: + mysql: + zabbix_proxy_database: mysql + zabbix_proxy_database_long: mysql + zabbix_proxy_dbport: 3306 + zabbix_proxy_dbhost: mysql-host + zabbix_proxy_dbhost_run_install: false + zabbix_proxy_privileged_host: '%' + zabbix_proxy_mysql_login_host: mysql-host + zabbix_proxy_mysql_login_user: root + zabbix_proxy_mysql_login_password: changeme + zabbix_proxy_mysql_login_port: 3306 + postgresql: + zabbix_proxy_database: pgsql + zabbix_proxy_database_long: postgresql + zabbix_proxy_dbport: 5432 + zabbix_proxy_dbhost: postgresql-host + zabbix_proxy_dbhost_run_install: false + zabbix_proxy_pgsql_login_host: postgresql-host + zabbix_proxy_pgsql_login_user: postgres + zabbix_proxy_pgsql_login_password: changeme + zabbix_proxy_pgsql_login_port: 5432 + sqlite3: + zabbix_proxy_database: sqlite3 + zabbix_proxy_database_long: sqlite3 + zabbix_proxy_dbname: /path/to/sqlite3.db + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml new file mode 100644 index 00000000..67b5aaa6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml @@ -0,0 +1,129 @@ +--- +- name: Prepare + hosts: localhost + connection: local + pre_tasks: + + - name: "Create MySQL Container" + docker_container: + name: mysql-host + image: mysql:5.7 + state: started + recreate: yes + networks: + - name: zabbix + env: + MYSQL_ROOT_PASSWORD: changeme + no_log: true + with_items: "{{ molecule_yml.platforms }}" + when: + - '"mysql" in item.groups' + + - name: "Create postgresql Container" + docker_container: + name: postgresql-host + image: postgres + state: started + recreate: yes + networks: + - name: zabbix + env: + POSTGRES_PASSWORD: changeme + no_log: true + with_items: "{{ molecule_yml.platforms }}" + when: + - '"postgresql" in item.groups' + +- name: Prepare + hosts: all + tasks: + + - name: "Set short version name" + set_fact: + zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}" + + - name: "Create group for imaginary host" + add_host: + name: imaginary-host + groups: + - mysql + - postgresql + changed_when: False + + - name: "Installing packages on CentOS" + yum: + name: + - net-tools + - which + - sudo + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family == 'RedHat' + + - name: "Installing packages on CentOS" + yum: + name: + - mysql + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family == 'RedHat' + - inventory_hostname in groups['mysql'] + + - name: "Apt update" + shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" + args: + warn: False + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family != 'RedHat' + + - name: "Installing packages on NON-CentOS" + apt: + name: + - net-tools + - apt-utils + - "{{ zabbix_python_prefix }}-pip" + - gpg-agent + - sudo + - doc-base + update_cache: True + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family != 'RedHat' + + - name: "Configure SUDO." + lineinfile: + dest: /etc/sudoers + line: "Defaults !requiretty" + state: present + + - name: "Make sure the docs can be installed. (RedHat)" + lineinfile: + dest: /etc/yum.conf + line: "tsflags=nodocs" + state: absent + when: + - ansible_os_family == 'RedHat' + + - name: "Make sure the docs can be installed. (Debian)" + lineinfile: + path: /etc/dpkg/dpkg.cfg.d/excludes + state: absent + regexp: 'path-exclude=/usr/share/doc/*' + when: + - ansible_os_family != 'RedHat' + + - name: PyMySQL + pip: + name: PyMySQL + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - inventory_hostname in groups['mysql'] diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/tests/test_default.py b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/tests/test_default.py new file mode 100644 index 00000000..a0edb127 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/tests/test_default.py @@ -0,0 +1,62 @@ +import os +import pytest + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_zabbixproxy_running_and_enabled(host): + zabbix = host.service("zabbix-proxy") + if host.system_info.distribution == 'centos': + assert zabbix.is_enabled + assert zabbix.is_running + else: + assert zabbix.is_running + + +@pytest.mark.parametrize("proxy", [("zabbix-proxy-pgsql"), ("zabbix-proxy-mysql"), ("zabbix-proxy-sqlite3")]) +def test_zabbix_package(host, proxy): + ansible_data = host.ansible.get_variables() + zabbixhost = ansible_data['inventory_hostname'] + + zabbixhost = zabbixhost.replace("-centos", "") + zabbixhost = zabbixhost.replace("-debian", "") + zabbixhost = zabbixhost.replace("-ubuntu", "") + + if zabbixhost == proxy: + if host.system_info.distribution in ['debian', 'ubuntu']: + zabbix_proxy = host.package(proxy) + assert zabbix_proxy.version.startswith("1:5.2") + elif host.system_info.distribution == 'centos': + zabbix_proxy = host.package(proxy) + assert zabbix_proxy.version.startswith("5.2") + assert zabbix_proxy.is_installed + + +def test_zabbix_proxy_dot_conf(host): + zabbix_proxy_conf = host.file("/etc/zabbix/zabbix_proxy.conf") + assert zabbix_proxy_conf.user == "zabbix" + assert zabbix_proxy_conf.group == "zabbix" + assert zabbix_proxy_conf.mode == 0o644 + + assert zabbix_proxy_conf.contains("ListenPort=10051") + assert zabbix_proxy_conf.contains("DebugLevel=3") + + +def test_zabbix_include_dir(host): + zabbix_include_dir = host.file("/etc/zabbix/zabbix_proxy.conf.d") + assert zabbix_include_dir.is_directory + assert zabbix_include_dir.user == "zabbix" + assert zabbix_include_dir.group == "zabbix" + # assert zabbix_include_dir.mode == 0o644 + + +def test_zabbix_proxy_logfile(host): + zabbix_logfile = host.file("/var/log/zabbix/zabbix_proxy.log") + + assert not zabbix_logfile.contains('Access denied for user') + assert not zabbix_logfile.contains('database is down: reconnecting') + assert zabbix_logfile.contains('current database version') + assert zabbix_logfile.contains(r"proxy #0 started \[main process\]") diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/converge.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/converge.yml new file mode 100644 index 00000000..e4ce78fa --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/converge.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + become: True + roles: + - role: zabbix_server diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/destroy.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/destroy.yml new file mode 100644 index 00000000..1a487480 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/destroy.yml @@ -0,0 +1,25 @@ +--- +- name: Destroy + hosts: localhost + connection: local + gather_facts: False + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}" + tasks: + - name: Destroy molecule instance(s) + docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(True) }}" + with_items: "{{ molecule_yml.platforms }}" + + - name: Destroy 3rd party instance(s) + docker_container: + name: '{{ item }}' + state: absent + force_kill: True + with_items: + - mysql-host + - postgresql-host diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/molecule.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/molecule.yml new file mode 100644 index 00000000..b5ab577d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/molecule.yml @@ -0,0 +1,52 @@ +--- + +driver: + name: docker +platforms: + - name: zabbix-server-${MY_MOLECULE_CONTAINER:-mysql-centos} + image: ${MY_MOLECULE_IMAGE:-"geerlingguy/docker-centos8-ansible"} + command: ${MY_MOLECULE_DOCKER_COMMAND:-""} + privileged: True + pre_build_image: True + networks: + - name: zabbix + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - ${MY_MOLECULE_GROUP:-mysql} + +provisioner: + name: ansible + lint: + name: ansible-lint + env: + ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix + ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + inventory: + group_vars: + mysql: + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + zabbix_server_dbhost: mysql-host + zabbix_server_dbhost_run_install: false + zabbix_server_privileged_host: '%' + zabbix_server_mysql_login_host: mysql-host + zabbix_server_mysql_login_user: root + zabbix_server_mysql_login_password: changeme + zabbix_server_mysql_login_port: 3306 + postgresql: + zabbix_server_database: pgsql + zabbix_server_database_long: postgresql + zabbix_server_dbport: 5432 + zabbix_server_dbhost: postgresql-host + zabbix_server_dbhost_run_install: false + zabbix_server_pgsql_login_host: postgresql-host + zabbix_server_pgsql_login_user: postgres + zabbix_server_pgsql_login_password: changeme + zabbix_server_pgsql_login_port: 5432 + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/prepare.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/prepare.yml new file mode 100644 index 00000000..071cdd1f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/prepare.yml @@ -0,0 +1,116 @@ +--- +- name: Prepare + hosts: localhost + connection: local + pre_tasks: + + - name: "Create MySQL Container" + docker_container: + name: mysql-host + image: mysql:5.7 + state: started + recreate: yes + networks: + - name: zabbix + env: + MYSQL_ROOT_PASSWORD: changeme + no_log: true + with_items: "{{ molecule_yml.platforms }}" + when: + - '"mysql" in item.groups' + + - name: "Create postgresql Container" + docker_container: + name: postgresql-host + image: postgres + state: started + recreate: yes + networks: + - name: zabbix + env: + POSTGRES_PASSWORD: changeme + no_log: true + with_items: "{{ molecule_yml.platforms }}" + when: + - '"postgresql" in item.groups' + +- name: Prepare + hosts: all + tasks: + + - name: "Create group for imaginary host" + add_host: + name: imaginary-host + groups: + - mysql + - postgresql + changed_when: False + + - name: "Installing packages on CentOS" + yum: + name: + - net-tools + - which + - sudo + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family == 'RedHat' + + - name: "Installing packages on CentOS" + yum: + name: + - mysql + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family == 'RedHat' + - inventory_hostname in groups['mysql'] + + - name: "Apt update" + shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" + args: + warn: False + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family != 'RedHat' + + - name: "Installing packages on NON-CentOS" + apt: + name: + - net-tools + - apt-utils + - python3-pip + - gpg-agent + - sudo + update_cache: True + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family != 'RedHat' + + - name: "Configure SUDO." + lineinfile: + dest: /etc/sudoers + line: "Defaults !requiretty" + state: present + + - name: "Make sure the docs are installed." + lineinfile: + dest: /etc/yum.conf + line: "tsflags=nodocs" + state: absent + when: + - ansible_os_family == 'RedHat' + + - name: PyMySQL + pip: + name: PyMySQL + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - inventory_hostname in groups['mysql'] diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/tests/test_default.py b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/tests/test_default.py new file mode 100644 index 00000000..0c45ad78 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_server/tests/test_default.py @@ -0,0 +1,62 @@ +import os +import pytest + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_zabbiserver_running_and_enabled(host): + zabbix = host.service("zabbix-server") + if host.system_info.distribution == 'centos': + assert zabbix.is_enabled + assert zabbix.is_running + else: + assert zabbix.is_running + + +@pytest.mark.parametrize("server", [("zabbix-server-pgsql"), ("zabbix-server-mysql")]) +def test_zabbix_package(host, server): + ansible_data = host.ansible.get_variables() + zabbixhost = ansible_data['inventory_hostname'] + + zabbixhost = zabbixhost.replace("-centos", "") + zabbixhost = zabbixhost.replace("-debian", "") + zabbixhost = zabbixhost.replace("-ubuntu", "") + + if zabbixhost == server: + if host.system_info.distribution in ['debian', 'ubuntu']: + zabbix_server = host.package(server) + assert zabbix_server.version.startswith("1:5.2") + elif host.system_info.distribution == 'centos': + zabbix_server = host.package(server) + assert zabbix_server.version.startswith("5.2") + assert zabbix_server.is_installed + + +def test_zabbix_server_dot_conf(host): + zabbix_server_conf = host.file("/etc/zabbix/zabbix_server.conf") + assert zabbix_server_conf.user == "zabbix" + assert zabbix_server_conf.group == "zabbix" + assert zabbix_server_conf.mode == 0o640 + + assert zabbix_server_conf.contains("ListenPort=10051") + assert zabbix_server_conf.contains("DebugLevel=3") + + +def test_zabbix_include_dir(host): + zabbix_include_dir = host.file("/etc/zabbix/zabbix_server.conf.d") + assert zabbix_include_dir.is_directory + assert zabbix_include_dir.user == "zabbix" + assert zabbix_include_dir.group == "zabbix" + # assert zabbix_include_dir.mode == 0o644 + + +def test_zabbix_server_logfile(host): + zabbix_logfile = host.file("/var/log/zabbix/zabbix_server.log") + + assert not zabbix_logfile.contains('Access denied for user') + assert not zabbix_logfile.contains('database is down: reconnecting') + assert zabbix_logfile.contains('current database version') + assert zabbix_logfile.contains(r"server #0 started \[main process\]") diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/converge.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/converge.yml new file mode 100644 index 00000000..bd70be66 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/converge.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: zabbix_web diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/destroy.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/destroy.yml new file mode 100644 index 00000000..1a487480 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/destroy.yml @@ -0,0 +1,25 @@ +--- +- name: Destroy + hosts: localhost + connection: local + gather_facts: False + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}" + tasks: + - name: Destroy molecule instance(s) + docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(True) }}" + with_items: "{{ molecule_yml.platforms }}" + + - name: Destroy 3rd party instance(s) + docker_container: + name: '{{ item }}' + state: absent + force_kill: True + with_items: + - mysql-host + - postgresql-host diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/molecule.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/molecule.yml new file mode 100644 index 00000000..74381e6d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/molecule.yml @@ -0,0 +1,96 @@ +--- +dependency: + name: galaxy + enabled: true + options: + ignore-certs: True + ignore-errors: True + role-file: molecule/zabbix_web/requirements.yml + +driver: + name: docker +platforms: + - name: zabbix-web-${MY_MOLECULE_CONTAINER:-mysql-centos8} + image: ${MY_MOLECULE_IMAGE:-"geerlingguy/docker-centos8-ansible"} + command: ${MY_MOLECULE_DOCKER_COMMAND:-""} + privileged: True + pre_build_image: True + networks: + - name: zabbix + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - ${MY_MOLECULE_GROUP:-mysql} + +provisioner: + name: ansible + lint: + name: ansible-lint + env: + ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix + ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + inventory: + group_vars: + mysql: + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + zabbix_server_dbhost: mysql-host + zabbix_server_dbhost_run_install: false + zabbix_server_privileged_host: '%' + zabbix_server_mysql_login_host: mysql-host + zabbix_server_mysql_login_user: root + zabbix_server_mysql_login_password: changeme + zabbix_server_mysql_login_port: 3306 + postgresql: + zabbix_server_database: pgsql + zabbix_server_database_long: postgresql + zabbix_server_dbport: 5432 + zabbix_server_dbhost: postgresql-host + zabbix_server_dbhost_run_install: false + zabbix_server_pgsql_login_host: postgresql-host + zabbix_server_pgsql_login_user: postgres + zabbix_server_pgsql_login_password: changeme + zabbix_server_pgsql_login_port: 5432 + host_vars: + zabbix-web-pgsql-debian: + zabbix_websrv: apache + php_default_version_debian: 7.4 + zabbix_php_fpm_conf_listen: False + zabbix_url: zabbix-web-pgsql-debian + zabbix_websrv_servername: zabbix-web-pgsql-debian + zabbix-web-mysql-debian: + zabbix_websrv: apache + php_default_version_debian: 7.4 + zabbix_php_fpm_conf_listen: False + zabbix_url: zabbix-web-mysql-debian + zabbix_websrv_servername: zabbix-web-mysql-debian + zabbix-web-pgsql-centos8: + ansible_rhn_repo_disable_gpg_check: True + zabbix_websrv: apache + zabbix_php_fpm_conf_listen: False + zabbix_url: zabbix-web-pgsql-centos8 + zabbix_websrv_servername: zabbix-web-pgsql-centos8 + zabbix-web-mysql-centos8: + ansible_rhn_repo_disable_gpg_check: True + php_fpm_pool_user: nginx + php_fpm_pool_group: nginx + zabbix_websrv: nginx + zabbix_php_fpm_conf_listen: False + zabbix_url: zabbix-web-mysql-centos8 + zabbix_websrv_servername: zabbix-web-mysql-centos8 + zabbix-web-mysql-ubuntu18: + zabbix_websrv: nginx + zabbix_php_fpm_conf_listen: False + zabbix_url: zabbix-web-mysql-ubuntu18 + zabbix_websrv_servername: zabbix-web-mysql-ubuntu18 + zabbix-web-pgsql-ubuntu20: + zabbix_php_fpm_conf_listen: False + zabbix_websrv: apache + zabbix_url: zabbix-web-pgsql-ubuntu20 + zabbix_websrv_servername: zabbix-web-pgsql-ubuntu20 + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/prepare.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/prepare.yml new file mode 100644 index 00000000..afb6d5a3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/prepare.yml @@ -0,0 +1,146 @@ +--- +- name: Prepare + hosts: localhost + connection: local + pre_tasks: + + - name: "Create MySQL Container" + docker_container: + name: mysql-host + image: mysql:5.7 + state: started + recreate: yes + networks: + - name: zabbix + env: + MYSQL_ROOT_PASSWORD: changeme + no_log: true + with_items: "{{ molecule_yml.platforms }}" + when: + - '"mysql" in item.groups' + + - name: "Create postgresql Container" + docker_container: + name: postgresql-host + image: postgres + state: started + recreate: yes + networks: + - name: zabbix + env: + POSTGRES_PASSWORD: changeme + no_log: true + with_items: "{{ molecule_yml.platforms }}" + when: + - '"postgresql" in item.groups' + +- name: Prepare + hosts: all + pre_tasks: + + - name: "Create group for imaginary host" + add_host: + name: imaginary-host + groups: + - mysql + - postgresql + changed_when: False + + - name: "Installing packages on CentOS" + yum: + name: + - net-tools + - which + - curl + - sudo + - "{{ 'python3-libselinux' if ansible_distribution_major_version == '8' else 'libselinux-python' }}" + - "{{ 'python3-pip' if ansible_distribution_major_version == '8' else 'python-pip' }}" + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family == 'RedHat' + + - name: "Installing packages (CentOS7)" + yum: + name: + - centos-release-scl + state: present + register: installation_dependencies + when: + - ansible_os_family == 'RedHat' + - ansible_distribution_major_version == '7' + + - name: "Installing packages on CentOS" + yum: + name: + - mysql + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family == 'RedHat' + - inventory_hostname in groups['mysql'] + + - name: "Installing packages on NON-CentOS" + apt: + name: + - net-tools + - curl + - apt-utils + - apt-transport-https + - ca-certificates + - python-apt + - gnupg2 + - "{{ 'python3-pip' if ansible_distribution == 'Ubuntu' else 'python-pip' }}" + - "{{ 'gnupg-agent' if ansible_distribution_major_version in ['7', '8'] else 'gpg-agent' }}" + - sudo + - vim + update_cache: True + state: present + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - ansible_os_family != 'RedHat' + + - name: "Configure SUDO." + lineinfile: + dest: /etc/sudoers + line: "Defaults !requiretty" + state: present + + - name: "Make sure the docs are installed." + lineinfile: + dest: /etc/yum.conf + line: "tsflags=nodocs" + state: absent + when: + - ansible_os_family == 'RedHat' + + - name: PyMySQL + pip: + name: PyMySQL + register: installation_dependencies + until: installation_dependencies is succeeded + when: + - inventory_hostname in groups['mysql'] + + roles: + - role: geerlingguy.apache + when: + - zabbix_websrv == "apache" + - role: geerlingguy.nginx + when: + - zabbix_websrv == "nginx" + - role: wdijkerman.php + when: + - ansible_os_family != 'RedHat' or (ansible_os_family == 'RedHat' and ansible_distribution_major_version == "8") + - role: zabbix_server + + post_tasks: + - name: "Remove file" + file: + path: '{{ item }}' + state: absent + with_items: + - /var/www/html/index.html diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/requirements.yml b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/requirements.yml new file mode 100644 index 00000000..16ccb519 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/requirements.yml @@ -0,0 +1,5 @@ +--- +- src: geerlingguy.apache +- src: geerlingguy.nginx +- name: wdijkerman.php + src: https://github.com/dj-wasabi/ansible-role-php.git diff --git a/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/tests/test_default.py b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/tests/test_default.py new file mode 100644 index 00000000..e67e2a0e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_web/tests/test_default.py @@ -0,0 +1,58 @@ +import os +import pytest + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +@pytest.mark.parametrize("server, redhat, debian", [ + ("zabbix-server-pgsql", "zabbix-web-pgsql", "zabbix-frontend-php"), + ("zabbix-server-mysql", "zabbix-web-mysql", "zabbix-frontend-php"), +]) +def test_zabbix_package(host, server, redhat, debian): + host = host.backend.get_hostname() + host = host.replace("-centos7", "") + host = host.replace("-centos8", "") + host = host.replace("-debian", "") + host = host.replace("-ubuntu", "") + + if host == server: + if host.system_info.distribution in ['debian', 'ubuntu']: + zabbix_web = host.package(debian) + assert zabbix_web.version.startswith("1:5.2") + elif host.system_info.distribution == 'centos': + zabbix_web = host.package(redhat) + assert zabbix_web.version.startswith("5.2") + assert zabbix_web.is_installed + + +def test_zabbix_web(host): + zabbix_web = host.file("/etc/zabbix/web/zabbix.conf.php") + ansible_variables = host.ansible.get_variables() + zabbix_websrv = str(ansible_variables['zabbix_websrv']) + + if host.system_info.distribution in ['debian', 'ubuntu']: + assert zabbix_web.user == "www-data" + assert zabbix_web.group == "www-data" + elif host.system_info.distribution == 'centos': + if zabbix_websrv == 'apache': + assert zabbix_web.user == "apache" + assert zabbix_web.group == "apache" + elif zabbix_websrv == 'nginx': + assert zabbix_web.user == "nginx" + assert zabbix_web.group == "nginx" + assert zabbix_web.mode == 0o640 + + +def test_zabbix_api(host): + my_host = host.ansible.get_variables() + zabbix_url = str(my_host['zabbix_url']) + hostname = 'http://' + zabbix_url + '/api_jsonrpc.php' + post_data = '{"jsonrpc": "2.0", "method": "user.login", "params": { "user": "Admin", "password": "zabbix" }, "id": 1, "auth": null}' + headers = 'Content-Type: application/json-rpc' + command = "curl -XPOST -H '" + str(headers) + "' -d '" + str(post_data) + "' '" + hostname + "'" + + cmd = host.run(command) + assert '"jsonrpc":"2.0","result":"' in cmd.stdout diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/doc_fragments/zabbix.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/doc_fragments/zabbix.py new file mode 100644 index 00000000..83f5c18e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/doc_fragments/zabbix.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +# Copyright: (c) 2017, Ansible, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +class ModuleDocFragment(object): + + # Standard documentation fragment + DOCUMENTATION = r''' +options: + server_url: + description: + - URL of Zabbix server, with protocol (http or https). + C(url) is an alias for C(server_url). + required: true + type: str + aliases: [ url ] + login_user: + description: + - Zabbix user name. + type: str + required: true + login_password: + description: + - Zabbix user password. + type: str + required: true + http_login_user: + description: + - Basic Auth login + type: str + http_login_password: + description: + - Basic Auth password + type: str + timeout: + description: + - The timeout of API request (seconds). + type: int + default: 10 + validate_certs: + description: + - If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. + type: bool + default: yes +notes: + - If you use I(login_password=zabbix), the word "zabbix" is replaced by "********" in all module output, because I(login_password) uses C(no_log). + See L(this FAQ,https://docs.ansible.com/ansible/latest/network/user_guide/faq.html#why-is-my-output-sometimes-replaced-with) for more information. +''' diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/__init__.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/base.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/base.py new file mode 100644 index 00000000..fbd324a3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/base.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible_collections.community.zabbix.plugins.module_utils.wrappers import ZapiWrapper + + +class ZabbixBase(object): + """ + The base class for deriving off module classes + """ + def __init__(self, module, zbx=None, zapi_wrapper=None): + self._module = module + + if zapi_wrapper is None: + self._zapi_wrapper = ZapiWrapper(module, zbx) + else: + self._zapi_wrapper = zapi_wrapper + + # include some backward compat properties for now + self._zapi = self._zapi_wrapper._zapi + self._zbx_api_version = self._zapi_wrapper._zbx_api_version diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/helpers.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/helpers.py new file mode 100644 index 00000000..4c45ef9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/helpers.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +def zabbix_common_argument_spec(): + """ + Return a dictionary with connection options. + The options are commonly used by most of Zabbix modules. + """ + return dict( + server_url=dict(type='str', required=True, aliases=['url']), + login_user=dict(type='str', required=True), + login_password=dict(type='str', required=True, no_log=True), + http_login_user=dict(type='str', required=False, default=None), + http_login_password=dict(type='str', required=False, default=None, no_log=True), + timeout=dict(type='int', default=10), + validate_certs=dict(type='bool', required=False, default=True), + ) + + +def helper_cleanup_data(obj): + """ + Removes the None values from the object and returns the object + Args: + obj: object to cleanup + + Returns: + object: cleaned object + """ + if isinstance(obj, (list, tuple, set)): + return type(obj)(helper_cleanup_data(x) for x in obj if x is not None) + elif isinstance(obj, dict): + return type(obj)((helper_cleanup_data(k), helper_cleanup_data(v)) + for k, v in obj.items() if k is not None and v is not None) + else: + return obj + + +def helper_to_numeric_value(strs, value): + """Converts string values to integers + + Parameters: + value: string value + + Returns: + int: converted integer + """ + if value is None: + return None + strs = [s.lower() if isinstance(s, str) else s for s in strs] + value = value.lower() + tmp_dict = dict(zip(strs, list(range(len(strs))))) + return tmp_dict[value] + + +def helper_convert_unicode_to_str(data): + """Converts unicode objects to strings in dictionary + + Parameters: + data: unicode object + + Returns: + dict: strings in dictionary + """ + if isinstance(data, dict): + return dict(map(helper_convert_unicode_to_str, data.items())) + elif isinstance(data, (list, tuple, set)): + return type(data)(map(helper_convert_unicode_to_str, data)) + elif data is None: + return data + else: + return str(data) + + +def helper_compare_lists(l1, l2, diff_dict): + """ + Compares l1 and l2 lists and adds the items that are different + to the diff_dict dictionary. + Used in recursion with helper_compare_dictionaries() function. + + Parameters: + l1: first list to compare + l2: second list to compare + diff_dict: dictionary to store the difference + + Returns: + dict: items that are different + """ + if len(l1) != len(l2): + diff_dict.append(l1) + return diff_dict + for i, item in enumerate(l1): + if isinstance(item, dict): + diff_dict.insert(i, {}) + diff_dict[i] = helper_compare_dictionaries(item, l2[i], diff_dict[i]) + else: + if item != l2[i]: + diff_dict.append(item) + while {} in diff_dict: + diff_dict.remove({}) + return diff_dict + + +def helper_compare_dictionaries(d1, d2, diff_dict): + """ + Compares d1 and d2 dictionaries and adds the items that are different + to the diff_dict dictionary. + Used in recursion with helper_compare_lists() function. + + Parameters: + d1: first dictionary to compare + d2: second dictionary to compare + diff_dict: dictionary to store the difference + + Returns: + dict: items that are different + """ + for k, v in d1.items(): + if k not in d2: + diff_dict[k] = v + continue + if isinstance(v, dict): + diff_dict[k] = {} + helper_compare_dictionaries(v, d2[k], diff_dict[k]) + if diff_dict[k] == {}: + del diff_dict[k] + else: + diff_dict[k] = v + elif isinstance(v, list): + diff_dict[k] = [] + helper_compare_lists(v, d2[k], diff_dict[k]) + if diff_dict[k] == []: + del diff_dict[k] + else: + diff_dict[k] = v + else: + if v != d2[k]: + diff_dict[k] = v + return diff_dict diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/wrappers.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/wrappers.py new file mode 100644 index 00000000..249dfc92 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/module_utils/wrappers.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +import atexit +import traceback + +from ansible.module_utils.basic import missing_required_lib + +try: + from zabbix_api import ZabbixAPI, Already_Exists, ZabbixAPIException + + HAS_ZABBIX_API = True +except ImportError: + ZBX_IMP_ERR = traceback.format_exc() + HAS_ZABBIX_API = False + + +class ZapiWrapper(object): + """ + A simple wrapper over the Zabbix API + """ + def __init__(self, module, zbx=None): + self._module = module + + if not HAS_ZABBIX_API: + module.fail_json(msg=missing_required_lib('zabbix-api', url='https://pypi.org/project/zabbix-api/'), exception=ZBX_IMP_ERR) + + # check if zbx is already instantiated or not + if zbx is not None and isinstance(zbx, ZabbixAPI): + self._zapi = zbx + else: + server_url = module.params['server_url'] + http_login_user = module.params['http_login_user'] + http_login_password = module.params['http_login_password'] + validate_certs = module.params['validate_certs'] + timeout = module.params['timeout'] + self._zapi = ZabbixAPI(server_url, timeout=timeout, user=http_login_user, passwd=http_login_password, + validate_certs=validate_certs) + + self.login() + + self._zbx_api_version = self._zapi.api_version()[:5] + + def login(self): + # check if api already logged in + if not self._zapi.auth != '': + try: + login_user = self._module.params['login_user'] + login_password = self._module.params['login_password'] + self._zapi.login(login_user, login_password) + atexit.register(self._zapi.logout) + except Exception as e: + self._module.fail_json(msg="Failed to connect to Zabbix server: %s" % e) + + +class ScreenItem(object): + @staticmethod + def create(zapi_wrapper, data, ignoreExists=False): + try: + zapi_wrapper._zapi.screenitem.create(data) + except Already_Exists as ex: + if not ignoreExists: + raise ex + + @staticmethod + def delete(zapi_wrapper, id_list=None): + try: + if id_list is None: + id_list = [] + zapi_wrapper._zapi.screenitem.delete(id_list) + except ZabbixAPIException as ex: + raise ex diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/__init__.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_action.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_action.py new file mode 100644 index 00000000..b6dc7d2f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_action.py @@ -0,0 +1,2054 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: zabbix_action + +short_description: Create/Delete/Update Zabbix actions + + +description: + - This module allows you to create, modify and delete Zabbix actions. + +author: + - Ruben Tsirunyan (@rubentsirunyan) + - Ruben Harutyunov (@K-DOT) + +requirements: + - "zabbix-api >= 0.5.4" + +options: + name: + description: + - Name of the action + required: true + event_source: + description: + - Type of events that the action will handle. + - Required when C(state=present). + required: false + choices: ['trigger', 'discovery', 'auto_registration', 'internal'] + state: + description: + - State of the action. + - On C(present), it will create an action if it does not exist or update the action if the associated data is different. + - On C(absent), it will remove the action if it exists. + choices: ['present', 'absent'] + default: 'present' + status: + description: + - Status of the action. + choices: ['enabled', 'disabled'] + default: 'enabled' + pause_in_maintenance: + description: + - Whether to pause escalation during maintenance periods or not. + - Can be used when I(event_source=trigger). + type: 'bool' + default: true + esc_period: + description: + - Default operation step duration. Must be greater than 60 seconds. + - Accepts only seconds in int for <= Zabbix 3.2 + - Accepts seconds, time unit with suffix and user macro since => Zabbix 3.4 + - Required when C(state=present). + required: false + conditions: + type: list + elements: dict + description: + - List of conditions to use for filtering results. + - For more information about suboptions of this option please + check out Zabbix API documentation U(https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_filter_condition) + suboptions: + type: + description: + - Type (label) of the condition. + - 'Possible values when I(event_source=trigger):' + - ' - C(host_group)' + - ' - C(host)' + - ' - C(trigger)' + - ' - C(trigger_name)' + - ' - C(trigger_severity)' + - ' - C(time_period)' + - ' - C(host_template)' + - ' - C(application)' + - ' - C(maintenance_status) known in Zabbix 4.0 and above as "Problem is suppressed"' + - ' - C(event_tag)' + - ' - C(event_tag_value)' + - 'Possible values when I(event_source=discovery):' + - ' - C(host_IP)' + - ' - C(discovered_service_type)' + - ' - C(discovered_service_port)' + - ' - C(discovery_status)' + - ' - C(uptime_or_downtime_duration)' + - ' - C(received_value)' + - ' - C(discovery_rule)' + - ' - C(discovery_check)' + - ' - C(proxy)' + - ' - C(discovery_object)' + - 'Possible values when I(event_source=auto_registration):' + - ' - C(proxy)' + - ' - C(host_name)' + - ' - C(host_metadata)' + - 'Possible values when I(event_source=internal):' + - ' - C(host_group)' + - ' - C(host)' + - ' - C(host_template)' + - ' - C(application)' + - ' - C(event_type)' + value: + description: + - Value to compare with. + - 'When I(type=discovery_status), the choices are:' + - ' - C(up)' + - ' - C(down)' + - ' - C(discovered)' + - ' - C(lost)' + - 'When I(type=discovery_object), the choices are:' + - ' - C(host)' + - ' - C(service)' + - 'When I(type=event_type), the choices are:' + - ' - C(item in not supported state)' + - ' - C(item in normal state)' + - ' - C(LLD rule in not supported state)' + - ' - C(LLD rule in normal state)' + - ' - C(trigger in unknown state)' + - ' - C(trigger in normal state)' + - 'When I(type=trigger_severity), the choices are (case-insensitive):' + - ' - C(not classified)' + - ' - C(information)' + - ' - C(warning)' + - ' - C(average)' + - ' - C(high)' + - ' - C(disaster)' + - Irrespective of user-visible names being changed in Zabbix. Defaults to C(not classified) if omitted. + - Besides the above options, this is usually either the name + of the object or a string to compare with. + value2: + description: + - Secondary value to compare with. + - Required for trigger actions when condition I(type=event_tag_value). + operator: + description: + - Condition operator. + - When I(type) is set to C(time_period), the choices are C(in), C(not in). + - C(matches), C(does not match), C(Yes) and C(No) condition operators work only with >= Zabbix 4.0 + choices: + - '=' + - '<>' + - 'like' + - 'not like' + - 'in' + - '>=' + - '<=' + - 'not in' + - 'matches' + - 'does not match' + - 'Yes' + - 'No' + formulaid: + description: + - Arbitrary unique ID that is used to reference the condition from a custom expression. + - Can only contain upper-case letters. + - Required for custom expression filters and ignored otherwise. + eval_type: + description: + - Filter condition evaluation method. + - Defaults to C(andor) if conditions are less then 2 or if + I(formula) is not specified. + - Defaults to C(custom_expression) when formula is specified. + choices: + - 'andor' + - 'and' + - 'or' + - 'custom_expression' + formula: + description: + - User-defined expression to be used for evaluating conditions with a custom expression. + - The expression must contain IDs that reference each condition by its formulaid. + - The IDs used in the expression must exactly match the ones + defined in the I(conditions). No condition can remain unused or omitted. + - Required when I(eval_type=custom_expression). + - Use sequential IDs that start at "A". If non-sequential IDs are used, Zabbix re-indexes them. + This makes each module run notice the difference in IDs and update the action. + default_message: + description: + - Problem message default text. + - With >= Zabbix 5.0 this field is removed from the API and is dropped silently by module. + - Works only with < Zabbix 5.0 + default_subject: + description: + - Problem message default subject. + - With >= Zabbix 5.0 this field is removed from the API and is dropped silently by module. + - Works only with < Zabbix 5.0 + recovery_default_message: + description: + - Recovery message text. + - With >= Zabbix 5.0 this field is removed from the API and is dropped silently by module. + - Works only with >= Zabbix 3.2 and < Zabbix 5.0 + recovery_default_subject: + description: + - Recovery message subject. + - With >= Zabbix 5.0 this field is removed from the API and is dropped silently by module. + - Works only with >= Zabbix 3.2 and < Zabbix 5.0 + acknowledge_default_message: + description: + - Update operation (known as "Acknowledge operation" before Zabbix 4.0) message text. + - With >= Zabbix 5.0 this field is removed from the API and is dropped silently by module. + - Works only with >= Zabbix 3.4 and < Zabbix 5.0 + acknowledge_default_subject: + description: + - Update operation (known as "Acknowledge operation" before Zabbix 4.0) message subject. + - With >= Zabbix 5.0 this field is removed from the API and is dropped silently by module. + - Works only with >= Zabbix 3.4 and < Zabbix 5.0 + operations: + type: list + description: + - List of action operations + suboptions: + type: + description: + - Type of operation. + - 'Valid choices when setting type for I(recovery_operations) and I(acknowledge_operations):' + - ' - C(send_message)' + - ' - C(remote_command)' + - ' - C(notify_all_involved)' + - Choice C(notify_all_involved) only supported in I(recovery_operations) and I(acknowledge_operations). + choices: + - send_message + - remote_command + - add_host + - remove_host + - add_to_host_group + - remove_from_host_group + - link_to_template + - unlink_from_template + - enable_host + - disable_host + - set_host_inventory_mode + - notify_all_involved + esc_period: + description: + - Duration of an escalation step in seconds. + - Must be greater than 60 seconds. + - Accepts only seconds in int for <= Zabbix 3.2 + - Accepts seconds, time unit with suffix and user macro since => Zabbix 3.4 + - If set to 0 or 0s, the default action escalation period will be used. + default: 0s + esc_step_from: + description: + - Step to start escalation from. + default: 1 + esc_step_to: + description: + - Step to end escalation at. + - Specify 0 for infinitely. + default: 1 + send_to_groups: + type: list + description: + - User groups to send messages to. + send_to_users: + type: list + description: + - Users (usernames or aliases) to send messages to. + message: + description: + - Operation message text. + - Will check the 'default message' and use the text from I(default_message) if this and I(default_subject) are not specified + subject: + description: + - Operation message subject. + - Will check the 'default message' and use the text from I(default_subject) if this and I(default_subject) are not specified + media_type: + description: + - Media type that will be used to send the message. + - Can be used with I(type=send_message) or I(type=notify_all_involved) inside I(acknowledge_operations). + - Set to C(all) for all media types + default: 'all' + operation_condition: + type: 'str' + description: + - The action operation condition object defines a condition that must be met to perform the current operation. + choices: + - acknowledged + - not_acknowledged + host_groups: + type: list + description: + - List of host groups host should be added to. + - Required when I(type=add_to_host_group) or I(type=remove_from_host_group). + templates: + type: list + description: + - List of templates host should be linked to. + - Required when I(type=link_to_template) or I(type=unlink_from_template). + inventory: + description: + - Host inventory mode. + - Required when I(type=set_host_inventory_mode). + choices: + - manual + - automatic + command_type: + description: + - Type of operation command. + - Required when I(type=remote_command). + choices: + - custom_script + - ipmi + - ssh + - telnet + - global_script + command: + description: + - Command to run. + - Required when I(type=remote_command) and I(command_type!=global_script). + execute_on: + description: + - Target on which the custom script operation command will be executed. + - Required when I(type=remote_command) and I(command_type=custom_script). + choices: + - agent + - server + - proxy + run_on_groups: + description: + - Host groups to run remote commands on. + - Required when I(type=remote_command) and I(run_on_hosts) is not set. + run_on_hosts: + description: + - Hosts to run remote commands on. + - Required when I(type=remote_command) and I(run_on_groups) is not set. + - If set to 0 the command will be run on the current host. + ssh_auth_type: + description: + - Authentication method used for SSH commands. + - Required when I(type=remote_command) and I(command_type=ssh). + choices: + - password + - public_key + ssh_privatekey_file: + description: + - Name of the private key file used for SSH commands with public key authentication. + - Required when I(ssh_auth_type=public_key). + - Can be used when I(type=remote_command). + ssh_publickey_file: + description: + - Name of the public key file used for SSH commands with public key authentication. + - Required when I(ssh_auth_type=public_key). + - Can be used when I(type=remote_command). + username: + description: + - User name used for authentication. + - Required when I(ssh_auth_type in [public_key, password]) or I(command_type=telnet). + - Can be used when I(type=remote_command). + password: + description: + - Password used for authentication. + - Required when I(ssh_auth_type=password) or I(command_type=telnet). + - Can be used when I(type=remote_command). + port: + description: + - Port number used for authentication. + - Can be used when I(command_type in [ssh, telnet]) and I(type=remote_command). + script_name: + description: + - The name of script used for global script commands. + - Required when I(command_type=global_script). + - Can be used when I(type=remote_command). + recovery_operations: + type: list + description: + - List of recovery operations. + - C(Suboptions) are the same as for I(operations). + - Works only with >= Zabbix 3.2 + acknowledge_operations: + type: list + description: + - List of acknowledge operations. + - Action acknowledge operations are known as update operations since Zabbix 4.0. + - C(Suboptions) are the same as for I(operations). + - Works only with >= Zabbix 3.4 + aliases: [ update_operations ] + +notes: + - Only Zabbix >= 3.0 is supported. + + +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = ''' +# Trigger action with only one condition +- name: Deploy trigger action + community.zabbix.zabbix_action: + server_url: "http://zabbix.example.com/zabbix/" + login_user: Admin + login_password: secret + name: "Send alerts to Admin" + event_source: 'trigger' + state: present + status: enabled + esc_period: 60 + conditions: + - type: 'trigger_severity' + operator: '>=' + value: 'Information' + operations: + - type: send_message + subject: "Something bad is happening" + message: "Come on, guys do something" + media_type: 'Email' + send_to_users: + - 'Admin' + +# Trigger action with multiple conditions and operations +- name: Deploy trigger action + community.zabbix.zabbix_action: + server_url: "http://zabbix.example.com/zabbix/" + login_user: Admin + login_password: secret + name: "Send alerts to Admin" + event_source: 'trigger' + state: present + status: enabled + esc_period: 1m + conditions: + - type: 'trigger_name' + operator: 'like' + value: 'Zabbix agent is unreachable' + formulaid: A + - type: 'trigger_severity' + operator: '>=' + value: 'disaster' + formulaid: B + formula: A or B + operations: + - type: send_message + media_type: 'Email' + send_to_users: + - 'Admin' + - type: remote_command + command: 'systemctl restart zabbix-agent' + command_type: custom_script + execute_on: server + run_on_hosts: + - 0 + +# Trigger action with recovery and acknowledge operations +- name: Deploy trigger action + community.zabbix.zabbix_action: + server_url: "http://zabbix.example.com/zabbix/" + login_user: Admin + login_password: secret + name: "Send alerts to Admin" + event_source: 'trigger' + state: present + status: enabled + esc_period: 1h + conditions: + - type: 'trigger_severity' + operator: '>=' + value: 'Information' + operations: + - type: send_message + subject: "Something bad is happening" + message: "Come on, guys do something" + media_type: 'Email' + send_to_users: + - 'Admin' + recovery_operations: + - type: send_message + subject: "Host is down" + message: "Come on, guys do something" + media_type: 'Email' + send_to_users: + - 'Admin' + acknowledge_operations: + - type: send_message + media_type: 'Email' + send_to_users: + - 'Admin' +''' + +RETURN = ''' +msg: + description: The result of the operation + returned: success + type: str + sample: 'Action Deleted: Register webservers, ID: 0001' +''' + + +from distutils.version import LooseVersion +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +from ansible_collections.community.zabbix.plugins.module_utils.wrappers import ZapiWrapper +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Zapi(ZapiWrapper): + def __init__(self, module, zbx=None): + super(Zapi, self).__init__(module, zbx) + self._zapi_wrapper = self + + def check_if_action_exists(self, name): + """Check if action exists. + + Args: + name: Name of the action. + + Returns: + The return value. True for success, False otherwise. + + """ + try: + _action = self._zapi.action.get({ + "selectOperations": "extend", + "selectRecoveryOperations": "extend", + "selectAcknowledgeOperations": "extend", + "selectFilter": "extend", + 'filter': {'name': [name]} + }) + if len(_action) > 0: + _action[0]['recovery_operations'] = _action[0].pop('recoveryOperations', []) + _action[0]['acknowledge_operations'] = _action[0].pop('acknowledgeOperations', []) + return _action + except Exception as e: + self._module.fail_json(msg="Failed to check if action '%s' exists: %s" % (name, e)) + + def get_action_by_name(self, name): + """Get action by name + + Args: + name: Name of the action. + + Returns: + dict: Zabbix action + + """ + try: + action_list = self._zapi.action.get({ + 'output': 'extend', + 'filter': {'name': [name]} + }) + if len(action_list) < 1: + self._module.fail_json(msg="Action not found: " % name) + else: + return action_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get ID of '%s': %s" % (name, e)) + + def get_host_by_host_name(self, host_name): + """Get host by host name + + Args: + host_name: host name. + + Returns: + host matching host name + + """ + try: + host_list = self._zapi.host.get({ + 'output': 'extend', + 'selectInventory': 'extend', + 'filter': {'host': [host_name]} + }) + if len(host_list) < 1: + self._module.fail_json(msg="Host not found: %s" % host_name) + else: + return host_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get host '%s': %s" % (host_name, e)) + + def get_hostgroup_by_hostgroup_name(self, hostgroup_name): + """Get host group by host group name + + Args: + hostgroup_name: host group name. + + Returns: + host group matching host group name + + """ + try: + hostgroup_list = self._zapi.hostgroup.get({ + 'output': 'extend', + 'filter': {'name': [hostgroup_name]} + }) + if len(hostgroup_list) < 1: + self._module.fail_json(msg="Host group not found: %s" % hostgroup_name) + else: + return hostgroup_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get host group '%s': %s" % (hostgroup_name, e)) + + def get_template_by_template_name(self, template_name): + """Get template by template name + + Args: + template_name: template name. + + Returns: + template matching template name + + """ + try: + template_list = self._zapi.template.get({ + 'output': 'extend', + 'filter': {'host': [template_name]} + }) + if len(template_list) < 1: + self._module.fail_json(msg="Template not found: %s" % template_name) + else: + return template_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get template '%s': %s" % (template_name, e)) + + def get_trigger_by_trigger_name(self, trigger_name): + """Get trigger by trigger name + + Args: + trigger_name: trigger name. + + Returns: + trigger matching trigger name + + """ + try: + trigger_list = self._zapi.trigger.get({ + 'output': 'extend', + 'filter': {'description': [trigger_name]} + }) + if len(trigger_list) < 1: + self._module.fail_json(msg="Trigger not found: %s" % trigger_name) + else: + return trigger_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get trigger '%s': %s" % (trigger_name, e)) + + def get_discovery_rule_by_discovery_rule_name(self, discovery_rule_name): + """Get discovery rule by discovery rule name + + Args: + discovery_rule_name: discovery rule name. + + Returns: + discovery rule matching discovery rule name + + """ + try: + discovery_rule_list = self._zapi.drule.get({ + 'output': 'extend', + 'filter': {'name': [discovery_rule_name]} + }) + if len(discovery_rule_list) < 1: + self._module.fail_json(msg="Discovery rule not found: %s" % discovery_rule_name) + else: + return discovery_rule_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get discovery rule '%s': %s" % (discovery_rule_name, e)) + + def get_discovery_check_by_discovery_check_name(self, discovery_check_name): + """Get discovery check by discovery check name + + Args: + discovery_check_name: discovery check name. + + Returns: + discovery check matching discovery check name + + """ + try: + discovery_check_list = self._zapi.dcheck.get({ + 'output': 'extend', + 'filter': {'name': [discovery_check_name]} + }) + if len(discovery_check_list) < 1: + self._module.fail_json(msg="Discovery check not found: %s" % discovery_check_name) + else: + return discovery_check_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get discovery check '%s': %s" % (discovery_check_name, e)) + + def get_proxy_by_proxy_name(self, proxy_name): + """Get proxy by proxy name + + Args: + proxy_name: proxy name. + + Returns: + proxy matching proxy name + + """ + try: + proxy_list = self._zapi.proxy.get({ + 'output': 'extend', + 'filter': {'host': [proxy_name]} + }) + if len(proxy_list) < 1: + self._module.fail_json(msg="Proxy not found: %s" % proxy_name) + else: + return proxy_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get proxy '%s': %s" % (proxy_name, e)) + + def get_mediatype_by_mediatype_name(self, mediatype_name): + """Get mediatype by mediatype name + + Args: + mediatype_name: mediatype name + + Returns: + mediatype matching mediatype name + + """ + if LooseVersion(self._zbx_api_version) >= LooseVersion('4.4'): + filter = {'name': [mediatype_name]} + else: + filter = {'description': [mediatype_name]} + + try: + if str(mediatype_name).lower() == 'all': + return '0' + mediatype_list = self._zapi.mediatype.get({ + 'output': 'extend', + 'filter': filter + }) + if len(mediatype_list) < 1: + self._module.fail_json(msg="Media type not found: %s" % mediatype_name) + else: + return mediatype_list[0]['mediatypeid'] + except Exception as e: + self._module.fail_json(msg="Failed to get mediatype '%s': %s" % (mediatype_name, e)) + + def get_user_by_user_name(self, user_name): + """Get user by user name + + Args: + user_name: user name + + Returns: + user matching user name + + """ + try: + user_list = self._zapi.user.get({ + 'output': 'extend', + 'filter': {'alias': [user_name]} + }) + if len(user_list) < 1: + self._module.fail_json(msg="User not found: %s" % user_name) + else: + return user_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get user '%s': %s" % (user_name, e)) + + def get_usergroup_by_usergroup_name(self, usergroup_name): + """Get usergroup by usergroup name + + Args: + usergroup_name: usergroup name + + Returns: + usergroup matching usergroup name + + """ + try: + usergroup_list = self._zapi.usergroup.get({ + 'output': 'extend', + 'filter': {'name': [usergroup_name]} + }) + if len(usergroup_list) < 1: + self._module.fail_json(msg="User group not found: %s" % usergroup_name) + else: + return usergroup_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get user group '%s': %s" % (usergroup_name, e)) + + # get script by script name + def get_script_by_script_name(self, script_name): + """Get script by script name + + Args: + script_name: script name + + Returns: + script matching script name + + """ + try: + if script_name is None: + return {} + script_list = self._zapi.script.get({ + 'output': 'extend', + 'filter': {'name': [script_name]} + }) + if len(script_list) < 1: + self._module.fail_json(msg="Script not found: %s" % script_name) + else: + return script_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get script '%s': %s" % (script_name, e)) + + +class Action(ZabbixBase): + def __init__(self, module, zbx=None, zapi_wrapper=None): + super(Action, self).__init__(module, zbx, zapi_wrapper) + self.existing_data = None + + def _construct_parameters(self, **kwargs): + """Construct parameters. + + Args: + **kwargs: Arbitrary keyword parameters. + + Returns: + dict: dictionary of specified parameters + """ + + _params = { + 'name': kwargs['name'], + 'eventsource': to_numeric_value([ + 'trigger', + 'discovery', + 'auto_registration', + 'internal'], kwargs['event_source']), + 'esc_period': kwargs.get('esc_period'), + 'filter': kwargs['conditions'], + 'def_longdata': kwargs['default_message'], + 'def_shortdata': kwargs['default_subject'], + 'r_longdata': kwargs['recovery_default_message'], + 'r_shortdata': kwargs['recovery_default_subject'], + 'ack_longdata': kwargs['acknowledge_default_message'], + 'ack_shortdata': kwargs['acknowledge_default_subject'], + 'operations': kwargs['operations'], + 'recovery_operations': kwargs.get('recovery_operations'), + 'acknowledge_operations': kwargs.get('acknowledge_operations'), + 'status': to_numeric_value([ + 'enabled', + 'disabled'], kwargs['status']) + } + + if kwargs['event_source'] == 'trigger': + if LooseVersion(self._zbx_api_version) >= LooseVersion('4.0'): + _params['pause_suppressed'] = '1' if kwargs['pause_in_maintenance'] else '0' + else: + _params['maintenance_mode'] = '1' if kwargs['pause_in_maintenance'] else '0' + + if LooseVersion(self._zbx_api_version) >= LooseVersion('5.0'): + # remove some fields regarding + # https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object + _params.pop('def_longdata', None) + _params.pop('def_shortdata', None) + _params.pop('r_longdata', None) + _params.pop('r_shortdata', None) + + if (LooseVersion(self._zbx_api_version) < LooseVersion('3.4') + or LooseVersion(self._zbx_api_version) >= LooseVersion('5.0')): + _params.pop('ack_longdata', None) + _params.pop('ack_shortdata', None) + + return _params + + def check_difference(self, **kwargs): + """Check difference between action and user specified parameters. + + Args: + **kwargs: Arbitrary keyword parameters. + + Returns: + dict: dictionary of differences + """ + existing_action = convert_unicode_to_str(self._zapi_wrapper.check_if_action_exists(kwargs['name'])[0]) + parameters = convert_unicode_to_str(self._construct_parameters(**kwargs)) + change_parameters = {} + _diff = cleanup_data(compare_dictionaries(parameters, existing_action, change_parameters)) + return _diff + + def update_action(self, **kwargs): + """Update action. + + Args: + **kwargs: Arbitrary keyword parameters. + + Returns: + action: updated action + """ + try: + if self._module.check_mode: + self._module.exit_json(msg="Action would be updated if check mode was not specified: %s" % kwargs, changed=True) + kwargs['actionid'] = kwargs.pop('action_id') + return self._zapi.action.update(kwargs) + except Exception as e: + self._module.fail_json(msg="Failed to update action '%s': %s" % (kwargs['actionid'], e)) + + def add_action(self, **kwargs): + """Add action. + + Args: + **kwargs: Arbitrary keyword parameters. + + Returns: + action: added action + """ + try: + if self._module.check_mode: + self._module.exit_json(msg="Action would be added if check mode was not specified", changed=True) + parameters = self._construct_parameters(**kwargs) + action_list = self._zapi.action.create(parameters) + return action_list['actionids'][0] + except Exception as e: + self._module.fail_json(msg="Failed to create action '%s': %s" % (kwargs['name'], e)) + + def delete_action(self, action_id): + """Delete action. + + Args: + action_id: Action id + + Returns: + action: deleted action + """ + try: + if self._module.check_mode: + self._module.exit_json(msg="Action would be deleted if check mode was not specified", changed=True) + return self._zapi.action.delete([action_id]) + except Exception as e: + self._module.fail_json(msg="Failed to delete action '%s': %s" % (action_id, e)) + + +class Operations(Zapi): + def _construct_operationtype(self, operation): + """Construct operation type. + + Args: + operation: operation to construct + + Returns: + str: constructed operation + """ + try: + return to_numeric_value([ + "send_message", + "remote_command", + "add_host", + "remove_host", + "add_to_host_group", + "remove_from_host_group", + "link_to_template", + "unlink_from_template", + "enable_host", + "disable_host", + "set_host_inventory_mode"], operation['type'] + ) + except Exception: + self._module.fail_json(msg="Unsupported value '%s' for operation type." % operation['type']) + + def _construct_opmessage(self, operation): + """Construct operation message. + + Args: + operation: operation to construct the message + + Returns: + dict: constructed operation message + """ + try: + return { + 'default_msg': '0' if operation.get('message') is not None or operation.get('subject') is not None else '1', + 'mediatypeid': self._zapi_wrapper.get_mediatype_by_mediatype_name( + operation.get('media_type') + ) if operation.get('media_type') is not None else '0', + 'message': operation.get('message'), + 'subject': operation.get('subject'), + } + except Exception as e: + self._module.fail_json(msg="Failed to construct operation message. The error was: %s" % e) + + def _construct_opmessage_usr(self, operation): + """Construct operation message user. + + Args: + operation: operation to construct the message user + + Returns: + list: constructed operation message user or None if operation not found + """ + if operation.get('send_to_users') is None: + return None + return [{ + 'userid': self._zapi_wrapper.get_user_by_user_name(_user)['userid'] + } for _user in operation.get('send_to_users')] + + def _construct_opmessage_grp(self, operation): + """Construct operation message group. + + Args: + operation: operation to construct the message group + + Returns: + list: constructed operation message group or None if operation not found + """ + if operation.get('send_to_groups') is None: + return None + return [{ + 'usrgrpid': self._zapi_wrapper.get_usergroup_by_usergroup_name(_group)['usrgrpid'] + } for _group in operation.get('send_to_groups')] + + def _construct_opcommand(self, operation): + """Construct operation command. + + Args: + operation: operation to construct command + + Returns: + list: constructed operation command + """ + try: + return { + 'type': to_numeric_value([ + 'custom_script', + 'ipmi', + 'ssh', + 'telnet', + 'global_script'], operation.get('command_type', 'custom_script')), + 'command': operation.get('command'), + 'execute_on': to_numeric_value([ + 'agent', + 'server', + 'proxy'], operation.get('execute_on', 'server')), + 'scriptid': self._zapi_wrapper.get_script_by_script_name( + operation.get('script_name') + ).get('scriptid'), + 'authtype': to_numeric_value([ + 'password', + 'public_key' + ], operation.get('ssh_auth_type')), + 'privatekey': operation.get('ssh_privatekey_file'), + 'publickey': operation.get('ssh_publickey_file'), + 'username': operation.get('username'), + 'password': operation.get('password'), + 'port': operation.get('port') + } + except Exception as e: + self._module.fail_json(msg="Failed to construct operation command. The error was: %s" % e) + + def _construct_opcommand_hst(self, operation): + """Construct operation command host. + + Args: + operation: operation to construct command host + + Returns: + list: constructed operation command host + """ + if operation.get('run_on_hosts') is None: + return None + return [{ + 'hostid': self._zapi_wrapper.get_host_by_host_name(_host)['hostid'] + } if str(_host) != '0' else {'hostid': '0'} for _host in operation.get('run_on_hosts')] + + def _construct_opcommand_grp(self, operation): + """Construct operation command group. + + Args: + operation: operation to construct command group + + Returns: + list: constructed operation command group + """ + if operation.get('run_on_groups') is None: + return None + return [{ + 'groupid': self._zapi_wrapper.get_hostgroup_by_hostgroup_name(_group)['hostid'] + } for _group in operation.get('run_on_groups')] + + def _construct_opgroup(self, operation): + """Construct operation group. + + Args: + operation: operation to construct group + + Returns: + list: constructed operation group + """ + return [{ + 'groupid': self._zapi_wrapper.get_hostgroup_by_hostgroup_name(_group)['groupid'] + } for _group in operation.get('host_groups', [])] + + def _construct_optemplate(self, operation): + """Construct operation template. + + Args: + operation: operation to construct template + + Returns: + list: constructed operation template + """ + return [{ + 'templateid': self._zapi_wrapper.get_template_by_template_name(_template)['templateid'] + } for _template in operation.get('templates', [])] + + def _construct_opinventory(self, operation): + """Construct operation inventory. + + Args: + operation: operation to construct inventory + + Returns: + dict: constructed operation inventory + """ + return { + 'inventory_mode': to_numeric_value([ + 'manual', + 'automatic' + ], operation.get('inventory')) + } + + def _construct_opconditions(self, operation): + """Construct operation conditions. + + Args: + operation: operation to construct the conditions + + Returns: + list: constructed operation conditions + """ + _opcond = operation.get('operation_condition') + if _opcond is not None: + if _opcond == 'acknowledged': + _value = '1' + elif _opcond == 'not_acknowledged': + _value = '0' + return [{ + 'conditiontype': '14', + 'operator': '0', + 'value': _value + }] + return [] + + def construct_the_data(self, operations): + """Construct the operation data using helper methods. + + Args: + operation: operation to construct + + Returns: + list: constructed operation data + """ + constructed_data = [] + for op in operations: + operation_type = self._construct_operationtype(op) + constructed_operation = { + 'operationtype': operation_type, + 'esc_period': op.get('esc_period'), + 'esc_step_from': op.get('esc_step_from'), + 'esc_step_to': op.get('esc_step_to') + } + # Send Message type + if constructed_operation['operationtype'] == '0': + constructed_operation['opmessage'] = self._construct_opmessage(op) + constructed_operation['opmessage_usr'] = self._construct_opmessage_usr(op) + constructed_operation['opmessage_grp'] = self._construct_opmessage_grp(op) + constructed_operation['opconditions'] = self._construct_opconditions(op) + + # Send Command type + if constructed_operation['operationtype'] == '1': + constructed_operation['opcommand'] = self._construct_opcommand(op) + constructed_operation['opcommand_hst'] = self._construct_opcommand_hst(op) + constructed_operation['opcommand_grp'] = self._construct_opcommand_grp(op) + constructed_operation['opconditions'] = self._construct_opconditions(op) + + # Add to/Remove from host group + if constructed_operation['operationtype'] in ('4', '5'): + constructed_operation['opgroup'] = self._construct_opgroup(op) + + # Link/Unlink template + if constructed_operation['operationtype'] in ('6', '7'): + constructed_operation['optemplate'] = self._construct_optemplate(op) + + # Set inventory mode + if constructed_operation['operationtype'] == '10': + constructed_operation['opinventory'] = self._construct_opinventory(op) + + constructed_data.append(constructed_operation) + + return cleanup_data(constructed_data) + + +class RecoveryOperations(Operations): + """ + Restructures the user defined recovery operations data to fit the Zabbix API requirements + """ + def _construct_operationtype(self, operation): + """Construct operation type. + + Args: + operation: operation to construct type + + Returns: + str: constructed operation type + """ + try: + return to_numeric_value([ + "send_message", + "remote_command", + None, + None, + None, + None, + None, + None, + None, + None, + None, + "notify_all_involved"], operation['type'] + ) + except Exception: + self._module.fail_json(msg="Unsupported value '%s' for recovery operation type." % operation['type']) + + def construct_the_data(self, operations): + """Construct the recovery operations data using helper methods. + + Args: + operation: operation to construct + + Returns: + list: constructed recovery operations data + """ + constructed_data = [] + for op in operations: + operation_type = self._construct_operationtype(op) + constructed_operation = { + 'operationtype': operation_type, + } + + # Send Message type + if constructed_operation['operationtype'] in ('0', '11'): + constructed_operation['opmessage'] = self._construct_opmessage(op) + constructed_operation['opmessage_usr'] = self._construct_opmessage_usr(op) + constructed_operation['opmessage_grp'] = self._construct_opmessage_grp(op) + + # Send Command type + if constructed_operation['operationtype'] == '1': + constructed_operation['opcommand'] = self._construct_opcommand(op) + constructed_operation['opcommand_hst'] = self._construct_opcommand_hst(op) + constructed_operation['opcommand_grp'] = self._construct_opcommand_grp(op) + + constructed_data.append(constructed_operation) + + return cleanup_data(constructed_data) + + +class AcknowledgeOperations(Operations): + """ + Restructures the user defined acknowledge operations data to fit the Zabbix API requirements + """ + def _construct_operationtype(self, operation): + """Construct operation type. + + Args: + operation: operation to construct type + + Returns: + str: constructed operation type + """ + try: + return to_numeric_value([ + "send_message", + "remote_command", + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + "notify_all_involved"], operation['type'] + ) + except Exception: + self._module.fail_json(msg="Unsupported value '%s' for acknowledge operation type." % operation['type']) + + def construct_the_data(self, operations): + """Construct the acknowledge operations data using helper methods. + + Args: + operation: operation to construct + + Returns: + list: constructed acknowledge operations data + """ + constructed_data = [] + for op in operations: + operation_type = self._construct_operationtype(op) + constructed_operation = { + 'operationtype': operation_type, + } + + # Send Message type + if constructed_operation['operationtype'] in ('0', '11'): + constructed_operation['opmessage'] = self._construct_opmessage(op) + constructed_operation['opmessage_usr'] = self._construct_opmessage_usr(op) + constructed_operation['opmessage_grp'] = self._construct_opmessage_grp(op) + + # Send Command type + if constructed_operation['operationtype'] == '1': + constructed_operation['opcommand'] = self._construct_opcommand(op) + constructed_operation['opcommand_hst'] = self._construct_opcommand_hst(op) + constructed_operation['opcommand_grp'] = self._construct_opcommand_grp(op) + + constructed_data.append(constructed_operation) + + return cleanup_data(constructed_data) + + +class Filter(Zapi): + def _construct_evaltype(self, _eval_type, _formula, _conditions): + """Construct the eval type + + Args: + _formula: zabbix condition evaluation formula + _conditions: list of conditions to check + + Returns: + dict: constructed acknowledge operations data + """ + if len(_conditions) <= 1: + return { + 'evaltype': '0', + 'formula': None + } + if _eval_type == 'andor': + return { + 'evaltype': '0', + 'formula': None + } + if _eval_type == 'and': + return { + 'evaltype': '1', + 'formula': None + } + if _eval_type == 'or': + return { + 'evaltype': '2', + 'formula': None + } + if _eval_type == 'custom_expression': + if _formula is not None: + return { + 'evaltype': '3', + 'formula': _formula + } + else: + self._module.fail_json(msg="'formula' is required when 'eval_type' is set to 'custom_expression'") + if _formula is not None: + return { + 'evaltype': '3', + 'formula': _formula + } + return { + 'evaltype': '0', + 'formula': None + } + + def _construct_conditiontype(self, _condition): + """Construct the condition type + + Args: + _condition: condition to check + + Returns: + str: constructed condition type data + """ + try: + return to_numeric_value([ + "host_group", + "host", + "trigger", + "trigger_name", + "trigger_severity", + "trigger_value", + "time_period", + "host_ip", + "discovered_service_type", + "discovered_service_port", + "discovery_status", + "uptime_or_downtime_duration", + "received_value", + "host_template", + None, + "application", + "maintenance_status", + None, + "discovery_rule", + "discovery_check", + "proxy", + "discovery_object", + "host_name", + "event_type", + "host_metadata", + "event_tag", + "event_tag_value"], _condition['type'] + ) + except Exception: + self._module.fail_json(msg="Unsupported value '%s' for condition type." % _condition['type']) + + def _construct_operator(self, _condition): + """Construct operator + + Args: + _condition: condition to construct + + Returns: + str: constructed operator + """ + try: + return to_numeric_value([ + "=", + "<>", + "like", + "not like", + "in", + ">=", + "<=", + "not in", + "matches", + "does not match", + "Yes", + "No"], _condition['operator'] + ) + except Exception: + self._module.fail_json(msg="Unsupported value '%s' for operator." % _condition['operator']) + + def _construct_value(self, conditiontype, value): + """Construct operator + + Args: + conditiontype: type of condition to construct + value: value to construct + + Returns: + str: constructed value + """ + try: + # Host group + if conditiontype == '0': + return self._zapi_wrapper.get_hostgroup_by_hostgroup_name(value)['groupid'] + # Host + if conditiontype == '1': + return self._zapi_wrapper.get_host_by_host_name(value)['hostid'] + # Trigger + if conditiontype == '2': + return self._zapi_wrapper.get_trigger_by_trigger_name(value)['triggerid'] + # Trigger name: return as is + # Trigger severity + if conditiontype == '4': + return to_numeric_value([ + "not classified", + "information", + "warning", + "average", + "high", + "disaster"], value or "not classified" + ) + + # Trigger value + if conditiontype == '5': + return to_numeric_value([ + "ok", + "problem"], value or "ok" + ) + # Time period: return as is + # Host IP: return as is + # Discovered service type + if conditiontype == '8': + return to_numeric_value([ + "SSH", + "LDAP", + "SMTP", + "FTP", + "HTTP", + "POP", + "NNTP", + "IMAP", + "TCP", + "Zabbix agent", + "SNMPv1 agent", + "SNMPv2 agent", + "ICMP ping", + "SNMPv3 agent", + "HTTPS", + "Telnet"], value + ) + # Discovered service port: return as is + # Discovery status + if conditiontype == '10': + return to_numeric_value([ + "up", + "down", + "discovered", + "lost"], value + ) + if conditiontype == '13': + return self._zapi_wrapper.get_template_by_template_name(value)['templateid'] + if conditiontype == '18': + return self._zapi_wrapper.get_discovery_rule_by_discovery_rule_name(value)['druleid'] + if conditiontype == '19': + return self._zapi_wrapper.get_discovery_check_by_discovery_check_name(value)['dcheckid'] + if conditiontype == '20': + return self._zapi_wrapper.get_proxy_by_proxy_name(value)['proxyid'] + if conditiontype == '21': + return to_numeric_value([ + "pchldrfor0", + "host", + "service"], value + ) + if conditiontype == '23': + return to_numeric_value([ + "item in not supported state", + "item in normal state", + "LLD rule in not supported state", + "LLD rule in normal state", + "trigger in unknown state", + "trigger in normal state"], value + ) + return value + except Exception: + self._module.fail_json( + msg="""Unsupported value '%s' for specified condition type. + Check out Zabbix API documentation for supported values for + condition type '%s' at + https://www.zabbix.com/documentation/3.4/manual/api/reference/action/object#action_filter_condition""" % (value, conditiontype) + ) + + def construct_the_data(self, _eval_type, _formula, _conditions): + """Construct the user defined filter conditions to fit the Zabbix API + requirements operations data using helper methods. + + Args: + _formula: zabbix condition evaluation formula + _conditions: conditions to construct + + Returns: + dict: user defined filter conditions + """ + if _conditions is None: + return None + constructed_data = {} + constructed_data['conditions'] = [] + for cond in _conditions: + condition_type = self._construct_conditiontype(cond) + constructed_data['conditions'].append({ + "conditiontype": condition_type, + "value": self._construct_value(condition_type, cond.get("value")), + "value2": cond.get("value2"), + "formulaid": cond.get("formulaid"), + "operator": self._construct_operator(cond) + }) + _constructed_evaltype = self._construct_evaltype( + _eval_type, + _formula, + constructed_data['conditions'] + ) + constructed_data['evaltype'] = _constructed_evaltype['evaltype'] + constructed_data['formula'] = _constructed_evaltype['formula'] + return cleanup_data(constructed_data) + + +def convert_unicode_to_str(data): + """Converts unicode objects to strings in dictionary + args: + data: unicode object + + Returns: + dict: strings in dictionary + """ + if isinstance(data, dict): + return dict(map(convert_unicode_to_str, data.items())) + elif isinstance(data, (list, tuple, set)): + return type(data)(map(convert_unicode_to_str, data)) + elif data is None: + return data + else: + return str(data) + + +def to_numeric_value(strs, value): + """Converts string values to integers + Args: + value: string value + + Returns: + int: converted integer + """ + if value is None: + return value + + strs = [s.lower() if isinstance(s, str) else s for s in strs] + value = value.lower() + tmp_dict = dict(zip(strs, list(range(len(strs))))) + return str(tmp_dict[value]) + + +def compare_lists(l1, l2, diff_dict): + """ + Compares l1 and l2 lists and adds the items that are different + to the diff_dict dictionary. + Used in recursion with compare_dictionaries() function. + Args: + l1: first list to compare + l2: second list to compare + diff_dict: dictionary to store the difference + + Returns: + dict: items that are different + """ + if len(l1) != len(l2): + diff_dict.append(l1) + return diff_dict + for i, item in enumerate(l1): + if isinstance(item, dict): + diff_dict.insert(i, {}) + diff_dict[i] = compare_dictionaries(item, l2[i], diff_dict[i]) + else: + if item != l2[i]: + diff_dict.append(item) + while {} in diff_dict: + diff_dict.remove({}) + return diff_dict + + +def compare_dictionaries(d1, d2, diff_dict): + """ + Compares d1 and d2 dictionaries and adds the items that are different + to the diff_dict dictionary. + Used in recursion with compare_lists() function. + Args: + d1: first dictionary to compare + d2: second dictionary to compare + diff_dict: dictionary to store the difference + + Returns: + dict: items that are different + """ + for k, v in d1.items(): + if k not in d2: + diff_dict[k] = v + continue + if isinstance(v, dict): + diff_dict[k] = {} + compare_dictionaries(v, d2[k], diff_dict[k]) + if diff_dict[k] == {}: + del diff_dict[k] + else: + diff_dict[k] = v + elif isinstance(v, list): + diff_dict[k] = [] + compare_lists(v, d2[k], diff_dict[k]) + if diff_dict[k] == []: + del diff_dict[k] + else: + diff_dict[k] = v + else: + if v != d2[k]: + diff_dict[k] = v + return diff_dict + + +def cleanup_data(obj): + """Removes the None values from the object and returns the object + Args: + obj: object to cleanup + + Returns: + object: cleaned object + """ + if isinstance(obj, (list, tuple, set)): + return type(obj)(cleanup_data(x) for x in obj if x is not None) + elif isinstance(obj, dict): + return type(obj)((cleanup_data(k), cleanup_data(v)) + for k, v in obj.items() if k is not None and v is not None) + else: + return obj + + +def main(): + """Main ansible module function + """ + + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + esc_period=dict(type='str', required=False), + name=dict(type='str', required=True), + event_source=dict(type='str', required=False, choices=['trigger', 'discovery', 'auto_registration', 'internal']), + state=dict(type='str', required=False, default='present', choices=['present', 'absent']), + status=dict(type='str', required=False, default='enabled', choices=['enabled', 'disabled']), + pause_in_maintenance=dict(type='bool', required=False, default=True), + default_message=dict(type='str', required=False, default=''), + default_subject=dict(type='str', required=False, default=''), + recovery_default_message=dict(type='str', required=False, default=''), + recovery_default_subject=dict(type='str', required=False, default=''), + acknowledge_default_message=dict(type='str', required=False, default=''), + acknowledge_default_subject=dict(type='str', required=False, default=''), + conditions=dict( + type='list', + required=False, + default=[], + elements='dict', + options=dict( + formulaid=dict(type='str', required=False), + operator=dict(type='str', required=True), + type=dict(type='str', required=True), + value=dict(type='str', required=True), + value2=dict(type='str', required=False) + ), + required_if=[ + ['type', 'event_tag_value', ['value2']], + ] + ), + formula=dict(type='str', required=False, default=None), + eval_type=dict(type='str', required=False, default=None, choices=['andor', 'and', 'or', 'custom_expression']), + operations=dict( + type='list', + required=False, + default=[], + elements='dict', + options=dict( + type=dict( + type='str', + required=True, + choices=[ + 'send_message', + 'remote_command', + 'add_host', + 'remove_host', + 'add_to_host_group', + 'remove_from_host_group', + 'link_to_template', + 'unlink_from_template', + 'enable_host', + 'disable_host', + 'set_host_inventory_mode', + ] + ), + esc_period=dict(type='str', required=False), + esc_step_from=dict(type='int', required=False, default=1), + esc_step_to=dict(type='int', required=False, default=1), + operation_condition=dict( + type='str', + required=False, + default=None, + choices=['acknowledged', 'not_acknowledged'] + ), + # when type is remote_command + command_type=dict( + type='str', + required=False, + choices=[ + 'custom_script', + 'ipmi', + 'ssh', + 'telnet', + 'global_script' + ] + ), + command=dict(type='str', required=False), + execute_on=dict( + type='str', + required=False, + choices=['agent', 'server', 'proxy'] + ), + password=dict(type='str', required=False), + port=dict(type='int', required=False), + run_on_groups=dict(type='list', required=False), + run_on_hosts=dict(type='list', required=False), + script_name=dict(type='str', required=False), + ssh_auth_type=dict(type='str', required=False, choices=['password', 'public_key']), + ssh_privatekey_file=dict(type='str', required=False), + ssh_publickey_file=dict(type='str', required=False), + username=dict(type='str', required=False), + # when type is send_message + media_type=dict(type='str', required=False), + subject=dict(type='str', required=False), + message=dict(type='str', required=False), + send_to_groups=dict(type='list', required=False), + send_to_users=dict(type='list', required=False), + # when type is add_to_host_group or remove_from_host_group + host_groups=dict(type='list', required=False), + # when type is set_host_inventory_mode + inventory=dict(type='str', required=False, choices=['manual', 'automatic']), + # when type is link_to_template or unlink_from_template + templates=dict(type='list', required=False) + ), + required_if=[ + ['type', 'remote_command', ['command_type']], + ['type', 'remote_command', ['run_on_groups', 'run_on_hosts'], True], + ['command_type', 'custom_script', ['command', 'execute_on']], + ['command_type', 'ipmi', ['command']], + ['command_type', 'ssh', ['command', 'ssh_auth_type']], + ['ssh_auth_type', 'password', ['username', 'password']], + ['ssh_auth_type', 'public_key', ['username', 'ssh_privatekey_file', 'ssh_publickey_file']], + ['command_type', 'telnet', ['command', 'username', 'password']], + ['command_type', 'global_script', ['script_name']], + ['type', 'add_to_host_group', ['host_groups']], + ['type', 'remove_from_host_group', ['host_groups']], + ['type', 'link_to_template', ['templates']], + ['type', 'unlink_from_template', ['templates']], + ['type', 'set_host_inventory_mode', ['inventory']], + ['type', 'send_message', ['send_to_users', 'send_to_groups'], True] + ] + ), + recovery_operations=dict( + type='list', + required=False, + default=[], + elements='dict', + options=dict( + type=dict( + type='str', + required=True, + choices=[ + 'send_message', + 'remote_command', + 'notify_all_involved' + ] + ), + # when type is remote_command + command_type=dict( + type='str', + required=False, + choices=[ + 'custom_script', + 'ipmi', + 'ssh', + 'telnet', + 'global_script' + ] + ), + command=dict(type='str', required=False), + execute_on=dict( + type='str', + required=False, + choices=['agent', 'server', 'proxy'] + ), + password=dict(type='str', required=False), + port=dict(type='int', required=False), + run_on_groups=dict(type='list', required=False), + run_on_hosts=dict(type='list', required=False), + script_name=dict(type='str', required=False), + ssh_auth_type=dict(type='str', required=False, choices=['password', 'public_key']), + ssh_privatekey_file=dict(type='str', required=False), + ssh_publickey_file=dict(type='str', required=False), + username=dict(type='str', required=False), + # when type is send_message + media_type=dict(type='str', required=False), + subject=dict(type='str', required=False), + message=dict(type='str', required=False), + send_to_groups=dict(type='list', required=False), + send_to_users=dict(type='list', required=False), + ), + required_if=[ + ['type', 'remote_command', ['command_type']], + ['type', 'remote_command', [ + 'run_on_groups', + 'run_on_hosts' + ], True], + ['command_type', 'custom_script', [ + 'command', + 'execute_on' + ]], + ['command_type', 'ipmi', ['command']], + ['command_type', 'ssh', ['command', 'ssh_auth_type']], + ['ssh_auth_type', 'password', ['username', 'password']], + ['ssh_auth_type', 'public_key', ['username', 'ssh_privatekey_file', 'ssh_publickey_file']], + ['command_type', 'telnet', ['command', 'username', 'password']], + ['command_type', 'global_script', ['script_name']], + ['type', 'send_message', ['send_to_users', 'send_to_groups'], True] + ] + ), + acknowledge_operations=dict( + type='list', + required=False, + default=[], + elements='dict', + aliases=['update_operations'], + options=dict( + type=dict( + type='str', + required=True, + choices=[ + 'send_message', + 'remote_command', + 'notify_all_involved' + ] + ), + # when type is remote_command + command_type=dict( + type='str', + required=False, + choices=[ + 'custom_script', + 'ipmi', + 'ssh', + 'telnet', + 'global_script' + ] + ), + command=dict(type='str', required=False), + execute_on=dict( + type='str', + required=False, + choices=['agent', 'server', 'proxy'] + ), + password=dict(type='str', required=False), + port=dict(type='int', required=False), + run_on_groups=dict(type='list', required=False), + run_on_hosts=dict(type='list', required=False), + script_name=dict(type='str', required=False), + ssh_auth_type=dict(type='str', required=False, choices=['password', 'public_key']), + ssh_privatekey_file=dict(type='str', required=False), + ssh_publickey_file=dict(type='str', required=False), + username=dict(type='str', required=False), + # when type is send_message + media_type=dict(type='str', required=False), + subject=dict(type='str', required=False), + message=dict(type='str', required=False), + send_to_groups=dict(type='list', required=False), + send_to_users=dict(type='list', required=False), + ), + required_if=[ + ['type', 'remote_command', ['command_type']], + ['type', 'remote_command', [ + 'run_on_groups', + 'run_on_hosts' + ], True], + ['command_type', 'custom_script', [ + 'command', + 'execute_on' + ]], + ['command_type', 'ipmi', ['command']], + ['command_type', 'ssh', ['command', 'ssh_auth_type']], + ['ssh_auth_type', 'password', ['username', 'password']], + ['ssh_auth_type', 'public_key', ['username', 'ssh_privatekey_file', 'ssh_publickey_file']], + ['command_type', 'telnet', ['command', 'username', 'password']], + ['command_type', 'global_script', ['script_name']], + ['type', 'send_message', ['send_to_users', 'send_to_groups'], True] + ] + ) + )) + module = AnsibleModule( + argument_spec=argument_spec, + required_if=[ + ['state', 'present', [ + 'esc_period', + 'event_source' + ]] + ], + supports_check_mode=True + ) + + name = module.params['name'] + esc_period = module.params['esc_period'] + event_source = module.params['event_source'] + state = module.params['state'] + status = module.params['status'] + pause_in_maintenance = module.params['pause_in_maintenance'] + default_message = module.params['default_message'] + default_subject = module.params['default_subject'] + recovery_default_message = module.params['recovery_default_message'] + recovery_default_subject = module.params['recovery_default_subject'] + acknowledge_default_message = module.params['acknowledge_default_message'] + acknowledge_default_subject = module.params['acknowledge_default_subject'] + conditions = module.params['conditions'] + formula = module.params['formula'] + eval_type = module.params['eval_type'] + operations = module.params['operations'] + recovery_operations = module.params['recovery_operations'] + acknowledge_operations = module.params['acknowledge_operations'] + + zapi_wrapper = Zapi(module) + action = Action(module, zapi_wrapper=zapi_wrapper) + + action_exists = zapi_wrapper.check_if_action_exists(name) + ops = Operations(module, zapi_wrapper) + recovery_ops = RecoveryOperations(module, zapi_wrapper) + acknowledge_ops = AcknowledgeOperations(module, zapi_wrapper) + fltr = Filter(module, zapi_wrapper) + + if action_exists: + action_id = zapi_wrapper.get_action_by_name(name)['actionid'] + if state == "absent": + result = action.delete_action(action_id) + module.exit_json(changed=True, msg="Action Deleted: %s, ID: %s" % (name, result)) + else: + difference = action.check_difference( + action_id=action_id, + name=name, + event_source=event_source, + esc_period=esc_period, + status=status, + pause_in_maintenance=pause_in_maintenance, + default_message=default_message, + default_subject=default_subject, + recovery_default_message=recovery_default_message, + recovery_default_subject=recovery_default_subject, + acknowledge_default_message=acknowledge_default_message, + acknowledge_default_subject=acknowledge_default_subject, + operations=ops.construct_the_data(operations), + recovery_operations=recovery_ops.construct_the_data(recovery_operations), + acknowledge_operations=acknowledge_ops.construct_the_data(acknowledge_operations), + conditions=fltr.construct_the_data(eval_type, formula, conditions) + ) + + if difference == {}: + module.exit_json(changed=False, msg="Action is up to date: %s" % (name)) + else: + result = action.update_action( + action_id=action_id, + **difference + ) + module.exit_json(changed=True, msg="Action Updated: %s, ID: %s" % (name, result)) + else: + if state == "absent": + module.exit_json(changed=False) + else: + action_id = action.add_action( + name=name, + event_source=event_source, + esc_period=esc_period, + status=status, + pause_in_maintenance=pause_in_maintenance, + default_message=default_message, + default_subject=default_subject, + recovery_default_message=recovery_default_message, + recovery_default_subject=recovery_default_subject, + acknowledge_default_message=acknowledge_default_message, + acknowledge_default_subject=acknowledge_default_subject, + operations=ops.construct_the_data(operations), + recovery_operations=recovery_ops.construct_the_data(recovery_operations), + acknowledge_operations=acknowledge_ops.construct_the_data(acknowledge_operations), + conditions=fltr.construct_the_data(eval_type, formula, conditions) + ) + module.exit_json(changed=True, msg="Action created: %s, ID: %s" % (name, action_id)) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_discovery_rule.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_discovery_rule.py new file mode 100644 index 00000000..a8f13508 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_discovery_rule.py @@ -0,0 +1,691 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Tobias Birkefeld (@tcraxs) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = r''' +--- +module: zabbix_discovery_rule +short_description: Create/delete/update Zabbix discovery rules +description: + - Create discovery rule. + - Delete existing discovery rule. + - Update existing discovery rule with new options. +author: + - "Tobias Birkefeld (@tcraxs)" +requirements: + - "zabbix-api >= 0.5.4" +options: + state: + description: + - Create or delete discovery rules. + type: str + default: "present" + choices: [ "present", "absent" ] + name: + description: + - Name of the discovery rule. + required: true + type: str + iprange: + description: + - One or several IP ranges to check separated by commas. + type: list + elements: str + dchecks: + description: + - List of dictionaries of discovery check objects. + - For more information, review discovery check object documentation at + U(https://www.zabbix.com/documentation/current/manual/api/reference/dcheck/object) + suboptions: + type: + description: + - Type of check. + type: str + choices: ['SSH', + 'LDAP', + 'SMTP', + 'FTP', + 'HTTP', + 'POP', + 'NNTP', + 'IMAP', + 'TCP', + 'Zabbix', + 'SNMPv1', + 'SNMPv2', + 'ICMP', + 'SNMPv3', + 'HTTPS', + 'Telnet'] + ports: + description: + - One or several port ranges to check separated by commas. Used for all checks except for ICMP. + type: str + key: + description: + - "The value of this property differs depending on the type of the check:" + - "- key to query for Zabbix agent checks" + - "- SNMP OID for SNMPv1, SNMPv2 and SNMPv3 checks" + type: str + snmp_community: + description: + - SNMP community. + - Required for SNMPv1 and SNMPv2 agent checks. + type: str + snmpv3_authpassphrase: + description: + - Authentication passphrase used for SNMPv3 agent checks with security level set to authNoPriv or authPriv. + type: str + snmpv3_authprotocol: + description: + - Authentication protocol used for SNMPv3 agent checks with security level set to authNoPriv or authPriv. + - "Possible values:" + - MD5 + - SHA + type: str + choices: ["MD5", "SHA"] + snmpv3_contextname: + description: + - SNMPv3 context name. Used only by SNMPv3 checks. + type: str + snmpv3_privpassphrase: + description: + - Privacy passphrase used for SNMPv3 agent checks with security level set to authPriv. + type: str + snmpv3_privprotocol: + description: + - Privacy protocol used for SNMPv3 agent checks with security level set to authPriv. + - "Possible values:" + - DES + - AES + type: str + choices: ["DES", "AES"] + snmpv3_securitylevel: + description: + - Security level used for SNMPv3 agent checks. + - "Possible values:" + - noAuthNoPriv + - authNoPriv + - authPriv + type: str + choices: ["noAuthNoPriv", "authNoPriv", "authPriv"] + snmpv3_securityname: + description: + - Security name used for SNMPv3 agent checks. + type: str + uniq: + description: + - Whether to use this check as a device uniqueness criteria. + - Only a single unique check can be configured for a discovery rule. + - Used for Zabbix agent, SNMPv1, SNMPv2 and SNMPv3 agent checks. + - "Possible values:" + - "no - (default) do not use this check as a uniqueness criteria" + - "yes - use this check as a uniqueness criteria" + type: bool + default: no + host_source: + description: + - Source for host name. + - "Possible values:" + - "DNS (default)" + - "IP" + - "discovery - discovery value of this check" + - Options is available since Zabbix 4.4 + type: str + default: "DNS" + choices: ["DNS", "IP", "discovery"] + name_source: + description: + - Source for visible name. + - "Possible values:" + - "none - (default) not specified" + - "DNS" + - "IP" + - "discovery - discovery value of this check" + - Options is available since Zabbix 4.4 + type: str + default: "None" + choices: ["None", "DNS", "IP", "discovery"] + type: list + elements: dict + aliases: [ "dcheck" ] + delay: + description: + - Execution interval of the discovery rule. + - Accepts seconds, time unit with suffix and user macro. + type: str + default: "1h" + proxy: + description: + - Name of the proxy used for discovery. + type: str + status: + description: + - Whether the discovery rule is enabled. + - "Possible values:" + - enabled (default) + - disabled + type: str + default: "enabled" + choices: ["enabled", "disabled"] +notes: + - Only Zabbix >= 4.0 is supported. +extends_documentation_fragment: + - community.zabbix.zabbix +''' + +EXAMPLES = r''' +# Base create discovery rule example +- name: Create discovery rule with ICMP and zabbix agent checks + community.zabbix.zabbix_discovery_rule: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + name: ACME + state: present + iprange: 192.168.1.1-255 + dchecks: + - type: ICMP + - type: Zabbix + key: "system.hostname" + ports: 10050 + uniq: yes + host_source: "discovery" + +# Base update (add new dcheck) discovery rule example +- name: Create discovery rule with ICMP and zabbix agent checks + community.zabbix.zabbix_discovery_rule: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + name: ACME + state: present + iprange: 192.168.1.1-255 + dchecks: + - type: SNMPv3 + snmp_community: CUSTOMER@snmp3-readonly + ports: "161" + key: iso.3.6.1.2.1.1.1.0 + snmpv3_contextname: "ContextName" + snmpv3_securityname: "SecurityName" + snmpv3_securitylevel: "authPriv" + snmpv3_authprotocol: "SHA" + snmpv3_authpassphrase: "SeCrEt" + snmpv3_privprotocol: "AES" + snmpv3_privpassphrase: "TopSecret" + uniq: no + host_source: "DNS" + name_source: "None" + +# Base delete discovery rule example +- name: Delete discovery rule + community.zabbix.zabbix_discovery_rule: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + name: ACME + state: absent +''' + +RETURN = r''' +state: + description: Discovery rule state at the end of execution. + returned: on success + type: str + sample: 'present' +drule: + description: Discovery rule name. + returned: on success + type: str + sample: 'ACME' +druleid: + description: Discovery rule id. + returned: on success + type: str + sample: '42' +msg: + description: The result of the operation + returned: always + type: str + sample: 'Discovery rule created: ACME, ID: 42' +''' + + +from distutils.version import LooseVersion +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Dchecks(ZabbixBase): + """ + Restructures the user defined discovery checks to fit the Zabbix API requirements + """ + + def construct_the_data(self, _dchecks): + """Construct the user defined discovery check to fit the Zabbix API + requirements + Args: + _dchecks: discovery checks to construct + Returns: + dict: user defined discovery checks + """ + if _dchecks is None: + return None + constructed_data = [] + for check in _dchecks: + constructed_check = { + 'type': zabbix_utils.helper_to_numeric_value([ + 'SSH', + 'LDAP', + 'SMTP', + 'FTP', + 'HTTP', + 'POP', + 'NNTP', + 'IMAP', + 'TCP', + 'Zabbix', + 'SNMPv1', + 'SNMPv2', + 'ICMP', + 'SNMPv3', + 'HTTPS', + 'Telnet'], check.get('type') + ), + 'uniq': int(check.get('uniq')) + } + if LooseVersion(self._zbx_api_version) >= LooseVersion('4.4'): + constructed_check.update({ + 'host_source': zabbix_utils.helper_to_numeric_value([ + 'None', + 'DNS', + 'IP', + 'discovery'], check.get('host_source') + ), + 'name_source': zabbix_utils.helper_to_numeric_value([ + 'None', + 'DNS', + 'IP', + 'discovery'], check.get('name_source') + ) + }) + if constructed_check['type'] in (0, 1, 2, 3, 4, 5, 6, 7, 8, 14, 15): + constructed_check['ports'] = check.get('ports') + if constructed_check['type'] == 9: + constructed_check['ports'] = check.get('ports') + constructed_check['key_'] = check.get('key') + if constructed_check['type'] in (10, 11): + constructed_check['ports'] = check.get('ports') + constructed_check['snmp_community'] = check.get('snmp_community') + constructed_check['key_'] = check.get('key') + if constructed_check['type'] == 13: + constructed_check['ports'] = check.get('ports') + constructed_check['key_'] = check.get('key') + constructed_check['snmpv3_contextname'] = check.get('snmpv3_contextname') + constructed_check['snmpv3_securityname'] = check.get('snmpv3_securityname') + constructed_check['snmpv3_securitylevel'] = zabbix_utils.helper_to_numeric_value([ + 'noAuthNoPriv', + 'authNoPriv', + 'authPriv'], check.get('snmpv3_securitylevel') + ) + if constructed_check['snmpv3_securitylevel'] in (1, 2): + constructed_check['snmpv3_authprotocol'] = zabbix_utils.helper_to_numeric_value([ + 'MD5', + 'SHA'], check.get('snmpv3_authprotocol') + ) + constructed_check['snmpv3_authpassphrase'] = check.get('snmpv3_authpassphrase') + if constructed_check['snmpv3_securitylevel'] == 2: + constructed_check['snmpv3_privprotocol'] = zabbix_utils.helper_to_numeric_value([ + 'DES', + 'AES'], check.get('snmpv3_privprotocol') + ) + constructed_check['snmpv3_privpassphrase'] = check.get('snmpv3_privpassphrase') + constructed_data.append(constructed_check) + return zabbix_utils.helper_cleanup_data(constructed_data) + + +class DiscoveryRule(ZabbixBase): + def check_if_drule_exists(self, name): + """Check if discovery rule exists. + Args: + name: Name of the discovery rule. + Returns: + The return value. True for success, False otherwise. + """ + try: + _drule = self._zapi.drule.get({ + 'output': 'extend', + 'selectDChecks': 'extend', + 'filter': {'name': [name]} + }) + if len(_drule) > 0: + return _drule + except Exception as e: + self._module.fail_json(msg="Failed to check if discovery rule '%s' exists: %s" + % (name, e)) + + def get_drule_by_drule_name(self, name): + """Get discovery rule by discovery rule name + Args: + name: discovery rule name. + Returns: + discovery rule matching discovery rule name + """ + try: + drule_list = self._zapi.drule.get({ + 'output': 'extend', + 'selectDChecks': 'extend', + 'filter': {'name': [name]} + }) + if len(drule_list) < 1: + self._module.fail_json(msg="Discovery rule not found: %s" % name) + else: + return drule_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get discovery rule '%s': %s" % (name, e)) + + def get_proxy_by_proxy_name(self, proxy_name): + """Get proxy by proxy name + Args: + proxy_name: proxy name. + Returns: + proxy matching proxy name + """ + try: + proxy_list = self._zapi.proxy.get({ + 'output': 'extend', + 'selectInterface': 'extend', + 'filter': {'host': [proxy_name]} + }) + if len(proxy_list) < 1: + self._module.fail_json(msg="Proxy not found: %s" % proxy_name) + else: + return proxy_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get proxy '%s': %s" % (proxy_name, e)) + + def _construct_parameters(self, **kwargs): + """Construct parameters. + Args: + **kwargs: Arbitrary keyword parameters. + Returns: + dict: dictionary of specified parameters + """ + _params = { + 'name': kwargs['name'], + 'iprange': ','.join(kwargs['iprange']), + 'delay': kwargs['delay'], + 'status': zabbix_utils.helper_to_numeric_value([ + 'enabled', + 'disabled'], kwargs['status'] + ), + 'dchecks': kwargs['dchecks'] + } + if kwargs['proxy']: + _params['proxy_hostid'] = self.get_proxy_by_proxy_name(kwargs['proxy'])['proxyid'] + return _params + + def check_difference(self, **kwargs): + """Check difference between discovery rule and user specified parameters. + Args: + **kwargs: Arbitrary keyword parameters. + Returns: + dict: dictionary of differences + """ + existing_drule = zabbix_utils.helper_convert_unicode_to_str(self.check_if_drule_exists(kwargs['name'])[0]) + parameters = zabbix_utils.helper_convert_unicode_to_str(self._construct_parameters(**kwargs)) + change_parameters = {} + if existing_drule['nextcheck']: + existing_drule.pop('nextcheck') + _diff = zabbix_utils.helper_cleanup_data(compare_dictionaries(parameters, existing_drule, change_parameters)) + return _diff + + def update_drule(self, **kwargs): + """Update discovery rule. + Args: + **kwargs: Arbitrary keyword parameters. + Returns: + drule: updated discovery rule + """ + try: + if self._module.check_mode: + self._module.exit_json(msg="Discovery rule would be updated if check mode was not specified: ID %s" % kwargs['drule_id'], changed=True) + kwargs['druleid'] = kwargs.pop('drule_id') + return self._zapi.drule.update(kwargs) + except Exception as e: + self._module.fail_json(msg="Failed to update discovery rule ID '%s': %s" % (kwargs['drule_id'], e)) + + def add_drule(self, **kwargs): + """Add discovery rule + Args: + **kwargs: Arbitrary keyword parameters + Returns: + drule: created discovery rule + """ + try: + if self._module.check_mode: + self._module.exit_json(msg="Discovery rule would be added if check mode was not specified", changed=True) + parameters = self._construct_parameters(**kwargs) + drule_list = self._zapi.drule.create(parameters) + return drule_list['druleids'][0] + except Exception as e: + self._module.fail_json(msg="Failed to create discovery rule %s: %s" % (kwargs['name'], e)) + + def delete_drule(self, drule_id): + """Delete discovery rule. + Args: + drule_id: Discovery rule id + Returns: + drule: deleted discovery rule + """ + try: + if self._module.check_mode: + self._module.exit_json(changed=True, msg="Discovery rule would be deleted if check mode was not specified") + return self._zapi.drule.delete([drule_id]) + except Exception as e: + self._module.fail_json(msg="Failed to delete discovery rule '%s': %s" % (drule_id, e)) + + +def compare_lists(l1, l2, diff_dict): + """ + Compares l1 and l2 lists and adds the items that are different + to the diff_dict dictionary. + Used in recursion with compare_dictionaries() function. + Args: + l1: first list to compare + l2: second list to compare + diff_dict: dictionary to store the difference + Returns: + dict: items that are different + """ + if len(l1) != len(l2): + diff_dict.append(l1) + return diff_dict + for i, item in enumerate(l1): + if isinstance(item, dict): + diff_dict.insert(i, {}) + diff_dict[i] = compare_dictionaries(item, l2[i], diff_dict[i]) + else: + if item != l2[i]: + diff_dict.append(item) + while {} in diff_dict: + diff_dict.remove({}) + return diff_dict + + +def compare_dictionaries(d1, d2, diff_dict): + """ + Compares d1 and d2 dictionaries and adds the items that are different + to the diff_dict dictionary. + Used in recursion with compare_lists() function. + Args: + d1: first dictionary to compare + d2: second dictionary to compare + diff_dict: dictionary to store the difference + Returns: + dict: items that are different + """ + for k, v in d1.items(): + if k not in d2: + diff_dict[k] = v + continue + if isinstance(v, dict): + diff_dict[k] = {} + compare_dictionaries(v, d2[k], diff_dict[k]) + if diff_dict[k] == {}: + del diff_dict[k] + else: + diff_dict[k] = v + elif isinstance(v, list): + diff_dict[k] = [] + compare_lists(v, d2[k], diff_dict[k]) + if diff_dict[k] == []: + del diff_dict[k] + else: + diff_dict[k] = v + else: + if v != d2[k]: + diff_dict[k] = v + return diff_dict + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update( + name=dict(type='str', required=True), + iprange=dict(type='list', required=False, elements='str'), + dchecks=dict( + type='list', + required=False, + aliases=['dcheck'], + elements='dict', + options=dict( + type=dict(type='str', choices=[ + 'SSH', + 'LDAP', + 'SMTP', + 'FTP', + 'HTTP', + 'POP', + 'NNTP', + 'IMAP', + 'TCP', + 'Zabbix', + 'SNMPv1', + 'SNMPv2', + 'ICMP', + 'SNMPv3', + 'HTTPS', + 'Telnet'] + ), + ports=dict(type='str'), + key=dict(type='str'), + snmp_community=dict(type='str'), + snmpv3_authpassphrase=dict(type='str'), + snmpv3_authprotocol=dict(type='str', choices=['MD5', 'SHA']), + snmpv3_contextname=dict(type='str'), + snmpv3_privpassphrase=dict(type='str'), + snmpv3_privprotocol=dict(type='str', choices=['DES', 'AES']), + snmpv3_securitylevel=dict(type='str', choices=['noAuthNoPriv', 'authNoPriv', 'authPriv']), + snmpv3_securityname=dict(type='str'), + uniq=dict(type='bool', default=False), + host_source=dict(type='str', choices=['DNS', 'IP', 'discovery'], default='DNS'), + name_source=dict(type='str', choices=['None', 'DNS', 'IP', 'discovery'], default='None') + ), + required_if=[ + ['type', 'SSH', ['ports']], + ['type', 'LDAP', ['ports']], + ['type', 'SMTP', ['ports']], + ['type', 'FTP', ['ports']], + ['type', 'HTTP', ['ports']], + ['type', 'POP', ['ports']], + ['type', 'NNTP', ['ports']], + ['type', 'IMAP', ['ports']], + ['type', 'TCP', ['ports']], + ['type', 'Zabbix', ['ports', 'key']], + ['type', 'SNMPv1', ['ports', 'key', 'snmp_community']], + ['type', 'SNMPv2', ['ports', 'key', 'snmp_community']], + ['type', 'SNMPv3', ['ports', 'key']], + ['type', 'HTTPS', ['ports']], + ['type', 'Telnet', ['ports']], + ['snmpv3_securitylevel', 'authPriv', ['snmpv3_privpassphrase']] + ] + ), + delay=dict(type='str', required=False, default='1h'), + proxy=dict(type='str', required=False, default=None), + status=dict(type='str', default="enabled", choices=["enabled", "disabled"]), + state=dict(type='str', default='present', choices=['present', 'absent']) + ) + + module = AnsibleModule( + argument_spec=argument_spec, + required_if=[ + ['state', 'present', ['name', 'iprange', 'dchecks']], + ['state', 'absent', ['name']], + ], + supports_check_mode=True + ) + + state = module.params['state'] + name = module.params['name'] + iprange = module.params['iprange'] + dchecks = module.params['dchecks'] + delay = module.params['delay'] + proxy = module.params['proxy'] + status = module.params['status'] + + drule = DiscoveryRule(module) + # reuse zabbix-api login + zbx = drule._zapi + dcks = Dchecks(module, zbx) + + drule_exists = drule.check_if_drule_exists(name) + + if drule_exists: + drule_id = drule.get_drule_by_drule_name(name)['druleid'] + if state == "absent": + drule.delete_drule(drule_id) + module.exit_json(changed=True, state=state, drule=name, druleid=drule_id, msg="Discovery Rule deleted: %s, ID: %s" % (name, drule_id)) + else: + difference = drule.check_difference( + drule_id=drule_id, + name=name, + iprange=iprange, + dchecks=dcks.construct_the_data(dchecks), + delay=delay, + proxy=proxy, + status=status + ) + + if difference == {}: + module.exit_json(changed=False, state=state, drule=name, druleid=drule_id, msg="Discovery Rule is up to date: %s" % name) + else: + drule_id = drule.update_drule( + drule_id=drule_id, + **difference + ) + module.exit_json(changed=True, state=state, drule=name, druleid=drule_id, msg="Discovery Rule updated: %s, ID: %s" % (name, drule_id)) + else: + if state == "absent": + module.exit_json(changed=False, state=state, drule=name, msg="Discovery rule %s does not exist, nothing to delete" % name) + else: + drule_id = drule.add_drule( + name=name, + iprange=iprange, + dchecks=dcks.construct_the_data(dchecks), + delay=delay, + proxy=proxy, + status=status + ) + module.exit_json(changed=True, state=state, drule=name, druleid=drule_id, msg="Discovery Rule created: %s, ID: %s" % (name, drule_id)) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group.py new file mode 100644 index 00000000..9946051f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group.py @@ -0,0 +1,176 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# (c) 2013-2014, Epic Games, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: zabbix_group +short_description: Create/delete Zabbix host groups +description: + - Create host groups if they do not exist. + - Delete existing host groups if they exist. +author: + - "Cove (@cove)" + - "Tony Minfei Ding (!UNKNOWN)" + - "Harrison Gu (@harrisongu)" +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + state: + description: + - Create or delete host group. + required: false + type: str + default: "present" + choices: [ "present", "absent" ] + host_groups: + description: + - List of host groups to create or delete. + required: true + type: list + elements: str + aliases: [ "host_group" ] + +extends_documentation_fragment: +- community.zabbix.zabbix + +notes: + - Too many concurrent updates to the same group may cause Zabbix to return errors, see examples for a workaround if needed. +''' + +EXAMPLES = r''' +# Base create host groups example +- name: Create host groups + local_action: + module: community.zabbix.zabbix_group + server_url: http://monitor.example.com + login_user: username + login_password: password + state: present + host_groups: + - Example group1 + - Example group2 + +# Limit the Zabbix group creations to one host since Zabbix can return an error when doing concurrent updates +- name: Create host groups + local_action: + module: community.zabbix.zabbix_group + server_url: http://monitor.example.com + login_user: username + login_password: password + state: present + host_groups: + - Example group1 + - Example group2 + when: inventory_hostname==groups['group_name'][0] +''' + + +import traceback + +try: + from zabbix_api import Already_Exists + + HAS_ZABBIX_API = True +except ImportError: + ZBX_IMP_ERR = traceback.format_exc() + HAS_ZABBIX_API = False + +from ansible.module_utils.basic import AnsibleModule, missing_required_lib + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class HostGroup(ZabbixBase): + # create host group(s) if not exists + def create_host_group(self, group_names): + try: + group_add_list = [] + for group_name in group_names: + result = self._zapi.hostgroup.get({'filter': {'name': group_name}}) + if not result: + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.hostgroup.create({'name': group_name}) + group_add_list.append(group_name) + except Already_Exists: + return group_add_list + return group_add_list + except Exception as e: + self._module.fail_json(msg="Failed to create host group(s): %s" % e) + + # delete host group(s) + def delete_host_group(self, group_ids): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.hostgroup.delete(group_ids) + except Exception as e: + self._module.fail_json(msg="Failed to delete host group(s), Exception: %s" % e) + + # get group ids by name + def get_group_ids(self, host_groups): + group_ids = [] + + group_list = self._zapi.hostgroup.get({'output': 'extend', 'filter': {'name': host_groups}}) + for group in group_list: + group_id = group['groupid'] + group_ids.append(group_id) + return group_ids, group_list + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + host_groups=dict(type='list', required=True, aliases=['host_group']), + state=dict(type='str', default="present", choices=['present', 'absent']), + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + if not HAS_ZABBIX_API: + module.fail_json(msg=missing_required_lib('zabbix-api', url='https://pypi.org/project/zabbix-api/'), exception=ZBX_IMP_ERR) + + host_groups = module.params['host_groups'] + state = module.params['state'] + + hostGroup = HostGroup(module) + + group_ids = [] + group_list = [] + if host_groups: + group_ids, group_list = hostGroup.get_group_ids(host_groups) + + if state == "absent": + # delete host groups + if group_ids: + delete_group_names = [] + hostGroup.delete_host_group(group_ids) + for group in group_list: + delete_group_names.append(group['name']) + module.exit_json(changed=True, + result="Successfully deleted host group(s): %s." % ",".join(delete_group_names)) + else: + module.exit_json(changed=False, result="No host group(s) to delete.") + else: + # create host groups + group_add_list = hostGroup.create_host_group(host_groups) + if len(group_add_list) > 0: + module.exit_json(changed=True, result="Successfully created host group(s): %s" % group_add_list) + else: + module.exit_json(changed=False) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group_facts.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group_facts.py new file mode 100644 index 00000000..42eb88fd --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group_facts.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) me@mimiko.me +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +RETURN = r''' +--- +host_groups: + description: List of Zabbix groups. + returned: success + type: dict + sample: [ { "flags": "0", "groupid": "33", "internal": "0", "name": "Hostgruup A" } ] +''' + +DOCUMENTATION = r''' +--- +module: zabbix_group_info +short_description: Gather information about Zabbix hostgroup +description: + - This module allows you to search for Zabbix hostgroup entries. + - This module was called C(zabbix_group_facts) before Ansible 2.9. The usage did not change. +author: + - "Michael Miko (@RedWhiteMiko)" +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + hostgroup_name: + description: + - Name of the hostgroup in Zabbix. + - hostgroup is the unique identifier used and cannot be updated using this module. + required: true + type: list + elements: str + +extends_documentation_fragment: +- community.zabbix.zabbix +''' + +EXAMPLES = r''' +- name: Get hostgroup info + local_action: + module: community.zabbix.zabbix_group_info + server_url: http://monitor.example.com + login_user: username + login_password: password + hostgroup_name: + - ExampleHostgroup + timeout: 10 +''' + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Host(ZabbixBase): + def get_group_ids_by_group_names(self, group_names): + group_list = self._zapi.hostgroup.get({'output': 'extend', 'filter': {'name': group_names}}) + if len(group_list) < 1: + self._module.fail_json(msg="Hostgroup not found: %s" % group_names) + return group_list + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + hostgroup_name=dict(type='list', required=True), + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + if module._name == 'zabbix_group_facts': + module.deprecate("The 'zabbix_group_facts' module has been renamed to 'zabbix_group_info'", + collection_name="community.zabbix", version='2.0.0') # was 2.13 + + hostgroup_name = module.params['hostgroup_name'] + + host = Host(module) + host_groups = host.get_group_ids_by_group_names(hostgroup_name) + module.exit_json(host_groups=host_groups) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group_info.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group_info.py new file mode 100644 index 00000000..42eb88fd --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_group_info.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) me@mimiko.me +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +RETURN = r''' +--- +host_groups: + description: List of Zabbix groups. + returned: success + type: dict + sample: [ { "flags": "0", "groupid": "33", "internal": "0", "name": "Hostgruup A" } ] +''' + +DOCUMENTATION = r''' +--- +module: zabbix_group_info +short_description: Gather information about Zabbix hostgroup +description: + - This module allows you to search for Zabbix hostgroup entries. + - This module was called C(zabbix_group_facts) before Ansible 2.9. The usage did not change. +author: + - "Michael Miko (@RedWhiteMiko)" +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + hostgroup_name: + description: + - Name of the hostgroup in Zabbix. + - hostgroup is the unique identifier used and cannot be updated using this module. + required: true + type: list + elements: str + +extends_documentation_fragment: +- community.zabbix.zabbix +''' + +EXAMPLES = r''' +- name: Get hostgroup info + local_action: + module: community.zabbix.zabbix_group_info + server_url: http://monitor.example.com + login_user: username + login_password: password + hostgroup_name: + - ExampleHostgroup + timeout: 10 +''' + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Host(ZabbixBase): + def get_group_ids_by_group_names(self, group_names): + group_list = self._zapi.hostgroup.get({'output': 'extend', 'filter': {'name': group_names}}) + if len(group_list) < 1: + self._module.fail_json(msg="Hostgroup not found: %s" % group_names) + return group_list + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + hostgroup_name=dict(type='list', required=True), + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + if module._name == 'zabbix_group_facts': + module.deprecate("The 'zabbix_group_facts' module has been renamed to 'zabbix_group_info'", + collection_name="community.zabbix", version='2.0.0') # was 2.13 + + hostgroup_name = module.params['hostgroup_name'] + + host = Host(module) + host_groups = host.get_group_ids_by_group_names(hostgroup_name) + module.exit_json(host_groups=host_groups) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py new file mode 100644 index 00000000..82e14cc4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py @@ -0,0 +1,1205 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2013-2014, Epic Games, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: zabbix_host +short_description: Create/update/delete Zabbix hosts +description: + - This module allows you to create, modify and delete Zabbix host entries and associated group and template data. +author: + - "Cove (@cove)" + - Tony Minfei Ding (!UNKNOWN) + - Harrison Gu (@harrisongu) + - Werner Dijkerman (@dj-wasabi) + - Eike Frost (@eikef) +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + host_name: + description: + - Name of the host in Zabbix. + - I(host_name) is the unique identifier used and cannot be updated using this module. + required: true + type: str + visible_name: + description: + - Visible name of the host in Zabbix. + type: str + description: + description: + - Description of the host in Zabbix. + type: str + host_groups: + description: + - List of host groups the host is part of. + type: list + elements: str + link_templates: + description: + - List of templates linked to the host. + type: list + elements: str + inventory_mode: + description: + - Configure the inventory mode. + choices: ['automatic', 'manual', 'disabled'] + type: str + inventory_zabbix: + description: + - Add Facts for a zabbix inventory (e.g. Tag) (see example below). + - Please review the interface documentation for more information on the supported properties + - U(https://www.zabbix.com/documentation/3.2/manual/api/reference/host/object#host_inventory) + type: dict + status: + description: + - Monitoring status of the host. + choices: ['enabled', 'disabled'] + default: 'enabled' + type: str + state: + description: + - State of the host. + - On C(present), it will create if host does not exist or update the host if the associated data is different. + - On C(absent) will remove a host if it exists. + choices: ['present', 'absent'] + default: 'present' + type: str + proxy: + description: + - The name of the Zabbix proxy to be used. + type: str + interfaces: + type: list + elements: dict + description: + - List of interfaces to be created for the host (see example below). + - For more information, review host interface documentation at + - U(https://www.zabbix.com/documentation/4.0/manual/api/reference/hostinterface/object) + default: [] + suboptions: + type: + type: str + description: + - Interface type to add + - Numerical values are also accepted for interface type + - 1 = agent + - 2 = snmp + - 3 = ipmi + - 4 = jmx + choices: ['agent', '1', 'snmp', '2', 'ipmi', '3', 'jmx', '4'] + required: true + main: + type: int + description: + - Whether the interface is used as default. + - If multiple interfaces with the same type are provided, only one can be default. + - 0 (not default), 1 (default) + default: 0 + choices: [0, 1] + useip: + type: int + description: + - Connect to host interface with IP address instead of DNS name. + - 0 (don't use ip), 1 (use ip) + default: 0 + choices: [0, 1] + ip: + type: str + description: + - IP address used by host interface. + - Required if I(useip=1). + default: '' + dns: + type: str + description: + - DNS name of the host interface. + - Required if I(useip=0). + default: '' + port: + type: str + description: + - Port used by host interface. + - If not specified, default port for each type of interface is used + - 10050 if I(type='agent') + - 161 if I(type='snmp') + - 623 if I(type='ipmi') + - 12345 if I(type='jmx') + bulk: + type: int + description: + - Whether to use bulk SNMP requests. + - Only valid when interface I(type='snmp'). + - 0 (don't use bulk requests), 1 (use bulk requests) + - Works only with Zabbix <= 4.4 and is silently ignored in higher versions. + - Use I(details) with Zabbix >= 5.0. + choices: [0, 1] + default: 1 + details: + type: dict + description: + - Additional details for SNMP host interfaces. + - Required when I(type='snmp'). + - Works only with Zabbix >= 5.0. + default: {} + suboptions: + version: + type: int + description: + - SNMP version. + - 1 (SNMPv1), 2 (SNMPv2c), 3 (SNMPv3) + choices: [1, 2, 3] + default: 2 + bulk: + type: int + description: + - Whether to use bulk SNMP requests. + - 0 (don't use bulk requests), 1 (use bulk requests) + choices: [0, 1] + default: 1 + community: + type: str + description: + - SNMPv1 and SNMPv2 community string. + - Required when I(version=1) or I(version=2). + securityname: + type: str + description: + - SNMPv3 security name. + default: '' + contextname: + type: str + description: + - SNMPv3 context name. + default: '' + securitylevel: + type: int + description: + - SNMPv3 security level. + - 0 (noAuthNoPriv), 1 (authNoPriv), 2 (authPriv). + choices: [0, 1, 2] + default: 0 + authprotocol: + type: int + description: + - SNMPv3 authentication protocol. + - Used when I(securitylevel=1)(authNoPriv) or I(securitylevel=2)(AuthPriv). + - 0 (MD5), 1 (SHA) + default: 0 + choices: [0, 1] + authpassphrase: + type: str + description: + - SNMPv3 authentication passphrase. + - Used when I(securitylevel=1)(authNoPriv) or I(securitylevel=2)(AuthPriv). + default: '' + privprotocol: + type: int + description: + - SNMPv3 privacy protocol. + - Used when I(securitylevel=2)(authPriv). + - 0 (DES), 1 (AES) + default: 0 + choices: [0, 1] + privpassphrase: + type: str + description: + - SNMPv3 privacy passphrase. + - Used when I(securitylevel=2)(AuthPriv). + default: '' + tls_connect: + description: + - Specifies what encryption to use for outgoing connections. + - Possible values, 1 (no encryption), 2 (PSK), 4 (certificate). + - Works only with >= Zabbix 3.0 + default: 1 + type: int + tls_accept: + description: + - Specifies what types of connections are allowed for incoming connections. + - The tls_accept parameter accepts values of 1 to 7 + - Possible values, 1 (no encryption), 2 (PSK), 4 (certificate). + - Values can be combined. + - Works only with >= Zabbix 3.0 + default: 1 + type: int + tls_psk_identity: + description: + - It is a unique name by which this specific PSK is referred to by Zabbix components + - Do not put sensitive information in the PSK identity string, it is transmitted over the network unencrypted. + - Works only with >= Zabbix 3.0 + type: str + tls_psk: + description: + - PSK value is a hard to guess string of hexadecimal digits. + - The preshared key, at least 32 hex digits. Required if either I(tls_connect) or I(tls_accept) has PSK enabled. + - Works only with >= Zabbix 3.0 + type: str + ca_cert: + description: + - Required certificate issuer. + - Works only with >= Zabbix 3.0 + aliases: [ tls_issuer ] + type: str + tls_subject: + description: + - Required certificate subject. + - Works only with >= Zabbix 3.0 + type: str + ipmi_authtype: + description: + - IPMI authentication algorithm. + - Please review the Host object documentation for more information on the supported properties + - 'https://www.zabbix.com/documentation/3.4/manual/api/reference/host/object' + - Possible values are, C(0) (none), C(1) (MD2), C(2) (MD5), C(4) (straight), C(5) (OEM), C(6) (RMCP+), + with -1 being the API default. + - Please note that the Zabbix API will treat absent settings as default when updating + any of the I(ipmi_)-options; this means that if you attempt to set any of the four + options individually, the rest will be reset to default values. + type: int + ipmi_privilege: + description: + - IPMI privilege level. + - Please review the Host object documentation for more information on the supported properties + - 'https://www.zabbix.com/documentation/3.4/manual/api/reference/host/object' + - Possible values are C(1) (callback), C(2) (user), C(3) (operator), C(4) (admin), C(5) (OEM), with C(2) + being the API default. + - also see the last note in the I(ipmi_authtype) documentation + type: int + ipmi_username: + description: + - IPMI username. + - also see the last note in the I(ipmi_authtype) documentation + type: str + ipmi_password: + description: + - IPMI password. + - also see the last note in the I(ipmi_authtype) documentation + type: str + force: + description: + - Overwrite the host configuration, even if already present. + type: bool + default: 'yes' + macros: + description: + - List of user macros to assign to the zabbix host. + - Providing I(macros=[]) with I(force=yes) will clean all of the existing user macros from the host. + type: list + elements: dict + suboptions: + macro: + description: + - Name of the user macro. + - Can be in zabbix native format "{$MACRO}" or short format "MACRO". + type: str + required: true + value: + description: + - Value of the user macro. + type: str + required: true + description: + description: + - Description of the user macro. + - Works only with >= Zabbix 4.4. + type: str + required: false + default: '' + type: + description: + - Type of the macro. + - Works only with >= Zabbix 5.0. + - Since value is not returned by API for secret macros, there is no reliable way to + detect changes in the content of secret macro value. + - To update secret macro value, please update description alongside it so it passes + the check. + choices: [text, secret] + type: str + required: false + default: text + aliases: [ user_macros ] + tags: + description: + - List of host tags to assign to the zabbix host. + - Works only with >= Zabbix 4.2. + - Providing I(tags=[]) with I(force=yes) will clean all of the tags from the host. + type: list + elements: dict + suboptions: + tag: + description: + - Name of the host tag. + type: str + required: true + value: + description: + - Value of the host tag. + type: str + default: '' + aliases: [ host_tags ] + +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = r''' +- name: Create a new host or update an existing host's info + local_action: + module: community.zabbix.zabbix_host + server_url: http://monitor.example.com + login_user: username + login_password: password + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - Example group1 + - Example group2 + link_templates: + - Example template1 + - Example template2 + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: "{{ your_tag }}" + alias: "{{ your_alias }}" + notes: "Special Informations: {{ your_informations | default('None') }}" + location: "{{ your_location }}" + site_rack: "{{ your_site_rack }}" + os: "{{ your_os }}" + hardware: "{{ your_hardware }}" + ipmi_authtype: 2 + ipmi_privilege: 4 + ipmi_username: username + ipmi_password: password + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.xx.xx.xx + dns: "" + port: "10050" + - type: 4 + main: 1 + useip: 1 + ip: 10.xx.xx.xx + dns: "" + port: "12345" + proxy: a.zabbix.proxy + macros: + - macro: '{$EXAMPLEMACRO}' + value: ExampleMacroValue + - macro: EXAMPLEMACRO2 + value: ExampleMacroValue2 + description: Example desc that work only with Zabbix 4.4 and higher + tags: + - tag: ExampleHostsTag + - tag: ExampleHostsTag2 + value: ExampleTagValue + +- name: Update an existing host's TLS settings + local_action: + module: community.zabbix.zabbix_host + server_url: http://monitor.example.com + login_user: username + login_password: password + host_name: ExampleHost + visible_name: ExampleName + host_groups: + - Example group1 + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 +''' + + +import copy + +from distutils.version import LooseVersion +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Host(ZabbixBase): + # exist host + def is_host_exist(self, host_name): + result = self._zapi.host.get({'filter': {'host': host_name}}) + return result + + # check if host group exists + def check_host_group_exist(self, group_names): + for group_name in group_names: + result = self._zapi.hostgroup.get({'filter': {'name': group_name}}) + if not result: + self._module.fail_json(msg="Hostgroup not found: %s" % group_name) + return True + + def get_template_ids(self, template_list): + template_ids = [] + if template_list is None or len(template_list) == 0: + return template_ids + for template in template_list: + template_list = self._zapi.template.get({'output': 'extend', 'filter': {'host': template}}) + if len(template_list) < 1: + self._module.fail_json(msg="Template not found: %s" % template) + else: + template_id = template_list[0]['templateid'] + template_ids.append(template_id) + return template_ids + + def add_host(self, host_name, group_ids, status, interfaces, proxy_id, visible_name, description, tls_connect, + tls_accept, tls_psk_identity, tls_psk, tls_issuer, tls_subject, ipmi_authtype, ipmi_privilege, + ipmi_username, ipmi_password, macros, tags): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + parameters = {'host': host_name, 'interfaces': interfaces, 'groups': group_ids, 'status': status, + 'tls_connect': tls_connect, 'tls_accept': tls_accept} + if proxy_id: + parameters['proxy_hostid'] = proxy_id + if visible_name: + parameters['name'] = visible_name + if tls_psk_identity is not None: + parameters['tls_psk_identity'] = tls_psk_identity + if tls_psk is not None: + parameters['tls_psk'] = tls_psk + if tls_issuer is not None: + parameters['tls_issuer'] = tls_issuer + if tls_subject is not None: + parameters['tls_subject'] = tls_subject + if description: + parameters['description'] = description + if ipmi_authtype is not None: + parameters['ipmi_authtype'] = ipmi_authtype + if ipmi_privilege is not None: + parameters['ipmi_privilege'] = ipmi_privilege + if ipmi_username is not None: + parameters['ipmi_username'] = ipmi_username + if ipmi_password is not None: + parameters['ipmi_password'] = ipmi_password + if macros is not None: + parameters['macros'] = macros + if tags is not None: + parameters['tags'] = tags + + host_list = self._zapi.host.create(parameters) + if len(host_list) >= 1: + return host_list['hostids'][0] + except Exception as e: + self._module.fail_json(msg="Failed to create host %s: %s" % (host_name, e)) + + def update_host(self, host_name, group_ids, status, host_id, interfaces, exist_interface_list, proxy_id, + visible_name, description, tls_connect, tls_accept, tls_psk_identity, tls_psk, tls_issuer, + tls_subject, ipmi_authtype, ipmi_privilege, ipmi_username, ipmi_password, macros, tags): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + parameters = {'hostid': host_id, 'groups': group_ids, 'status': status, 'tls_connect': tls_connect, + 'tls_accept': tls_accept} + if proxy_id >= 0: + parameters['proxy_hostid'] = proxy_id + if visible_name: + parameters['name'] = visible_name + if tls_psk_identity: + parameters['tls_psk_identity'] = tls_psk_identity + if tls_psk: + parameters['tls_psk'] = tls_psk + if tls_issuer: + parameters['tls_issuer'] = tls_issuer + if tls_subject: + parameters['tls_subject'] = tls_subject + if description: + parameters['description'] = description + if ipmi_authtype: + parameters['ipmi_authtype'] = ipmi_authtype + if ipmi_privilege: + parameters['ipmi_privilege'] = ipmi_privilege + if ipmi_username: + parameters['ipmi_username'] = ipmi_username + if ipmi_password: + parameters['ipmi_password'] = ipmi_password + if macros is not None: + parameters['macros'] = macros + if tags is not None: + parameters['tags'] = tags + + self._zapi.host.update(parameters) + interface_list_copy = exist_interface_list + if interfaces: + for interface in interfaces: + flag = False + interface_str = interface + for exist_interface in exist_interface_list: + interface_type = int(interface['type']) + exist_interface_type = int(exist_interface['type']) + if interface_type == exist_interface_type: + # update + interface_str['interfaceid'] = exist_interface['interfaceid'] + self._zapi.hostinterface.update(interface_str) + flag = True + interface_list_copy.remove(exist_interface) + break + if not flag: + # add + interface_str['hostid'] = host_id + self._zapi.hostinterface.create(interface_str) + # remove + remove_interface_ids = [] + for remove_interface in interface_list_copy: + interface_id = remove_interface['interfaceid'] + remove_interface_ids.append(interface_id) + if len(remove_interface_ids) > 0: + self._zapi.hostinterface.delete(remove_interface_ids) + except Exception as e: + self._module.fail_json(msg="Failed to update host %s: %s" % (host_name, e)) + + def delete_host(self, host_id, host_name): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.host.delete([host_id]) + except Exception as e: + self._module.fail_json(msg="Failed to delete host %s: %s" % (host_name, e)) + + # get host by host name + def get_host_by_host_name(self, host_name): + params = { + 'output': 'extend', + 'selectInventory': 'extend', + 'selectMacros': 'extend', + 'filter': { + 'host': [host_name] + } + } + + if LooseVersion(self._zbx_api_version) >= LooseVersion('4.2.0'): + params.update({'selectTags': 'extend'}) + + host_list = self._zapi.host.get(params) + if len(host_list) < 1: + self._module.fail_json(msg="Host not found: %s" % host_name) + else: + return host_list[0] + + # get proxyid by proxy name + def get_proxyid_by_proxy_name(self, proxy_name): + proxy_list = self._zapi.proxy.get({'output': 'extend', 'filter': {'host': [proxy_name]}}) + if len(proxy_list) < 1: + self._module.fail_json(msg="Proxy not found: %s" % proxy_name) + else: + return int(proxy_list[0]['proxyid']) + + # get group ids by group names + def get_group_ids_by_group_names(self, group_names): + if self.check_host_group_exist(group_names): + return self._zapi.hostgroup.get({'output': 'groupid', 'filter': {'name': group_names}}) + + # get host groups ids by host id + def get_group_ids_by_host_id(self, host_id): + return self._zapi.hostgroup.get({'output': 'groupid', 'hostids': host_id}) + + # get host templates by host id + def get_host_templates_by_host_id(self, host_id): + template_ids = [] + template_list = self._zapi.template.get({'output': 'extend', 'hostids': host_id}) + for template in template_list: + template_ids.append(template['templateid']) + return template_ids + + def construct_host_interfaces(self, interfaces): + """Ensures interfaces object is properly formatted before submitting it to API. + + Args: + interfaces (list): list of dictionaries for each interface present on the host. + + Returns: + (interfaces, ip) - where interfaces is original list reformated into a valid format + and ip is any IP address found on interface of type agent (printing purposes only). + """ + ip = "" + interface_types = {'agent': 1, 'snmp': 2, 'ipmi': 3, 'jmx': 4} + type_to_port = {1: '10050', 2: '161', 3: '623', 4: '12345'} + + for interface in interfaces: + if interface['type'] in list(interface_types.keys()): + interface['type'] = interface_types[interface['type']] + else: + interface['type'] = int(interface['type']) + + if interface['type'] == 1: + ip = interface.get('ip', '') + + if 'port' not in interface or interface['port'] is None: + interface['port'] = type_to_port.get(interface['type'], '') + + if LooseVersion(self._zbx_api_version) >= LooseVersion('5.0.0'): + if 'bulk' in interface: + del interface['bulk'] + + # Not handled in argument_spec with required_if since only SNMP interfaces are using details + if interface['type'] == 2: + if not interface['details']: + self._module.fail_json(msg='Option "details" required for SNMP interface {0}'.format(interface)) + + i_details = interface['details'] + if i_details['version'] < 3 and not i_details.get('community', False): + self._module.fail_json( + msg='Option "community" is required in "details" for SNMP interface {0}'.format(interface)) + + else: + interface['details'] = {} + + else: + if 'details' in interface: + del interface['details'] + + return (interfaces, ip) + + # check the exist_interfaces whether it equals the interfaces or not + def check_interface_properties(self, exist_interfaces, interfaces): + # hostinterface.details looks different based on the version of SNMP currently configured + snmp_ver_keys = { + 1: ['version', 'bulk', 'community'], + 2: ['version', 'bulk', 'community'], + 3: [ + 'version', 'bulk', 'securityname', 'securitylevel', 'authprotocol', + 'authpassphrase', 'privprotocol', 'privpassphrase', 'contextname' + ] + } + + i_ports = [] + for interface in interfaces: + i_ports.append(interface['port']) + + exist_i_ports = [] + for interface in exist_interfaces: + exist_i_ports.append(interface['port']) + + if sorted(i_ports) != sorted(exist_i_ports): + return True + + for exist_interface in exist_interfaces: + exist_interface_port = str(exist_interface['port']) + + # Zabbix API should return empty dictionary instead of list, workaround: + if 'details' in exist_interface and not exist_interface['details']: + exist_interface['details'] = {} + + for interface in interfaces: + if str(interface['port']) == exist_interface_port: + for key in interface.keys(): + # since 5.0, zabbix API returns details for each host interface, but only SNMP is not empty + if key == 'details': + if interface['details']: + # only data relevant to a particular version are returned and rest should be filtered + snmp_ver = int(interface['details']['version']) + for dkey in list(interface['details'].keys()): + if dkey not in snmp_ver_keys[snmp_ver]: + interface['details'].pop(dkey) + else: + interface['details'][dkey] = str(interface['details'][dkey]) + + # either compare empty or filtered dictionaries + if interface['details'] != exist_interface['details']: + return True + + elif str(exist_interface[key]) != str(interface[key]): + return True + + return False + + # get the status of host by host + def get_host_status_by_host(self, host): + return host['status'] + + # check all the properties before link or clear template + def check_all_properties(self, host_id, group_ids, status, interfaces, template_ids, + exist_interfaces, host, proxy_id, visible_name, description, host_name, + inventory_mode, inventory_zabbix, tls_accept, tls_psk_identity, tls_psk, + tls_issuer, tls_subject, tls_connect, ipmi_authtype, ipmi_privilege, + ipmi_username, ipmi_password, macros, tags): + # get the existing host's groups + exist_host_groups = sorted(self.get_group_ids_by_host_id(host_id), key=lambda k: k['groupid']) + if sorted(group_ids, key=lambda k: k['groupid']) != exist_host_groups: + return True + + # get the existing status + exist_status = self.get_host_status_by_host(host) + if int(status) != int(exist_status): + return True + + # check the exist_interfaces whether it equals the interfaces or not + if self.check_interface_properties(exist_interfaces, interfaces): + return True + + # get the existing templates + exist_template_ids = self.get_host_templates_by_host_id(host_id) + if set(list(template_ids)) != set(exist_template_ids): + return True + + if int(host['proxy_hostid']) != int(proxy_id): + return True + + # Check whether the visible_name has changed; Zabbix defaults to the technical hostname if not set. + if visible_name: + if host['name'] != visible_name: + return True + + # Only compare description if it is given as a module parameter + if description: + if host['description'] != description: + return True + + if inventory_mode: + if LooseVersion(self._zbx_api_version) <= LooseVersion('4.4.0'): + if host['inventory']: + if int(host['inventory']['inventory_mode']) != self.inventory_mode_numeric(inventory_mode): + return True + elif inventory_mode != 'disabled': + return True + else: + if int(host['inventory_mode']) != self.inventory_mode_numeric(inventory_mode): + return True + + if inventory_zabbix: + proposed_inventory = copy.deepcopy(host['inventory']) + proposed_inventory.update(inventory_zabbix) + if proposed_inventory != host['inventory']: + return True + + if tls_accept is not None and 'tls_accept' in host: + if int(host['tls_accept']) != tls_accept: + return True + + if tls_psk_identity is not None and 'tls_psk_identity' in host: + if host['tls_psk_identity'] != tls_psk_identity: + return True + + if tls_psk is not None and 'tls_psk' in host: + if host['tls_psk'] != tls_psk: + return True + + if tls_issuer is not None and 'tls_issuer' in host: + if host['tls_issuer'] != tls_issuer: + return True + + if tls_subject is not None and 'tls_subject' in host: + if host['tls_subject'] != tls_subject: + return True + + if tls_connect is not None and 'tls_connect' in host: + if int(host['tls_connect']) != tls_connect: + return True + if ipmi_authtype is not None: + if int(host['ipmi_authtype']) != ipmi_authtype: + return True + if ipmi_privilege is not None: + if int(host['ipmi_privilege']) != ipmi_privilege: + return True + if ipmi_username is not None: + if host['ipmi_username'] != ipmi_username: + return True + if ipmi_password is not None: + if host['ipmi_password'] != ipmi_password: + return True + + # hostmacroid and hostid are present in every item of host['macros'] and need to be removed + if macros is not None and 'macros' in host: + t_macros = copy.deepcopy(macros) # make copy to prevent change in original data + existing_macros = sorted(host['macros'], key=lambda k: k['macro']) + for macro in existing_macros: + macro.pop('hostid', False) + macro.pop('hostmacroid', False) + if 'type' in macro: + macro['type'] = int(macro['type']) + + # 'secret' type macros don't return 'value' from API + if LooseVersion(self._zbx_api_version) >= LooseVersion('5.0'): + for macro in t_macros: + if macro['type'] == 1: + macro.pop('value', False) + + if sorted(t_macros, key=lambda k: k['macro']) != existing_macros: + return True + + if tags is not None and 'tags' in host: + if sorted(tags, key=lambda k: k['tag']) != sorted(host['tags'], key=lambda k: k['tag']): + return True + + return False + + # link or clear template of the host + def link_or_clear_template(self, host_id, template_id_list, tls_connect, tls_accept, tls_psk_identity, tls_psk, + tls_issuer, tls_subject, ipmi_authtype, ipmi_privilege, ipmi_username, ipmi_password): + # get host's exist template ids + exist_template_id_list = self.get_host_templates_by_host_id(host_id) + + exist_template_ids = set(exist_template_id_list) + template_ids = set(template_id_list) + template_id_list = list(template_ids) + + # get unlink and clear templates + templates_clear = exist_template_ids.difference(template_ids) + templates_clear_list = list(templates_clear) + request_str = {'hostid': host_id, 'templates': template_id_list, 'templates_clear': templates_clear_list, + 'tls_connect': tls_connect, 'tls_accept': tls_accept, 'ipmi_authtype': ipmi_authtype, + 'ipmi_privilege': ipmi_privilege, 'ipmi_username': ipmi_username, 'ipmi_password': ipmi_password} + if tls_psk_identity is not None: + request_str['tls_psk_identity'] = tls_psk_identity + if tls_psk is not None: + request_str['tls_psk'] = tls_psk + if tls_issuer is not None: + request_str['tls_issuer'] = tls_issuer + if tls_subject is not None: + request_str['tls_subject'] = tls_subject + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.host.update(request_str) + except Exception as e: + self._module.fail_json(msg="Failed to link template to host: %s" % e) + + def inventory_mode_numeric(self, inventory_mode): + if inventory_mode == "automatic": + return int(1) + elif inventory_mode == "manual": + return int(0) + elif inventory_mode == "disabled": + return int(-1) + return inventory_mode + + # Update the host inventory_mode + def update_inventory_mode(self, host_id, inventory_mode): + + # nothing was set, do nothing + if not inventory_mode: + return + + inventory_mode = self.inventory_mode_numeric(inventory_mode) + + # watch for - https://support.zabbix.com/browse/ZBX-6033 + request_str = {'hostid': host_id, 'inventory_mode': inventory_mode} + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.host.update(request_str) + except Exception as e: + self._module.fail_json(msg="Failed to set inventory_mode to host: %s" % e) + + def update_inventory_zabbix(self, host_id, inventory): + + if not inventory: + return + + request_str = {'hostid': host_id, 'inventory': inventory} + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.host.update(request_str) + except Exception as e: + self._module.fail_json(msg="Failed to set inventory to host: %s" % e) + + +def normalize_macro_name(macro_name): + # Zabbix handles macro names in upper case characters + if ':' in macro_name: + macro_name = ':'.join([macro_name.split(':')[0].upper(), ':'.join(macro_name.split(':')[1:])]) + else: + macro_name = macro_name.upper() + + # Valid format for macro is {$MACRO} + if not macro_name.startswith('{$'): + macro_name = '{$' + macro_name + if not macro_name.endswith('}'): + macro_name = macro_name + '}' + + return macro_name + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + host_name=dict(type='str', required=True), + host_groups=dict(type='list', required=False), + link_templates=dict(type='list', required=False), + status=dict(type='str', default="enabled", choices=['enabled', 'disabled']), + state=dict(type='str', default="present", choices=['present', 'absent']), + inventory_mode=dict(type='str', required=False, choices=['automatic', 'manual', 'disabled']), + ipmi_authtype=dict(type='int', default=None), + ipmi_privilege=dict(type='int', default=None), + ipmi_username=dict(type='str', required=False, default=None), + ipmi_password=dict(type='str', required=False, default=None, no_log=True), + tls_connect=dict(type='int', default=1), + tls_accept=dict(type='int', default=1), + tls_psk_identity=dict(type='str', required=False), + tls_psk=dict(type='str', required=False), + ca_cert=dict(type='str', required=False, aliases=['tls_issuer']), + tls_subject=dict(type='str', required=False), + inventory_zabbix=dict(type='dict', required=False), + interfaces=dict( + type='list', + elements='dict', + default=[], + options=dict( + type=dict(type='str', required=True, choices=['agent', '1', 'snmp', '2', 'ipmi', '3', 'jmx', '4']), + main=dict(type='int', choices=[0, 1], default=0), + useip=dict(type='int', choices=[0, 1], default=0), + ip=dict(type='str', default=''), + dns=dict(type='str', default=''), + port=dict(type='str'), + bulk=dict(type='int', choices=[0, 1], default=1), + details=dict( + type='dict', + default={}, + options=dict( + version=dict(type='int', choices=[1, 2, 3], default=2), + bulk=dict(type='int', choices=[0, 1], default=1), + community=dict(type='str'), + securityname=dict(type='str', default=''), + contextname=dict(type='str', default=''), + securitylevel=dict(type='int', choices=[0, 1, 2], default=0), + authprotocol=dict(type='int', choices=[0, 1], default=0), + authpassphrase=dict(type='str', default=''), + privprotocol=dict(type='int', choices=[0, 1], default=0), + privpassphrase=dict(type='str', default='') + ) + ) + ), + required_if=[ + ['useip', 0, ['dns']], + ['useip', 1, ['ip']] + ] + ), + force=dict(type='bool', default=True), + proxy=dict(type='str', required=False), + visible_name=dict(type='str', required=False), + description=dict(type='str', required=False), + macros=dict( + type='list', + elements='dict', + aliases=['user_macros'], + options=dict( + macro=dict(type='str', required=True), + value=dict(type='str', required=True), + description=dict(type='str', default=''), + type=dict(type='str', default='text', choices=['text', 'secret']) + ) + ), + tags=dict( + type='list', + elements='dict', + aliases=['host_tags'], + options=dict( + tag=dict(type='str', required=True), + value=dict(type='str', default='') + ) + ) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + host_name = module.params['host_name'] + visible_name = module.params['visible_name'] + description = module.params['description'] + host_groups = module.params['host_groups'] + link_templates = module.params['link_templates'] + inventory_mode = module.params['inventory_mode'] + ipmi_authtype = module.params['ipmi_authtype'] + ipmi_privilege = module.params['ipmi_privilege'] + ipmi_username = module.params['ipmi_username'] + ipmi_password = module.params['ipmi_password'] + tls_connect = module.params['tls_connect'] + tls_accept = module.params['tls_accept'] + tls_psk_identity = module.params['tls_psk_identity'] + tls_psk = module.params['tls_psk'] + tls_issuer = module.params['ca_cert'] + tls_subject = module.params['tls_subject'] + inventory_zabbix = module.params['inventory_zabbix'] + status = module.params['status'] + state = module.params['state'] + interfaces = module.params['interfaces'] + force = module.params['force'] + proxy = module.params['proxy'] + macros = module.params['macros'] + tags = module.params['tags'] + + # convert enabled to 0; disabled to 1 + status = 1 if status == "disabled" else 0 + + host = Host(module) + + template_ids = [] + if link_templates: + template_ids = host.get_template_ids(link_templates) + + group_ids = [] + + if host_groups: + group_ids = host.get_group_ids_by_group_names(host_groups) + + interfaces, ip = host.construct_host_interfaces(interfaces) + + if macros: + # convert macros to zabbix native format - {$MACRO} + for macro in macros: + macro['macro'] = normalize_macro_name(macro['macro']) + + if LooseVersion(host._zbx_api_version) <= LooseVersion('4.4.0'): + if 'description' in macro: + macro.pop('description', False) + + if 'type' in macro: + if LooseVersion(host._zbx_api_version) < LooseVersion('5.0.0'): + macro.pop('type') + else: + if macro['type'] == 'text': + macro['type'] = 0 + elif macro['type'] == 'secret': + macro['type'] = 1 + + # Use proxy specified, or set to 0 + if proxy: + proxy_id = host.get_proxyid_by_proxy_name(proxy) + else: + proxy_id = 0 + + # check if host exist + is_host_exist = host.is_host_exist(host_name) + + if is_host_exist: + # get host id by host name + zabbix_host_obj = host.get_host_by_host_name(host_name) + host_id = zabbix_host_obj['hostid'] + + # If proxy is not specified as a module parameter, use the existing setting + if proxy is None: + proxy_id = int(zabbix_host_obj['proxy_hostid']) + + if state == "absent": + # remove host + host.delete_host(host_id, host_name) + module.exit_json(changed=True, result="Successfully delete host %s" % host_name) + else: + if not host_groups: + # if host_groups have not been specified when updating an existing host, just + # get the group_ids from the existing host without updating them. + group_ids = host.get_group_ids_by_host_id(host_id) + + # get existing host's interfaces + exist_interfaces = host._zapi.hostinterface.get({'output': 'extend', 'hostids': host_id}) + exist_interfaces.sort(key=lambda x: int(x['interfaceid'])) + + # When force=no is specified, append existing interfaces to interfaces to update. When + # no interfaces have been specified, copy existing interfaces as specified from the API. + # Do the same with templates and host groups. + if not force or not interfaces: + for interface in copy.deepcopy(exist_interfaces): + # remove values not used during hostinterface.add/update calls + for key in tuple(interface.keys()): + if key in ['interfaceid', 'hostid']: + interface.pop(key, None) + + for index in interface.keys(): + if index in ['useip', 'main', 'type', 'bulk']: + interface[index] = int(interface[index]) + elif index == 'details' and not interface[index]: + interface[index] = {} + + if interface not in interfaces: + interfaces.append(interface) + + if not force or link_templates is None: + template_ids = list(set(template_ids + host.get_host_templates_by_host_id(host_id))) + + if not force: + for group_id in host.get_group_ids_by_host_id(host_id): + if group_id not in group_ids: + group_ids.append(group_id) + + # Macros not present in host.update will be removed if we dont copy them when force=no + if macros is not None and 'macros' in zabbix_host_obj.keys(): + provided_macros = [m['macro'] for m in macros] + existing_macros = zabbix_host_obj['macros'] + for macro in existing_macros: + if macro['macro'] not in provided_macros: + macros.append(macro) + + # Tags not present in host.update will be removed if we dont copy them when force=no + if tags is not None and 'tags' in zabbix_host_obj.keys(): + provided_tags = [t['tag'] for t in tags] + existing_tags = zabbix_host_obj['tags'] + for tag in existing_tags: + if tag['tag'] not in provided_tags: + tags.append(tag) + + # update host + if host.check_all_properties( + host_id, group_ids, status, interfaces, template_ids, exist_interfaces, zabbix_host_obj, proxy_id, + visible_name, description, host_name, inventory_mode, inventory_zabbix, tls_accept, + tls_psk_identity, tls_psk, tls_issuer, tls_subject, tls_connect, ipmi_authtype, ipmi_privilege, + ipmi_username, ipmi_password, macros, tags): + + host.update_host( + host_name, group_ids, status, host_id, interfaces, exist_interfaces, proxy_id, visible_name, + description, tls_connect, tls_accept, tls_psk_identity, tls_psk, tls_issuer, tls_subject, + ipmi_authtype, ipmi_privilege, ipmi_username, ipmi_password, macros, tags) + + host.link_or_clear_template( + host_id, template_ids, tls_connect, tls_accept, tls_psk_identity, tls_psk, tls_issuer, + tls_subject, ipmi_authtype, ipmi_privilege, ipmi_username, ipmi_password) + + host.update_inventory_mode(host_id, inventory_mode) + host.update_inventory_zabbix(host_id, inventory_zabbix) + + module.exit_json(changed=True, + result="Successfully update host %s (%s) and linked with template '%s'" + % (host_name, ip, link_templates)) + else: + module.exit_json(changed=False) + + else: + if state == "absent": + # the host is already deleted. + module.exit_json(changed=False) + + if not group_ids: + module.fail_json(msg="Specify at least one group for creating host '%s'." % host_name) + + if not interfaces or (interfaces and len(interfaces) == 0): + if LooseVersion(host._zbx_api_version) < LooseVersion('5.2.0'): + module.fail_json(msg="Specify at least one interface for creating host '%s'." % host_name) + + # create host + host_id = host.add_host( + host_name, group_ids, status, interfaces, proxy_id, visible_name, description, tls_connect, tls_accept, + tls_psk_identity, tls_psk, tls_issuer, tls_subject, ipmi_authtype, ipmi_privilege, ipmi_username, + ipmi_password, macros, tags) + + host.link_or_clear_template( + host_id, template_ids, tls_connect, tls_accept, tls_psk_identity, tls_psk, tls_issuer, tls_subject, + ipmi_authtype, ipmi_privilege, ipmi_username, ipmi_password) + + host.update_inventory_mode(host_id, inventory_mode) + host.update_inventory_zabbix(host_id, inventory_zabbix) + + module.exit_json(changed=True, result="Successfully added host %s (%s) and linked with template '%s'" % ( + host_name, ip, link_templates)) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_events_info.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_events_info.py new file mode 100644 index 00000000..d3412378 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_events_info.py @@ -0,0 +1,296 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) stephane.travassac@fr.clara.net +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +from __future__ import (absolute_import, division, print_function) + +__metaclass__ = type + +RETURN = ''' +--- +triggers_ok: + description: Host Zabbix Triggers in OK state + returned: On success + type: complex + contains: + comments: + description: Additional description of the trigger + type: str + description: + description: Name of the trigger + type: str + error: + description: Error text if there have been any problems when updating the state of the trigger + type: str + expression: + description: Reduced trigger expression + type: str + flags: + description: Origin of the trigger + type: int + lastchange: + description: Time when the trigger last changed its state (timestamp) + type: int + priority: + description: Severity of the trigger + type: int + state: + description: State of the trigger + type: int + status: + description: Whether the trigger is enabled or disabled + type: int + templateid: + description: ID of the parent template trigger + type: int + triggerid: + description: ID of the trigger + type: int + type: + description: Whether the trigger can generate multiple problem events + type: int + url: + description: URL associated with the trigger + type: str + value: + description: Whether the trigger is in OK or problem state + type: int +triggers_problem: + description: Host Zabbix Triggers in problem state. See trigger and event objects in API documentation of your zabbix version for more + returned: On success + type: complex + contains: + comments: + description: Additional description of the trigger + type: str + description: + description: Name of the trigger + type: str + error: + description: Error text if there have been any problems when updating the state of the trigger + type: str + expression: + description: Reduced trigger expression + type: str + flags: + description: Origin of the trigger + type: int + last_event: + description: last event informations + type: complex + contains: + acknowledged: + description: If set to true return only acknowledged events + type: int + acknowledges: + description: acknowledges informations + type: complex + contains: + alias: + description: Account who acknowledge + type: str + clock: + description: Time when the event was created (timestamp) + type: int + message: + description: Text of the acknowledgement message + type: str + clock: + description: Time when the event was created (timestamp) + type: int + eventid: + description: ID of the event + type: int + value: + description: State of the related object + type: int + lastchange: + description: Time when the trigger last changed its state (timestamp) + type: int + priority: + description: Severity of the trigger + type: int + state: + description: State of the trigger + type: int + status: + description: Whether the trigger is enabled or disabled + type: int + templateid: + description: ID of the parent template trigger + type: int + triggerid: + description: ID of the trigger + type: int + type: + description: Whether the trigger can generate multiple problem events + type: int + url: + description: URL associated with the trigger + type: str + value: + description: Whether the trigger is in OK or problem state + type: int +''' + +DOCUMENTATION = ''' +--- +module: zabbix_host_events_info +short_description: Get all triggers about a Zabbix host +description: + - This module allows you to see if a Zabbix host have no active alert to make actions on it. + For this case use module Ansible 'fail' to exclude host in trouble. + - Length of "triggers_ok" allow if template's triggers exist for Zabbix Host +author: + - "Stéphane Travassac (@stravassac)" +requirements: + - "python >= 2.7" + - "zabbix-api >= 0.5.3" +options: + host_identifier: + description: + - Identifier of Zabbix Host + required: true + type: str + host_id_type: + description: + - Type of host_identifier + choices: + - hostname + - visible_name + - hostid + required: false + default: hostname + type: str + trigger_severity: + description: + - Zabbix severity for search filter + default: average + required: false + choices: + - not_classified + - information + - warning + - average + - high + - disaster + type: str +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = ''' +- name: exclude machine if alert active on it + community.zabbix.zabbix_host_events_info: + server_url: "{{ zabbix_url }}" + login_user: "{{ lookup('env','ZABBIX_USER') }}" + login_password: "{{ lookup('env','ZABBIX_PASSWORD') }}" + host_identifier: "{{inventory_hostname}}" + host_id_type: "hostname" + timeout: 120 + register: zbx_host + delegate_to: localhost +- fail: + msg: "machine alert in zabbix" + when: zbx_host['triggers_problem']|length > 0 +''' + + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Host(ZabbixBase): + def get_host(self, host_identifier, host_inventory, search_key): + """ Get host by hostname|visible_name|hostid """ + host = self._zapi.host.get( + {'output': 'extend', 'selectParentTemplates': ['name'], 'filter': {search_key: host_identifier}, + 'selectInventory': host_inventory}) + if len(host) < 1: + self._module.fail_json(msg="Host not found: %s" % host_identifier) + else: + return host[0] + + def get_triggers_by_host_id_in_problem_state(self, host_id, trigger_severity): + """ Get triggers in problem state from a hostid""" + # https://www.zabbix.com/documentation/3.4/manual/api/reference/trigger/get + output = 'extend' + triggers_list = self._zapi.trigger.get({'output': output, 'hostids': host_id, + 'min_severity': trigger_severity}) + return triggers_list + + def get_last_event_by_trigger_id(self, triggers_id): + """ Get the last event from triggerid""" + output = ['eventid', 'clock', 'acknowledged', 'value'] + select_acknowledges = ['clock', 'alias', 'message'] + event = self._zapi.event.get({'output': output, 'objectids': triggers_id, + 'select_acknowledges': select_acknowledges, "limit": 1, "sortfield": "clock", + "sortorder": "DESC"}) + return event[0] + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + host_identifier=dict(type='str', required=True), + host_id_type=dict( + default='hostname', + type='str', + choices=['hostname', 'visible_name', 'hostid']), + trigger_severity=dict( + type='str', + required=False, + default='average', + choices=['not_classified', 'information', 'warning', 'average', 'high', 'disaster']), + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + trigger_severity_map = {'not_classified': 0, 'information': 1, 'warning': 2, 'average': 3, 'high': 4, 'disaster': 5} + host_id = module.params['host_identifier'] + host_id_type = module.params['host_id_type'] + trigger_severity = trigger_severity_map[module.params['trigger_severity']] + + host_inventory = 'hostid' + + host = Host(module) + + if host_id_type == 'hostname': + zabbix_host = host.get_host(host_id, host_inventory, 'host') + host_id = zabbix_host['hostid'] + + elif host_id_type == 'visible_name': + zabbix_host = host.get_host(host_id, host_inventory, 'name') + host_id = zabbix_host['hostid'] + + elif host_id_type == 'hostid': + ''' check hostid exist''' + zabbix_host = host.get_host(host_id, host_inventory, 'hostid') + + triggers = host.get_triggers_by_host_id_in_problem_state(host_id, trigger_severity) + + triggers_ok = [] + triggers_problem = [] + for trigger in triggers: + # tGet last event for trigger with problem value = 1 + # https://www.zabbix.com/documentation/3.4/manual/api/reference/trigger/object + if int(trigger['value']) == 1: + event = host.get_last_event_by_trigger_id(trigger['triggerid']) + trigger['last_event'] = event + triggers_problem.append(trigger) + else: + triggers_ok.append(trigger) + + module.exit_json(ok=True, triggers_ok=triggers_ok, triggers_problem=triggers_problem) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_facts.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_facts.py new file mode 100644 index 00000000..c2e7a773 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_facts.py @@ -0,0 +1,213 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) me@mimiko.me +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +RETURN = r''' +--- +hosts: + description: List of Zabbix hosts. See https://www.zabbix.com/documentation/4.0/manual/api/reference/host/get for list of host values. + returned: success + type: dict + sample: [ { "available": "1", "description": "", "disable_until": "0", "error": "", "flags": "0", "groups": ["1"], "host": "Host A", ... } ] +''' + +DOCUMENTATION = r''' +--- +module: zabbix_host_info +short_description: Gather information about Zabbix host +description: + - This module allows you to search for Zabbix host entries. + - This module was called C(zabbix_host_facts) before Ansible 2.9. The usage did not change. +author: + - "Michael Miko (@RedWhiteMiko)" +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + host_name: + description: + - Name of the host in Zabbix. + - host_name is the unique identifier used and cannot be updated using this module. + - Required when I(host_ip) is not used. + required: false + type: str + host_ip: + description: + - Host interface IP of the host in Zabbix. + - Required when I(host_name) is not used. + required: false + type: list + elements: str + exact_match: + description: + - Find the exact match + type: bool + default: no + remove_duplicate: + description: + - Remove duplicate host from host result + type: bool + default: yes + host_inventory: + description: + - List of host inventory keys to display in result. + - Whole host inventory is retrieved if keys are not specified. + type: list + elements: str + required: false +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = r''' +- name: Get host info + local_action: + module: community.zabbix.zabbix_host_info + server_url: http://monitor.example.com + login_user: username + login_password: password + host_name: ExampleHost + host_ip: 127.0.0.1 + timeout: 10 + exact_match: no + remove_duplicate: yes + +- name: Reduce host inventory information to provided keys + local_action: + module: community.zabbix.zabbix_host_info + server_url: http://monitor.example.com + login_user: username + login_password: password + host_name: ExampleHost + host_inventory: + - os + - tag + host_ip: 127.0.0.1 + timeout: 10 + exact_match: no + remove_duplicate: yes +''' + + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Host(ZabbixBase): + def get_hosts_by_host_name(self, host_name, exact_match, host_inventory): + """ Get host by host name """ + search_key = 'search' + if exact_match: + search_key = 'filter' + host_list = self._zapi.host.get({ + 'output': 'extend', + 'selectParentTemplates': ['name'], + search_key: {'host': [host_name]}, + 'selectInventory': host_inventory, + 'selectGroups': 'extend', + 'selectTags': 'extend', + 'selectMacros': 'extend' + }) + if len(host_list) < 1: + self._module.fail_json(msg="Host not found: %s" % host_name) + else: + return host_list + + def get_hosts_by_ip(self, host_ips, host_inventory): + """ Get host by host ip(s) """ + hostinterfaces = self._zapi.hostinterface.get({ + 'output': 'extend', + 'filter': { + 'ip': host_ips + } + }) + if len(hostinterfaces) < 1: + self._module.fail_json(msg="Host not found: %s" % host_ips) + host_list = [] + for hostinterface in hostinterfaces: + host = self._zapi.host.get({ + 'output': 'extend', + 'selectGroups': 'extend', + 'selectParentTemplates': ['name'], + 'hostids': hostinterface['hostid'], + 'selectInventory': host_inventory, + 'selectTags': 'extend', + 'selectMacros': 'extend' + }) + host[0]['hostinterfaces'] = hostinterface + host_list.append(host[0]) + return host_list + + def delete_duplicate_hosts(self, hosts): + """ Delete duplicated hosts """ + unique_hosts = [] + listed_hostnames = [] + for zabbix_host in hosts: + if zabbix_host['name'] in listed_hostnames: + continue + unique_hosts.append(zabbix_host) + listed_hostnames.append(zabbix_host['name']) + return unique_hosts + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + host_name=dict(type='str', default='', required=False), + host_ip=dict(type='list', default=[], required=False), + exact_match=dict(type='bool', required=False, default=False), + remove_duplicate=dict(type='bool', required=False, default=True), + host_inventory=dict(type='list', default=[], required=False) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + if module._name == 'zabbix_host_facts': + module.deprecate("The 'zabbix_host_facts' module has been renamed to 'zabbix_host_info'", + collection_name="community.zabbix", version='2.0.0') # was 2.13 + + host_name = module.params['host_name'] + host_ips = module.params['host_ip'] + exact_match = module.params['exact_match'] + is_remove_duplicate = module.params['remove_duplicate'] + host_inventory = module.params['host_inventory'] + + if not host_inventory: + host_inventory = 'extend' + + host = Host(module) + + if host_name: + hosts = host.get_hosts_by_host_name(host_name, exact_match, host_inventory) + if is_remove_duplicate: + hosts = host.delete_duplicate_hosts(hosts) + extended_hosts = [] + for zabbix_host in hosts: + zabbix_host['hostinterfaces'] = host._zapi.hostinterface.get({ + 'output': 'extend', 'hostids': zabbix_host['hostid'] + }) + extended_hosts.append(zabbix_host) + module.exit_json(ok=True, hosts=extended_hosts) + + elif host_ips: + extended_hosts = host.get_hosts_by_ip(host_ips, host_inventory) + if is_remove_duplicate: + hosts = host.delete_duplicate_hosts(extended_hosts) + module.exit_json(ok=True, hosts=extended_hosts) + else: + module.exit_json(ok=False, hosts=[], result="No Host present") + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_info.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_info.py new file mode 100644 index 00000000..c2e7a773 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_host_info.py @@ -0,0 +1,213 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) me@mimiko.me +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +RETURN = r''' +--- +hosts: + description: List of Zabbix hosts. See https://www.zabbix.com/documentation/4.0/manual/api/reference/host/get for list of host values. + returned: success + type: dict + sample: [ { "available": "1", "description": "", "disable_until": "0", "error": "", "flags": "0", "groups": ["1"], "host": "Host A", ... } ] +''' + +DOCUMENTATION = r''' +--- +module: zabbix_host_info +short_description: Gather information about Zabbix host +description: + - This module allows you to search for Zabbix host entries. + - This module was called C(zabbix_host_facts) before Ansible 2.9. The usage did not change. +author: + - "Michael Miko (@RedWhiteMiko)" +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + host_name: + description: + - Name of the host in Zabbix. + - host_name is the unique identifier used and cannot be updated using this module. + - Required when I(host_ip) is not used. + required: false + type: str + host_ip: + description: + - Host interface IP of the host in Zabbix. + - Required when I(host_name) is not used. + required: false + type: list + elements: str + exact_match: + description: + - Find the exact match + type: bool + default: no + remove_duplicate: + description: + - Remove duplicate host from host result + type: bool + default: yes + host_inventory: + description: + - List of host inventory keys to display in result. + - Whole host inventory is retrieved if keys are not specified. + type: list + elements: str + required: false +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = r''' +- name: Get host info + local_action: + module: community.zabbix.zabbix_host_info + server_url: http://monitor.example.com + login_user: username + login_password: password + host_name: ExampleHost + host_ip: 127.0.0.1 + timeout: 10 + exact_match: no + remove_duplicate: yes + +- name: Reduce host inventory information to provided keys + local_action: + module: community.zabbix.zabbix_host_info + server_url: http://monitor.example.com + login_user: username + login_password: password + host_name: ExampleHost + host_inventory: + - os + - tag + host_ip: 127.0.0.1 + timeout: 10 + exact_match: no + remove_duplicate: yes +''' + + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Host(ZabbixBase): + def get_hosts_by_host_name(self, host_name, exact_match, host_inventory): + """ Get host by host name """ + search_key = 'search' + if exact_match: + search_key = 'filter' + host_list = self._zapi.host.get({ + 'output': 'extend', + 'selectParentTemplates': ['name'], + search_key: {'host': [host_name]}, + 'selectInventory': host_inventory, + 'selectGroups': 'extend', + 'selectTags': 'extend', + 'selectMacros': 'extend' + }) + if len(host_list) < 1: + self._module.fail_json(msg="Host not found: %s" % host_name) + else: + return host_list + + def get_hosts_by_ip(self, host_ips, host_inventory): + """ Get host by host ip(s) """ + hostinterfaces = self._zapi.hostinterface.get({ + 'output': 'extend', + 'filter': { + 'ip': host_ips + } + }) + if len(hostinterfaces) < 1: + self._module.fail_json(msg="Host not found: %s" % host_ips) + host_list = [] + for hostinterface in hostinterfaces: + host = self._zapi.host.get({ + 'output': 'extend', + 'selectGroups': 'extend', + 'selectParentTemplates': ['name'], + 'hostids': hostinterface['hostid'], + 'selectInventory': host_inventory, + 'selectTags': 'extend', + 'selectMacros': 'extend' + }) + host[0]['hostinterfaces'] = hostinterface + host_list.append(host[0]) + return host_list + + def delete_duplicate_hosts(self, hosts): + """ Delete duplicated hosts """ + unique_hosts = [] + listed_hostnames = [] + for zabbix_host in hosts: + if zabbix_host['name'] in listed_hostnames: + continue + unique_hosts.append(zabbix_host) + listed_hostnames.append(zabbix_host['name']) + return unique_hosts + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + host_name=dict(type='str', default='', required=False), + host_ip=dict(type='list', default=[], required=False), + exact_match=dict(type='bool', required=False, default=False), + remove_duplicate=dict(type='bool', required=False, default=True), + host_inventory=dict(type='list', default=[], required=False) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + if module._name == 'zabbix_host_facts': + module.deprecate("The 'zabbix_host_facts' module has been renamed to 'zabbix_host_info'", + collection_name="community.zabbix", version='2.0.0') # was 2.13 + + host_name = module.params['host_name'] + host_ips = module.params['host_ip'] + exact_match = module.params['exact_match'] + is_remove_duplicate = module.params['remove_duplicate'] + host_inventory = module.params['host_inventory'] + + if not host_inventory: + host_inventory = 'extend' + + host = Host(module) + + if host_name: + hosts = host.get_hosts_by_host_name(host_name, exact_match, host_inventory) + if is_remove_duplicate: + hosts = host.delete_duplicate_hosts(hosts) + extended_hosts = [] + for zabbix_host in hosts: + zabbix_host['hostinterfaces'] = host._zapi.hostinterface.get({ + 'output': 'extend', 'hostids': zabbix_host['hostid'] + }) + extended_hosts.append(zabbix_host) + module.exit_json(ok=True, hosts=extended_hosts) + + elif host_ips: + extended_hosts = host.get_hosts_by_ip(host_ips, host_inventory) + if is_remove_duplicate: + hosts = host.delete_duplicate_hosts(extended_hosts) + module.exit_json(ok=True, hosts=extended_hosts) + else: + module.exit_json(ok=False, hosts=[], result="No Host present") + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_hostmacro.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_hostmacro.py new file mode 100644 index 00000000..d2571b36 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_hostmacro.py @@ -0,0 +1,223 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2013-2014, Epic Games, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: zabbix_hostmacro +short_description: Create/update/delete Zabbix host macros +description: + - manages Zabbix host macros, it can create, update or delete them. +author: + - "Cove (@cove)" + - Dean Hailin Song (!UNKNOWN) +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + host_name: + description: + - Name of the host. + required: true + type: str + macro_name: + description: + - Name of the host macro in zabbix native format C({$MACRO}) or simple format C(MACRO). + required: true + type: str + macro_value: + description: + - Value of the host macro. + - Required if I(state=present). + type: str + state: + description: + - State of the macro. + - On C(present), it will create if macro does not exist or update the macro if the associated data is different. + - On C(absent) will remove a macro if it exists. + required: false + choices: ['present', 'absent'] + type: str + default: "present" + force: + description: + - Only updates an existing macro if set to C(yes). + default: 'yes' + type: bool + +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = r''' +- name: Create new host macro or update an existing macro's value + local_action: + module: community.zabbix.zabbix_hostmacro + server_url: http://monitor.example.com + login_user: username + login_password: password + host_name: ExampleHost + macro_name: EXAMPLE.MACRO + macro_value: Example value + state: present + +# Values with curly brackets need to be quoted otherwise they will be interpreted as a dictionary +- name: Create new host macro in Zabbix native format + local_action: + module: community.zabbix.zabbix_hostmacro + server_url: http://monitor.example.com + login_user: username + login_password: password + host_name: ExampleHost + macro_name: "{$EXAMPLE.MACRO}" + macro_value: Example value + state: present + +- name: Delete existing host macro + local_action: + module: community.zabbix.zabbix_hostmacro + server_url: http://monitor.example.com + login_user: username + login_password: password + host_name: ExampleHost + macro_name: "{$EXAMPLE.MACRO}" + state: absent +''' + + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class HostMacro(ZabbixBase): + # get host id by host name + def get_host_id(self, host_name): + try: + host_list = self._zapi.host.get({'output': 'extend', 'filter': {'host': host_name}}) + if len(host_list) < 1: + self._module.fail_json(msg="Host not found: %s" % host_name) + else: + host_id = host_list[0]['hostid'] + return host_id + except Exception as e: + self._module.fail_json(msg="Failed to get the host %s id: %s." % (host_name, e)) + + # get host macro + def get_host_macro(self, macro_name, host_id): + try: + host_macro_list = self._zapi.usermacro.get( + {"output": "extend", "selectSteps": "extend", 'hostids': [host_id], 'filter': {'macro': macro_name}}) + if len(host_macro_list) > 0: + return host_macro_list[0] + return None + except Exception as e: + self._module.fail_json(msg="Failed to get host macro %s: %s" % (macro_name, e)) + + # create host macro + def create_host_macro(self, macro_name, macro_value, host_id): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.usermacro.create({'hostid': host_id, 'macro': macro_name, 'value': macro_value}) + self._module.exit_json(changed=True, result="Successfully added host macro %s" % macro_name) + except Exception as e: + self._module.fail_json(msg="Failed to create host macro %s: %s" % (macro_name, e)) + + # update host macro + def update_host_macro(self, host_macro_obj, macro_name, macro_value): + host_macro_id = host_macro_obj['hostmacroid'] + if host_macro_obj['macro'] == macro_name and host_macro_obj['value'] == macro_value: + self._module.exit_json(changed=False, result="Host macro %s already up to date" % macro_name) + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.usermacro.update({'hostmacroid': host_macro_id, 'value': macro_value}) + self._module.exit_json(changed=True, result="Successfully updated host macro %s" % macro_name) + except Exception as e: + self._module.fail_json(msg="Failed to update host macro %s: %s" % (macro_name, e)) + + # delete host macro + def delete_host_macro(self, host_macro_obj, macro_name): + host_macro_id = host_macro_obj['hostmacroid'] + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.usermacro.delete([host_macro_id]) + self._module.exit_json(changed=True, result="Successfully deleted host macro %s" % macro_name) + except Exception as e: + self._module.fail_json(msg="Failed to delete host macro %s: %s" % (macro_name, e)) + + +def normalize_macro_name(macro_name): + # Zabbix handles macro names in upper case characters + if ':' in macro_name: + macro_name = ':'.join([macro_name.split(':')[0].upper(), ':'.join(macro_name.split(':')[1:])]) + else: + macro_name = macro_name.upper() + + # Valid format for macro is {$MACRO} + if not macro_name.startswith('{$'): + macro_name = '{$' + macro_name + if not macro_name.endswith('}'): + macro_name = macro_name + '}' + + return macro_name + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + host_name=dict(type='str', required=True), + macro_name=dict(type='str', required=True), + macro_value=dict(type='str', required=False), + state=dict(type='str', default='present', choices=['present', 'absent']), + force=dict(type='bool', default=True) + )) + module = AnsibleModule( + argument_spec=argument_spec, + required_if=[ + ['state', 'present', ['macro_value']] + ], + supports_check_mode=True + ) + + host_name = module.params['host_name'] + macro_name = normalize_macro_name(module.params['macro_name']) + macro_value = module.params['macro_value'] + state = module.params['state'] + force = module.params['force'] + + host_macro_class_obj = HostMacro(module) + + if host_name: + host_id = host_macro_class_obj.get_host_id(host_name) + host_macro_obj = host_macro_class_obj.get_host_macro(macro_name, host_id) + + if state == 'absent': + if not host_macro_obj: + module.exit_json(changed=False, msg="Host Macro %s does not exist" % macro_name) + else: + # delete a macro + host_macro_class_obj.delete_host_macro(host_macro_obj, macro_name) + else: + if not host_macro_obj: + # create host macro + host_macro_class_obj.create_host_macro(macro_name, macro_value, host_id) + elif force: + # update host macro + host_macro_class_obj.update_host_macro(host_macro_obj, macro_name, macro_value) + else: + module.exit_json(changed=False, result="Host macro %s already exists and force is set to no" % macro_name) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_maintenance.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_maintenance.py new file mode 100644 index 00000000..0329fb4f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_maintenance.py @@ -0,0 +1,365 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2013, Alexander Bulimov +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' + +module: zabbix_maintenance +short_description: Create Zabbix maintenance windows +description: + - This module will let you create Zabbix maintenance windows. +author: "Alexander Bulimov (@abulimov)" +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + state: + description: + - Create or remove a maintenance window. Maintenance window to remove is identified by name. + default: present + choices: [ "present", "absent" ] + type: str + host_names: + description: + - Hosts to manage maintenance window for. + - B(Required) option when I(state=present) and I(host_groups) is not used. + aliases: [ "host_name" ] + type: list + elements: str + host_groups: + description: + - Host groups to manage maintenance window for. + - B(Required) option when I(state=present) and I(host_names) is not used. + aliases: [ "host_group" ] + type: list + elements: str + minutes: + description: + - Length of maintenance window in minutes. + default: 10 + type: int + name: + description: + - Unique name of maintenance window. + required: true + type: str + desc: + description: + - Short description of maintenance window. + default: Created by Ansible + type: str + collect_data: + description: + - Type of maintenance. With data collection, or without. + type: bool + default: 'yes' + +extends_documentation_fragment: +- community.zabbix.zabbix + + +notes: + - Useful for setting hosts in maintenance mode before big update, + and removing maintenance window after update. + - Module creates maintenance window from now() to now() + minutes, + so if Zabbix server's time and host's time are not synchronized, + you will get strange results. + - Install required module with 'pip install zabbix-api' command. +''' + +EXAMPLES = r''' +- name: Create a named maintenance window for host www1 for 90 minutes + community.zabbix.zabbix_maintenance: + name: Update of www1 + host_name: www1.example.com + state: present + minutes: 90 + server_url: https://monitoring.example.com + login_user: ansible + login_password: pAsSwOrD + +- name: Create a named maintenance window for host www1 and host groups Office and Dev + community.zabbix.zabbix_maintenance: + name: Update of www1 + host_name: www1.example.com + host_groups: + - Office + - Dev + state: present + server_url: https://monitoring.example.com + login_user: ansible + login_password: pAsSwOrD + +- name: Create a named maintenance window for hosts www1 and db1, without data collection. + community.zabbix.zabbix_maintenance: + name: update + host_names: + - www1.example.com + - db1.example.com + state: present + collect_data: False + server_url: https://monitoring.example.com + login_user: ansible + login_password: pAsSwOrD + +- name: Remove maintenance window by name + community.zabbix.zabbix_maintenance: + name: Test1 + state: absent + server_url: https://monitoring.example.com + login_user: ansible + login_password: pAsSwOrD +''' + + +import datetime +import time + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class MaintenanceModule(ZabbixBase): + def create_maintenance(self, group_ids, host_ids, start_time, maintenance_type, period, name, desc): + end_time = start_time + period + try: + self._zapi.maintenance.create( + { + "groupids": group_ids, + "hostids": host_ids, + "name": name, + "maintenance_type": maintenance_type, + "active_since": str(start_time), + "active_till": str(end_time), + "description": desc, + "timeperiods": [{ + "timeperiod_type": "0", + "start_date": str(start_time), + "period": str(period), + }] + } + ) + # zabbix_api can call sys.exit() so we need to catch SystemExit here + except (Exception, SystemExit) as e: + return 1, None, str(e) + return 0, None, None + + def update_maintenance(self, maintenance_id, group_ids, host_ids, start_time, maintenance_type, period, desc): + end_time = start_time + period + try: + self._zapi.maintenance.update( + { + "maintenanceid": maintenance_id, + "groupids": group_ids, + "hostids": host_ids, + "maintenance_type": maintenance_type, + "active_since": str(start_time), + "active_till": str(end_time), + "description": desc, + "timeperiods": [{ + "timeperiod_type": "0", + "start_date": str(start_time), + "period": str(period), + }] + } + ) + # zabbix_api can call sys.exit() so we need to catch SystemExit here + except (Exception, SystemExit) as e: + return 1, None, str(e) + return 0, None, None + + def get_maintenance(self, name): + try: + maintenances = self._zapi.maintenance.get( + { + "filter": + { + "name": name, + }, + "selectGroups": "extend", + "selectHosts": "extend" + } + ) + # zabbix_api can call sys.exit() so we need to catch SystemExit here + except (Exception, SystemExit) as e: + return 1, None, str(e) + + for maintenance in maintenances: + maintenance["groupids"] = [group["groupid"] for group in maintenance["groups"]] if "groups" in maintenance else [] + maintenance["hostids"] = [host["hostid"] for host in maintenance["hosts"]] if "hosts" in maintenance else [] + return 0, maintenance, None + + return 0, None, None + + def delete_maintenance(self, maintenance_id): + try: + self._zapi.maintenance.delete([maintenance_id]) + # zabbix_api can call sys.exit() so we need to catch SystemExit here + except (Exception, SystemExit) as e: + return 1, None, str(e) + return 0, None, None + + def get_group_ids(self, host_groups): + group_ids = [] + for group in host_groups: + try: + result = self._zapi.hostgroup.get( + { + "output": "extend", + "filter": + { + "name": group + } + } + ) + # zabbix_api can call sys.exit() so we need to catch SystemExit here + except (Exception, SystemExit) as e: + return 1, None, str(e) + + if not result: + return 1, None, "Group id for group %s not found" % group + + group_ids.append(result[0]["groupid"]) + + return 0, group_ids, None + + def get_host_ids(self, host_names): + host_ids = [] + for host in host_names: + try: + result = self._zapi.host.get( + { + "output": "extend", + "filter": + { + "name": host + } + } + ) + # zabbix_api can call sys.exit() so we need to catch SystemExit here + except (Exception, SystemExit) as e: + return 1, None, str(e) + + if not result: + return 1, None, "Host id for host %s not found" % host + + host_ids.append(result[0]["hostid"]) + + return 0, host_ids, None + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + state=dict(type='str', required=False, default='present', choices=['present', 'absent']), + host_names=dict(type='list', required=False, default=None, aliases=['host_name']), + minutes=dict(type='int', required=False, default=10), + host_groups=dict(type='list', required=False, default=None, aliases=['host_group']), + name=dict(type='str', required=True), + desc=dict(type='str', required=False, default="Created by Ansible"), + collect_data=dict(type='bool', required=False, default=True), + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + maint = MaintenanceModule(module) + + host_names = module.params['host_names'] + host_groups = module.params['host_groups'] + state = module.params['state'] + minutes = module.params['minutes'] + name = module.params['name'] + desc = module.params['desc'] + collect_data = module.params['collect_data'] + + if collect_data: + maintenance_type = 0 + else: + maintenance_type = 1 + + changed = False + + if state == "present": + if not host_names and not host_groups: + module.fail_json(msg="At least one host_name or host_group must be defined for each created maintenance.") + + now = datetime.datetime.now().replace(second=0) + start_time = time.mktime(now.timetuple()) + period = 60 * int(minutes) # N * 60 seconds + + if host_groups: + (rc, group_ids, error) = maint.get_group_ids(host_groups) + if rc != 0: + module.fail_json(msg="Failed to get group_ids: %s" % error) + else: + group_ids = [] + + if host_names: + (rc, host_ids, error) = maint.get_host_ids(host_names) + if rc != 0: + module.fail_json(msg="Failed to get host_ids: %s" % error) + else: + host_ids = [] + + (rc, maintenance, error) = maint.get_maintenance(name) + if rc != 0: + module.fail_json(msg="Failed to check maintenance %s existence: %s" % (name, error)) + + if maintenance and ( + sorted(group_ids) != sorted(maintenance["groupids"]) + or sorted(host_ids) != sorted(maintenance["hostids"]) + or str(maintenance_type) != maintenance["maintenance_type"] + or str(int(start_time)) != maintenance["active_since"] + or str(int(start_time + period)) != maintenance["active_till"] + or str(desc) != maintenance['description'] + ): + if module.check_mode: + changed = True + else: + (rc, data, error) = maint.update_maintenance(maintenance["maintenanceid"], group_ids, host_ids, start_time, maintenance_type, period, desc) + if rc == 0: + changed = True + else: + module.fail_json(msg="Failed to update maintenance: %s" % error) + + if not maintenance: + if module.check_mode: + changed = True + else: + (rc, data, error) = maint.create_maintenance(group_ids, host_ids, start_time, maintenance_type, period, name, desc) + if rc == 0: + changed = True + else: + module.fail_json(msg="Failed to create maintenance: %s" % error) + + if state == "absent": + + (rc, maintenance, error) = maint.get_maintenance(name) + if rc != 0: + module.fail_json(msg="Failed to check maintenance %s existence: %s" % (name, error)) + + if maintenance: + if module.check_mode: + changed = True + else: + (rc, data, error) = maint.delete_maintenance(maintenance["maintenanceid"]) + if rc == 0: + changed = True + else: + module.fail_json(msg="Failed to remove maintenance: %s" % error) + + module.exit_json(changed=changed) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_map.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_map.py new file mode 100644 index 00000000..fab7cc6e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_map.py @@ -0,0 +1,790 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2017-2018, Antony Alekseyev +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = r''' +--- +module: zabbix_map +author: + - "Antony Alekseyev (@Akint)" +short_description: Create/update/delete Zabbix maps +description: + - "This module allows you to create, modify and delete Zabbix map entries, + using Graphviz binaries and text description written in DOT language. + Nodes of the graph will become map elements and edges will become links between map elements. + See U(https://en.wikipedia.org/wiki/DOT_(graph_description_language)) and U(https://www.graphviz.org/) for details. + Inspired by U(http://blog.zabbix.com/maps-for-the-lazy/)." + - "The following extra node attributes are supported: + C(zbx_host) contains name of the host in Zabbix. Use this if desired type of map element is C(host). + C(zbx_group) contains name of the host group in Zabbix. Use this if desired type of map element is C(host group). + C(zbx_map) contains name of the map in Zabbix. Use this if desired type of map element is C(map). + C(zbx_label) contains label of map element. + C(zbx_image) contains name of the image used to display the element in default state. + C(zbx_image_disabled) contains name of the image used to display disabled map element. + C(zbx_image_maintenance) contains name of the image used to display map element in maintenance. + C(zbx_image_problem) contains name of the image used to display map element with problems. + C(zbx_url) contains map element URL in C(name:url) format. + More than one URL could be specified by adding a postfix (e.g., C(zbx_url1), C(zbx_url2))." + - "The following extra link attributes are supported: + C(zbx_draw_style) contains link line draw style. Possible values: C(line), C(bold), C(dotted), C(dashed). + C(zbx_trigger) contains name of the trigger used as a link indicator in C(host_name:trigger_name) format. + More than one trigger could be specified by adding a postfix (e.g., C(zbx_trigger1), C(zbx_trigger2)). + C(zbx_trigger_color) contains indicator color specified either as CSS3 name or as a hexadecimal code starting with C(#). + C(zbx_trigger_draw_style) contains indicator draw style. Possible values are the same as for C(zbx_draw_style)." +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" + - pydotplus + - webcolors + - Pillow + - Graphviz +options: + name: + description: + - Name of the map. + required: true + aliases: [ "map_name" ] + type: str + data: + description: + - Graph written in DOT language. + required: false + aliases: [ "dot_data" ] + type: str + state: + description: + - State of the map. + - On C(present), it will create if map does not exist or update the map if the associated data is different. + - On C(absent) will remove the map if it exists. + required: false + choices: ['present', 'absent'] + default: "present" + type: str + width: + description: + - Width of the map. + required: false + default: 800 + type: int + height: + description: + - Height of the map. + required: false + default: 600 + type: int + margin: + description: + - Size of white space between map's borders and its elements. + required: false + default: 40 + type: int + expand_problem: + description: + - Whether the problem trigger will be displayed for elements with a single problem. + required: false + type: bool + default: true + highlight: + description: + - Whether icon highlighting is enabled. + required: false + type: bool + default: true + label_type: + description: + - Map element label type. + required: false + choices: ['label', 'ip', 'name', 'status', 'nothing', 'custom'] + default: "name" + type: str + default_image: + description: + - Name of the Zabbix image used to display the element if this element doesn't have the C(zbx_image) attribute defined. + required: false + aliases: [ "image" ] + type: str + +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +RETURN = r''' # ''' + +EXAMPLES = r''' +### +### Example inventory: +# [web] +# web[01:03].example.com ansible_host=127.0.0.1 +# [db] +# db.example.com ansible_host=127.0.0.1 +# [backup] +# backup.example.com ansible_host=127.0.0.1 +### +### Each inventory host is present in Zabbix with a matching name. +### +### Contents of 'map.j2': +# digraph G { +# graph [layout=dot splines=false overlap=scale] +# INTERNET [zbx_url="Google:https://google.com" zbx_image="Cloud_(96)"] +# {% for web_host in groups.web %} +# {% set web_loop = loop %} +# web{{ '%03d' % web_loop.index }} [zbx_host="{{ web_host }}"] +# INTERNET -> web{{ '%03d' % web_loop.index }} [zbx_trigger="{{ web_host }}:Zabbix agent on {HOST.NAME} is unreachable for 5 minutes"] +# {% for db_host in groups.db %} +# {% set db_loop = loop %} +# web{{ '%03d' % web_loop.index }} -> db{{ '%03d' % db_loop.index }} +# {% endfor %} +# {% endfor %} +# { rank=same +# {% for db_host in groups.db %} +# {% set db_loop = loop %} +# db{{ '%03d' % db_loop.index }} [zbx_host="{{ db_host }}"] +# {% for backup_host in groups.backup %} +# {% set backup_loop = loop %} +# db{{ '%03d' % db_loop.index }} -> backup{{ '%03d' % backup_loop.index }} [color="blue"] +# {% endfor %} +# {% endfor %} +# {% for backup_host in groups.backup %} +# {% set backup_loop = loop %} +# backup{{ '%03d' % backup_loop.index }} [zbx_host="{{ backup_host }}"] +# {% endfor %} +# } +# } +### +### Create Zabbix map "Demo Map" made of template 'map.j2' +- name: Create Zabbix map + community.zabbix.zabbix_map: + server_url: http://zabbix.example.com + login_user: username + login_password: password + name: Demo map + state: present + data: "{{ lookup('template', 'map.j2') }}" + default_image: Server_(64) + expand_problem: no + highlight: no + label_type: label + delegate_to: localhost + run_once: yes +''' + + +import base64 +import traceback + +from io import BytesIO +from operator import itemgetter +from distutils.version import LooseVersion +from ansible.module_utils.basic import AnsibleModule, missing_required_lib + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +try: + import pydotplus + HAS_PYDOTPLUS = True +except ImportError: + PYDOT_IMP_ERR = traceback.format_exc() + HAS_PYDOTPLUS = False + +try: + import webcolors + HAS_WEBCOLORS = True +except ImportError: + WEBCOLORS_IMP_ERR = traceback.format_exc() + HAS_WEBCOLORS = False + +try: + from PIL import Image + HAS_PIL = True +except ImportError: + PIL_IMP_ERR = traceback.format_exc() + HAS_PIL = False + + +class Map(ZabbixBase): + def __init__(self, module, zbx=None, zapi_wrapper=None): + super(Map, self).__init__(module, zbx, zapi_wrapper) + self.map_name = module.params['name'] + self.dot_data = module.params['data'] + self.width = module.params['width'] + self.height = module.params['height'] + self.state = module.params['state'] + self.default_image = module.params['default_image'] + self.map_id = self._get_sysmap_id(self.map_name) + self.margin = module.params['margin'] + self.expand_problem = module.params['expand_problem'] + self.highlight = module.params['highlight'] + self.label_type = module.params['label_type'] + self.selements_sort_keys = self._get_selements_sort_keys() + + def _build_graph(self): + try: + graph_without_positions = pydotplus.graph_from_dot_data(self.dot_data) + dot_data_with_positions = graph_without_positions.create_dot() + graph_with_positions = pydotplus.graph_from_dot_data(dot_data_with_positions) + if graph_with_positions: + return graph_with_positions + except Exception as e: + self._module.fail_json(msg="Failed to build graph from DOT data: %s" % e) + + def get_map_config(self): + if not self.dot_data: + self._module.fail_json(msg="'data' is mandatory with state 'present'") + graph = self._build_graph() + nodes = self._get_graph_nodes(graph) + edges = self._get_graph_edges(graph) + icon_ids = self._get_icon_ids() + map_config = { + 'name': self.map_name, + 'label_type': self._get_label_type_id(self.label_type), + 'expandproblem': int(self.expand_problem), + 'highlight': int(self.highlight), + 'width': self.width, + 'height': self.height, + 'selements': self._get_selements(graph, nodes, icon_ids), + 'links': self._get_links(nodes, edges), + } + return map_config + + def _get_label_type_id(self, label_type): + label_type_ids = { + 'label': 0, + 'ip': 1, + 'name': 2, + 'status': 3, + 'nothing': 4, + 'custom': 5, + } + try: + label_type_id = label_type_ids[label_type] + except Exception as e: + self._module.fail_json(msg="Failed to find id for label type '%s': %s" % (label_type, e)) + return label_type_id + + def _get_images_info(self, data, icon_ids): + images = [ + { + 'dot_tag': 'zbx_image', + 'zbx_property': 'iconid_off', + 'mandatory': True + }, + { + 'dot_tag': 'zbx_image_disabled', + 'zbx_property': 'iconid_disabled', + 'mandatory': False + }, + { + 'dot_tag': 'zbx_image_maintenance', + 'zbx_property': 'iconid_maintenance', + 'mandatory': False + }, + { + 'dot_tag': 'zbx_image_problem', + 'zbx_property': 'iconid_on', + 'mandatory': False + } + ] + images_info = {} + default_image = self.default_image if self.default_image else sorted(icon_ids.items())[0][0] + for image in images: + image_name = data.get(image['dot_tag'], None) + if not image_name: + if image['mandatory']: + image_name = default_image + else: + continue + image_name = remove_quotes(image_name) + if image_name in icon_ids: + images_info[image['zbx_property']] = icon_ids[image_name] + if not image['mandatory']: + images_info['use_iconmap'] = 0 + else: + self._module.fail_json(msg="Failed to find id for image '%s'" % image_name) + return images_info + + def _get_element_type(self, data): + types = { + 'host': 0, + 'sysmap': 1, + 'trigger': 2, + 'group': 3, + 'image': 4 + } + element_type = { + 'elementtype': types['image'], + } + if LooseVersion(self._zbx_api_version) < LooseVersion('3.4'): + element_type.update({ + 'elementid': "0", + }) + for type_name, type_id in sorted(types.items()): + field_name = 'zbx_' + type_name + if field_name in data: + method_name = '_get_' + type_name + '_id' + element_name = remove_quotes(data[field_name]) + get_element_id = getattr(self, method_name, None) + if get_element_id: + elementid = get_element_id(element_name) + if elementid and int(elementid) > 0: + element_type.update({ + 'elementtype': type_id, + 'label': element_name + }) + if LooseVersion(self._zbx_api_version) < LooseVersion('3.4'): + element_type.update({ + 'elementid': elementid, + }) + else: + element_type.update({ + 'elements': [{ + type_name + 'id': elementid, + }], + }) + break + else: + self._module.fail_json(msg="Failed to find id for %s '%s'" % (type_name, element_name)) + return element_type + + # get list of map elements (nodes) + def _get_selements(self, graph, nodes, icon_ids): + selements = [] + icon_sizes = {} + scales = self._get_scales(graph) + for selementid, (node, data) in enumerate(nodes.items(), start=1): + selement = { + 'selementid': selementid + } + data['selementid'] = selementid + + images_info = self._get_images_info(data, icon_ids) + selement.update(images_info) + image_id = images_info['iconid_off'] + if image_id not in icon_sizes: + icon_sizes[image_id] = self._get_icon_size(image_id) + + pos = self._convert_coordinates(data['pos'], scales, icon_sizes[image_id]) + selement.update(pos) + + selement['label'] = remove_quotes(node) + element_type = self._get_element_type(data) + selement.update(element_type) + + label = self._get_label(data) + if label: + selement['label'] = label + + urls = self._get_urls(data) + if urls: + selement['urls'] = urls + + selements.append(selement) + return selements + + def _get_links(self, nodes, edges): + links = {} + for edge in edges: + link_id = tuple(sorted(edge.obj_dict['points'])) + node1, node2 = link_id + data = edge.obj_dict['attributes'] + + if "style" in data and data['style'] == "invis": + continue + + if link_id not in links: + links[link_id] = { + 'selementid1': min(nodes[node1]['selementid'], nodes[node2]['selementid']), + 'selementid2': max(nodes[node1]['selementid'], nodes[node2]['selementid']), + } + link = links[link_id] + + if "color" not in link: + link['color'] = self._get_color_hex(remove_quotes(data.get('color', 'green'))) + + if "zbx_draw_style" not in link: + link['drawtype'] = self._get_link_draw_style_id(remove_quotes(data.get('zbx_draw_style', 'line'))) + + label = self._get_label(data) + if label and "label" not in link: + link['label'] = label + + triggers = self._get_triggers(data) + if triggers: + if "linktriggers" not in link: + link['linktriggers'] = [] + link['linktriggers'] += triggers + + return list(links.values()) + + def _get_urls(self, data): + urls = [] + for url_raw in [remove_quotes(value) for key, value in data.items() if key.startswith("zbx_url")]: + try: + name, url = url_raw.split(':', 1) + except Exception as e: + self._module.fail_json(msg="Failed to parse zbx_url='%s': %s" % (url_raw, e)) + urls.append({ + 'name': name, + 'url': url, + }) + return urls + + def _get_triggers(self, data): + triggers = [] + for trigger_definition in [remove_quotes(value) for key, value in data.items() if key.startswith("zbx_trigger")]: + triggerid = self._get_trigger_id(trigger_definition) + if triggerid: + triggers.append({ + 'triggerid': triggerid, + 'color': self._get_color_hex(remove_quotes(data.get('zbx_trigger_color', 'red'))), + 'drawtype': self._get_link_draw_style_id(remove_quotes(data.get('zbx_trigger_draw_style', 'bold'))), + }) + else: + self._module.fail_json(msg="Failed to find trigger '%s'" % (trigger_definition)) + return triggers + + @staticmethod + def _get_label(data, default=None): + if "zbx_label" in data: + label = remove_quotes(data['zbx_label']).replace('\\n', '\n') + elif "label" in data: + label = remove_quotes(data['label']) + else: + label = default + return label + + def _get_sysmap_id(self, map_name): + exist_map = self._zapi.map.get({'filter': {'name': map_name}}) + if exist_map: + return exist_map[0]['sysmapid'] + return None + + def _get_group_id(self, group_name): + exist_group = self._zapi.hostgroup.get({'filter': {'name': group_name}}) + if exist_group: + return exist_group[0]['groupid'] + return None + + def map_exists(self): + return bool(self.map_id) + + def create_map(self, map_config): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + result = self._zapi.map.create(map_config) + if result: + return result + except Exception as e: + self._module.fail_json(msg="Failed to create map: %s" % e) + + def update_map(self, map_config): + if not self.map_id: + self._module.fail_json(msg="Failed to update map: map_id is unknown. Try to create_map instead.") + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + map_config['sysmapid'] = self.map_id + result = self._zapi.map.update(map_config) + if result: + return result + except Exception as e: + self._module.fail_json(msg="Failed to update map: %s" % e) + + def delete_map(self): + if not self.map_id: + self._module.fail_json(msg="Failed to delete map: map_id is unknown.") + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.map.delete([self.map_id]) + except Exception as e: + self._module.fail_json(msg="Failed to delete map, Exception: %s" % e) + + def is_exist_map_correct(self, generated_map_config): + exist_map_configs = self._zapi.map.get({ + 'sysmapids': self.map_id, + 'selectLinks': 'extend', + 'selectSelements': 'extend' + }) + exist_map_config = exist_map_configs[0] + if not self._is_dicts_equal(generated_map_config, exist_map_config): + return False + if not self._is_selements_equal(generated_map_config['selements'], exist_map_config['selements']): + return False + self._update_ids(generated_map_config, exist_map_config) + if not self._is_links_equal(generated_map_config['links'], exist_map_config['links']): + return False + return True + + def _get_selements_sort_keys(self): + keys_to_sort = ['label'] + if LooseVersion(self._zbx_api_version) < LooseVersion('3.4'): + keys_to_sort.insert(0, 'elementid') + return keys_to_sort + + def _is_selements_equal(self, generated_selements, exist_selements): + if len(generated_selements) != len(exist_selements): + return False + generated_selements_sorted = sorted(generated_selements, key=itemgetter(*self.selements_sort_keys)) + exist_selements_sorted = sorted(exist_selements, key=itemgetter(*self.selements_sort_keys)) + for (generated_selement, exist_selement) in zip(generated_selements_sorted, exist_selements_sorted): + if LooseVersion(self._zbx_api_version) >= LooseVersion('3.4'): + if not self._is_elements_equal(generated_selement.get('elements', []), exist_selement.get('elements', [])): + return False + if not self._is_dicts_equal(generated_selement, exist_selement, ['selementid']): + return False + if not self._is_urls_equal(generated_selement.get('urls', []), exist_selement.get('urls', [])): + return False + return True + + def _is_urls_equal(self, generated_urls, exist_urls): + if len(generated_urls) != len(exist_urls): + return False + generated_urls_sorted = sorted(generated_urls, key=itemgetter('name', 'url')) + exist_urls_sorted = sorted(exist_urls, key=itemgetter('name', 'url')) + for (generated_url, exist_url) in zip(generated_urls_sorted, exist_urls_sorted): + if not self._is_dicts_equal(generated_url, exist_url, ['selementid']): + return False + return True + + def _is_elements_equal(self, generated_elements, exist_elements): + if len(generated_elements) != len(exist_elements): + return False + generated_elements_sorted = sorted(generated_elements, key=lambda k: k.values()[0]) + exist_elements_sorted = sorted(exist_elements, key=lambda k: k.values()[0]) + for (generated_element, exist_element) in zip(generated_elements_sorted, exist_elements_sorted): + if not self._is_dicts_equal(generated_element, exist_element, ['selementid']): + return False + return True + + # since generated IDs differ from real Zabbix ones, make real IDs match generated ones + def _update_ids(self, generated_map_config, exist_map_config): + generated_selements_sorted = sorted(generated_map_config['selements'], key=itemgetter(*self.selements_sort_keys)) + exist_selements_sorted = sorted(exist_map_config['selements'], key=itemgetter(*self.selements_sort_keys)) + id_mapping = {} + for (generated_selement, exist_selement) in zip(generated_selements_sorted, exist_selements_sorted): + id_mapping[exist_selement['selementid']] = generated_selement['selementid'] + for link in exist_map_config['links']: + link['selementid1'] = id_mapping[link['selementid1']] + link['selementid2'] = id_mapping[link['selementid2']] + if link['selementid2'] < link['selementid1']: + link['selementid1'], link['selementid2'] = link['selementid2'], link['selementid1'] + + def _is_links_equal(self, generated_links, exist_links): + if len(generated_links) != len(exist_links): + return False + generated_links_sorted = sorted(generated_links, key=itemgetter('selementid1', 'selementid2', 'color', 'drawtype')) + exist_links_sorted = sorted(exist_links, key=itemgetter('selementid1', 'selementid2', 'color', 'drawtype')) + for (generated_link, exist_link) in zip(generated_links_sorted, exist_links_sorted): + if not self._is_dicts_equal(generated_link, exist_link, ['selementid1', 'selementid2']): + return False + if not self._is_triggers_equal(generated_link.get('linktriggers', []), exist_link.get('linktriggers', [])): + return False + return True + + def _is_triggers_equal(self, generated_triggers, exist_triggers): + if len(generated_triggers) != len(exist_triggers): + return False + generated_triggers_sorted = sorted(generated_triggers, key=itemgetter('triggerid')) + exist_triggers_sorted = sorted(exist_triggers, key=itemgetter('triggerid')) + for (generated_trigger, exist_trigger) in zip(generated_triggers_sorted, exist_triggers_sorted): + if not self._is_dicts_equal(generated_trigger, exist_trigger): + return False + return True + + @staticmethod + def _is_dicts_equal(d1, d2, exclude_keys=None): + if exclude_keys is None: + exclude_keys = [] + for key in d1.keys(): + if isinstance(d1[key], dict) or isinstance(d1[key], list): + continue + if key in exclude_keys: + continue + # compare as strings since Zabbix API returns everything as strings + if key not in d2 or str(d2[key]) != str(d1[key]): + return False + return True + + def _get_host_id(self, hostname): + hostid = self._zapi.host.get({'filter': {'host': hostname}}) + if hostid: + return str(hostid[0]['hostid']) + + def _get_trigger_id(self, trigger_definition): + try: + host, trigger = trigger_definition.split(':', 1) + except Exception as e: + self._module.fail_json(msg="Failed to parse zbx_trigger='%s': %s" % (trigger_definition, e)) + triggerid = self._zapi.trigger.get({ + 'host': host, + 'filter': { + 'description': trigger + } + }) + if triggerid: + return str(triggerid[0]['triggerid']) + + def _get_icon_ids(self): + icons_list = self._zapi.image.get({}) + icon_ids = {} + for icon in icons_list: + icon_ids[icon['name']] = icon['imageid'] + return icon_ids + + def _get_icon_size(self, icon_id): + icons_list = self._zapi.image.get({ + 'imageids': [ + icon_id + ], + 'select_image': True + }) + if len(icons_list) > 0: + icon_base64 = icons_list[0]['image'] + else: + self._module.fail_json(msg="Failed to find image with id %s" % icon_id) + image = Image.open(BytesIO(base64.b64decode(icon_base64))) + icon_width, icon_height = image.size + return icon_width, icon_height + + @staticmethod + def _get_node_attributes(node): + attr = {} + if "attributes" in node.obj_dict: + attr.update(node.obj_dict['attributes']) + pos = node.get_pos() + if pos is not None: + pos = remove_quotes(pos) + xx, yy = pos.split(",") + attr['pos'] = (float(xx), float(yy)) + return attr + + def _get_graph_nodes(self, parent): + nodes = {} + for node in parent.get_nodes(): + node_name = node.get_name() + if node_name in ('node', 'graph', 'edge'): + continue + nodes[node_name] = self._get_node_attributes(node) + for subgraph in parent.get_subgraphs(): + nodes.update(self._get_graph_nodes(subgraph)) + return nodes + + def _get_graph_edges(self, parent): + edges = [] + for edge in parent.get_edges(): + edges.append(edge) + for subgraph in parent.get_subgraphs(): + edges += self._get_graph_edges(subgraph) + return edges + + def _get_scales(self, graph): + bb = remove_quotes(graph.get_bb()) + min_x, min_y, max_x, max_y = bb.split(",") + scale_x = (self.width - self.margin * 2) / (float(max_x) - float(min_x)) if float(max_x) != float(min_x) else 0 + scale_y = (self.height - self.margin * 2) / (float(max_y) - float(min_y)) if float(max_y) != float(min_y) else 0 + return { + 'min_x': float(min_x), + 'min_y': float(min_y), + 'max_x': float(max_x), + 'max_y': float(max_y), + 'scale_x': float(scale_x), + 'scale_y': float(scale_y), + } + + # transform Graphviz coordinates to Zabbix's ones + def _convert_coordinates(self, pos, scales, icon_size): + return { + 'x': int((pos[0] - scales['min_x']) * scales['scale_x'] - icon_size[0] / 2 + self.margin), + 'y': int((scales['max_y'] - pos[1] + scales['min_y']) * scales['scale_y'] - icon_size[1] / 2 + self.margin), + } + + def _get_color_hex(self, color_name): + if color_name.startswith('#'): + color_hex = color_name + else: + try: + color_hex = webcolors.name_to_hex(color_name) + except Exception as e: + self._module.fail_json(msg="Failed to get RGB hex for color '%s': %s" % (color_name, e)) + color_hex = color_hex.strip('#').upper() + return color_hex + + def _get_link_draw_style_id(self, draw_style): + draw_style_ids = { + 'line': 0, + 'bold': 2, + 'dotted': 3, + 'dashed': 4 + } + try: + draw_style_id = draw_style_ids[draw_style] + except Exception as e: + self._module.fail_json(msg="Failed to find id for draw type '%s': %s" % (draw_style, e)) + return draw_style_id + + +# If a string has single or double quotes around it, remove them. +def remove_quotes(s): + if (s[0] == s[-1]) and s.startswith(("'", '"')): + s = s[1:-1] + return s + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + name=dict(type='str', required=True, aliases=['map_name']), + data=dict(type='str', required=False, aliases=['dot_data']), + width=dict(type='int', default=800), + height=dict(type='int', default=600), + state=dict(type='str', default="present", choices=['present', 'absent']), + default_image=dict(type='str', required=False, aliases=['image']), + margin=dict(type='int', default=40), + expand_problem=dict(type='bool', default=True), + highlight=dict(type='bool', default=True), + label_type=dict(type='str', default='name', choices=['label', 'ip', 'name', 'status', 'nothing', 'custom']), + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + if not HAS_PYDOTPLUS: + module.fail_json(msg=missing_required_lib('pydotplus', url='https://pypi.org/project/pydotplus/'), exception=PYDOT_IMP_ERR) + if not HAS_WEBCOLORS: + module.fail_json(msg=missing_required_lib('webcolors', url='https://pypi.org/project/webcolors/'), exception=WEBCOLORS_IMP_ERR) + if not HAS_PIL: + module.fail_json(msg=missing_required_lib('Pillow', url='https://pypi.org/project/Pillow/'), exception=PIL_IMP_ERR) + + sysmap = Map(module) + + if sysmap.state == "absent": + if sysmap.map_exists(): + sysmap.delete_map() + module.exit_json(changed=True, result="Successfully deleted map: %s" % sysmap.map_name) + else: + module.exit_json(changed=False) + else: + map_config = sysmap.get_map_config() + if sysmap.map_exists(): + if sysmap.is_exist_map_correct(map_config): + module.exit_json(changed=False) + else: + sysmap.update_map(map_config) + module.exit_json(changed=True, result="Successfully updated map: %s" % sysmap.map_name) + else: + sysmap.create_map(map_config) + module.exit_json(changed=True, result="Successfully created map: %s" % sysmap.map_name) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_mediatype.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_mediatype.py new file mode 100644 index 00000000..41f2740e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_mediatype.py @@ -0,0 +1,787 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: zabbix_mediatype +short_description: Create/Update/Delete Zabbix media types +description: + - This module allows you to create, modify and delete Zabbix media types. +author: + - Ruben Tsirunyan (@rubentsirunyan) +requirements: + - "zabbix-api >= 0.5.4" + +options: + name: + type: 'str' + description: + - Name of the media type. + required: true + description: + type: 'str' + description: + - Description of the media type. + - Works only with Zabbix versions 4.4 or newer. + default: '' + state: + type: 'str' + description: + - Desired state of the mediatype. + - On C(present), it will create a mediatype if it does not exist or update the mediatype if the associated data is different. + - On C(absent), it will remove the mediatype if it exists. + choices: + - present + - absent + default: 'present' + type: + type: 'str' + description: + - Type of the media type. + - Media types I(jabber) and I(ez_texting) works only with Zabbix versions 4.2 or older. + - Media type I(webhook) works only with Zabbix versions 4.4 or newer. + choices: + - email + - script + - sms + - webhook + - jabber + - ez_texting + required: true + status: + type: 'str' + description: + - Whether the media type is enabled or no. + choices: + - enabled + - disabled + default: 'enabled' + max_sessions: + type: 'int' + description: + - The maximum number of alerts that can be processed in parallel. + - Possible value is 1 when I(type=sms) and 0-100 otherwise. + - Works only with Zabbix versions 3.4 or newer. + default: 1 + max_attempts: + type: 'int' + description: + - The maximum number of attempts to send an alert. + - Possible range is 0-10. + - Works only with Zabbix versions 3.4 or newer. + default: 3 + attempt_interval: + type: 'int' + description: + - The interval between retry attempts. + - Possible range is 0-60. + - Works only with Zabbix versions 3.4 or newer. + default: 10 + script_name: + type: 'str' + description: + - The name of the executed script. + - Required when I(type=script). + script_params: + type: 'list' + elements: str + description: + - List of script parameters. + - Required when I(type=script). + gsm_modem: + type: 'str' + description: + - Serial device name of the gsm modem. + - Required when I(type=sms). + username: + type: 'str' + description: + - Username or Jabber identifier. + - Required when I(type=jabber) or I(type=ez_texting). + - Required when I(type=email) and I(smtp_authentication=true). + password: + type: 'str' + description: + - Authentication password. + - Required when I(type=jabber) or I(type=ez_texting). + - Required when I(type=email) and I(smtp_authentication=true). + smtp_server: + type: 'str' + description: + - SMTP server host. + - Required when I(type=email). + default: 'localhost' + smtp_server_port: + type: 'int' + description: + - SMTP server port. + - Required when I(type=email). + default: 25 + smtp_helo: + type: 'str' + description: + - SMTP HELO. + - Required when I(type=email). + default: 'localhost' + smtp_email: + type: 'str' + description: + - Email address from which notifications will be sent. + - Required when I(type=email). + smtp_authentication: + type: 'bool' + description: + - Whether SMTP authentication with username and password should be enabled or not. + - If set to C(true), C(username) and C(password) should be specified. + default: false + smtp_security: + type: 'str' + description: + - SMTP connection security level to use. + choices: + - None + - STARTTLS + - SSL/TLS + smtp_verify_host: + type: 'bool' + description: + - SSL verify host for SMTP. + - Can be specified when I(smtp_security=STARTTLS) or I(smtp_security=SSL/TLS) + default: false + smtp_verify_peer: + type: 'bool' + description: + - SSL verify peer for SMTP. + - Can be specified when I(smtp_security=STARTTLS) or I(smtp_security=SSL/TLS) + default: false + message_text_limit: + type: 'str' + description: + - The message text limit. + - Required when I(type=ez_texting). + - 160 characters for USA and 136 characters for Canada. + choices: + - USA + - Canada + webhook_script: + type: 'str' + description: + - Required when I(type=webhook). + - JavaScript code that will perform webhook operation. + - This code has access to all parameters in I(webhook_params). + - It may perform HTTP GET, POST, PUT and DELETE requests and has control over HTTP headers and request body. + - It may return OK status along with an optional list of tags and tag values or an error string. + - Works only with Zabbix versions 4.4 or newer. + webhook_timeout: + type: 'str' + description: + - Can be used when I(type=webhook). + - Execution timeout for JavaScript code in I(webhook_script). + - Possible values are 1-60s. + default: 30s + process_tags: + type: 'bool' + description: + - Can be used when I(type=webhook). + - Process returned JSON property values as tags. + - These tags are added to the already existing (if any) problem event tags in Zabbix. + default: false + event_menu: + type: 'bool' + description: + - Can be used when I(type=webhook). + - Includes entry in Event menu with link to created external ticket. + default: false + event_menu_url: + type: 'str' + description: + - Requred when I(event_menu=True). + - Event menu entry underlying URL. + event_menu_name: + type: 'str' + description: + - Requred when I(event_menu=True). + - Event menu entry name. + webhook_params: + type: 'list' + elements: 'dict' + description: + - Can be used when I(type=webhook). + - Webhook variables that are passed to webhook script when executed. + default: [] + suboptions: + name: + type: 'str' + description: + - Name of the parameter. + required: true + value: + type: 'str' + description: + - Value of the parameter. + - All macros that are supported in problem notifications are supported in the parameters. + - Values are URL-encoded automatically. Values from macros are resolved and then URL-encoded automatically. + default: '' + message_templates: + type: 'list' + elements: 'dict' + description: + - Default notification messages for the event types. + - Works only with Zabbix versions 5.0 or newer. + default: [] + suboptions: + eventsource: + type: 'str' + description: + - Event source. + - Required when I(recovery) is used. + choices: + - triggers + - discovery + - autoregistration + - internal + recovery: + type: 'str' + description: + - Operation mode. + - Required when I(eventsource) is used. + choices: + - operations + - recovery_operations + - update_operations + subject: + type: 'str' + description: + - Subject of the default message. + - May contain macros and is limited to 255 characters. + default: '' + body: + type: 'str' + description: + - Body of the default message. + - May contain macros. + default: '' + +extends_documentation_fragment: +- community.zabbix.zabbix + + +''' + +RETURN = r''' # ''' + +EXAMPLES = r''' +- name: 'Create an email mediatype with SMTP authentication' + community.zabbix.zabbix_mediatype: + name: "Ops email" + server_url: "http://example.com/zabbix/" + login_user: Admin + login_password: "zabbix" + type: 'email' + smtp_server: 'example.com' + smtp_server_port: 2000 + smtp_email: 'ops@example.com' + smtp_authentication: true + username: 'smtp_user' + password: 'smtp_pass' + +- name: 'Create a script mediatype' + community.zabbix.zabbix_mediatype: + name: "my script" + server_url: "http://example.com/zabbix/" + login_user: Admin + login_password: "zabbix" + type: 'script' + script_name: 'my_script.py' + script_params: + - 'arg1' + - 'arg2' + +- name: 'Create a jabber mediatype' + community.zabbix.zabbix_mediatype: + name: "My jabber" + server_url: "http://example.com/zabbix/" + login_user: Admin + login_password: "zabbix" + type: 'jabber' + username: 'jabber_id' + password: 'jabber_pass' + +- name: 'Create a SMS mediatype' + community.zabbix.zabbix_mediatype: + name: "My SMS Mediatype" + server_url: "http://example.com/zabbix/" + login_user: Admin + login_password: "zabbix" + type: 'sms' + gsm_modem: '/dev/ttyS0' + +# Supported since Zabbix 4.4 +- name: 'Create a webhook mediatype' + community.zabbix.zabbix_mediatype: + name: "My webhook Mediatype" + server_url: "http://example.com/zabbix/" + login_user: Admin + login_password: "zabbix" + type: 'webhook' + webhook_script: "{{ lookup('file', 'slack.js') }}" + webhook_params: + - name: alert_message + value: '{ALERT.MESSAGE}' + - name: zabbix_url + value: '{$ZABBIX.URL}' + process_tags: True + event_menu: true + event_menu_name: "Open in Slack: '{EVENT.TAGS.__channel_name}'" + event_menu_url: '{EVENT.TAGS.__message_link}' + +# Supported since Zabbix 5.0 +- name: 'Create an email mediatype with message templates' + community.zabbix.zabbix_mediatype: + name: "Ops email" + server_url: "http://example.com/zabbix/" + login_user: Admin + login_password: "zabbix" + type: 'email' + smtp_email: 'ops@example.com' + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME}" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: triggers + recovery: recovery_operations + subject: "Resolved: {EVENT.NAME}" + body: "Problem resolved at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: triggers + recovery: update_operations + subject: "Updated problem: {EVENT.NAME}" + body: "{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" +''' + + +from distutils.version import LooseVersion +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +def diff(existing, new): + """Constructs the diff for Ansible's --diff option. + + Args: + existing (dict): Existing mediatype data. + new (dict): New mediatype data. + + Returns: + A dictionary like {'before': existing, 'after': new} + with filtered empty values. + """ + before = {} + after = {} + for key in new: + before[key] = existing[key] + if new[key] is None: + after[key] = '' + else: + after[key] = new[key] + return {'before': before, 'after': after} + + +class MediaTypeModule(ZabbixBase): + def check_if_mediatype_exists(self, name): + """Checks if mediatype exists. + + Args: + name: Zabbix mediatype name + + Returns: + Tuple of (True, `id of the mediatype`) if mediatype exists, (False, None) otherwise + """ + filter_key_name = 'description' + if LooseVersion(self._zbx_api_version) >= LooseVersion('4.4'): + # description key changed to name key from zabbix 4.4 + filter_key_name = 'name' + + try: + mediatype_list = self._zapi.mediatype.get({ + 'output': 'extend', + 'filter': {filter_key_name: [name]} + }) + if len(mediatype_list) < 1: + return False, None + else: + return True, mediatype_list[0]['mediatypeid'] + except Exception as e: + self._module.fail_json(msg="Failed to get ID of the mediatype '{name}': {e}".format(name=name, e=e)) + + def construct_parameters(self): + """Translates data to a format suitable for Zabbix API and filters + the ones that are related to the specified mediatype type. + + Returns: + A dictionary of arguments that are related to transport type, + and are in a format that is understandable by Zabbix API. + """ + truths = {'False': '0', 'True': '1'} + parameters = dict( + status='0' if self._module.params['status'] == 'enabled' else '1', + type={ + 'email': '0', + 'script': '1', + 'sms': '2', + 'jabber': '3', + 'webhook': '4', + 'ez_texting': '100' + }.get(self._module.params['type']), + ) + + if LooseVersion(self._zbx_api_version) >= LooseVersion('4.4'): + parameters.update(dict( + name=self._module.params['name'], + description=self._module.params['description'], + )) + else: + parameters.update(dict(description=self._module.params['name'])) + + if LooseVersion(self._zbx_api_version) >= LooseVersion('3.4'): + parameters.update(dict( + maxsessions=str(self._module.params['max_sessions']), + maxattempts=str(self._module.params['max_attempts']), + attempt_interval=str(self._module.params['attempt_interval']) + )) + + if self._module.params['message_templates'] and LooseVersion(self._zbx_api_version) >= LooseVersion('5.0'): + msg_templates = [] + for template in self._module.params['message_templates']: + msg_templates.append(dict( + eventsource={ + 'triggers': '0', + 'discovery': '1', + 'autoregistration': '2', + 'internal': '3'}.get(template['eventsource']), + recovery={ + 'operations': '0', + 'recovery_operations': '1', + 'update_operations': '2'}.get(template['recovery']), + subject=template['subject'], + message=template['body'] + )) + parameters.update(dict(message_templates=msg_templates)) + + if self._module.params['type'] == 'email': + parameters.update(dict( + smtp_server=self._module.params['smtp_server'], + smtp_port=str(self._module.params['smtp_server_port']), + smtp_helo=self._module.params['smtp_helo'], + smtp_email=self._module.params['smtp_email'], + smtp_security={'None': '0', 'STARTTLS': '1', 'SSL/TLS': '2'}.get(str(self._module.params['smtp_security'])), + smtp_authentication=truths.get(str(self._module.params['smtp_authentication'])), + smtp_verify_host=truths.get(str(self._module.params['smtp_verify_host'])), + smtp_verify_peer=truths.get(str(self._module.params['smtp_verify_peer'])), + username=self._module.params['username'], + passwd=self._module.params['password'] + )) + return parameters + + elif self._module.params['type'] == 'script': + if self._module.params['script_params'] is None: + _script_params = '' # ZBX-15706 + else: + _script_params = '\n'.join(str(i) for i in self._module.params['script_params']) + '\n' + parameters.update(dict( + exec_path=self._module.params['script_name'], + exec_params=_script_params + )) + return parameters + + elif self._module.params['type'] == 'sms': + parameters.update(dict(gsm_modem=self._module.params['gsm_modem'])) + return parameters + + elif self._module.params['type'] == 'webhook' and LooseVersion(self._zbx_api_version) >= LooseVersion('4.4'): + parameters.update(dict( + script=self._module.params['webhook_script'], + timeout=self._module.params['webhook_timeout'], + process_tags=truths.get(str(self._module.params['process_tags'])), + show_event_menu=truths.get(str(self._module.params['event_menu'])), + parameters=self._module.params['webhook_params'] + )) + if self._module.params['event_menu']: + parameters.update(dict( + event_menu_url=self._module.params['event_menu_url'], + event_menu_name=self._module.params['event_menu_name'] + )) + return parameters + + elif self._module.params['type'] == 'jabber' and LooseVersion(self._zbx_api_version) <= LooseVersion('4.2'): + parameters.update(dict( + username=self._module.params['username'], + passwd=self._module.params['password'] + )) + return parameters + + elif self._module.params['type'] == 'ez_texting' and LooseVersion(self._zbx_api_version) <= LooseVersion('4.2'): + parameters.update(dict( + username=self._module.params['username'], + passwd=self._module.params['password'], + exec_path={'USA': '0', 'Canada': '1'}.get(self._module.params['message_text_limit']), + )) + return parameters + + self._module.fail_json(msg="%s is unsupported for Zabbix version %s" % (parameters['unsupported_parameter'], parameters['zbx_api_version'])) + + def validate_params(self, params): + """Validates arguments that are required together. + + Fails the module with the message that shows the missing + requirements if there are some. + + Args: + params (list): Each element of this list + is a list like + ['argument_key', 'argument_value', ['required_arg_1', + 'required_arg_2']]. + Format is the same as `required_if` parameter of AnsibleModule. + """ + for param in params: + if self._module.params[param[0]] == param[1]: + if None in [self._module.params[i] for i in param[2]]: + self._module.fail_json( + msg="Following arguments are required when {key} is {value}: {arguments}".format( + key=param[0], + value=param[1], + arguments=', '.join(param[2]) + ) + ) + + def get_update_params(self, mediatype_id, **kwargs): + """Filters only the parameters that are different and need to be updated. + + Args: + mediatype_id (int): ID of the mediatype to be updated. + **kwargs: Parameters for the new mediatype. + + Returns: + A tuple where the first element is a dictionary of parameters + that need to be updated and the second one is a dictionary + returned by diff() function with + existing mediatype data and new params passed to it. + """ + get_params = {'output': 'extend', 'mediatypeids': [mediatype_id]} + if LooseVersion(self._zbx_api_version) >= LooseVersion('5.0'): + get_params.update({'selectMessageTemplates': 'extend'}) + + existing_mediatype = self._zapi.mediatype.get(get_params)[0] + + if existing_mediatype['type'] != kwargs['type']: + return kwargs, diff(existing_mediatype, kwargs) + else: + params_to_update = {} + for key in kwargs: + # sort list of parameters to prevent mismatch due to reordering + if key == 'parameters' and (kwargs[key] != [] or existing_mediatype[key] != []): + kwargs[key] = sorted(kwargs[key], key=lambda x: x['name']) + existing_mediatype[key] = sorted(existing_mediatype[key], key=lambda x: x['name']) + + if key == 'message_templates' and (kwargs[key] != [] or existing_mediatype[key] != []): + kwargs[key] = sorted(kwargs[key], key=lambda x: x['subject']) + existing_mediatype[key] = sorted(existing_mediatype[key], key=lambda x: x['subject']) + + if (not (kwargs[key] is None and existing_mediatype[key] == '')) and kwargs[key] != existing_mediatype[key]: + params_to_update[key] = kwargs[key] + return params_to_update, diff(existing_mediatype, kwargs) + + def delete_mediatype(self, mediatype_id): + try: + return self._zapi.mediatype.delete([mediatype_id]) + except Exception as e: + self._module.fail_json(msg="Failed to delete mediatype '{_id}': {e}".format(_id=mediatype_id, e=e)) + + def update_mediatype(self, **kwargs): + try: + self._zapi.mediatype.update(kwargs) + except Exception as e: + self._module.fail_json(msg="Failed to update mediatype '{_id}': {e}".format(_id=kwargs['mediatypeid'], e=e)) + + def create_mediatype(self, **kwargs): + try: + self._zapi.mediatype.create(kwargs) + except Exception as e: + self._module.fail_json(msg="Failed to create mediatype '{name}': {e}".format(name=kwargs['name'], e=e)) + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + name=dict(type='str', required=True), + description=dict(type='str', required=False, default=''), + state=dict(type='str', default='present', choices=['present', 'absent']), + type=dict(type='str', choices=['email', 'script', 'sms', 'webhook', 'jabber', 'ez_texting'], required=True), + status=dict(type='str', default='enabled', choices=['enabled', 'disabled'], required=False), + max_sessions=dict(type='int', default=1, required=False), + max_attempts=dict(type='int', default=3, required=False), + attempt_interval=dict(type='int', default=10, required=False), + # Script + script_name=dict(type='str', required=False), + script_params=dict(type='list', required=False), + # SMS + gsm_modem=dict(type='str', required=False), + # Jabber + username=dict(type='str', required=False), + password=dict(type='str', required=False, no_log=True), + # Email + smtp_server=dict(type='str', default='localhost', required=False), + smtp_server_port=dict(type='int', default=25, required=False), + smtp_helo=dict(type='str', default='localhost', required=False), + smtp_email=dict(type='str', required=False), + smtp_security=dict(type='str', required=False, choices=['None', 'STARTTLS', 'SSL/TLS']), + smtp_authentication=dict(type='bool', default=False, required=False), + smtp_verify_host=dict(type='bool', default=False, required=False), + smtp_verify_peer=dict(type='bool', default=False, required=False), + # EZ Text + message_text_limit=dict(type='str', required=False, choices=['USA', 'Canada']), + # Webhook + webhook_script=dict(type='str'), + webhook_timeout=dict(type='str', default='30s'), + process_tags=dict(type='bool', default=False), + event_menu=dict(type='bool', default=False), + event_menu_url=dict(type='str'), + event_menu_name=dict(type='str'), + webhook_params=dict( + type='list', + elements='dict', + default=[], + required=False, + options=dict( + name=dict(type='str', required=True), + value=dict(type='str', default='') + ) + ), + message_templates=dict( + type='list', + elements='dict', + default=[], + required=False, + options=dict( + eventsource=dict(type='str', choices=['triggers', 'discovery', 'autoregistration', 'internal']), + recovery=dict(type='str', choices=['operations', 'recovery_operations', 'update_operations']), + subject=dict(type='str', default=''), + body=dict(type='str', default='') + ), + required_together=[ + ['eventsource', 'recovery'] + ], + ) + )) + + # this is used to simulate `required_if` of `AnsibleModule`, but only when state=present + required_params = [ + ['type', 'email', ['smtp_email']], + ['type', 'script', ['script_name']], + ['type', 'sms', ['gsm_modem']], + ['type', 'jabber', ['username', 'password']], + ['type', 'ez_texting', ['username', 'password', 'message_text_limit']], + ['type', 'webhook', ['webhook_script']], + ['event_menu', True, ['event_menu_url', 'event_menu_name']], + ['smtp_authentication', True, ['username', 'password']] + ] + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + state = module.params['state'] + name = module.params['name'] + + mediatype = MediaTypeModule(module) + if module.params['state'] == 'present': + mediatype.validate_params(required_params) + mediatype_exists, mediatype_id = mediatype.check_if_mediatype_exists(name) + + parameters = mediatype.construct_parameters() + + if mediatype_exists: + if state == 'absent': + if module.check_mode: + module.exit_json( + changed=True, + msg="Mediatype would have been deleted. Name: {name}, ID: {_id}".format( + name=name, + _id=mediatype_id + ) + ) + mediatype_id = mediatype.delete_mediatype(mediatype_id) + module.exit_json( + changed=True, + msg="Mediatype deleted. Name: {name}, ID: {_id}".format( + name=name, + _id=mediatype_id + ) + ) + else: + params_to_update, diff = mediatype.get_update_params(mediatype_id, **parameters) + if params_to_update == {}: + module.exit_json( + changed=False, + msg="Mediatype is up to date: {name}".format(name=name) + ) + else: + if module.check_mode: + module.exit_json( + changed=True, + diff=diff, + msg="Mediatype would have been updated. Name: {name}, ID: {_id}".format( + name=name, + _id=mediatype_id + ) + ) + mediatype_id = mediatype.update_mediatype(mediatypeid=mediatype_id, **params_to_update) + module.exit_json( + changed=True, + diff=diff, + msg="Mediatype updated. Name: {name}, ID: {_id}".format( + name=name, + _id=mediatype_id + ) + ) + else: + if state == "absent": + module.exit_json(changed=False) + else: + if module.check_mode: + module.exit_json( + changed=True, + msg="Mediatype would have been created. Name: {name}, ID: {_id}".format( + name=name, + _id=mediatype_id + ) + ) + mediatype_id = mediatype.create_mediatype(**parameters) + module.exit_json( + changed=True, + msg="Mediatype created: {name}, ID: {_id}".format( + name=name, + _id=mediatype_id + ) + ) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_proxy.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_proxy.py new file mode 100644 index 00000000..5a1876e2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_proxy.py @@ -0,0 +1,430 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# (c) 2017, Alen Komic +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: zabbix_proxy +short_description: Create/delete/get/update Zabbix proxies +description: + - This module allows you to create, modify, get and delete Zabbix proxy entries. +author: + - "Alen Komic (@akomic)" +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + proxy_name: + description: + - Name of the proxy in Zabbix. + required: true + type: str + proxy_address: + description: + - Comma-delimited list of IP/CIDR addresses or DNS names to accept active proxy requests from. + - Requires I(status=active). + - Works only with >= Zabbix 4.0. ( remove option for <= 4.0 ) + required: false + type: str + description: + description: + - Description of the proxy. + required: false + type: str + status: + description: + - Type of proxy. (4 - active, 5 - passive) + required: false + choices: ['active', 'passive'] + default: "active" + type: str + tls_connect: + description: + - Connections to proxy. + required: false + choices: ['no_encryption','PSK','certificate'] + default: 'no_encryption' + type: str + tls_accept: + description: + - Connections from proxy. + required: false + choices: ['no_encryption','PSK','certificate'] + default: 'no_encryption' + type: str + ca_cert: + description: + - Certificate issuer. + required: false + aliases: [ tls_issuer ] + type: str + tls_subject: + description: + - Certificate subject. + required: false + type: str + tls_psk_identity: + description: + - PSK identity. Required if either I(tls_connect) or I(tls_accept) has PSK enabled. + required: false + type: str + tls_psk: + description: + - The preshared key, at least 32 hex digits. Required if either I(tls_connect) or I(tls_accept) has PSK enabled. + required: false + type: str + state: + description: + - State of the proxy. + - On C(present), it will create if proxy does not exist or update the proxy if the associated data is different. + - On C(absent) will remove a proxy if it exists. + required: false + choices: ['present', 'absent'] + default: "present" + type: str + interface: + description: + - Dictionary with params for the interface when proxy is in passive mode. + - For more information, review proxy interface documentation at + - U(https://www.zabbix.com/documentation/4.0/manual/api/reference/proxy/object#proxy_interface). + required: false + suboptions: + useip: + type: int + description: + - Connect to proxy interface with IP address instead of DNS name. + - 0 (don't use ip), 1 (use ip). + default: 0 + choices: [0, 1] + ip: + type: str + description: + - IP address used by proxy interface. + - Required if I(useip=1). + default: '' + dns: + type: str + description: + - DNS name of the proxy interface. + - Required if I(useip=0). + default: '' + port: + type: str + description: + - Port used by proxy interface. + default: '10051' + type: + type: int + description: + - Interface type to add. + - This suboption is currently ignored for Zabbix proxy. + - This suboption is deprecated since Ansible 2.10 and will eventually be removed in 2.14. + required: false + default: 0 + main: + type: int + description: + - Whether the interface is used as default. + - This suboption is currently ignored for Zabbix proxy. + - This suboption is deprecated since Ansible 2.10 and will eventually be removed in 2.14. + required: false + default: 0 + default: {} + type: dict + +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = r''' +- name: Create or update a proxy with proxy type active + local_action: + module: community.zabbix.zabbix_proxy + server_url: http://monitor.example.com + login_user: username + login_password: password + proxy_name: ExampleProxy + description: ExampleProxy + status: active + state: present + proxy_address: ExampleProxy.local + +- name: Create a new passive proxy using only it's IP + local_action: + module: community.zabbix.zabbix_proxy + server_url: http://monitor.example.com + login_user: username + login_password: password + proxy_name: ExampleProxy + description: ExampleProxy + status: passive + state: present + interface: + useip: 1 + ip: 10.1.1.2 + port: 10051 + +- name: Create a new passive proxy using only it's DNS + local_action: + module: community.zabbix.zabbix_proxy + server_url: http://monitor.example.com + login_user: username + login_password: password + proxy_name: ExampleProxy + description: ExampleProxy + status: passive + state: present + interface: + dns: proxy.example.com + port: 10051 +''' + +RETURN = r''' # ''' + + +from distutils.version import LooseVersion +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Proxy(ZabbixBase): + def __init__(self, module, zbx=None, zapi_wrapper=None): + super(Proxy, self).__init__(module, zbx, zapi_wrapper) + self.existing_data = None + + def proxy_exists(self, proxy_name): + result = self._zapi.proxy.get({'output': 'extend', + 'selectInterface': 'extend', + 'filter': {'host': proxy_name}}) + + if len(result) > 0 and 'proxyid' in result[0]: + self.existing_data = result[0] + return result[0]['proxyid'] + else: + return result + + def add_proxy(self, data): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + + parameters = {} + for item in data: + if data[item]: + parameters[item] = data[item] + + if 'proxy_address' in data and data['status'] != '5': + parameters.pop('proxy_address', False) + + if 'interface' in data and data['status'] != '6': + parameters.pop('interface', False) + + proxy_ids_list = self._zapi.proxy.create(parameters) + self._module.exit_json(changed=True, + result="Successfully added proxy %s (%s)" % (data['host'], data['status'])) + if len(proxy_ids_list) >= 1: + return proxy_ids_list['proxyids'][0] + except Exception as e: + self._module.fail_json(msg="Failed to create proxy %s: %s" % (data['host'], e)) + + def delete_proxy(self, proxy_id, proxy_name): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.proxy.delete([proxy_id]) + self._module.exit_json(changed=True, result="Successfully deleted proxy %s" % proxy_name) + except Exception as e: + self._module.fail_json(msg="Failed to delete proxy %s: %s" % (proxy_name, str(e))) + + def compile_interface_params(self, new_interface): + old_interface = {} + if 'interface' in self.existing_data and \ + len(self.existing_data['interface']) > 0: + old_interface = self.existing_data['interface'] + + for item in ['type', 'main']: + new_interface.pop(item, False) + + if LooseVersion(self._zbx_api_version) >= LooseVersion('5.0.0'): + if old_interface: + old_interface['details'] = str(old_interface['details']) + + final_interface = old_interface.copy() + final_interface.update(new_interface) + final_interface = dict((k, str(v)) for k, v in final_interface.items()) + + if final_interface != old_interface: + return final_interface + else: + return {} + + def update_proxy(self, proxy_id, data): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + parameters = {'proxyid': proxy_id} + + for item in data: + if data[item] and item in self.existing_data and \ + self.existing_data[item] != data[item]: + parameters[item] = data[item] + + if 'interface' in parameters: + parameters.pop('interface') + + if 'proxy_address' in data and data['status'] != '5': + parameters.pop('proxy_address', False) + + if 'interface' in data and data['status'] != '6': + parameters.pop('interface', False) + + if 'interface' in data and data['status'] == '6': + new_interface = self.compile_interface_params(data['interface']) + if len(new_interface) > 0: + parameters['interface'] = new_interface + + if len(parameters) > 1: + self._zapi.proxy.update(parameters) + self._module.exit_json( + changed=True, + result="Successfully updated proxy %s (%s)" % + (data['host'], proxy_id) + ) + else: + self._module.exit_json(changed=False) + except Exception as e: + self._module.fail_json(msg="Failed to update proxy %s: %s" % + (data['host'], e)) + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + proxy_name=dict(type='str', required=True), + proxy_address=dict(type='str', required=False), + status=dict(type='str', default="active", choices=['active', 'passive']), + state=dict(type='str', default="present", choices=['present', 'absent']), + description=dict(type='str', required=False), + tls_connect=dict(type='str', default='no_encryption', choices=['no_encryption', 'PSK', 'certificate']), + tls_accept=dict(type='str', default='no_encryption', choices=['no_encryption', 'PSK', 'certificate']), + ca_cert=dict(type='str', required=False, default=None, aliases=['tls_issuer']), + tls_subject=dict(type='str', required=False, default=None), + tls_psk_identity=dict(type='str', required=False, default=None), + tls_psk=dict(type='str', required=False, default=None), + interface=dict( + type='dict', + required=False, + default={}, + options=dict( + useip=dict(type='int', choices=[0, 1], default=0), + ip=dict(type='str', default=''), + dns=dict(type='str', default=''), + port=dict(type='str', default='10051'), + type=dict(type='int', default=0, removed_in_version="3.0.0", removed_from_collection='community.zabbix'), # was Ansible 2.14 + main=dict(type='int', default=0, removed_in_version="3.0.0", removed_from_collection='community.zabbix'), # was Ansible 2.14 + ), + ) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + proxy_name = module.params['proxy_name'] + proxy_address = module.params['proxy_address'] + description = module.params['description'] + status = module.params['status'] + tls_connect = module.params['tls_connect'] + tls_accept = module.params['tls_accept'] + tls_issuer = module.params['ca_cert'] + tls_subject = module.params['tls_subject'] + tls_psk_identity = module.params['tls_psk_identity'] + tls_psk = module.params['tls_psk'] + state = module.params['state'] + interface = module.params['interface'] + + # convert enabled to 0; disabled to 1 + status = 6 if status == "passive" else 5 + + if tls_connect == 'certificate': + tls_connect = 4 + elif tls_connect == 'PSK': + tls_connect = 2 + else: + tls_connect = 1 + + if tls_accept == 'certificate': + tls_accept = 4 + elif tls_accept == 'PSK': + tls_accept = 2 + else: + tls_accept = 1 + + proxy = Proxy(module) + + # check if proxy already exists + proxy_id = proxy.proxy_exists(proxy_name) + + if proxy_id: + if state == "absent": + # remove proxy + proxy.delete_proxy(proxy_id, proxy_name) + else: + proxy.update_proxy(proxy_id, { + 'host': proxy_name, + 'description': description, + 'status': str(status), + 'tls_connect': str(tls_connect), + 'tls_accept': str(tls_accept), + 'tls_issuer': tls_issuer, + 'tls_subject': tls_subject, + 'tls_psk_identity': tls_psk_identity, + 'tls_psk': tls_psk, + 'interface': interface, + 'proxy_address': proxy_address + }) + else: + if state == "absent": + # the proxy is already deleted. + module.exit_json(changed=False) + + proxy_id = proxy.add_proxy(data={ + 'host': proxy_name, + 'description': description, + 'status': str(status), + 'tls_connect': str(tls_connect), + 'tls_accept': str(tls_accept), + 'tls_issuer': tls_issuer, + 'tls_subject': tls_subject, + 'tls_psk_identity': tls_psk_identity, + 'tls_psk': tls_psk, + 'interface': interface, + 'proxy_address': proxy_address + }) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_screen.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_screen.py new file mode 100644 index 00000000..6a980aee --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_screen.py @@ -0,0 +1,448 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2013-2014, Epic Games, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: zabbix_screen +short_description: Create/update/delete Zabbix screens +description: + - This module allows you to create, modify and delete Zabbix screens and associated graph data. +author: + - "Cove (@cove)" + - "Tony Minfei Ding (!UNKNOWN)" + - "Harrison Gu (@harrisongu)" +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + screens: + description: + - List of screens to be created/updated/deleted (see example). + type: list + elements: dict + required: true + suboptions: + screen_name: + description: + - Screen name will be used. + - If a screen has already been added, the screen name won't be updated. + type: str + required: true + host_group: + description: + - Host group(s) will be used for searching hosts. + - Required if I(state=present). + type: list + elements: str + aliases: [ 'host_groups' ] + state: + description: + - I(present) - Create a screen if it doesn't exist. If the screen already exists, the screen will be updated as needed. + - I(absent) - If a screen exists, the screen will be deleted. + type: str + default: present + choices: + - absent + - present + graph_names: + description: + - Graph names will be added to a screen. Case insensitive. + - Required if I(state=present). + type: list + elements: str + graph_width: + description: + - Graph width will be set in graph settings. + type: int + graph_height: + description: + - Graph height will be set in graph settings. + type: int + graphs_in_row: + description: + - Limit columns of a screen and make multiple rows. + type: int + default: 3 + sort: + description: + - Sort hosts alphabetically. + - If there are numbers in hostnames, leading zero should be used. + type: bool + default: no + +extends_documentation_fragment: +- community.zabbix.zabbix + + +notes: + - Too many concurrent updates to the same screen may cause Zabbix to return errors, see examples for a workaround if needed. +''' + +EXAMPLES = r''' +# Create/update a screen. +- name: Create a new screen or update an existing screen's items 5 in a row + local_action: + module: community.zabbix.zabbix_screen + server_url: http://monitor.example.com + login_user: username + login_password: password + screens: + - screen_name: ExampleScreen1 + host_group: Example group1 + state: present + graph_names: + - Example graph1 + - Example graph2 + graph_width: 200 + graph_height: 100 + graphs_in_row: 5 + +# Create/update multi-screen +- name: Create two of new screens or update the existing screens' items + local_action: + module: community.zabbix.zabbix_screen + server_url: http://monitor.example.com + login_user: username + login_password: password + screens: + - screen_name: ExampleScreen1 + host_group: Example group1 + state: present + graph_names: + - Example graph1 + - Example graph2 + graph_width: 200 + graph_height: 100 + - screen_name: ExampleScreen2 + host_group: Example group2 + state: present + graph_names: + - Example graph1 + - Example graph2 + graph_width: 200 + graph_height: 100 + +# Limit the Zabbix screen creations to one host since Zabbix can return an error when doing concurrent updates +- name: Create a new screen or update an existing screen's items + local_action: + module: community.zabbix.zabbix_screen + server_url: http://monitor.example.com + login_user: username + login_password: password + state: present + screens: + - screen_name: ExampleScreen + host_group: Example group + state: present + graph_names: + - Example graph1 + - Example graph2 + graph_width: 200 + graph_height: 100 + when: inventory_hostname==groups['group_name'][0] + +# Create/update using multiple hosts_groups. Hosts NOT present in all listed host_groups will be skipped. +- name: Create new screen or update the existing screen's items for hosts in both given groups + local_action: + module: community.zabbix.zabbix_screen + server_url: http://monitor.example.com + login_user: username + login_password: password + screens: + - screen_name: ExampleScreen1 + host_group: + - Example group1 + - Example group2 + state: present + graph_names: + - Example graph1 + - Example graph2 + graph_width: 200 + graph_height: 100 +''' + + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +from ansible_collections.community.zabbix.plugins.module_utils.wrappers import ScreenItem +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Screen(ZabbixBase): + # get list of group ids by list of group names + def get_host_group_ids(self, group_names): + if not group_names: + self._module.fail_json(msg="group_name is required") + hostGroup_list = self._zapi.hostgroup.get({'output': 'extend', 'filter': {'name': group_names}}) + if not hostGroup_list: + self._module.fail_json(msg="Host group not found: {0}".format(group_names)) + else: + hostGroup_ids = [g['groupid'] for g in hostGroup_list] + return hostGroup_ids + + # get monitored host_ids by host_group_ids + # (the hosts belonging to all given groups) + def get_host_ids_by_group_ids(self, group_ids, sort): + host_list = self._zapi.host.get({'output': 'extend', 'selectGroups': 'groupid', 'groupids': group_ids, 'monitored_hosts': 1}) + if not host_list: + self._module.fail_json(msg="No hosts in the all group(s) with ids {0}".format(group_ids)) + else: + if sort: + host_list = sorted(host_list, key=lambda name: name['name']) + host_ids = [] + for host in host_list: + host_group_ids = [g['groupid'] for g in host['groups']] + # Check if all search group ids are in hosts group ids + if set(group_ids).issubset(host_group_ids): + host_id = host['hostid'] + host_ids.append(host_id) + return host_ids + + # get screen + def get_screen_id(self, screen_name): + if screen_name == "": + self._module.fail_json(msg="screen_name is required") + try: + screen_id_list = self._zapi.screen.get({'output': 'extend', 'search': {"name": screen_name}}) + if len(screen_id_list) >= 1: + screen_id = screen_id_list[0]['screenid'] + return screen_id + return None + except Exception as e: + self._module.fail_json(msg="Failed to get screen %s from Zabbix: %s" % (screen_name, e)) + + # create screen + def create_screen(self, screen_name, h_size, v_size): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + screen = self._zapi.screen.create({'name': screen_name, 'hsize': h_size, 'vsize': v_size}) + return screen['screenids'][0] + except Exception as e: + self._module.fail_json(msg="Failed to create screen %s: %s" % (screen_name, e)) + + # update screen + def update_screen(self, screen_id, screen_name, h_size, v_size): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.screen.update({'screenid': screen_id, 'hsize': h_size, 'vsize': v_size}) + except Exception as e: + self._module.fail_json(msg="Failed to update screen %s: %s" % (screen_name, e)) + + # delete screen + def delete_screen(self, screen_id, screen_name): + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.screen.delete([screen_id]) + except Exception as e: + self._module.fail_json(msg="Failed to delete screen %s: %s" % (screen_name, e)) + + # get graph ids + def get_graph_ids(self, hosts, graph_name_list): + graph_id_lists = [] + vsize = 1 + for host in hosts: + graph_id_list = self.get_graphs_by_host_id(graph_name_list, host) + size = len(graph_id_list) + if size > 0: + graph_id_lists.extend(graph_id_list) + if vsize < size: + vsize = size + return graph_id_lists, vsize + + # getGraphs + def get_graphs_by_host_id(self, graph_name_list, host_id): + graph_ids = [] + for graph_name in graph_name_list: + graphs_list = self._zapi.graph.get({'output': 'extend', 'search': {'name': graph_name}, 'hostids': host_id}) + graph_id_list = [] + if len(graphs_list) > 0: + for graph in graphs_list: + graph_id = graph['graphid'] + graph_id_list.append(graph_id) + if len(graph_id_list) > 0: + graph_ids.extend(graph_id_list) + return graph_ids + + # get screen items + def get_screen_items(self, screen_id): + screen_item_list = self._zapi.screenitem.get({'output': 'extend', 'screenids': screen_id}) + return screen_item_list + + # delete screen items + def delete_screen_items(self, screen_id, screen_item_id_list): + if len(screen_item_id_list) == 0: + return True + screen_item_list = self.get_screen_items(screen_id) + if len(screen_item_list) > 0: + if self._module.check_mode: + self._module.exit_json(changed=True) + ScreenItem.delete(self, screen_item_id_list) + return True + return False + + # get screen's hsize and vsize + def get_hsize_vsize(self, hosts, v_size, graphs_in_row): + h_size = len(hosts) + # when there is only one host, put all graphs in a row + if h_size == 1: + if v_size <= graphs_in_row: + h_size = v_size + else: + h_size = graphs_in_row + v_size = (v_size - 1) // h_size + 1 + # when len(hosts) is more then graphs_in_row + elif len(hosts) > graphs_in_row: + h_size = graphs_in_row + v_size = (len(hosts) // graphs_in_row + 1) * v_size + + return h_size, v_size + + # create screen_items + def create_screen_items(self, screen_id, hosts, graph_name_list, width, height, h_size, graphs_in_row): + if len(hosts) < 4: + if width is None or width < 0: + width = 500 + else: + if width is None or width < 0: + width = 200 + if height is None or height < 0: + height = 100 + + # when there're only one host, only one row is not good. + if len(hosts) == 1: + graph_id_list = self.get_graphs_by_host_id(graph_name_list, hosts[0]) + for i, graph_id in enumerate(graph_id_list): + if graph_id is not None: + ScreenItem.create(self, ignoreExists=True, data={'screenid': screen_id, 'resourcetype': 0, 'resourceid': graph_id, + 'width': width, 'height': height, + 'x': i % h_size, 'y': i // h_size, 'colspan': 1, 'rowspan': 1, + 'elements': 0, 'valign': 0, 'halign': 0, + 'style': 0, 'dynamic': 0, 'sort_triggers': 0}) + else: + for i, host in enumerate(hosts): + graph_id_list = self.get_graphs_by_host_id(graph_name_list, host) + for j, graph_id in enumerate(graph_id_list): + if graph_id is not None: + ScreenItem.create(self, ignoreExists=True, data={'screenid': screen_id, 'resourcetype': 0, 'resourceid': graph_id, + 'width': width, 'height': height, + 'x': i % graphs_in_row, 'y': len(graph_id_list) * (i // graphs_in_row) + j, + 'colspan': 1, 'rowspan': 1, + 'elements': 0, 'valign': 0, 'halign': 0, + 'style': 0, 'dynamic': 0, 'sort_triggers': 0}) + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + screens=dict( + type='list', + elements='dict', + required=True, + options=dict( + screen_name=dict(type='str', required=True), + host_group=dict(type='list', aliases=['host_groups'], elements='str'), + state=dict(type='str', default='present', choices=['absent', 'present']), + graph_names=dict(type='list', elements='str'), + graph_width=dict(type='int', default=None), + graph_height=dict(type='int', default=None), + graphs_in_row=dict(type='int', default=3), + sort=dict(default=False, type='bool'), + ), + required_if=[ + ['state', 'present', ['host_group']] + ] + ) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + screens = module.params['screens'] + + screen = Screen(module) + created_screens = [] + changed_screens = [] + deleted_screens = [] + + for zabbix_screen in screens: + screen_name = zabbix_screen['screen_name'] + screen_id = screen.get_screen_id(screen_name) + state = zabbix_screen['state'] + sort = zabbix_screen['sort'] + + if state == "absent": + if screen_id: + screen_item_list = screen.get_screen_items(screen_id) + screen_item_id_list = [] + for screen_item in screen_item_list: + screen_item_id = screen_item['screenitemid'] + screen_item_id_list.append(screen_item_id) + screen.delete_screen_items(screen_id, screen_item_id_list) + screen.delete_screen(screen_id, screen_name) + + deleted_screens.append(screen_name) + else: + host_group = zabbix_screen['host_group'] + graph_names = zabbix_screen['graph_names'] + graphs_in_row = zabbix_screen['graphs_in_row'] + graph_width = zabbix_screen['graph_width'] + graph_height = zabbix_screen['graph_height'] + host_group_ids = screen.get_host_group_ids(host_group) + hosts = screen.get_host_ids_by_group_ids(host_group_ids, sort) + if not hosts: + module.fail_json(msg="No hosts found belongin to all given groups: %s" % host_group) + screen_item_id_list = [] + resource_id_list = [] + + graph_ids, v_size = screen.get_graph_ids(hosts, graph_names) + h_size, v_size = screen.get_hsize_vsize(hosts, v_size, graphs_in_row) + + if not screen_id: + # create screen + screen_id = screen.create_screen(screen_name, h_size, v_size) + screen.create_screen_items(screen_id, hosts, graph_names, graph_width, graph_height, h_size, graphs_in_row) + created_screens.append(screen_name) + else: + screen_item_list = screen.get_screen_items(screen_id) + + for screen_item in screen_item_list: + screen_item_id = screen_item['screenitemid'] + resource_id = screen_item['resourceid'] + screen_item_id_list.append(screen_item_id) + resource_id_list.append(resource_id) + + # when the screen items changed, then update + if graph_ids != resource_id_list: + deleted = screen.delete_screen_items(screen_id, screen_item_id_list) + if deleted: + screen.update_screen(screen_id, screen_name, h_size, v_size) + screen.create_screen_items(screen_id, hosts, graph_names, graph_width, graph_height, h_size, graphs_in_row) + changed_screens.append(screen_name) + + if created_screens and changed_screens: + module.exit_json(changed=True, result="Successfully created screen(s): %s, and updated screen(s): %s" % (",".join(created_screens), + ",".join(changed_screens))) + elif created_screens: + module.exit_json(changed=True, result="Successfully created screen(s): %s" % ",".join(created_screens)) + elif changed_screens: + module.exit_json(changed=True, result="Successfully updated screen(s): %s" % ",".join(changed_screens)) + elif deleted_screens: + module.exit_json(changed=True, result="Successfully deleted screen(s): %s" % ",".join(deleted_screens)) + else: + module.exit_json(changed=False) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_service.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_service.py new file mode 100644 index 00000000..8c6c89a5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_service.py @@ -0,0 +1,252 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2019, OVH SAS +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: zabbix_service +short_description: Create/update/delete Zabbix service +description: + - Create/update/delete Zabbix service. +author: + - "Emmanuel Riviere (@emriver)" +requirements: + - "python >= 2.7" + - "zabbix-api >= 0.5.4" +options: + name: + description: + - Name of Zabbix service + required: true + type: str + parent: + description: + - Name of Zabbix service parent + required: false + type: str + sla: + description: + - Sla value (i.e 99.99), goodsla in Zabbix API + required: false + type: float + calculate_sla: + description: + - If yes, calculate the SLA value for this service, showsla in Zabbix API + required: false + default: false + type: bool + algorithm: + description: + - Algorithm used to calculate the sla + - C(no), sla is not calculated + - C(one_child), problem if at least one child has a problem + - C(all_children), problem if all children have problems + required: false + type: str + choices: ["no", "one_child", "all_children"] + default: one_child + trigger_name: + description: + - Name of trigger linked to the service + required: false + type: str + trigger_host: + description: + - Name of host linked to the service + required: false + type: str + state: + description: + - 'State: present - create/update service; absent - delete service' + required: false + choices: [present, absent] + default: "present" + type: str + +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = ''' +--- +# Creates a new Zabbix service +- name: Manage services + local_action: + module: community.zabbix.zabbix_service + server_url: "https://192.168.1.1" + login_user: username + login_password: password + name: apache2 service + sla: 99.99 + calculate_sla: yes + algorithm: one_child + trigger_name: apache2 service status + trigger_host: webserver01 + state: present +''' + +RETURN = ''' +--- +''' + + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Service(ZabbixBase): + def get_service_ids(self, service_name): + service_ids = [] + services = self._zapi.service.get({'filter': {'name': service_name}}) + for service in services: + service_ids.append(service['serviceid']) + return service_ids + + def delete_service(self, service_ids): + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.service.delete(service_ids) + + def dump_services(self, service_ids): + services = self._zapi.service.get({'output': 'extend', 'filter': {'serviceid': service_ids}, 'selectParent': '1'}) + return services + + def generate_service_config(self, name, parent, sla, calculate_sla, trigger_name, trigger_host, algorithm): + algorithms = {'no': '0', 'one_child': '1', 'all_children': '2'} + algorithm = algorithms[algorithm] + + if calculate_sla: + calculate_sla = 1 + else: + calculate_sla = 0 + + # Zabbix api return when no trigger + trigger_id = 0 + if trigger_host and trigger_name: + # Retrieving the host to get the trigger + hosts = self._zapi.host.get({'filter': {'host': trigger_host}}) + if not hosts: + self._module.fail_json(msg="Target host %s not found" % trigger_host) + host_id = hosts[0]['hostid'] + + triggers = self._zapi.trigger.get({'filter': {'description': trigger_name}, 'hostids': [host_id]}) + if not triggers: + self._module.fail_json(msg="Trigger %s not found on host %s" % (trigger_name, trigger_host)) + trigger_id = triggers[0]['triggerid'] + + request = { + 'name': name, + 'algorithm': algorithm, + 'showsla': calculate_sla, + 'sortorder': 1, + 'goodsla': format(sla, '.4f'), # Sla has 4 decimals + 'triggerid': trigger_id + } + + if parent: + parent_ids = self.get_service_ids(parent) + if not parent_ids: + self._module.fail_json(msg="Parent %s not found" % parent) + request['parentid'] = parent_ids[0] + return request + + def create_service(self, name, parent, sla, calculate_sla, trigger_name, trigger_host, algorithm): + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.service.create(self.generate_service_config(name, parent, sla, calculate_sla, trigger_name, trigger_host, algorithm)) + + def update_service(self, service_id, name, parent, sla, calculate_sla, trigger_name, trigger_host, algorithm): + generated_config = self.generate_service_config(name, parent, sla, calculate_sla, trigger_name, trigger_host, algorithm) + live_config = self.dump_services(service_id)[0] + + item_to_check = ['name', 'showsla', 'algorithm', 'triggerid', 'sortorder', 'goodsla'] + change = False + for item in item_to_check: + if item == 'goodsla': + live_config[item] = format(float(live_config[item]), '.4f') + + if str(generated_config[item]) != str(live_config[item]): + change = True + + # In Zabbix 4.0 + # No parent returns : "parent": [] + # A parent returns : "parent": { "serviceid": 12 } + if 'parentid' in generated_config: + if 'serviceid' in live_config['parent']: + if generated_config['parentid'] != live_config['parent']['serviceid']: + change = True + else: + change = True + elif 'serviceid' in live_config['parent']: + change = True + + if not change: + self._module.exit_json(changed=False, msg="Service %s up to date" % name) + + if self._module.check_mode: + self._module.exit_json(changed=True) + generated_config['serviceid'] = service_id + self._zapi.service.update(generated_config) + self._module.exit_json(changed=True, msg="Service %s updated" % name) + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + name=dict(type='str', required=True), + parent=dict(type='str', required=False), + sla=dict(type='float', required=False), + calculate_sla=dict(type='bool', required=False, default=False), + algorithm=dict(default='one_child', required=False, choices=['no', 'one_child', 'all_children']), + trigger_name=dict(type='str', required=False), + trigger_host=dict(type='str', required=False), + state=dict(default="present", choices=['present', 'absent']), + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + name = module.params['name'] + parent = module.params['parent'] + sla = module.params['sla'] + calculate_sla = module.params['calculate_sla'] + algorithm = module.params['algorithm'] + trigger_name = module.params['trigger_name'] + trigger_host = module.params['trigger_host'] + state = module.params['state'] + + # Load service module + service = Service(module) + service_ids = service.get_service_ids(name) + + # Delete service + if state == "absent": + if not service_ids: + module.exit_json(changed=False, msg="Service not found, no change: %s" % name) + service.delete_service(service_ids) + module.exit_json(changed=True, result="Successfully deleted service(s) %s" % name) + + elif state == "present": + if (trigger_name and not trigger_host) or (trigger_host and not trigger_name): + module.fail_json(msg="Specify either both trigger_host and trigger_name or none to create or update a service") + # Does not exists going to create it + if not service_ids: + service.create_service(name, parent, sla, calculate_sla, trigger_name, trigger_host, algorithm) + module.exit_json(changed=True, msg="Service %s created" % name) + # Else we update it if needed + else: + service.update_service(service_ids[0], name, parent, sla, calculate_sla, trigger_name, trigger_host, algorithm) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py new file mode 100644 index 00000000..d4bba7db --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py @@ -0,0 +1,771 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2017, sookido +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: zabbix_template +short_description: Create/update/delete/dump Zabbix template +description: + - This module allows you to create, modify, delete and dump Zabbix templates. + - Multiple templates can be created or modified at once if passing JSON or XML to module. +author: + - "sookido (@sookido)" + - "Logan Vig (@logan2211)" + - "Dusan Matejka (@D3DeFi)" +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + template_name: + description: + - Name of Zabbix template. + - Required when I(template_json) or I(template_xml) are not used. + - Mutually exclusive with I(template_json) and I(template_xml). + required: false + type: str + template_json: + description: + - JSON dump of templates to import. + - Multiple templates can be imported this way. + - Mutually exclusive with I(template_name) and I(template_xml). + required: false + type: json + template_xml: + description: + - XML dump of templates to import. + - Multiple templates can be imported this way. + - You are advised to pass XML structure matching the structure used by your version of Zabbix server. + - Custom XML structure can be imported as long as it is valid, but may not yield consistent idempotent + results on subsequent runs. + - Mutually exclusive with I(template_name) and I(template_json). + required: false + type: str + template_groups: + description: + - List of host groups to add template to when template is created. + - Replaces the current host groups the template belongs to if the template is already present. + - Required when creating a new template with C(state=present) and I(template_name) is used. + Not required when updating an existing template. + required: false + type: list + elements: str + link_templates: + description: + - List of template names to be linked to the template. + - Templates that are not specified and are linked to the existing template will be only unlinked and not + cleared from the template. + required: false + type: list + elements: str + clear_templates: + description: + - List of template names to be unlinked and cleared from the template. + - This option is ignored if template is being created for the first time. + required: false + type: list + elements: str + macros: + description: + - List of user macros to create for the template. + - Macros that are not specified and are present on the existing template will be replaced. + - See examples on how to pass macros. + required: false + type: list + elements: dict + suboptions: + macro: + description: + - Name of the macro. + - Must be specified in {$NAME} format. + type: str + required: true + value: + description: + - Value of the macro. + type: str + required: true + dump_format: + description: + - Format to use when dumping template with C(state=dump). + - This option is deprecated and will eventually be removed in 2.14. + required: false + choices: [json, xml] + default: "json" + type: str + omit_date: + description: + - Removes the date field for the exported/dumped template + - Requires C(state=dump) + required: false + type: bool + default: false + state: + description: + - Required state of the template. + - On C(state=present) template will be created/imported or updated depending if it is already present. + - On C(state=dump) template content will get dumped into required format specified in I(dump_format). + - On C(state=absent) template will be deleted. + - The C(state=dump) is deprecated and will be removed in 2.14. The M(community.zabbix.zabbix_template_info) module should be used instead. + required: false + choices: [present, absent, dump] + default: "present" + type: str + +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = r''' +--- +- name: Create a new Zabbix template linked to groups, macros and templates + local_action: + module: community.zabbix.zabbix_template + server_url: http://127.0.0.1 + login_user: username + login_password: password + template_name: ExampleHost + template_groups: + - Role + - Role2 + link_templates: + - Example template1 + - Example template2 + macros: + - macro: '{$EXAMPLE_MACRO1}' + value: 30000 + - macro: '{$EXAMPLE_MACRO2}' + value: 3 + - macro: '{$EXAMPLE_MACRO3}' + value: 'Example' + state: present + +- name: Unlink and clear templates from the existing Zabbix template + local_action: + module: community.zabbix.zabbix_template + server_url: http://127.0.0.1 + login_user: username + login_password: password + template_name: ExampleHost + clear_templates: + - Example template3 + - Example template4 + state: present + +- name: Import Zabbix templates from JSON + local_action: + module: community.zabbix.zabbix_template + server_url: http://127.0.0.1 + login_user: username + login_password: password + template_json: "{{ lookup('file', 'zabbix_apache2.json') }}" + state: present + +- name: Import Zabbix templates from XML + local_action: + module: community.zabbix.zabbix_template + server_url: http://127.0.0.1 + login_user: username + login_password: password + template_xml: "{{ lookup('file', 'zabbix_apache2.json') }}" + state: present + +- name: Import Zabbix template from Ansible dict variable + community.zabbix.zabbix_template: + login_user: username + login_password: password + server_url: http://127.0.0.1 + template_json: + zabbix_export: + version: '3.2' + templates: + - name: Template for Testing + description: 'Testing template import' + template: Test Template + groups: + - name: Templates + applications: + - name: Test Application + state: present + +- name: Configure macros on the existing Zabbix template + local_action: + module: community.zabbix.zabbix_template + server_url: http://127.0.0.1 + login_user: username + login_password: password + template_name: Template + macros: + - macro: '{$TEST_MACRO}' + value: 'Example' + state: present + +- name: Delete Zabbix template + local_action: + module: community.zabbix.zabbix_template + server_url: http://127.0.0.1 + login_user: username + login_password: password + template_name: Template + state: absent + +- name: Dump Zabbix template as JSON + local_action: + module: community.zabbix.zabbix_template + server_url: http://127.0.0.1 + login_user: username + login_password: password + template_name: Template + omit_date: yes + state: dump + register: template_dump + +- name: Dump Zabbix template as XML + local_action: + module: community.zabbix.zabbix_template + server_url: http://127.0.0.1 + login_user: username + login_password: password + template_name: Template + dump_format: xml + omit_date: false + state: dump + register: template_dump +''' + +RETURN = r''' +--- +template_json: + description: The JSON dump of the template + returned: when state is dump and omit_date is no + type: str + sample: { + "zabbix_export":{ + "date":"2017-11-29T16:37:24Z", + "templates":[{ + "templates":[], + "description":"", + "httptests":[], + "screens":[], + "applications":[], + "discovery_rules":[], + "groups":[{"name":"Templates"}], + "name":"Test Template", + "items":[], + "macros":[], + "template":"test" + }], + "version":"3.2", + "groups":[{ + "name":"Templates" + }] + } + } + +template_xml: + description: dump of the template in XML representation + returned: when state is dump, dump_format is xml and omit_date is yes + type: str + sample: |- + + + 4.2 + + + Templates + + + + + + +''' + + +import json +import traceback +import codecs +import xml.etree.ElementTree as ET + +from distutils.version import LooseVersion +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils._text import to_native +from ansible.module_utils.six import PY2 + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Template(ZabbixBase): + # check if host group exists + def check_host_group_exist(self, group_names): + for group_name in group_names: + result = self._zapi.hostgroup.get({'filter': {'name': group_name}}) + if not result: + self._module.fail_json(msg="Hostgroup not found: %s" % + group_name) + return True + + # get group ids by group names + def get_group_ids_by_group_names(self, group_names): + group_ids = [] + if group_names is None or len(group_names) == 0: + return group_ids + if self.check_host_group_exist(group_names): + group_list = self._zapi.hostgroup.get({'output': 'extend', 'filter': {'name': group_names}}) + for group in group_list: + group_id = group['groupid'] + group_ids.append({'groupid': group_id}) + return group_ids + + def get_template_ids(self, template_list): + template_ids = [] + if template_list is None or len(template_list) == 0: + return template_ids + for template in template_list: + template_list = self._zapi.template.get({'output': 'extend', 'filter': {'host': template}}) + if len(template_list) < 1: + continue + else: + template_id = template_list[0]['templateid'] + template_ids.append(template_id) + return template_ids + + def add_template(self, template_name, group_ids, link_template_ids, macros): + if self._module.check_mode: + self._module.exit_json(changed=True) + + self._zapi.template.create({'host': template_name, 'groups': group_ids, 'templates': link_template_ids, + 'macros': macros}) + + def check_template_changed(self, template_ids, template_groups, link_templates, clear_templates, + template_macros, template_content, template_type): + """Compares template parameters to already existing values if any are found. + + template_json - JSON structures are compared as deep sorted dictionaries, + template_xml - XML structures are compared as strings, but filtered and formatted first, + If none above is used, all the other arguments are compared to their existing counterparts + retrieved from Zabbix API.""" + changed = False + # Compare filtered and formatted XMLs strings for any changes. It is expected that provided + # XML has same structure as Zabbix uses (e.g. it was optimally exported via Zabbix GUI or API) + if template_content is not None and template_type == 'xml': + existing_template = self.dump_template(template_ids, template_type='xml') + + if self.filter_xml_template(template_content) != self.filter_xml_template(existing_template): + changed = True + + return changed + + existing_template = self.dump_template(template_ids, template_type='json') + # Compare JSON objects as deep sorted python dictionaries + if template_content is not None and template_type == 'json': + parsed_template_json = self.load_json_template(template_content) + if self.diff_template(parsed_template_json, existing_template): + changed = True + + return changed + + # If neither template_json or template_xml were used, user provided all parameters via module options + if template_groups is not None: + existing_groups = [g['name'] for g in existing_template['zabbix_export']['groups']] + + if set(template_groups) != set(existing_groups): + changed = True + + if 'templates' not in existing_template['zabbix_export']['templates'][0]: + existing_template['zabbix_export']['templates'][0]['templates'] = [] + + # Check if any new templates would be linked or any existing would be unlinked + exist_child_templates = [t['name'] for t in existing_template['zabbix_export']['templates'][0]['templates']] + if link_templates is not None: + if set(link_templates) != set(exist_child_templates): + changed = True + else: + if set([]) != set(exist_child_templates): + changed = True + + # Mark that there will be changes when at least one existing template will be unlinked + if clear_templates is not None: + for t in clear_templates: + if t in exist_child_templates: + changed = True + break + + if 'macros' not in existing_template['zabbix_export']['templates'][0]: + existing_template['zabbix_export']['templates'][0]['macros'] = [] + + if template_macros is not None: + existing_macros = existing_template['zabbix_export']['templates'][0]['macros'] + if template_macros != existing_macros: + changed = True + + return changed + + def update_template(self, template_ids, group_ids, link_template_ids, clear_template_ids, template_macros): + template_changes = {} + if group_ids is not None: + template_changes.update({'groups': group_ids}) + + if link_template_ids is not None: + template_changes.update({'templates': link_template_ids}) + else: + template_changes.update({'templates': []}) + + if clear_template_ids is not None: + template_changes.update({'templates_clear': clear_template_ids}) + + if template_macros is not None: + template_changes.update({'macros': template_macros}) + + if template_changes: + # If we got here we know that only one template was provided via template_name + template_changes.update({'templateid': template_ids[0]}) + self._zapi.template.update(template_changes) + + def delete_template(self, templateids): + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.template.delete(templateids) + + def ordered_json(self, obj): + # Deep sort json dicts for comparison + if isinstance(obj, dict): + return sorted((k, self.ordered_json(v)) for k, v in obj.items()) + if isinstance(obj, list): + return sorted(self.ordered_json(x) for x in obj) + else: + return obj + + def dump_template(self, template_ids, template_type='json', omit_date=False): + try: + dump = self._zapi.configuration.export({'format': template_type, 'options': {'templates': template_ids}}) + if template_type == 'xml': + xmlroot = ET.fromstring(dump.encode('utf-8')) + # remove date field if requested + if omit_date: + date = xmlroot.find(".date") + if date is not None: + xmlroot.remove(date) + if PY2: + return str(ET.tostring(xmlroot, encoding='utf-8')) + else: + return str(ET.tostring(xmlroot, encoding='utf-8').decode('utf-8')) + else: + return self.load_json_template(dump, omit_date=omit_date) + + except Exception as e: + self._module.fail_json(msg='Unable to export template: %s' % e) + + def diff_template(self, template_json_a, template_json_b): + # Compare 2 zabbix templates and return True if they differ. + template_json_a = self.filter_template(template_json_a) + template_json_b = self.filter_template(template_json_b) + if self.ordered_json(template_json_a) == self.ordered_json(template_json_b): + return False + return True + + def filter_template(self, template_json): + # Filter the template json to contain only the keys we will update + keep_keys = set(['graphs', 'templates', 'triggers', 'value_maps']) + unwanted_keys = set(template_json['zabbix_export']) - keep_keys + for unwanted_key in unwanted_keys: + del template_json['zabbix_export'][unwanted_key] + + # Versions older than 2.4 do not support description field within template + desc_not_supported = False + if LooseVersion(self._zbx_api_version) < LooseVersion('2.4'): + desc_not_supported = True + + # Filter empty attributes from template object to allow accurate comparison + for template in template_json['zabbix_export']['templates']: + for key in list(template.keys()): + if not template[key] or (key == 'description' and desc_not_supported): + template.pop(key) + + return template_json + + def filter_xml_template(self, template_xml): + """Filters out keys from XML template that may wary between exports (e.g date or version) and + keys that are not imported via this module. + + It is advised that provided XML template exactly matches XML structure used by Zabbix""" + # Strip last new line and convert string to ElementTree + parsed_xml_root = self.load_xml_template(template_xml.strip()) + keep_keys = ['graphs', 'templates', 'triggers', 'value_maps'] + + # Remove unwanted XML nodes + for node in list(parsed_xml_root): + if node.tag not in keep_keys: + parsed_xml_root.remove(node) + + # Filter empty attributes from template objects to allow accurate comparison + for template in list(parsed_xml_root.find('templates')): + for element in list(template): + if element.text is None and len(list(element)) == 0: + template.remove(element) + + # Filter new lines and indentation + xml_root_text = list(line.strip() for line in ET.tostring(parsed_xml_root, encoding='utf8', method='xml').decode().split('\n')) + return ''.join(xml_root_text) + + def load_json_template(self, template_json, omit_date=False): + try: + jsondoc = json.loads(template_json) + if omit_date and 'date' in jsondoc['zabbix_export']: + del jsondoc['zabbix_export']['date'] + return jsondoc + except ValueError as e: + self._module.fail_json(msg='Invalid JSON provided', details=to_native(e), exception=traceback.format_exc()) + + def load_xml_template(self, template_xml): + try: + return ET.fromstring(template_xml) + except ET.ParseError as e: + self._module.fail_json(msg='Invalid XML provided', details=to_native(e), exception=traceback.format_exc()) + + def import_template(self, template_content, template_type='json'): + if self._module.check_mode: + self._module.exit_json(changed=True) + + # rules schema latest version + update_rules = { + 'applications': { + 'createMissing': True, + 'deleteMissing': True + }, + 'discoveryRules': { + 'createMissing': True, + 'updateExisting': True, + 'deleteMissing': True + }, + 'graphs': { + 'createMissing': True, + 'updateExisting': True, + 'deleteMissing': True + }, + 'groups': { + 'createMissing': True + }, + 'httptests': { + 'createMissing': True, + 'updateExisting': True, + 'deleteMissing': True + }, + 'items': { + 'createMissing': True, + 'updateExisting': True, + 'deleteMissing': True + }, + 'templates': { + 'createMissing': True, + 'updateExisting': True + }, + 'templateLinkage': { + 'createMissing': True + }, + 'templateScreens': { + 'createMissing': True, + 'updateExisting': True, + 'deleteMissing': True + }, + 'triggers': { + 'createMissing': True, + 'updateExisting': True, + 'deleteMissing': True + }, + 'valueMaps': { + 'createMissing': True, + 'updateExisting': True + } + } + + try: + # updateExisting for application removed from zabbix api after 3.2 + if LooseVersion(self._zbx_api_version) <= LooseVersion('3.2'): + update_rules['applications']['updateExisting'] = True + + # templateLinkage.deleteMissing only available in 4.0 branch higher .16 and higher 4.4.4 + # it's not available in 4.2 branches or lower 4.0.16 + if LooseVersion(self._zbx_api_version).version[:2] == LooseVersion('4.0').version and \ + LooseVersion(self._zbx_api_version).version[:3] >= LooseVersion('4.0.16').version: + update_rules['templateLinkage']['deleteMissing'] = True + if LooseVersion(self._zbx_api_version) >= LooseVersion('4.4.4'): + update_rules['templateLinkage']['deleteMissing'] = True + + # templateScreens is named templateDashboards in zabbix >= 5.2 + # https://support.zabbix.com/browse/ZBX-18677 + if LooseVersion(self._zbx_api_version) >= LooseVersion('5.2'): + update_rules["templateDashboards"] = update_rules.pop("templateScreens") + + template_content = codecs.decode(template_content, 'unicode-escape') + import_data = {'format': template_type, 'source': template_content, 'rules': update_rules} + self._zapi.configuration.import_(import_data) + except Exception as e: + self._module.fail_json(msg='Unable to import template', details=to_native(e), + exception=traceback.format_exc()) + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + template_name=dict(type='str', required=False), + template_json=dict(type='json', required=False), + template_xml=dict(type='str', required=False), + template_groups=dict(type='list', required=False), + link_templates=dict(type='list', required=False), + clear_templates=dict(type='list', required=False), + macros=dict( + type='list', + elements='dict', + options=dict( + macro=dict(type='str', required=True), + value=dict(type='str', required=True) + ) + ), + omit_date=dict(type='bool', required=False, default=False), + dump_format=dict(type='str', required=False, default='json', choices=['json', 'xml']), + state=dict(type='str', default="present", choices=['present', 'absent', 'dump']), + )) + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=[ + ['template_name', 'template_json', 'template_xml'] + ], + mutually_exclusive=[ + ['template_name', 'template_json', 'template_xml'] + ], + required_if=[ + ['state', 'absent', ['template_name']], + ['state', 'dump', ['template_name']] + ], + supports_check_mode=True + ) + + template_name = module.params['template_name'] + template_json = module.params['template_json'] + template_xml = module.params['template_xml'] + template_groups = module.params['template_groups'] + link_templates = module.params['link_templates'] + clear_templates = module.params['clear_templates'] + template_macros = module.params['macros'] + omit_date = module.params['omit_date'] + dump_format = module.params['dump_format'] + state = module.params['state'] + + template = Template(module) + + # Identify template names for IDs retrieval + # Template names are expected to reside in ['zabbix_export']['templates'][*]['template'] for both data types + template_content, template_type = None, None + if template_json is not None: + template_type = 'json' + template_content = template_json + json_parsed = template.load_json_template(template_content) + template_names = list(t['template'] for t in json_parsed['zabbix_export']['templates']) + + elif template_xml is not None: + template_type = 'xml' + template_content = template_xml + xml_parsed = template.load_xml_template(template_content) + template_names = list(t.find('template').text for t in list(xml_parsed.find('templates'))) + + else: + template_names = [template_name] + + template_ids = template.get_template_ids(template_names) + + if state == "absent": + if not template_ids: + module.exit_json(changed=False, msg="Template not found. No changed: %s" % template_name) + + template.delete_template(template_ids) + module.exit_json(changed=True, result="Successfully deleted template %s" % template_name) + + elif state == "dump": + module.deprecate("The 'dump' state has been deprecated and will be removed, use 'zabbix_template_info' module instead.", + collection_name="community.zabbix", version='3.0.0') # was 2.14 + if not template_ids: + module.fail_json(msg='Template not found: %s' % template_name) + + if dump_format == 'json': + module.exit_json(changed=False, template_json=template.dump_template(template_ids, template_type='json', omit_date=omit_date)) + elif dump_format == 'xml': + module.exit_json(changed=False, template_xml=template.dump_template(template_ids, template_type='xml', omit_date=omit_date)) + + elif state == "present": + # Load all subelements for template that were provided by user + group_ids = None + if template_groups is not None: + group_ids = template.get_group_ids_by_group_names(template_groups) + + link_template_ids = None + if link_templates is not None: + link_template_ids = template.get_template_ids(link_templates) + + clear_template_ids = None + if clear_templates is not None: + clear_template_ids = template.get_template_ids(clear_templates) + + if template_macros is not None: + # Zabbix configuration.export does not differentiate python types (numbers are returned as strings) + for macroitem in template_macros: + for key in macroitem: + macroitem[key] = str(macroitem[key]) + + if not template_ids: + # Assume new templates are being added when no ID's were found + if template_content is not None: + template.import_template(template_content, template_type) + module.exit_json(changed=True, result="Template import successful") + + else: + if group_ids is None: + module.fail_json(msg='template_groups are required when creating a new Zabbix template') + + template.add_template(template_name, group_ids, link_template_ids, template_macros) + module.exit_json(changed=True, result="Successfully added template: %s" % template_name) + + else: + changed = template.check_template_changed(template_ids, template_groups, link_templates, clear_templates, + template_macros, template_content, template_type) + + if module.check_mode: + module.exit_json(changed=changed) + + if changed: + if template_type is not None: + template.import_template(template_content, template_type) + else: + template.update_template(template_ids, group_ids, link_template_ids, clear_template_ids, + template_macros) + + module.exit_json(changed=changed, result="Template successfully updated") + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_template_info.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_template_info.py new file mode 100644 index 00000000..248d6a97 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_template_info.py @@ -0,0 +1,232 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, sky-joker +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +module: zabbix_template_info +short_description: Gather information about Zabbix template +author: + - sky-joker (@sky-joker) +description: + - This module allows you to search for Zabbix template. +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + template_name: + description: + - Name of the template in Zabbix. + required: true + type: str + format: + description: + - Format to use when dumping template. + choices: ['json', 'xml'] + default: json + type: str + omit_date: + description: + - Removes the date field for the dumped template + required: false + type: bool + default: false +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = ''' +- name: Get Zabbix template as JSON + community.zabbix.zabbix_template_info: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + template_name: Template + format: json + omit_date: yes + register: template_json + +- name: Get Zabbix template as XML + community.zabbix.zabbix_template_info: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + template_name: Template + format: xml + omit_date: no + register: template_json +''' + +RETURN = ''' +--- +template_json: + description: The JSON of the template + returned: when format is json and omit_date is true + type: str + sample: { + "zabbix_export": { + "version": "4.0", + "groups": [ + { + "name": "Templates" + } + ], + "templates": [ + { + "template": "Test Template", + "name": "Template for Testing", + "description": "Testing template import", + "groups": [ + { + "name": "Templates" + } + ], + "applications": [ + { + "name": "Test Application" + } + ], + "items": [], + "discovery_rules": [], + "httptests": [], + "macros": [], + "templates": [], + "screens": [] + } + ] + } + } + +template_xml: + description: The XML of the template + returned: when format is xml and omit_date is false + type: str + sample: >- + + 4.0 + 2019-10-27T14:49:57Z + + + Templates + + + + + + +''' + + +import traceback +import json +import xml.etree.ElementTree as ET + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils._text import to_native +from ansible.module_utils.six import PY2 + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class TemplateInfo(ZabbixBase): + def get_template_id(self, template_name): + template_id = [] + try: + template_list = self._zapi.template.get({'output': 'extend', + 'filter': {'host': template_name}}) + except Exception as e: + self._module.fail_json(msg='Failed to get template: %s' % e) + + if template_list: + template_id.append(template_list[0]['templateid']) + + return template_id + + def load_json_template(self, template_json, omit_date=False): + try: + jsondoc = json.loads(template_json) + # remove date field if requested + if omit_date and 'date' in jsondoc['zabbix_export']: + del jsondoc['zabbix_export']['date'] + return jsondoc + except ValueError as e: + self._module.fail_json(msg='Invalid JSON provided', details=to_native(e), exception=traceback.format_exc()) + + def dump_template(self, template_id, template_type='json', omit_date=False): + try: + dump = self._zapi.configuration.export({'format': template_type, 'options': {'templates': template_id}}) + if template_type == 'xml': + xmlroot = ET.fromstring(dump.encode('utf-8')) + # remove date field if requested + if omit_date: + date = xmlroot.find(".date") + if date is not None: + xmlroot.remove(date) + if PY2: + return str(ET.tostring(xmlroot, encoding='utf-8')) + else: + return str(ET.tostring(xmlroot, encoding='utf-8').decode('utf-8')) + else: + return self.load_json_template(dump, omit_date) + except Exception as e: + self._module.fail_json(msg='Unable to export template: %s' % e) + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + template_name=dict(type='str', required=True), + omit_date=dict(type='bool', required=False, default=False), + format=dict(type='str', choices=['json', 'xml'], default='json') + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=False + ) + + template_name = module.params['template_name'] + omit_date = module.params['omit_date'] + format = module.params['format'] + + template_info = TemplateInfo(module) + + template_id = template_info.get_template_id(template_name) + + if not template_id: + module.fail_json(msg='Template not found: %s' % template_name) + + if format == 'json': + module.exit_json(changed=False, template_json=template_info.dump_template(template_id, template_type='json', omit_date=omit_date)) + elif format == 'xml': + module.exit_json(changed=False, template_xml=template_info.dump_template(template_id, template_type='xml', omit_date=omit_date)) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_user.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_user.py new file mode 100644 index 00000000..faf50a5d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_user.py @@ -0,0 +1,696 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, sky-joker +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = r''' +module: zabbix_user +short_description: Create/update/delete Zabbix users +author: + - sky-joker (@sky-joker) +description: + - This module allows you to create, modify and delete Zabbix users. +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + alias: + description: + - Name of the user alias in Zabbix. + - alias is the unique identifier used and cannot be updated using this module. + required: true + type: str + name: + description: + - Name of the user. + default: '' + type: str + surname: + description: + - Surname of the user. + default: '' + type: str + usrgrps: + description: + - User groups to add the user to. + - Required when I(state=present). + required: false + type: list + elements: str + passwd: + description: + - User's password. + - Required unless all of the I(usrgrps) are set to use LDAP as frontend access. + - Always required for Zabbix versions lower than 4.0. + required: false + type: str + override_passwd: + description: + - Override password for the user. + - Password will not be updated on subsequent runs without setting this value to yes. + default: no + type: bool + lang: + description: + - Language code of the user's language. + - C(default) can be used with Zabbix version 5.2 or higher. + default: 'en_GB' + choices: + - 'en_GB' + - 'en_US' + - 'zh_CN' + - 'cs_CZ' + - 'fr_FR' + - 'he_IL' + - 'it_IT' + - 'ko_KR' + - 'ja_JP' + - 'nb_NO' + - 'pl_PL' + - 'pt_BR' + - 'pt_PT' + - 'ru_RU' + - 'sk_SK' + - 'tr_TR' + - 'uk_UA' + - 'default' + type: str + theme: + description: + - User's theme. + default: 'default' + choices: + - 'default' + - 'blue-theme' + - 'dark-theme' + type: str + autologin: + description: + - Whether to enable auto-login. + - If enable autologin, cannot enable autologout. + default: false + type: bool + autologout: + description: + - User session life time in seconds. If set to 0, the session will never expire. + - If enable autologout, cannot enable autologin. + default: '0' + type: str + refresh: + description: + - Automatic refresh period in seconds. + default: '30' + type: str + rows_per_page: + description: + - Amount of object rows to show per page. + default: '50' + type: str + after_login_url: + description: + - URL of the page to redirect the user to after logging in. + default: '' + type: str + user_medias: + description: + - Set the user's media. + - If not set, makes no changes to media. + suboptions: + mediatype: + description: + - Media type name to set. + default: 'Email' + type: str + sendto: + description: + - Address, user name or other identifier of the recipient. + required: true + type: str + period: + description: + - Time when the notifications can be sent as a time period or user macros separated by a semicolon. + - Please review the documentation for more information on the supported time period. + - https://www.zabbix.com/documentation/4.0/manual/appendix/time_period + default: '1-7,00:00-24:00' + type: str + severity: + description: + - Trigger severities to send notifications about. + suboptions: + not_classified: + description: + - severity not_classified enable/disable. + default: True + type: bool + information: + description: + - severity information enable/disable. + default: True + type: bool + warning: + description: + - severity warning enable/disable. + default: True + type: bool + average: + description: + - severity average enable/disable. + default: True + type: bool + high: + description: + - severity high enable/disable. + default: True + type: bool + disaster: + description: + - severity disaster enable/disable. + default: True + type: bool + default: + not_classified: True + information: True + warning: True + average: True + high: True + disaster: True + type: dict + active: + description: + - Whether the media is enabled. + default: true + type: bool + type: list + elements: dict + type: + description: + - Type of the user. + - I(type) is necessary if Zabbix version is 5.0 or lower. + default: 'Zabbix user' + choices: + - 'Zabbix user' + - 'Zabbix admin' + - 'Zabbix super admin' + type: str + timezone: + description: + - User's time zone. + - I(timezone) can be used with Zabbix version 5.2 or higher. + - For the full list of supported time zones please refer to U(https://www.php.net/manual/en/timezones.php) + default: default + type: str + version_added: 1.2.0 + role_name: + description: + - User's role. + - I(role_name) is required when Zabbix version is 5.2 or higher. + default: 'User role' + type: str + version_added: 1.2.0 + state: + description: + - State of the user. + - On C(present), it will create if user does not exist or update the user if the associated data is different. + - On C(absent) will remove a user if it exists. + default: 'present' + choices: ['present', 'absent'] + type: str +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = r''' +- name: create a new zabbix user. + community.zabbix.zabbix_user: + server_url: "http://zabbix.example.com/zabbix/" + login_user: Admin + login_password: secret + alias: example + name: user name + surname: user surname + usrgrps: + - Guests + - Disabled + passwd: password + lang: en_GB + theme: blue-theme + autologin: no + autologout: '0' + refresh: '30' + rows_per_page: '200' + after_login_url: '' + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: no + type: Zabbix super admin + state: present + +- name: delete existing zabbix user. + community.zabbix.zabbix_user: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + alias: example + usrgrps: + - Guests + passwd: password + user_medias: + - sendto: example@example.com + state: absent +''' + +RETURN = r''' +user_ids: + description: User id created or changed + returned: success + type: dict + sample: { "userids": [ "5" ] } +''' + + +import copy + +from distutils.version import LooseVersion +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class User(ZabbixBase): + def get_usergroups_by_name(self, usrgrps): + params = { + 'output': ['usrgrpid', 'name', 'gui_access'], + 'filter': { + 'name': usrgrps + } + } + res = self._zapi.usergroup.get(params) + if res: + ids = [{'usrgrpid': g['usrgrpid']} for g in res] + # User can be created password-less only when all groups are LDAP + # Verify there are no groups with different access methods + not_ldap = bool([g for g in res if g['gui_access'] != '2']) + not_found_groups = set(usrgrps) - set([g['name'] for g in res]) + if not_found_groups: + self._module.fail_json(msg='User groups not found: %s' % not_found_groups) + return ids, not_ldap + else: + self._module.fail_json(msg='No user groups found') + + def check_user_exist(self, alias): + zbx_user = self._zapi.user.get({'output': 'extend', 'filter': {'alias': alias}, + 'getAccess': True, 'selectMedias': 'extend', + 'selectUsrgrps': 'extend'}) + return zbx_user + + def convert_user_medias_parameter_types(self, user_medias): + copy_user_medias = copy.deepcopy(user_medias) + for user_media in copy_user_medias: + media_types = self._zapi.mediatype.get({'output': 'extend'}) + for media_type in media_types: + if LooseVersion(self._zbx_api_version) < LooseVersion('4.4'): + if media_type['description'] == user_media['mediatype']: + user_media['mediatypeid'] = media_type['mediatypeid'] + break + else: + if media_type['name'] == user_media['mediatype']: + user_media['mediatypeid'] = media_type['mediatypeid'] + break + + if 'mediatypeid' not in user_media: + self._module.fail_json(msg="Media type not found: %s" % user_media['mediatype']) + else: + del user_media['mediatype'] + + severity_binary_number = '' + for severity_key in 'disaster', 'high', 'average', 'warning', 'information', 'not_classified': + if user_media['severity'][severity_key]: + severity_binary_number = severity_binary_number + '1' + else: + severity_binary_number = severity_binary_number + '0' + user_media['severity'] = str(int(severity_binary_number, 2)) + + if user_media['active']: + user_media['active'] = '0' + else: + user_media['active'] = '1' + + return copy_user_medias + + def get_roleid_by_name(self, role_name): + roles = self._zapi.role.get({'output': 'extend'}) + for role in roles: + if role['name'] == role_name: + return role['roleid'] + + self._module.fail_json(msg="Role not found: %s" % role_name) + + def user_parameter_difference_check(self, zbx_user, alias, name, surname, user_group_ids, passwd, lang, theme, + autologin, autologout, refresh, rows_per_page, url, user_medias, user_type, + timezone, role_name, override_passwd): + + if user_medias: + user_medias = self.convert_user_medias_parameter_types(user_medias) + + # existing data + existing_data = copy.deepcopy(zbx_user[0]) + usrgrpids = [] + for usrgrp in existing_data['usrgrps']: + usrgrpids.append({'usrgrpid': usrgrp['usrgrpid']}) + + existing_data['usrgrps'] = sorted(usrgrpids, key=lambda x: x['usrgrpid']) + + # Processing for zabbix 4.0 and above. + # In zabbix 4.0 and above, Email sendto is of type list. + # This module, one media supports only one Email sendto. + # Therefore following processing extract one Email from list. + if LooseVersion(self._zbx_api_version) >= LooseVersion('4.0'): + for media in existing_data['medias']: + if isinstance(media['sendto'], list): + media['sendto'] = media['sendto'][0] + + existing_data['user_medias'] = sorted(existing_data['medias'], key=lambda x: x['sendto']) + for del_key in ['medias', 'attempt_clock', 'attempt_failed', 'attempt_ip', 'debug_mode', 'users_status', + 'gui_access']: + del existing_data[del_key] + + for user_media in existing_data['user_medias']: + for del_key in ['mediaid', 'userid']: + del user_media[del_key] + + # request data + request_data = { + 'userid': zbx_user[0]['userid'], + 'alias': alias, + 'name': name, + 'surname': surname, + 'usrgrps': sorted(user_group_ids, key=lambda x: x['usrgrpid']), + 'lang': lang, + 'theme': theme, + 'autologin': autologin, + 'autologout': autologout, + 'refresh': refresh, + 'rows_per_page': rows_per_page, + 'url': url, + } + + if user_medias: + request_data['user_medias'] = sorted(user_medias, key=lambda x: x['sendto']) + else: + del existing_data['user_medias'] + + if override_passwd: + request_data['passwd'] = passwd + + # The type key has changed to roleid key since Zabbix 5.2 + if LooseVersion(self._zbx_api_version) < LooseVersion('5.2'): + request_data['type'] = user_type + else: + request_data['roleid'] = self.get_roleid_by_name(role_name) + request_data['timezone'] = timezone + + user_parameter_difference_check_result = True + if existing_data == request_data: + user_parameter_difference_check_result = False + + diff_params = { + "before": existing_data, + "after": request_data + } + + return user_parameter_difference_check_result, diff_params + + def add_user(self, alias, name, surname, user_group_ids, passwd, lang, theme, autologin, autologout, refresh, + rows_per_page, url, user_medias, user_type, not_ldap, timezone, role_name): + + if user_medias: + user_medias = self.convert_user_medias_parameter_types(user_medias) + + user_ids = {} + + request_data = { + 'alias': alias, + 'name': name, + 'surname': surname, + 'usrgrps': user_group_ids, + 'lang': lang, + 'theme': theme, + 'autologin': autologin, + 'autologout': autologout, + 'refresh': refresh, + 'rows_per_page': rows_per_page, + 'url': url, + } + if user_medias: + request_data['user_medias'] = user_medias + + if LooseVersion(self._zbx_api_version) < LooseVersion('4.0') or not_ldap: + request_data['passwd'] = passwd + + # The type key has changed to roleid key since Zabbix 5.2 + if LooseVersion(self._zbx_api_version) < LooseVersion('5.2'): + request_data['type'] = user_type + else: + request_data['roleid'] = self.get_roleid_by_name(role_name) + request_data['timezone'] = timezone + + diff_params = {} + if not self._module.check_mode: + try: + user_ids = self._zapi.user.create(request_data) + except Exception as e: + self._module.fail_json(msg="Failed to create user %s: %s" % (alias, e)) + else: + diff_params = { + "before": "", + "after": request_data + } + + return user_ids, diff_params + + def update_user(self, zbx_user, alias, name, surname, user_group_ids, passwd, lang, theme, autologin, autologout, + refresh, rows_per_page, url, user_medias, user_type, timezone, role_name, override_passwd): + + if user_medias: + user_medias = self.convert_user_medias_parameter_types(user_medias) + + user_ids = {} + + request_data = { + 'userid': zbx_user[0]['userid'], + 'alias': alias, + 'name': name, + 'surname': surname, + 'usrgrps': user_group_ids, + 'lang': lang, + 'theme': theme, + 'autologin': autologin, + 'autologout': autologout, + 'refresh': refresh, + 'rows_per_page': rows_per_page, + 'url': url, + } + + if override_passwd: + request_data['passwd'] = passwd + + # The type key has changed to roleid key since Zabbix 5.2 + if LooseVersion(self._zbx_api_version) < LooseVersion('5.2'): + request_data['type'] = user_type + else: + request_data['roleid'] = self.get_roleid_by_name(role_name) + request_data['timezone'] = timezone + + # In the case of zabbix 3.2 or less, it is necessary to use updatemedia method to update media. + if LooseVersion(self._zbx_api_version) <= LooseVersion('3.2'): + try: + user_ids = self._zapi.user.update(request_data) + except Exception as e: + self._module.fail_json(msg="Failed to update user %s: %s" % (alias, e)) + + try: + if user_medias: + user_ids = self._zapi.user.updatemedia({ + 'users': [{'userid': zbx_user[0]['userid']}], + 'medias': user_medias + }) + except Exception as e: + self._module.fail_json(msg="Failed to update user medias %s: %s" % (alias, e)) + + if LooseVersion(self._zbx_api_version) >= LooseVersion('3.4'): + try: + if user_medias: + request_data['user_medias'] = user_medias + user_ids = self._zapi.user.update(request_data) + except Exception as e: + self._module.fail_json(msg="Failed to update user %s: %s" % (alias, e)) + + return user_ids + + def delete_user(self, zbx_user, alias): + user_ids = {} + diff_params = {} + + if not self._module.check_mode: + try: + user_ids = self._zapi.user.delete([zbx_user[0]['userid']]) + except Exception as e: + self._module.fail_json(msg="Failed to delete user %s: %s" % (alias, e)) + else: + diff_params = { + "before": zbx_user[0], + "after": "" + } + + return user_ids, diff_params + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + alias=dict(type='str', required=True), + name=dict(type='str', default=''), + surname=dict(type='str', default=''), + usrgrps=dict(type='list'), + passwd=dict(type='str', required=False, no_log=True), + override_passwd=dict(type='bool', required=False, default=False, no_log=False), + lang=dict(type='str', default='en_GB', choices=['en_GB', 'en_US', 'zh_CN', 'cs_CZ', 'fr_FR', + 'he_IL', 'it_IT', 'ko_KR', 'ja_JP', 'nb_NO', + 'pl_PL', 'pt_BR', 'pt_PT', 'ru_RU', 'sk_SK', + 'tr_TR', 'uk_UA', 'default']), + theme=dict(type='str', default='default', choices=['default', 'blue-theme', 'dark-theme']), + autologin=dict(type='bool', default=False), + autologout=dict(type='str', default='0'), + refresh=dict(type='str', default='30'), + rows_per_page=dict(type='str', default='50'), + after_login_url=dict(type='str', default=''), + user_medias=dict(type='list', default=None, elements='dict', + options=dict(mediatype=dict(type='str', default='Email'), + sendto=dict(type='str', required=True), + period=dict(type='str', default='1-7,00:00-24:00'), + severity=dict(type='dict', + options=dict( + not_classified=dict(type='bool', default=True), + information=dict(type='bool', default=True), + warning=dict(type='bool', default=True), + average=dict(type='bool', default=True), + high=dict(type='bool', default=True), + disaster=dict(type='bool', default=True)), + default=dict( + not_classified=True, + information=True, + warning=True, + average=True, + high=True, + disaster=True)), + active=dict(type='bool', default=True))), + timezone=dict(type='str', default='default'), + role_name=dict(type='str', default='User role'), + type=dict(type='str', default='Zabbix user', choices=['Zabbix user', 'Zabbix admin', 'Zabbix super admin']), + state=dict(type='str', default="present", choices=['present', 'absent']) + )) + module = AnsibleModule( + argument_spec=argument_spec, + required_if=[ + ['state', 'present', ['usrgrps']] + ], + supports_check_mode=True + ) + + alias = module.params['alias'] + name = module.params['name'] + surname = module.params['surname'] + usrgrps = module.params['usrgrps'] + passwd = module.params['passwd'] + override_passwd = module.params['override_passwd'] + lang = module.params['lang'] + theme = module.params['theme'] + autologin = module.params['autologin'] + autologout = module.params['autologout'] + refresh = module.params['refresh'] + rows_per_page = module.params['rows_per_page'] + after_login_url = module.params['after_login_url'] + user_medias = module.params['user_medias'] + user_type = module.params['type'] + timezone = module.params['timezone'] + role_name = module.params['role_name'] + state = module.params['state'] + + if autologin: + autologin = '1' + else: + autologin = '0' + + user_type_dict = { + 'Zabbix user': '1', + 'Zabbix admin': '2', + 'Zabbix super admin': '3' + } + user_type = user_type_dict[user_type] + + user = User(module) + + user_ids = {} + zbx_user = user.check_user_exist(alias) + if state == 'present': + user_group_ids, not_ldap = user.get_usergroups_by_name(usrgrps) + if LooseVersion(user._zbx_api_version) < LooseVersion('4.0') or not_ldap: + if passwd is None: + module.fail_json(msg='User password is required. One or more groups are not LDAP based.') + + if zbx_user: + diff_check_result, diff_params = user.user_parameter_difference_check(zbx_user, alias, name, surname, + user_group_ids, passwd, lang, theme, + autologin, autologout, refresh, + rows_per_page, after_login_url, + user_medias, user_type, timezone, + role_name, override_passwd) + + if not module.check_mode and diff_check_result: + user_ids = user.update_user(zbx_user, alias, name, surname, user_group_ids, passwd, lang, + theme, autologin, autologout, refresh, rows_per_page, after_login_url, + user_medias, user_type, timezone, role_name, override_passwd) + else: + diff_check_result = True + user_ids, diff_params = user.add_user(alias, name, surname, user_group_ids, passwd, lang, theme, autologin, + autologout, refresh, rows_per_page, after_login_url, user_medias, + user_type, not_ldap, timezone, role_name) + + if state == 'absent': + if zbx_user: + diff_check_result = True + user_ids, diff_params = user.delete_user(zbx_user, alias) + else: + diff_check_result = False + diff_params = {} + + if not module.check_mode: + if user_ids: + module.exit_json(changed=True, user_ids=user_ids) + else: + module.exit_json(changed=False) + else: + if diff_check_result: + module.exit_json(changed=True, diff=diff_params) + else: + module.exit_json(changed=False, diff=diff_params) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_user_info.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_user_info.py new file mode 100644 index 00000000..a6a1d5f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_user_info.py @@ -0,0 +1,132 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, sky-joker +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +module: zabbix_user_info +short_description: Gather information about Zabbix user +author: + - sky-joker (@sky-joker) +description: + - This module allows you to search for Zabbix user entries. +requirements: + - "python >= 2.6" + - "zabbix-api >= 0.5.4" +options: + alias: + description: + - Name of the user alias in Zabbix. + required: true + type: str +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +EXAMPLES = ''' +- name: Get zabbix user info + community.zabbix.zabbix_user_info: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + alias: example +''' + +RETURN = ''' +zabbix_user: + description: example + returned: always + type: dict + sample: { + "alias": "example", + "attempt_clock": "0", + "attempt_failed": "0", + "attempt_ip": "", + "autologin": "0", + "autologout": "0", + "debug_mode": "0", + "gui_access": "0", + "lang": "en_GB", + "medias": [ + { + "active": "0", + "mediaid": "668", + "mediatypeid": "1", + "period": "1-7,00:00-24:00", + "sendto": "example@example.com", + "severity": "63", + "userid": "660" + } + ], + "name": "user", + "refresh": "30s", + "rows_per_page": "50", + "surname": "example", + "theme": "default", + "type": "1", + "url": "", + "userid": "660", + "users_status": "0", + "usrgrps": [ + { + "debug_mode": "0", + "gui_access": "0", + "name": "Guests", + "users_status": "0", + "usrgrpid": "8" + } + ] + } +''' + + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class User(ZabbixBase): + def get_user_by_user_alias(self, alias): + zabbix_user = "" + try: + zabbix_user = self._zapi.user.get({'output': 'extend', 'filter': {'alias': alias}, + 'getAccess': True, 'selectMedias': 'extend', + 'selectUsrgrps': 'extend'}) + except Exception as e: + self._zapi.logout() + self._module.fail_json(msg="Failed to get user information: %s" % e) + + if not zabbix_user: + zabbix_user = {} + else: + zabbix_user = zabbix_user[0] + + return zabbix_user + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + alias=dict(type='str', required=True), + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + alias = module.params['alias'] + + user = User(module) + zabbix_user = user.get_user_by_user_alias(alias) + module.exit_json(changed=False, zabbix_user=zabbix_user) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_usergroup.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_usergroup.py new file mode 100644 index 00000000..310c54db --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_usergroup.py @@ -0,0 +1,498 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Tobias Birkefeld (@tcraxs) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = r''' +--- +module: zabbix_usergroup +short_description: Create/delete/update Zabbix user groups +description: + - Create user groups if they do not exist. + - Delete existing user groups if they exist and are empty. + - Update existing user groups. +author: + - "Tobias Birkefeld (@tcraxs)" +requirements: + - "zabbix-api >= 0.5.4" +options: + name: + description: + - Name of the user group to create, update or delete. + required: true + type: str + aliases: [ "user_group" ] + gui_access: + description: + - Frontend authentication method of the users in the group. + - "Possible values:" + - default - use the system default authentication method; + - internal - use internal authentication; + - LDAP - use LDAP authentication; + - disable - disable access to the frontend. + required: false + type: str + default: "default" + choices: [ "default", "internal", "LDAP", "disable"] + debug_mode: + description: + - Whether debug mode is enabled or disabled. + required: false + type: str + default: "disabled" + choices: [ "disabled", "enabled" ] + status: + description: + - Whether the user group is enabled or disabled. + required: false + type: str + default: "enabled" + choices: [ "enabled", "disabled" ] + rights: + description: + - Permissions to assign to the group + required: false + type: list + elements: dict + suboptions: + host_group: + description: + - Name of the host group to add permission to. + required: true + type: str + permission: + description: + - Access level to the host group. + required: true + type: str + choices: [ "denied", "read-only", "read-write" ] + tag_filters: + description: + - Tag based permissions to assign to the group + required: false + type: list + elements: dict + suboptions: + host_group: + description: + - Name of the host group to add permission to. + required: true + type: str + tag: + description: + - Tag name. + required: false + type: str + default: '' + value: + description: + - Tag value. + required: false + type: str + default: '' + state: + description: + - State of the user group. + - On C(present), it will create if user group does not exist or update the user group if the associated data is different. + - On C(absent) will remove a user group if it exists. + required: false + type: str + default: "present" + choices: [ "present", "absent" ] +notes: + - Only Zabbix >= 4.0 is supported. +extends_documentation_fragment: +- community.zabbix.zabbix +''' + +EXAMPLES = r''' +# Base create user group example +- name: Create user group + community.zabbix.zabbix_usergroup: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + name: ACME + state: present + +# Base create user group with disabled gui access +- name: Create user group with disabled gui access + community.zabbix.zabbix_usergroup: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + name: ACME + gui_access: disable + +# Base create user group with permissions +- name: Create user group with permissions + community.zabbix.zabbix_usergroup: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + name: ACME + rights: + - host_group: Webserver + permission: read-write + - host_group: Databaseserver + permission: read-only + state: present + +# Base create user group with tag permissions +- name: Create user group with tag permissions + community.zabbix.zabbix_usergroup: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + name: ACME + tag_filters: + - host_group: Webserver + tag: Application + value: Java + - host_group: Discovered hosts + tag: Service + value: JIRA + state: present + +# Base delete user groups example +- name: Delete user groups + community.zabbix.zabbix_usergroup: + server_url: "http://zabbix.example.com/zabbix/" + login_user: admin + login_password: secret + name: ACME + state: absent +''' + +RETURN = r''' +state: + description: User group state at the end of execution. + returned: on success + type: str + sample: 'present' +usergroup: + description: User group name. + returned: on success + type: str + sample: 'ACME' +usrgrpid: + description: User group id, if created, changed or deleted. + returned: on success + type: str + sample: '42' +msg: + description: The result of the operation + returned: always + type: str + sample: 'User group created: ACME, ID: 42' +''' + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +class Rights(ZabbixBase): + """ + Restructure the user defined rights to fit the Zabbix API requirements + """ + + def get_hostgroup_by_hostgroup_name(self, name): + """Get host group by host group name. + + Parameters: + name: Name of the host group. + + Returns: + host group matching host group name. + """ + try: + _hostgroup = self._zapi.hostgroup.get({ + 'output': 'extend', + 'filter': {'name': [name]} + }) + if len(_hostgroup) < 1: + self._module.fail_json(msg='Host group not found: %s' % name) + else: + return _hostgroup[0] + except Exception as e: + self._module.fail_json(msg='Failed to get host group "%s": %s' % (name, e)) + + def construct_the_data(self, _rights): + """Construct the user defined rights to fit the Zabbix API requirements + + Parameters: + _rights: rights to construct + + Returns: + dict: user defined rights + """ + if _rights is None: + return [] + constructed_data = [] + for right in _rights: + constructed_right = { + 'id': self.get_hostgroup_by_hostgroup_name(right.get('host_group'))['groupid'], + 'permission': zabbix_utils.helper_to_numeric_value([ + 'denied', + None, + 'read-only', + 'read-write'], right.get('permission') + ) + } + constructed_data.append(constructed_right) + return zabbix_utils.helper_cleanup_data(constructed_data) + + +class TagFilters(Rights): + """ + Restructure the user defined tag_filters to fit the Zabbix API requirements + """ + + def construct_the_data(self, _tag_filters): + """Construct the user defined tag filters to fit the Zabbix API requirements + + Parameters: + _tag_filters: tag filters to construct + + Returns: + dict: user defined tag filters + """ + if _tag_filters is None: + return [] + constructed_data = [] + for tag_filter in _tag_filters: + constructed_tag_filter = { + 'groupid': self.get_hostgroup_by_hostgroup_name(tag_filter.get('host_group'))['groupid'], + 'tag': tag_filter.get('tag'), + 'value': tag_filter.get('value') + } + constructed_data.append(constructed_tag_filter) + return zabbix_utils.helper_cleanup_data(constructed_data) + + +class UserGroup(ZabbixBase): + def _construct_parameters(self, **kwargs): + """Construct parameters of UserGroup object + + Parameters: + **kwargs: Arbitrary keyword parameters. + + Returns: + dict: dictionary of specified parameters + """ + _params = { + 'name': kwargs['name'], + 'gui_access': zabbix_utils.helper_to_numeric_value([ + 'default', + 'internal', + 'LDAP', + 'disable'], kwargs['gui_access'] + ), + 'debug_mode': zabbix_utils.helper_to_numeric_value([ + 'disabled', + 'enabled'], kwargs['debug_mode'] + ), + 'users_status': zabbix_utils.helper_to_numeric_value([ + 'enabled', + 'disabled'], kwargs['status'] + ), + 'rights': kwargs['rights'], + 'tag_filters': kwargs['tag_filters'] + } + return _params + + def check_if_usergroup_exists(self, name): + """Check if user group exists. + + Parameters: + name: Name of the user group. + + Returns: + The return value. True for success, False otherwise. + """ + try: + _usergroup = self._zapi.usergroup.get({ + 'output': 'extend', + 'filter': {'name': [name]} + }) + if len(_usergroup) > 0: + return _usergroup + except Exception as e: + self._module.fail_json(msg='Failed to check if user group "%s" exists: %s' % (name, e)) + + def get_usergroup_by_usergroup_name(self, name): + """Get user group by user group name. + + Parameters: + name: Name of the user group. + + Returns: + User group matching user group name. + """ + try: + _usergroup = self._zapi.usergroup.get({ + 'output': 'extend', + 'selectTagFilters': 'extend', + 'selectRights': 'extend', + 'filter': {'name': [name]} + }) + if len(_usergroup) < 1: + self._module.fail_json(msg='User group not found: %s' % name) + else: + return _usergroup[0] + except Exception as e: + self._module.fail_json(msg='Failed to get user group "%s": %s' % (name, e)) + + def check_difference(self, **kwargs): + """Check difference between user group and user specified parameters. + + Parameters: + **kwargs: Arbitrary keyword parameters. + + Returns: + dict: dictionary of differences + """ + existing_usergroup = zabbix_utils.helper_convert_unicode_to_str(self.get_usergroup_by_usergroup_name(kwargs['name'])) + parameters = zabbix_utils.helper_convert_unicode_to_str(self._construct_parameters(**kwargs)) + change_parameters = {} + _diff = zabbix_utils.helper_compare_dictionaries(parameters, existing_usergroup, change_parameters) + return _diff + + def update(self, **kwargs): + """Update user group. + + Parameters: + **kwargs: Arbitrary keyword parameters. + + Returns: + usergroup: updated user group + """ + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + return self._zapi.usergroup.update(kwargs) + except Exception as e: + self._module.fail_json(msg='Failed to update user group "%s": %s' % (kwargs['usrgrpid'], e)) + + def add(self, **kwargs): + """Add user group. + + Parameters: + **kwargs: Arbitrary keyword parameters. + + Returns: + usergroup: added user group + """ + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + parameters = self._construct_parameters(**kwargs) + usergroup = self._zapi.usergroup.create(parameters) + return usergroup['usrgrpids'][0] + except Exception as e: + self._module.fail_json(msg='Failed to create user group "%s": %s' % (kwargs['name'], e)) + + def delete(self, usrgrpid): + """Delete user group. + + Parameters: + usrgrpid: User group id. + + Returns: + usergroup: deleted user group + """ + try: + if self._module.check_mode: + self._module.exit_json(changed=True) + else: + return self._zapi.usergroup.delete([usrgrpid]) + except Exception as e: + self._module.fail_json(msg='Failed to delete user group "%s": %s' % (usrgrpid, e)) + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update( + name=dict(type='str', required=True, aliases=['user_group']), + gui_access=dict(type='str', required=False, default='default', choices=['default', 'internal', 'LDAP', 'disable']), + debug_mode=dict(type='str', required=False, default='disabled', choices=['disabled', 'enabled']), + status=dict(type='str', required=False, default='enabled', choices=['enabled', 'disabled']), + rights=dict(type='list', elements='dict', required=False, options=dict( + host_group=dict(type='str', required=True), + permission=dict(type='str', required=True, choices=['denied', 'read-only', 'read-write']) + )), + tag_filters=dict(type='list', elements='dict', required=False, options=dict( + host_group=dict(type='str', required=True), + tag=dict(type='str', default=''), + value=dict(type='str', default='') + )), + state=dict(type='str', default='present', choices=['present', 'absent']) + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + name = module.params['name'] + gui_access = module.params['gui_access'] + debug_mode = module.params['debug_mode'] + status = module.params['status'] + rights = module.params['rights'] + tag_filters = module.params['tag_filters'] + state = module.params['state'] + + userGroup = UserGroup(module) + # reuse zabbix-api login + zbx = userGroup._zapi + rgts = Rights(module, zbx) + tgflts = TagFilters(module, zbx) + + usergroup_exists = userGroup.check_if_usergroup_exists(name) + + if usergroup_exists: + usrgrpid = userGroup.get_usergroup_by_usergroup_name(name)['usrgrpid'] + if state == 'absent': + userGroup.delete(usrgrpid) + module.exit_json(changed=True, state=state, usergroup=name, usrgrpid=usrgrpid, msg='User group deleted: %s, ID: %s' % (name, usrgrpid)) + else: + difference = userGroup.check_difference( + usrgrpid=usrgrpid, + name=name, + gui_access=gui_access, + debug_mode=debug_mode, + status=status, + rights=rgts.construct_the_data(rights), + tag_filters=tgflts.construct_the_data(tag_filters) + ) + if difference == {}: + module.exit_json(changed=False, state=state, usergroup=name, usrgrpid=usrgrpid, msg='User group is up to date: %s' % name) + else: + userGroup.update( + usrgrpid=usrgrpid, + **difference + ) + module.exit_json(changed=True, state=state, usergroup=name, usrgrpid=usrgrpid, msg='User group updated: %s, ID: %s' % (name, usrgrpid)) + else: + if state == 'absent': + module.exit_json(changed=False, state=state, usergroup=name, msg='User group %s does not exists, nothing to delete' % name) + else: + usrgrpid = userGroup.add( + name=name, + gui_access=gui_access, + debug_mode=debug_mode, + status=status, + rights=rgts.construct_the_data(rights), + tag_filters=tgflts.construct_the_data(tag_filters) + ) + module.exit_json(changed=True, state=state, usergroup=name, usrgrpid=usrgrpid, msg='User group created: %s, ID: %s' % (name, usrgrpid)) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_valuemap.py b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_valuemap.py new file mode 100644 index 00000000..f0e66ea9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/plugins/modules/zabbix_valuemap.py @@ -0,0 +1,295 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2019, Ruben Tsirunyan +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: zabbix_valuemap +short_description: Create/update/delete Zabbix value maps +description: + - This module allows you to create, modify and delete Zabbix value maps. +author: + - "Ruben Tsirunyan (@rubentsirunyan)" +requirements: + - "zabbix-api >= 0.5.4" +options: + name: + type: 'str' + description: + - Name of the value map. + required: true + state: + type: 'str' + description: + - State of the value map. + - On C(present), it will create a value map if it does not exist or update the value map if the associated data is different. + - On C(absent), it will remove the value map if it exists. + choices: ['present', 'absent'] + default: 'present' + mappings: + type: 'list' + elements: dict + description: + - List of value mappings for the value map. + - Required when I(state=present). + suboptions: + value: + type: 'str' + description: Original value. + required: true + map_to: + type: 'str' + description: Value to which the original value is mapped to. + required: true + +extends_documentation_fragment: +- community.zabbix.zabbix + +''' + +RETURN = r''' +''' + +EXAMPLES = r''' +- name: Create a value map + local_action: + module: community.zabbix.zabbix_valuemap + server_url: http://zabbix.example.com + login_user: username + login_password: password + name: Numbers + mappings: + - value: 1 + map_to: one + - value: 2 + map_to: two + state: present +''' + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase +import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils + + +def construct_parameters(**kwargs): + """Translates data to a format suitable for Zabbix API + + Args: + **kwargs: Arguments passed to the module. + + Returns: + A dictionary of arguments in a format that is understandable by Zabbix API. + """ + if kwargs['mappings'] is None: + return dict( + name=kwargs['name'] + ) + + return dict( + name=kwargs['name'], + mappings=[ + dict( + value=mapping['value'], + newvalue=mapping['map_to'] + ) for mapping in kwargs['mappings'] + ] + ) + + +def diff(existing, new): + """Constructs the diff for Ansible's --diff option. + + Args: + existing (dict): Existing valuemap data. + new (dict): New valuemap data. + + Returns: + A dictionary like {'before': existing, 'after': new} + with filtered empty values. + """ + before = {} + after = {} + for key in new: + before[key] = existing[key] + if new[key] is None: + after[key] = '' + else: + after[key] = new[key] + + return {'before': before, 'after': after} + + +def get_update_params(existing_valuemap, **kwargs): + """Filters only the parameters that are different and need to be updated. + + Args: + existing_valuemap (dict): Existing valuemap. + **kwargs: Parameters for the new valuemap. + + Returns: + A tuple where the first element is a dictionary of parameters + that need to be updated and the second one is a dictionary + returned by diff() function with + existing valuemap data and new params passed to it. + """ + + params_to_update = {} + if sorted(existing_valuemap['mappings'], key=lambda k: k['value']) != sorted(kwargs['mappings'], key=lambda k: k['value']): + params_to_update['mappings'] = kwargs['mappings'] + return params_to_update, diff(existing_valuemap, kwargs) + + +class ValuemapModule(ZabbixBase): + def check_if_valuemap_exists(self, name): + """Checks if value map exists. + + Args: + name: Zabbix valuemap name + + Returns: + tuple: First element is True if valuemap exists and False otherwise. + Second element is a dictionary of valuemap object if it exists. + """ + try: + valuemap_list = self._zapi.valuemap.get({ + 'output': 'extend', + 'selectMappings': 'extend', + 'filter': {'name': [name]} + }) + if len(valuemap_list) < 1: + return False, None + else: + return True, valuemap_list[0] + except Exception as e: + self._module.fail_json(msg="Failed to get ID of the valuemap '{name}': {e}".format(name=name, e=e)) + + def delete(self, valuemap_id): + try: + return self._zapi.valuemap.delete([valuemap_id]) + except Exception as e: + self._module.fail_json(msg="Failed to delete valuemap '{_id}': {e}".format(_id=valuemap_id, e=e)) + + def update(self, **kwargs): + try: + self._zapi.valuemap.update(kwargs) + except Exception as e: + self._module.fail_json(msg="Failed to update valuemap '{_id}': {e}".format(_id=kwargs['valuemapid'], e=e)) + + def create(self, **kwargs): + try: + self._zapi.valuemap.create(kwargs) + except Exception as e: + self._module.fail_json(msg="Failed to create valuemap '{name}': {e}".format(name=kwargs['description'], e=e)) + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + name=dict(type='str', required=True), + state=dict(type='str', default='present', choices=['present', 'absent']), + mappings=dict( + type='list', + elements='dict', + options=dict( + value=dict(type='str', required=True), + map_to=dict(type='str', required=True) + ) + ) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'present', ['mappings']], + ] + ) + + vm = ValuemapModule(module) + + name = module.params['name'] + state = module.params['state'] + mappings = module.params['mappings'] + + valuemap_exists, valuemap_object = vm.check_if_valuemap_exists(name) + + parameters = construct_parameters( + name=name, + mappings=mappings + ) + + if valuemap_exists: + valuemap_id = valuemap_object['valuemapid'] + if state == 'absent': + if module.check_mode: + module.exit_json( + changed=True, + msg="Value map would have been deleted. Name: {name}, ID: {_id}".format( + name=name, + _id=valuemap_id + ) + ) + valuemap_id = vm.delete(valuemap_id) + module.exit_json( + changed=True, + msg="Value map deleted. Name: {name}, ID: {_id}".format( + name=name, + _id=valuemap_id + ) + ) + else: + params_to_update, diff = get_update_params(valuemap_object, **parameters) + if params_to_update == {}: + module.exit_json( + changed=False, + msg="Value map is up to date: {name}".format(name=name) + ) + else: + if module.check_mode: + module.exit_json( + changed=True, + diff=diff, + msg="Value map would have been updated. Name: {name}, ID: {_id}".format( + name=name, + _id=valuemap_id + ) + ) + valuemap_id = vm.update(valuemapid=valuemap_id, **params_to_update) + module.exit_json( + changed=True, + diff=diff, + msg="Value map updated. Name: {name}, ID: {_id}".format( + name=name, + _id=valuemap_id + ) + ) + else: + if state == "absent": + module.exit_json(changed=False) + else: + if module.check_mode: + module.exit_json( + changed=True, + msg="Value map would have been created. Name: {name}, ID: {_id}".format( + name=name, + _id=valuemap_id + ) + ) + valuemap_id = vm.create(**parameters) + module.exit_json( + changed=True, + msg="Value map created: {name}, ID: {_id}".format( + name=name, + _id=valuemap_id + ) + ) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/README.md b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/README.md new file mode 100644 index 00000000..f13b7e4c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/README.md @@ -0,0 +1,509 @@ +# community.zabbix.zabbix_agent role + +![Zabbix Agent](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_agent/badge.svg) + +**Table of Contents** + +- [Requirements](#requirements) + * [Operating systems](#operating-systems) + + [Windows](#windows) + * [Local system access](#local-system-access) + * [Zabbix Versions](#zabbix-versions) +- [Getting started](#getting-started) + * [Minimal Configuration](#minimal-configuration) + * [Issues](#issues) +- [Role Variables](#role-variables) + * [Main variables](#main-variables) + + [Overall Zabbix](#overall-zabbix) + + [SElinux](#selinux) + + [Zabbix Agent](#zabbix-agent) + + [Zabbix Agent vs Zabbix Agent 2 configuration](#zabbix-agent-vs-zabbix-agent-2-configuration) + * [TLS Specific configuration](#tls-specific-configuration) + * [Zabbix API variables](#zabbix-api-variables) + * [Windows Variables](#windows-variables) + * [macOS Variables](#macos-variables) + * [Docker Variables](#docker-variables) + * [FirewallD/Iptables](#firewalld-iptables) + * [IPMI variables](#ipmi-variables) + * [proxy](#proxy) +- [Dependencies](#dependencies) +- [Example Playbook](#example-playbook) + * [zabbix_agent2_plugins](#zabbix-agent2-plugins) + * [agent_interfaces](#agent-interfaces) + * [Other interfaces](#other-interfaces) + * [Vars in role configuration](#vars-in-role-configuration) + * [Combination of group_vars and playbook](#combination-of-group-vars-and-playbook) + * [Example for TLS PSK encrypted agent communication](#example-for-tls-psk-encrypted-agent-communication) +- [Molecule](#molecule) +- [Deploying Userparameters](#deploying-userparameters) +- [License](#license) +- [Author Information](#author-information) + +# Requirements +## Operating systems +This role will work on the following operating systems: + + * Red Hat + * Fedora + * Debian + * Ubuntu + * opensuse + * Windows (Best effort) + * macOS + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +### Windows + +When you are a Windows user and using Ansible 2.10 or newer, then there is a dependency on a collection named `ansible.windows`. This collection is needed as the `win_service` is part of this collection and not standard in Ansible anymmore. Installing the collection: + +```sh +ansible-galaxy collection install ansible.windows +``` + +For more information, see: https://github.com/ansible-collections/community.zabbix/issues/236 + +## Local system access + +To successfully complete the install the role requires `python-netaddr` on the controller to be able to manage IP addresses. This requires that the library is available on your local machine (or that `pip` is installed to be able to run). This will likely mean that running the role will require `sudo` access to your local machine and therefore you may need the `-K` flag to be able to enter your local machine password if you are not running under root. + +## Zabbix Versions + +See the following list of supported Operating systems with the Zabbix releases: + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | V | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +# Getting started + +## Minimal Configuration + +In order to get the Zabbix Agent running, you'll have to define the following properties before executing the role: + +* `zabbix_agent_version` +* `zabbix_agent_server` +* `zabbix_agent_serveractive` (When using active checks) + +The `zabbix_agent_version` is optional. The latest available major.minor version of Zabbix will be installed on the host(s). If you want to use an older version, please specify this in the major.minor format. Example: `zabbix_agent_version: 4.0`, `zabbix_agent_version: 3.4` or `zabbix_agent_version: 2.2`. + +The `zabbix_agent_server` (and `zabbix_agent_serveractive`) should contain the ip or fqdn of the host running the Zabbix Server. + +## Issues + +Due to issue discussed on [#291](https://github.com/dj-wasabi/ansible-zabbix-agent/issues/291), the Ansible Version 2.9.{0,1,2} isn't working correctly on Windows related targets. + +# Role Variables + +## Main variables + +The following is an overview of all available configuration default for this role. + +### Overall Zabbix + +* `zabbix_agent_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. + +### SElinux + +* `zabbix_selinux`: Default: `False`. Enables an SELinux policy so that the server will run. + +### Zabbix Agent + +* `zabbix_agent_ip`: The IP address of the host. When not provided, it will be determined via the `ansible_default_ipv4` fact. +* `zabbix_agent2`: Default: `False`. When you want to install the `Zabbix Agent2` instead of the "old" `Zabbix Agent`. +* `zabbix_agent_server`: The ip address for the zabbix-server or zabbix-proxy. +* `zabbix_agent_serveractive`: The ip address for the zabbix-server or zabbix-proxy for active checks. +* `zabbix_agent_listeninterface`: Interface zabbix-agent listens on. Leave blank for all. +* `zabbix_agent_package_remove`: If `zabbix_agent2: True` and you want to remove the old installation. Default: `False`. +* `zabbix_agent_package`: The name of the zabbix-agent package. Default: `zabbix-agent`. In case for EPEL, it is automatically renamed. +* `zabbix_sender_package`: The name of the zabbix-sender package. Default: `zabbix-sender`. In case for EPEL, it is automatically renamed. +* `zabbix_get_package`: The name of the zabbix-get package. Default: `zabbix-get`. In case for EPEL, it is automatically renamed. +* `zabbix_agent_package_state`: If Zabbix-agent needs to be `present` or `latest`. +* `zabbix_agent_interfaces`: A list that configured the interfaces you can use when configuring via API. +* `zabbix_agent_install_agent_only`: Only install the Zabbix Agent and not the `zabbix-sender` and `zabbix-get` packages. Default: `False` +* `zabbix_agent_userparameters`: Default: `[]]`. List of userparameter names and scripts (if any). Detailed description is given in the [Deploying Userparameters](#deploying-userparameters) section. + * `name`: Userparameter name (should be the same with userparameter template file name) + * `scripts_dir`: Directory name of the custom scripts needed for userparameters +* `zabbix_agent_userparameters_templates_src`: indicates the relative path (from `templates/`) where userparameter templates are searched +* `zabbix_agent_userparameters_scripts_src`: indicates the relative path (from `files/`) where userparameter scripts are searched +* `zabbix_agent_runas_user`: Drop privileges to a specific, existing user on the system. Only has effect if run as 'root' and AllowRoot is disabled. +* `zabbix_agent_become_on_localhost`: Default: `True`. Set to `False` if you don't need to elevate privileges on localhost to install packages locally with pip. +* `zabbix_install_pip_packages`: Default: `True`. Set to `False` if you don't want to install the required pip packages. Useful when you control your environment completely. +* `zabbix_agent_apt_priority`: Add a weight (`Pin-Priority`) for the APT repository. +* `zabbix_agent_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. +* `zabbix_agent_dont_detect_ip`: Default `false`. When set to `true`, it won't detect available ip addresses on the host and no need for the Python module `netaddr` to be installed. + +### Zabbix Agent vs Zabbix Agent 2 configuration + +The following provides an overview of all the properties that can be set in the Zabbix Agent configuration file. When `(2)` is used in the name of the property, like `zabbix_agent(2)_pidfile`, it will show that you can configure `zabbix_agent_pidfile` for the Zabbix Agent configuration file and `zabbix_agent2_pidfile` for the Zabbix Agent 2 configuration file. + +Otherwise it just for the Zabbix Agent or for the Zabbix Agent 2. + +* `zabbix_agent(2)_pidfile`: name of pid file. +* `zabbix_agent(2)_logfile`: name of log file. +* `zabbix_agent(2)_logfilesize`: maximum size of log file in mb. +* `zabbix_agent2_logtype`: Specifies where log messages are written to +* `zabbix_agent(2)_debuglevel`: specifies debug level +* `zabbix_agent(2)_sourceip`: source ip address for outgoing connections. +* `zabbix_agent_enableremotecommands`: whether remote commands from zabbix server are allowed. +* `zabbix_agent_logremotecommands`: enable logging of executed shell commands as warnings. +* `zabbix_agent(2)_listenport`: agent will listen on this port for connections from the server. +* `zabbix_agent2_statusport`: Agent will listen on this port for HTTP status requests. +* `zabbix_agent_listenip`: list of comma delimited ip addresses that the agent should listen on. +* `zabbix_agent_startagents`: number of pre-forked instances of zabbix_agentd that process passive checks. +* `zabbix_agent(2)_hostname`: unique, case sensitive hostname. +* `zabbix_agent(2)_hostnameitem`: item used for generating hostname if it is undefined. +* `zabbix_agent(2)_hostmetadata`: optional parameter that defines host metadata. +* `zabbix_agent(2)_hostmetadataitem`: optional parameter that defines an item used for getting the metadata. +* `zabbix_agent(2)_refreshactivechecks`: how often list of active checks is refreshed, in seconds. +* `zabbix_agent(2)_buffersend`: do not keep data longer than n seconds in buffer. +* `zabbix_agent(2)_buffersize`: maximum number of values in a memory buffer. the agent will send all collected data to zabbix server or proxy if the buffer is full. +* `zabbix_agent2_enablepersistentbuffer`: 0 - disabled, in-memory buffer is used (default); 1 - use persistent buffer +* `zabbix_agent2_persistentbufferperiod`: Zabbix Agent2 will keep data for this time period in case of no connectivity with Zabbix server or proxy. Older data will be lost. Log data will be preserved. +* `zabbix_agent2_persistentbufferfile`: Zabbix Agent2 will keep SQLite database in this file * n is valid if `EnablePersistentBuffer=1` +* `zabbix_agent_maxlinespersecond`: maximum number of new lines the agent will send per second to zabbix server or proxy processing 'log' and 'logrt' active checks. +* `zabbix_agent_allowroot`: allow the agent to run as 'root'. if disabled and the agent is started by 'root', the agent will try to switch to user 'zabbix' instead. has no effect if started under a regular user. +* `zabbix_agent(2)_zabbix_alias`: sets an alias for parameter. it can be useful to substitute long and complex parameter name with a smaller and simpler one. +* `zabbix_agent(2)_timeout`: spend no more than timeout seconds on processing +* `zabbix_agent(2)_include`: you may include individual files or all files in a directory in the configuration file. +* `zabbix_agent(2)_include_mode`: The mode for the directory mentioned above. +* `zabbix_agent(2)_unsafeuserparameters`: allow all characters to be passed in arguments to user-defined parameters. +* `zabbix_agent_loadmodulepath`: Full path to location of agent modules. +* `zabbix_agent_loadmodule`: Module to load at agent startup. Modules are used to extend functionality of the agent. +* `zabbix_agent2_controlsocket`: The control socket, used to send runtime commands with '-R' option. +* `zabbix_agent_allowroot`: Allow the agent to run as 'root'. 0 - do not allow, 1 - allow +* `zabbix_agent2_plugins`: A list containing plugin configuration. + +## TLS Specific configuration + +These variables are specific for Zabbix 3.0 and higher. When `(2)` is used in the name of the property, like `zabbix_agent(2)_tlsconnect`, it will show that you can configure `zabbix_agent_tlsconnect` for the Zabbix Agent configuration file and `zabbix_agent2_tlsconnect` for the Zabbix Agent 2 configuration file. + +* `zabbix_agent(2)_tlsconnect`: How the agent should connect to server or proxy. Used for active checks. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_agent(2)_tlsaccept`: What incoming connections to accept. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_agent(2)_tlscafile`: Full pathname of a file containing the top-level CA(s) certificates for peer certificate verification. +* `zabbix_agent(2)_tlscrlfile`: Full pathname of a file containing revoked certificates. +* `zabbix_agent(2)_tlsservercertissuer`: Allowed server certificate issuer. +* `zabbix_agent(2)_tlsservercertsubject`: Allowed server certificate subject. +* `zabbix_agent(2)_tlscertfile`: Full pathname of a file containing the agent certificate or certificate chain. +* `zabbix_agent(2)_tlskeyfile`: Full pathname of a file containing the agent private key. +* `zabbix_agent(2)_tlspskidentity`: Unique, case sensitive string used to identify the pre-shared key. +* `zabbix_agent(2)_tlspskidentity_file`: Full pathname of a file containing the pre-shared key identity. +* `zabbix_agent(2)_tlspskfile`: Full pathname of a file containing the pre-shared key. +* `zabbix_agent(2)_tlspsk_secret`: The pre-shared secret key that should be placed in the file configured with `agent_tlspskfile`. +* `zabbix_agent(2)_tlspsk_auto`: Enables auto generation and storing of individual pre-shared keys and identities on clients. + +## Zabbix API variables + +These variables need to be overridden when you want to make use of the zabbix-api for automatically creating and or updating hosts. + +Host encryption configuration will be set to match agent configuration. + +When `zabbix_api_create_hostgroup` or `zabbix_api_create_hosts` is set to `True`, it will install on the host executing the Ansible playbook the `zabbix-api` python module. + +* `zabbix_url`: The url on which the Zabbix webpage is available. Example: http://zabbix.example.com +* `zabbix_api_http_user`: The http user to access zabbix url with Basic Auth +* `zabbix_api_http_password`: The http password to access zabbix url with Basic Auth +* `zabbix_api_create_hosts`: Default: `False`. When you want to enable the Zabbix API to create/delete the host. This has to be set to `True` if you want to make use of `zabbix_create_host`. +* `zabbix_api_create_hostgroup`: When you want to enable the Zabbix API to create/delete the hostgroups. This has to be set to `True` if you want to make use of `zabbix_create_hostgroup`.Default: `False` +* `zabbix_api_user`: Username of user which has API access. +* `zabbix_api_pass`: Password for the user which has API access. +* `zabbix_create_hostgroup`: present (Default) if the hostgroup needs to be created or absent if you want to delete it. This only works when `zabbix_api_create_hostgroup` is set to `True`. +* `zabbix_host_status`: enabled (Default) when host in monitored, disabled when host is disabled for monitoring. +* `zabbix_create_host`: present (Default) if the host needs to be created or absent is you want to delete it. This only works when `zabbix_api_create_hosts` is set to `True`. +* `zabbix_update_host`: yes (Default) if the host should be updated if already present. This only works when `zabbix_api_create_hosts` is set to `True`. +* `zabbix_useuip`: 1 if connection to zabbix-agent is made via ip, 0 for fqdn. +* `zabbix_host_groups`: A list of hostgroups which this host belongs to. +* `zabbix_link_templates`: A list of templates which needs to be link to this host. The templates should exist. +* `zabbix_macros`: A list with macro_key and macro_value for creating hostmacro's. +* `zabbix_inventory_mode`: Configure Zabbix inventory mode. Needed for building inventory data, manually when configuring a host or automatically by using some automatic population options. This has to be set to `automatic` if you want to make automatically building inventory data. +* `zabbix_visible_hostname` : Configure Zabbix visible name inside Zabbix web UI for the node. +* `zabbix_validate_certs` : yes (Default) if we need to validate tls certificates of the API. Use `no` in case self-signed certificates are used +* `zabbix_agent_description`: Description of the host in Zabbix. +* `zabbix_agent_inventory_zabbix`: Adds Facts for a zabbix inventory + +## Windows Variables + +**NOTE** + +_Supporting Windows is a best effort (I don't have the possibility to either test/verify changes on the various amount of available Windows instances). PRs specific to Windows will almost immediately be merged, unless someone is able to provide a Windows test mechanism via Travis for Pull Requests._ + +* `zabbix_version_long`: The long (major.minor.patch) version of the Zabbix Agent. This will be used to generate the `zabbix_win_download_link` link and for Zabbix Agent update if `zabbix_agent_package_state: latest`. +* `zabbix_win_download_link`: The download url to the `win.zip` file. +* `zabbix_win_install_dir`: The directory where Zabbix needs to be installed. +* `zabbix_agent_win_logfile`: The full path to the logfile for the Zabbix Agent. +* `zabbix_agent_win_include`: The directory in which the Zabbix specific configuration files are stored. +* `zabbix_agent_win_svc_recovery`: Enable Zabbix Agent service auto-recovery settings. + +## macOS Variables + +* `zabbix_version_long`: The long (major.minor.patch) version of the Zabbix Agent. This will be used to generate the `zabbix_mac_download_link` link. +* `zabbix_mac_download_link`: The download url to the `pkg` file. + +## Docker Variables + +When you don't want to install the Zabbix Agent on the host, but would like to run it in a container then these properties are useful. When `zabbix_agent_docker` is set to `True`, then a +Docker image will be downloaded and a Container will be started. No other installations will be done on the host, with the exception of the PSK file and the "Zabbix Include Directory". + +The following directories are mounted in the Container: + +``` + - /etc/zabbix/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d + - /:/hostfs:ro + - /etc:/hostfs/etc:ro + - /proc:/hostfs/proc:ro + - /sys:/hostfs/sys:ro + - /var/run:/var/run +``` + +Keep in mind that using the Zabbix Agent in a Container requires changes to the Zabbix Template for Linux as `/proc`, `/sys` and `/etc` are mounted in a directory `/hostfs`. + +* `zabbix_agent_docker`: Default: `False`. When set to `True`, it will install a Docker container on the target host instead of installation on the target. +* `zabbix_agent_docker_state`: Default: `started` +* `zabbix_agent_docker_name`: The name of the Container. Default: `zabbix-agent` +* `zabbix_agent_docker_image`: The name of the Docker image. Default: `zabbix/zabbix-agent` +* `zabbix_agent_docker_image_tag`: The tag of the Docker image. +* `zabbix_agent_docker_user_gid`: The group id of the zabbix user in the Container. +* `zabbix_agent_docker_user_uid`: The user id of the zabbix user in the Container. +* `zabbix_agent_docker_network_mode`: The name of the (Docker) network that should be used for the Container. Default `host`. +* `zabbix_agent_docker_restart_policy`: Default: `unless-stopped`. The restart policy of the Container. +* `zabbix_agent_docker_privileged`: When set to `True`, the container is running in privileged mode. +* `zabbix_agent_docker_ports`: A list with `:` values to open ports to the container. +* `zabbix_agent_docker_security_opts`: A list with available security options. +* `zabbix_agent_docker_volumes`: A list with all directories that needs to be available in the Container. +* `zabbix_agent_docker_env`: A dict with all environment variables that needs to be set for the Container. + +## FirewallD/Iptables + +* `zabbix_agent_firewall_enable`: If IPtables needs to be updated by opening an TCP port for port configured in `zabbix_agent_listenport`. +* `zabbix_agent_firewall_source`: When provided, IPtables will be configuring to only allow traffic from this IP address/range. +* `zabbix_agent_firewalld_enable`: If firewalld needs to be updated by opening an TCP port for port configured in `zabbix_agent_listenport` and `zabbix_agent_jmx_listenport` if defined. +* `zabbix_agent_firewalld_source`: When provided, firewalld will be configuring to only allow traffic for IP configured in `zabbix_agent_server`. +* `zabbix_agent_firewalld_zone`: When provided, the firewalld rule will be attached to this zone (only if zabbix_agent_firewalld_enable is set to true). The default behavior is to use the default zone define by the remote host firewalld configuration. +* `zabbix_agent_firewall_action`: Default: `insert`. When to `insert` the rule or to `append` to IPTables. +* `zabbix_agent_firewall_chain`: Default `INPUT`. Which `chain` to add the rule to IPTables. + + +## IPMI variables + +* `zabbix_agent_ipmi_authtype`: IPMI authentication algorithm. Possible values are 1 (callback), 2 (user), 3 (operator), 4 (admin), 5 (OEM), with 2 being the API default. +* `zabbix_agent_ipmi_password`: IPMI password. +* `zabbix_agent_ipmi_privilege`: IPMI privilege level. Possible values are 1 (callback), 2 (user), 3 (operator), 4 (admin), 5 (OEM), with 2 being the API default. +* `zabbix_agent_ipmi_username`: IPMI username. + +## proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +# Dependencies + +There are no dependencies on other roles. + +# Example Playbook + +## zabbix_agent2_plugins + +Specifically for the Zabbix Agent 2, a list of extra plugins can be configured. The following provides an overview of configuring the `SystemRun` plugin by setting the `LogRemoteCommands` to `0`: + +```yaml +zabbix_agent2_plugins: + - name: SystemRun + options: + - parameter: LogRemoteCommands + value: 0 +``` + +In the `zabbix_agent2.conf` an entry will be created with the following content: + +``` +Plugins.SystemRun.LogRemoteCommands=0 +``` + +## agent_interfaces + +This will configure the Zabbix Agent interface on the host. +```yaml +zabbix_agent_interfaces: + - type: 1 + main: 1 + useip: "{{ zabbix_useuip }}" + ip: "{{ zabbix_agent_ip }}" + dns: "{{ ansible_fqdn }}" + port: "{{ zabbix_agent_listenport }}" +``` + +## Other interfaces + +You can also configure the `zabbix_agent_interfaces` to add/configure snmp, jmx and ipmi interfaces. + +You'll have to use one of the following type numbers when configuring it: + +| Type Interface | Nr | +|-----------------|-------| +| Zabbix Agent | 1 | +| snmp | 2 | +| ipmi | 3 | +| jmx | 4 | + +Configuring a snmp interface will look like this: + +``` +zabbix_agent_interfaces: + - type: 2 + main: 1 + useip: "{{ zabbix_useuip }}" + ip: "{{ agent_ip }}" + dns: "{{ ansible_fqdn }}" + port: "{{ agent_listenport }}" +``` + +## Vars in role configuration +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + +```yaml + - hosts: all + roles: + - role: community.zabbix.zabbix_agent + zabbix_agent_server: 192.168.33.30 + zabbix_agent_serveractive: 192.168.33.30 + zabbix_url: http://zabbix.example.com + zabbix_api_use: true # use zabbix_api_create_hosts and/or zabbix_api_create_hostgroup from 0.8.0 + zabbix_api_user: Admin + zabbix_api_pass: zabbix + zabbix_create_host: present + zabbix_host_groups: + - Linux Servers + zabbix_link_templates: + - Template OS Linux + - Apache APP Template + zabbix_macros: + - macro_key: apache_type + macro_value: reverse_proxy +``` + +## Combination of group_vars and playbook +You can also use the group_vars or the host_vars files for setting the variables needed for this role. File you should change: `group_vars/all` or `host_vars/` (Where is the hostname of the machine running Zabbix Server) + +```yaml + zabbix_agent_server: 192.168.33.30 + zabbix_agent_serveractive: 192.168.33.30 + zabbix_url: http://zabbix.example.com + zabbix_api_use: true # use zabbix_api_create_hosts and/or zabbix_api_create_hostgroup from 0.8.0 + zabbix_api_user: Admin + zabbix_api_pass: zabbix + zabbix_create_host: present + zabbix_host_groups: + - Linux Servers + zabbix_link_templates: + - Template OS Linux + - Apache APP Template + zabbix_macros: + - macro_key: apache_type + macro_value: reverse_proxy +``` + +and in the playbook only specifying: + +```yaml + - hosts: all + roles: + - role: community.zabbix.zabbix_agent +``` + +## Example for TLS PSK encrypted agent communication + +Variables e.g. in the playbook or in `host_vars/myhost`: + +```yaml + zabbix_agent_tlsaccept: psk + zabbix_agent_tlsconnect: psk + zabbix_agent_tlspskidentity: "myhost PSK" + zabbix_agent_tlspsk_secret: b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d + zabbix_agent_tlspskfile: /etc/zabbix/zabbix_agent_pskfile.psk +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully. + +# Deploying Userparameters + +The following steps are required to install custom userparameters and/or scripts: + +* Put the desired userparameter file in the `templates/userparameters` directory and name it as `.j2`. For example: `templates/userparameters/mysql.j2`. You can change the default directory to a custom one modifying `zabbix_agent_userparameters_templates_src` variable. +* Put the scripts directory (if any) in the `files/scripts` directory. For example: `files/scripts/mysql`. You can change the default directory to a custom one modifying `zabbix_agent_userparameters_scripts_src` variable. +* Add `zabbix_agent_userparameters` variable to the playbook as a list of dictionaries and define userparameter name and scripts directory name (if there are no scripts just no not specify the `scripts_dir` variable). + +Example: + +```yaml +- hosts: mysql_servers + tasks: + - include_role: + name: community.zabbix.zabbix_agent + vars: + zabbix_agent_server: zabbix.mydomain.com + zabbix_agent_userparameters: + - name: mysql + scripts_dir: mysql + - name: galera + +``` + +Example of the "templates/userparameters/mysql.j2" file: + +``` +UserParameter=mysql.ping_to,mysqladmin -uroot ping | grep -c alive +``` + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/defaults/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/defaults/main.yml new file mode 100644 index 00000000..5aaef8e6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/defaults/main.yml @@ -0,0 +1,267 @@ +--- +# defaults file for zabbix-agent + +zabbix_agent2: False +zabbix_agent_version: 5.2 +zabbix_version: "{{ zabbix_agent_version }}" +zabbix_version_patch: 0 +zabbix_repo: zabbix +zabbix_agent_package_remove: False +zabbix_agent_package: zabbix-agent +zabbix_sender_package: zabbix-sender +zabbix_get_package: zabbix-get +zabbix_agent_package_state: present +zabbix_agent_server: +zabbix_agent_serveractive: +zabbix_selinux: False +zabbix_agent_src_reinstall: True +zabbix_agent_apt_priority: +zabbix_agent_conf_mode: "0644" +zabbix_agent_dont_detect_ip: False + +# Selinux related vars +selinux_allow_zabbix_run_sudo: False + +zabbix_agent_install_agent_only: False +zabbix_agent_packages: + - "{{ zabbix_agent_package }}" + - "{{ zabbix_sender_package }}" + - "{{ zabbix_get_package }}" + +# Zabbix role related vars +zabbix_install_pip_packages: true +zabbix_apt_force_apt_get: yes +zabbix_apt_install_recommends: no + +# Override Ansible specific facts +zabbix_agent_distribution_major_version: "{{ ansible_distribution_major_version }}" +zabbix_agent_distribution_release: "{{ ansible_distribution_release }}" +zabbix_agent_os_family: "{{ ansible_os_family }}" +zabbix_repo_yum_schema: https +zabbix_repo_yum_disabled: "*" +zabbix_repo_yum_enabled: [] +zabbix_repo_yum: + - name: zabbix + description: Zabbix Official Repository - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix/{{ zabbix_version }}/rhel/{{ zabbix_agent_distribution_major_version }}/$basearch/" + mode: '0644' + gpgcheck: 0 + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + - name: zabbix-non-supported + description: Zabbix Official Repository non-supported - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/non-supported/rhel/{{ zabbix_agent_distribution_major_version }}/$basearch/" + mode: '0644' + gpgcheck: 0 + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + +# Zabbix API stuff +zabbix_agent_server_url: "http://zabbix.dj-wasabi.local" +zabbix_url: "{{ zabbix_agent_server_url }}" +# zabbix_api_http_user: admin +# zabbix_api_http_password: admin +zabbix_api_user: Admin +zabbix_api_pass: zabbix +zabbix_api_create_hostgroup: False +zabbix_api_create_hosts: False +zabbix_create_hostgroup: present # or absent +zabbix_create_host: present # or absent +zabbix_update_host: yes +zabbix_host_status: enabled # or disabled +zabbix_proxy: null +zabbix_inventory_mode: disabled +zabbix_useuip: 1 +zabbix_host_groups: + - Linux servers +zabbix_link_templates: + - Template OS Linux by Zabbix agent + +zabbix_agent_interfaces: + - type: 1 + main: 1 + useip: "{{ zabbix_useuip }}" + ip: "{{ zabbix_agent_ip }}" + dns: "{{ ansible_fqdn }}" + port: "{{ zabbix_agent_listenport }}" + +zabbix_agent_firewall_enable: False +zabbix_agent_firewalld_enable: False +zabbix_agent_firewalld_source: "{{ zabbix_agent_server }}" +zabbix_agent_firewall_action: insert +zabbix_agent_firewall_chain: INPUT + +# By default, a null zone will trigger the use of the default zone on the remote host +zabbix_agent_firewalld_zone: +# Zabbix configuration variables +zabbix_agent_pidfile: /var/run/zabbix/zabbix_agentd.pid +zabbix_agent_logfile: /var/log/zabbix/zabbix_agentd.log +zabbix_agent_logfilesize: 100 +zabbix_agent_debuglevel: 3 +zabbix_agent_sourceip: +zabbix_agent_enableremotecommands: 0 +zabbix_agent_logremotecommands: 0 +zabbix_agent_listenport: 10050 +zabbix_agent_jmx_listenport: +zabbix_agent_listeninterface: +zabbix_agent_listenip: +zabbix_agent_startagents: 3 +zabbix_agent_hostname: "{{ inventory_hostname }}" +zabbix_agent_hostnameitem: +zabbix_agent_hostmetadata: +zabbix_agent_hostmetadataitem: +zabbix_agent_refreshactivechecks: 120 +zabbix_agent_buffersend: 5 +zabbix_agent_buffersize: 100 +zabbix_agent_maxlinespersecond: 100 +zabbix_agent_allowroot: 0 +zabbix_agent_zabbix_alias: +zabbix_agent_timeout: 3 +zabbix_agent_include: /etc/zabbix/zabbix_agentd.d +zabbix_agent_include_mode: '0750' +zabbix_agent_unsafeuserparameters: 0 +zabbix_agent_userparameters: [] +zabbix_agent_userparameters_templates_src: "userparameters" +zabbix_agent_userparameters_scripts_src: "scripts" +zabbix_agent_custom_scripts: false +zabbix_agent_loadmodulepath: ${libdir}/modules +zabbix_agent_loadmodule: +zabbix_agent_become_on_localhost: True +zabbix_agent_description: +zabbix_agent_inventory_zabbix: {} + +# TLS settings +zabbix_agent_tlsconnect: +zabbix_agent_tlsaccept: +zabbix_agent_tlscafile: +zabbix_agent_tlscrlfile: +zabbix_agent_tlsservercertissuer: +zabbix_agent_tlsservercertsubject: +zabbix_agent_tlscertfile: +zabbix_agent_tlskeyfile: +zabbix_agent_tlspskidentity: +zabbix_agent_tlspsk_auto: False + +zabbix_agent_tls_config: + unencrypted: '1' + psk: '2' + cert: '4' + +# IPMI settings +zabbix_agent_ipmi_authtype: 2 +zabbix_agent_ipmi_password: +zabbix_agent_ipmi_privilege: 2 +zabbix_agent_ipmi_username: + +# Zabbix Agent2 +zabbix_agent2_pidfile: /var/run/zabbix/zabbix_agent2.pid +zabbix_agent2_logfile: /var/log/zabbix/zabbix_agent2.log +zabbix_agent2_logtype: file +zabbix_agent2_statusport: 9999 +zabbix_agent2_include: /etc/zabbix/zabbix_agent2.d +zabbix_agent2_logfilesize: 100 +zabbix_agent2_debuglevel: 3 +zabbix_agent2_sourceip: +zabbix_agent2_listenport: 10050 +zabbix_agent2_listenip: +zabbix_agent2_hostname: "{{ inventory_hostname }}" +zabbix_agent2_hostnameitem: +zabbix_agent2_hostmetadata: +zabbix_agent2_hostmetadataitem: +zabbix_agent2_hostinterface: +zabbix_agent2_hostinterfaceitem: +zabbix_agent2_enablepersistentbuffer: 0 +zabbix_agent2_persistentbufferperiod: 1h +zabbix_agent2_persistentbufferfile: +zabbix_agent2_refreshactivechecks: 120 +zabbix_agent2_buffersend: 5 +zabbix_agent2_buffersize: 100 +zabbix_agent2_zabbix_alias: +zabbix_agent2_timeout: 3 +zabbix_agent2_include_mode: '0750' +zabbix_agent2_unsafeuserparameters: 0 +zabbix_agent2_controlsocket: /tmp/agent.sock +zabbix_agent2_plugins: [] + +# Zabbix Agent2 TLS settings +zabbix_agent2_tlsconnect: +zabbix_agent2_tlsaccept: +zabbix_agent2_tlscafile: +zabbix_agent2_tlscrlfile: +zabbix_agent2_tlsservercertissuer: +zabbix_agent2_tlsservercertsubject: +zabbix_agent2_tlscertfile: +zabbix_agent2_tlskeyfile: +zabbix_agent2_tlspskidentity: +zabbix_agent2_tlspsk_auto: False + +# Windows/macOS Related +zabbix_version_long: 4.4.4 + +# Windows Related +zabbix_win_package: zabbix_agent-{{ zabbix_version_long }}-windows-amd64-openssl.zip +zabbix_win_download_url: https://cdn.zabbix.com/zabbix/binaries/stable +zabbix_win_download_link: "{{ zabbix_win_download_url }}/{{ zabbix_agent_version }}/{{ zabbix_version_long }}/{{ zabbix_win_package }}" +zabbix_win_install_dir: 'C:\Zabbix' +zabbix_agent_win_logfile: 'C:\Zabbix\zabbix_agentd.log' +zabbix_agent_win_include: 'C:\Zabbix\zabbix_agent.d\' +zabbix_agent_win_svc_recovery: True + +# macOS Related +zabbix_mac_package: zabbix_agent-{{ zabbix_version_long }}-macos-amd64-openssl.pkg +zabbix_mac_download_url: https://www.zabbix.com/downloads +zabbix_mac_download_link: "{{ zabbix_mac_download_url }}/{{ zabbix_version_long }}/{{ zabbix_mac_package }}" + +# Zabbix Agent Docker facts +zabbix_agent_docker: False +zabbix_agent_docker_state: started +zabbix_agent_docker_name: zabbix-agent +zabbix_agent_docker_image: "zabbix/zabbix-agent" +zabbix_agent_docker_image_tag: "ubuntu-{{ zabbix_version }}.{{ zabbix_version_patch }}" +zabbix_agent_docker_user_gid: 101 +zabbix_agent_docker_user_uid: 101 +zabbix_agent_docker_network_mode: host +zabbix_agent_docker_restart_policy: unless-stopped +zabbix_agent_docker_privileged: False +zabbix_agent_docker_ports: + - 10050:10050 +zabbix_agent_docker_security_opts: + - apparmor:unconfined +zabbix_agent_docker_volumes: + - /etc/zabbix/zabbix_agentd.d:{{ zabbix_agent_include }} + - /:/hostfs:ro + - /etc:/hostfs/etc:ro + - /proc:/hostfs/proc:ro + - /sys:/hostfs/sys:ro + - /var/run:/var/run +zabbix_agent_docker_env: + ZBX_HOSTNAME: "{{ zabbix_agent_hostname }}" + ZBX_SERVER_HOST: "{{ zabbix_agent_server }}" + ZBX_PASSIVE_ALLOW: "{{ zabbix_agent_serverpassive_allow | default(omit) }}" + ZBX_PASSIVESERVERS: "{{ zabbix_agent_serverpassive | default(omit) }}" + ZBX_ACTIVE_ALLOW: "{{ zabbix_agent_serveractive_allow | default(omit) }}" + ZBX_LOADMODULE: "{{ zabbix_agent_loadmodule | default(omit) }}" + ZBX_DEBUGLEVEL: '{{ zabbix_agent_debuglevel }}' + ZBX_TIMEOUT: '{{ zabbix_agent_timeout }}' + ZBX_SOURCEIP: "{{ zabbix_agent_sourceip | default(omit) }}" + ZBX_ENABLEREMOTECOMMANDS: "{{ zabbix_agent_enableremotecommands | default(omit) }}" + ZBX_LOGREMOTECOMMANDS: "{{ zabbix_agent_logremotecommands | default(omit) }}" + ZBX_STARTAGENTS: "{{ zabbix_agent_startagents | default(omit) }}" + ZBX_HOSTNAMEITEM: "{{ zabbix_agent_hostnameitem | default(omit) }}" + ZBX_METADATA: "{{ zabbix_agent_hostmetadata | default(omit) }}" + ZBX_METADATAITEM: "{{ zabbix_agent_hostmetadataitem | default(omit) }}" + ZBX_REFRESHACTIVECHECKS: "{{ zabbix_agent_refreshactivechecks | default(omit) }}" + ZBX_BUFFERSEND: "{{ zabbix_agent_buffersend | default(omit) }}" + ZBX_BUFFERSIZE: "{{ zabbix_agent_buffersize | default(omit) }}" + ZBX_MAXLINESPERSECOND: "{{ zabbix_agent_maxlinespersecond | default(omit) }}" + ZBX_LISTENIP: "{{ zabbix_agent_listenip }}" + ZBX_UNSAFEUSERPARAMETERS: "{{ zabbix_agent_unsafeuserparameters | default(omit) }}" + ZBX_TLSCONNECT: "{{ zabbix_agent_tlsconnect | default(omit) }}" + ZBX_TLSACCEPT: "{{ zabbix_agent_tlsaccept | default(omit) }}" + ZBX_TLSCAFILE: "{{ zabbix_agent_tlscafile | default(omit) }}" + ZBX_TLSCRLFILE: "{{ zabbix_agent_tlscrlfile | default(omit) }}" + ZBX_TLSSERVERCERTISSUER: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}" + ZBX_TLSSERVERCERTSUBJECT: "{{ zabbix_agent_tlsservercertsubject | default(omit) }}" + ZBX_TLSCERTFILE: "{{ zabbix_agent_tlscertfile | default(omit) }}" + ZBX_TLSKEYFILE: "{{ zabbix_agent_tlskeyfile | default(omit) }}" + ZBX_TLSPSKIDENTITY: "{{ zabbix_agent_tlspskidentity | default(omit) }}" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/files/sample.conf b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/files/sample.conf new file mode 100644 index 00000000..64087779 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/files/sample.conf @@ -0,0 +1,3 @@ +# This is an sample userparameters file. + +UserParameter=mysql.ping_to,mysqladmin -uroot ping | grep -c alive diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/files/win_sample/doSomething.ps1 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/files/win_sample/doSomething.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/handlers/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/handlers/main.yml new file mode 100644 index 00000000..461f40b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/handlers/main.yml @@ -0,0 +1,36 @@ +--- +# handlers file for zabbix-agent + +- name: restart zabbix-agent + service: + name: "{{ zabbix_agent_service }}" + state: restarted + enabled: yes + become: yes + when: + - not zabbix_agent_docker + - zabbix_agent_os_family != "Windows" and zabbix_agent_os_family != "Darwin" + +- name: firewalld-reload + command: "firewall-cmd --reload" + +- name: restart win zabbix agent + win_service: + name: "{{ zabbix_win_agent_service }}" + state: restarted + when: + - zabbix_agent_os_family == "Windows" + +- name: restart mac zabbix agent + command: "launchctl kickstart -k system/{{ zabbix_agent_service }}" + become: true + when: + - not zabbix_agent_docker + - zabbix_agent_os_family == "Darwin" + +- name: "clean repo files from proxy creds" + shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + become: yes + when: + - ansible_os_family == 'RedHat' + - zabbix_http_proxy is defined or zabbix_https_proxy is defined diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/meta/main.yml new file mode 100644 index 00000000..c71c861b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/meta/main.yml @@ -0,0 +1,42 @@ +--- +galaxy_info: + author: Werner Dijkerman + description: Installing and maintaining zabbix-agent for RedHat/Debian/Ubuntu/Windows/Suse. + company: myCompany.Dotcom + license: MIT + min_ansible_version: 2.7 + platforms: + - name: EL + versions: + - 5 + - 6 + - 7 + - name: Ubuntu + versions: + - lucid + - precise + - trusty + - xenial + - bionic + - name: Debian + versions: + - squeeze + - wheezy + - jessie + - stretch + - buster + - name: opensuse + versions: + - 12.1 + - 12.2 + - 12.3 + - 13.1 + - 13.2 + - name: Windows + versions: + - all + + galaxy_tags: + - zabbix + - monitoring +dependencies: [] diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/Dockerfile.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/Dockerfile.j2 new file mode 100644 index 00000000..e6aa95d3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/Dockerfile.j2 @@ -0,0 +1,14 @@ +# Molecule managed + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/INSTALL.rst b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/INSTALL.rst new file mode 100644 index 00000000..071b9956 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/INSTALL.rst @@ -0,0 +1,26 @@ +******************************** +Docker driver installation guide +******************************** + +Requirements +============ + +* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html) +* Docker Engine +* docker-py +* docker + +Install +======= + +Ansible < 2.6 + +.. code-block:: bash + + $ sudo pip install docker-py + +Ansible >= 2.6 + +.. code-block:: bash + + $ sudo pip install docker diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/molecule.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/molecule.yml new file mode 100644 index 00000000..90a9e43c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/molecule.yml @@ -0,0 +1,81 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint + +platforms: + - name: zabbix-server-centos + image: milcom/centos7-systemd:latest + groups: + - zabbix_server + - mysql + privileged: True + networks: + - name: zabbix + published_ports: + - "80:80" + - name: zabbix-agent-centos + image: milcom/centos7-systemd:latest + groups: + - zabbix_agent + privileged: True + networks: + - name: zabbix + - name: zabbix-agent-debian + image: minimum2scp/systemd-stretch:latest + command: /sbin/init + groups: + - zabbix_agent + privileged: True + networks: + - name: zabbix + - name: zabbix-agent-ubuntu + image: solita/ubuntu-systemd:bionic + groups: + - zabbix_agent + privileged: True + networks: + - name: zabbix + +provisioner: + name: ansible + playbooks: + docker: + create: ../default/create.yml + destroy: ../default/destroy.yml + lint: + name: ansible-lint + inventory: + group_vars: + all: + zabbix_agent_src_reinstall: False + zabbix_api_create_hosts: True + zabbix_api_create_hostgroup: True + zabbix_url: http://zabbix-server-centos + zabbix_apache_servername: zabbix-server-centos + mysql: + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + database_type: mysql + database_type_long: mysql + host_vars: + zabbix-agent-fedora: + ansible_python_interpreter: /usr/bin/python3 + zabbix-agent-ubuntu: + zabbix_agent_tlsaccept: psk + zabbix_agent_tlsconnect: psk + zabbix_agent_tlspskidentity: "myhost PSK" + zabbix_agent_tlspsk_secret: b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d + zabbix_agent_tlspskfile: /etc/zabbix/zabbix_agent_pskfile.psk + +scenario: + name: with-server + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/playbook.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/playbook.yml new file mode 100644 index 00000000..2161b916 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/playbook.yml @@ -0,0 +1,24 @@ +--- +- name: Converge + hosts: all:!zabbix_server + pre_tasks: + - name: "Get IP Server" + shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1 + register: ip_address + delegate_to: zabbix-server-centos + changed_when: False + tags: + - skip_ansible_lint + + - name: "Get IP hosts" + shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1 + register: ip_address_host + changed_when: False + tags: + - skip_ansible_lint + + roles: + - role: ansible-zabbix-agent + zabbix_agent_ip: "{{ ip_address_host.stdout }}" + zabbix_agent_server: "{{ ip_address.stdout }}" + zabbix_agent_serveractive: "{{ ip_address.stdout }}" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/prepare.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/prepare.yml new file mode 100644 index 00000000..1776105c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/prepare.yml @@ -0,0 +1,114 @@ +--- +- name: Prepare + hosts: zabbix_server + pre_tasks: + - name: "Installing EPEL" + yum: + name: + - epel-release + state: present + when: ansible_distribution == 'CentOS' + + - name: "Installing packages" + yum: + name: + - net-tools + - which + - libselinux-python + - python-pip + state: present + register: installation_dependencies + when: ansible_distribution == 'CentOS' + + - name: "Installing which on NON-CentOS" + apt: + name: + - net-tools + - python-pip + - curl + state: present + when: ansible_distribution != 'CentOS' + + - name: "Configure SUDO." + lineinfile: + dest: /etc/sudoers + line: "Defaults !requiretty" + state: present + + - name: "Make sure the docs are installed." + lineinfile: + dest: /etc/yum.conf + line: "tsflags=nodocs" + state: absent + + - name: "Installing some python dependencies" + pip: + name: py-zabbix + state: present + + roles: + - role: geerlingguy.mysql + - role: dj-wasabi.zabbix-server + - role: dj-wasabi.zabbix-web + +- name: Prepare + hosts: all:!zabbix_server:!docker + tasks: + - name: "Installing packages on CentOS family" + yum: + name: + - net-tools + - which + state: present + when: + - ansible_os_family == 'RedHat' + + - name: "Installing packages on Debian family" + apt: + name: + - net-tools + state: present + when: + - ansible_os_family == 'Debian' + +- name: Converge + hosts: docker + tasks: + - name: "Download Docker CE repo file" + get_url: + url: https://download.docker.com/linux/centos/docker-ce.repo + dest: /etc/yum.repos.d/docker-ce.repo + mode: 0644 + register: zabbix_agent_prepare_docker_repo + until: zabbix_agent_prepare_docker_repo is succeeded + + - name: "Installing Epel" + package: + pkg: + - epel-release + state: present + register: zabbix_agent_prepare_docker_install + until: zabbix_agent_prepare_docker_install is succeeded + + - name: "Installing Docker" + package: + pkg: + - docker-ce + - python-pip + - python-setuptools + state: present + register: zabbix_agent_prepare_docker_install + until: zabbix_agent_prepare_docker_install is succeeded + + - name: "Installing Docker Python" + pip: + name: + - docker + state: present + register: zabbix_agent_prepare_docker_install + until: zabbix_agent_prepare_docker_install is succeeded + + - name: "Starting Docker service" + service: + name: docker + state: started diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/requirements.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/requirements.yml new file mode 100644 index 00000000..da9d004b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/requirements.yml @@ -0,0 +1,5 @@ +--- +- src: geerlingguy.apache +- src: geerlingguy.mysql +- src: dj-wasabi.zabbix-server +- src: dj-wasabi.zabbix-web diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/tests/test_agent.py b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/tests/test_agent.py new file mode 100644 index 00000000..5f373ca8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/tests/test_agent.py @@ -0,0 +1,44 @@ +import os +from zabbix_api import ZabbixAPI + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('zabbix_agent') + + +def authenticate(): + zapi = ZabbixAPI(server='http://zabbix-server-centos/api_jsonrpc.php') + zapi.login("Admin", "zabbix") + return zapi + + +def test_psk_host(host): + zapi = authenticate() + hostname = host.check_output('hostname -s') + host_name = "zabbix-agent-ubuntu" + + server_data = zapi.host.get({'output': 'extend', 'selectInventory': 'extend', 'filter': {'host': [hostname]}}) + + if hostname == host_name: + assert server_data[0]['tls_psk'] == "b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d" + assert server_data[0]['tls_psk_identity'] == "myhost PSK" + assert server_data[0]['tls_accept'] == "2" + else: + assert server_data[0]['tls_psk'] == "" + assert server_data[0]['tls_psk_identity'] == "" + assert server_data[0]['tls_accept'] == "1" + + +def test_zabbix_agent_psk(host): + hostname = host.check_output('hostname -s') + host_name = "zabbix-agent-ubuntu" + + psk_file = host.file("/etc/zabbix/zabbix_agent_pskfile.psk") + if hostname == host_name: + assert psk_file.user == "zabbix" + assert psk_file.group == "zabbix" + assert psk_file.mode == 0o400 + assert psk_file.contains("b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d") + else: + assert not psk_file.exists diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/tests/test_default.py b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/tests/test_default.py new file mode 100644 index 00000000..cbedaa17 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/tests/test_default.py @@ -0,0 +1,41 @@ +import os +from zabbix_api import ZabbixAPI + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('zabbix_server') + + +def authenticate(): + zapi = ZabbixAPI(server='http://zabbix-server-centos/api_jsonrpc.php') + zapi.login("Admin", "zabbix") + return zapi + + +def get_hosts(): + return [ + "zabbix-agent-debian", + "zabbix-agent-ubuntu", + "zabbix-agent-centos", + "zabbix-agent-docker-centos" + ] + + +def test_hosts(): + zapi = authenticate() + hosts = get_hosts() + servers = zapi.host.get({'output': ["hostid", "name"]}) + + for server in servers: + if server['name'] != 'Zabbix server': + assert server['name'] in hosts + + +def test_hosts_status(): + zapi = authenticate() + servers = zapi.host.get({'output': ["status", "name"]}) + + for server in servers: + if server['name'] != 'Zabbix server': + assert int(server['status']) == 0 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Darwin.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Darwin.yml new file mode 100644 index 00000000..243fd0ff --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Darwin.yml @@ -0,0 +1,170 @@ +--- + +- name: "Set default ip address for zabbix_agent_ip" + set_fact: + zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4'].address }}" + when: + - zabbix_agent_ip is not defined + - "'ansible_default_ipv4' in hostvars[inventory_hostname]" + +- name: "Get Total Private IP Addresses" + set_fact: + total_private_ip_addresses: "{{ ansible_all_ipv4_addresses | ipaddr('private') | length }}" + when: + - ansible_all_ipv4_addresses is defined + +- name: "Set first public ip address for zabbix_agent_ip" + set_fact: + zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ipaddr('public') | first }}" + zabbix_agent_server: "{{ zabbix_agent_server_public_ip | default(zabbix_agent_server) }}" + zabbix_agent_serveractive: "{{ zabbix_agent_serveractive_public_ip | default(zabbix_agent_serveractive) }}" + when: + - zabbix_agent_ip is not defined + - total_private_ip_addresses is defined + - total_private_ip_addresses == '0' + +- name: "Set first private ip address for zabbix_agent_ip" + set_fact: + zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ipaddr('private') | first }}" + when: + - zabbix_agent_ip is not defined + - total_private_ip_addresses is defined + - total_private_ip_addresses != '0' + +- name: "Fail invalid specified agent_listeninterface" + fail: + msg: "The specified network interface does not exist" + when: + - zabbix_agent_listeninterface + - (zabbix_agent_listeninterface not in ansible_all_ipv4_addresses) + tags: + - zabbix-agent + - config + +- name: "Set network interface" + set_fact: + network_interface: ansible_{{ zabbix_agent_listeninterface }} + when: + - zabbix_agent_listeninterface + - not zabbix_agent_listenip + +- name: "Get IP of agent_listeninterface when no agent_listenip specified" + set_fact: + zabbix_agent_listenip: "{{ hostvars[inventory_hostname][network_interface]['ipv4'].address | default('0.0.0.0') }}" + zabbix_agent_ip: "{{ hostvars[inventory_hostname][network_interface]['ipv4'].address | default('0.0.0.0') }}" + when: + - zabbix_agent_listeninterface + - not zabbix_agent_listenip + tags: + - zabbix-agent + - config + - api + +- name: "Default agent_listenip to all when not specified" + set_fact: + zabbix_agent_listenip: '0.0.0.0' + when: + - not zabbix_agent_listenip + tags: + - zabbix-agent + - config + +- name: "Fail invalid specified agent_listenip" + fail: + msg: "The agent_listenip does not exist" + when: + - zabbix_agent_listenip != '0.0.0.0' + - zabbix_agent_listenip != '127.0.0.1' + - (zabbix_agent_listenip not in ansible_all_ipv4_addresses) + tags: + - zabbix-agent + - config + +- name: "Configure zabbix-agent" + template: + src: zabbix_agentd.conf.j2 + dest: "/usr/local/etc/zabbix/{{ zabbix_agent_conf }}" + owner: root + group: wheel + mode: 0644 + notify: + - restart mac zabbix agent + become: yes + when: + - not (zabbix_agent_docker | bool) + tags: + - zabbix-agent + - config + - init + +- name: "Create directory for PSK file if not exist." + file: + path: "{{ zabbix_agent_tlspskfile | dirname }}" + mode: 0755 + state: directory + become: yes + when: + - zabbix_agent_tlspskfile is defined + +- name: "Place TLS PSK File" + copy: + dest: "{{ zabbix_agent_tlspskfile }}" + content: "{{ zabbix_agent_tlspsk_secret }}" + owner: zabbix + group: zabbix + mode: 0400 + become: yes + when: + - zabbix_agent_tlspskfile is defined + - zabbix_agent_tlspsk_secret is defined + notify: + - restart mac zabbix agent + +- name: "Create include dir zabbix-agent" + file: + path: "{{ zabbix_agent_include }}" + owner: root + group: zabbix + mode: 0750 + state: directory + become: yes + tags: + - config + - include + +- name: "Create pid file directory for zabbix-agent" + file: + path: /var/run/zabbix + state: directory + owner: zabbix + group: zabbix + mode: 0755 + become: yes + +- name: "Install the Docker container" + include: Docker.yml + when: + - zabbix_agent_docker | bool + +- name: "Check if zabbix-agent service is running" + shell: | + set -o pipefail + launchctl list | grep com.zabbix.zabbix_agentd | awk '{print $1}' + register: launchctl_pid + check_mode: no + changed_when: false + failed_when: launchctl_pid.rc == 2 + become: yes + tags: + - init + - service + +- name: "Make sure the zabbix-agent service is running" + command: launchctl start com.zabbix.zabbix_agentd + become: yes + when: + - not (zabbix_agent_docker | bool) + - launchctl_pid.stdout == "-" + tags: + - init + - service diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Debian.yml new file mode 100644 index 00000000..001d435e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Debian.yml @@ -0,0 +1,197 @@ +--- +# Tasks specific for Debian/Ubuntu Systems + +- name: "Include Zabbix gpg ids" + include_vars: zabbix.yml + +- name: "Set short version name" + set_fact: + zabbix_short_version: "{{ zabbix_version | regex_replace('\\.', '') }}" + zabbix_underscore_version: "{{ zabbix_version | regex_replace('\\.', '_') }}" + +- name: "Debian | Installing gnupg" + apt: + pkg: gnupg + update_cache: yes + cache_valid_time: 3600 + force: yes + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: gnupg_installed + until: gnupg_installed is succeeded + become: yes + +- name: "Debian | Install gpg key" + apt_key: + id: "{{ sign_keys[zabbix_short_version][zabbix_agent_distribution_release]['sign_key'] }}" + url: http://repo.zabbix.com/zabbix-official-repo.key + when: + - zabbix_repo == "zabbix" + become: yes + tags: + - zabbix-agent + - init + +- name: "Debian | Check for zabbix repositories" + find: + paths: /etc/apt/sources.list.d + patterns: repo_zabbix_com_zabbix*.list + excludes: "repo_zabbix_com_zabbix_{{ zabbix_underscore_version }}_ubuntu.list" + register: repositories + become: yes + when: + - ansible_distribution in ['Ubuntu', 'Debian'] + - zabbix_repo == "zabbix" + tags: + - zabbix-agent + - init + +- name: "Debian | Remove unecessary zabbix repositories" + file: + path: "{{ item.path }}" + state: absent + loop: "{{ repositories.files }}" + when: + - ansible_distribution in ['Ubuntu', 'Debian'] + - zabbix_repo == "zabbix" + - zabbix_agent_src_reinstall + become: yes + tags: + - zabbix-agent + - init + +- name: "Debian | Installing deb-src repository Debian" + apt_repository: + repo: "deb-src http://repo.zabbix.com/zabbix/{{ zabbix_version }}/debian/ {{ zabbix_agent_distribution_release }} main" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + when: + - ansible_distribution == "Debian" + - zabbix_repo == "zabbix" + become: yes + tags: + - zabbix-agent + - init + +- name: "Debian | Installing deb repository Debian" + apt_repository: + repo: "deb http://repo.zabbix.com/zabbix/{{ zabbix_version }}/debian/ {{ zabbix_agent_distribution_release }} main" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + when: + - ansible_distribution == "Debian" + - zabbix_repo == "zabbix" + become: yes + tags: + - zabbix-agent + - init + +- name: "Debian | Installing deb-src repository Ubuntu" + apt_repository: + repo: "deb-src http://repo.zabbix.com/zabbix/{{ zabbix_version }}/ubuntu/ {{ zabbix_agent_distribution_release }} main" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + when: + - ansible_distribution == "Ubuntu" + - zabbix_repo == "zabbix" + become: yes + tags: + - zabbix-agent + - init + +- name: "Debian | Installing deb repository Ubuntu" + apt_repository: + repo: "deb http://repo.zabbix.com/zabbix/{{ zabbix_version }}/ubuntu/ {{ zabbix_agent_distribution_release }} main" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + when: + - ansible_distribution == "Ubuntu" + - zabbix_repo == "zabbix" + become: yes + tags: + - zabbix-agent + - init + +- name: "Debian | Create /etc/apt/preferences.d/" + file: + path: /etc/apt/preferences.d/ + state: directory + when: + - zabbix_agent_apt_priority | int + become: yes + +- name: "Debian | Configuring the weight for APT" + copy: + dest: "/etc/apt/preferences.d/zabbix-agent-{{ zabbix_underscore_version }}" + content: | + Package: {{ zabbix_agent_package }} + Pin: origin repo.zabbix.com + Pin-Priority: {{ zabbix_agent_apt_priority | int }} + owner: root + when: + - zabbix_agent_apt_priority | int + become: yes + +# Note: set cache_valid_time=0 to ensure that an apt-get update after the added repo-key +# else you often get 'WARNING: The following packages cannot be authenticated! +# See also: +# http://askubuntu.com/questions/75565/why-am-i-getting-authentication-errors-for-packages-from-an-ubuntu-repository +- name: "Debian | Installing zabbix-agent" + apt: + pkg: "{{ zabbix_agent_packages }}" + state: "{{ zabbix_agent_package_state }}" + update_cache: yes + cache_valid_time: 0 + force_apt_get: "{{ zabbix_apt_force_apt_get }}" + install_recommends: "{{ zabbix_apt_install_recommends }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + when: ansible_distribution in ['Ubuntu', 'Debian'] + register: zabbix_agent_package_installed + until: zabbix_agent_package_installed is succeeded + become: yes + check_mode: no + tags: + - zabbix-agent + - init + +- name: "Mint | Installing zabbix-agent" + apt: + pkg: "zabbix-agent" + state: "{{ zabbix_agent_package_state }}" + update_cache: yes + cache_valid_time: 0 + force_apt_get: "{{ zabbix_apt_force_apt_get }}" + install_recommends: "{{ zabbix_apt_install_recommends }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + when: ansible_distribution not in ['Ubuntu', 'Debian'] + register: zabbix_agent_package_installed + until: zabbix_agent_package_installed is succeeded + become: yes + tags: + - zabbix-agent + - init + +- name: "Debian | Enable the service" + service: + name: "{{ zabbix_agent_service }}" + enabled: yes + use: service + become: yes + tags: + - zabbix-agent + - init + - service diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Docker.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Docker.yml new file mode 100644 index 00000000..4a4ce2ad --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Docker.yml @@ -0,0 +1,33 @@ +--- + +- name: "Create volume mount string" + set_fact: + volume_mount: "{{ zabbix_agent_tlspskfile }}:/var/lib/zabbix/enc/tlspskfile" + tls_key: + ZBX_TLSPSKFILE: tlspskfile + when: + - zabbix_agent_tlspskfile is defined + +- name: "Add zabbix_agent_tlspskfile to volume mount" + set_fact: + zabbix_agent_docker_volumes: "{{ zabbix_agent_docker_volumes + [ volume_mount ] }}" + zabbix_agent_docker_env: "{{ zabbix_agent_docker_env | combine(tls_key) }}" + when: + - zabbix_agent_tlspskfile is defined + +- name: "Ensure Zabbix Docker container is running" + docker_container: + name: "{{ zabbix_agent_docker_name }}" + image: "{{ zabbix_agent_docker_image }}:{{ zabbix_agent_docker_image_tag }}" + state: "{{ zabbix_agent_docker_state }}" + restart_policy: "{{ zabbix_agent_docker_restart_policy }}" + network_mode: "{{ zabbix_agent_docker_network_mode }}" + published_ports: "{{ zabbix_agent_docker_ports }}" + privileged: "{{ zabbix_agent_docker_privileged }}" + security_opts: "{{ zabbix_agent_docker_security_opts }}" + volumes: "{{ zabbix_agent_docker_volumes }}" + env: "{{ zabbix_agent_docker_env }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + become: yes diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Linux.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Linux.yml new file mode 100644 index 00000000..6d79ab91 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Linux.yml @@ -0,0 +1,216 @@ +--- + +- name: "Set default ip address for zabbix_agent_ip" + set_fact: + zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4'].address }}" + when: + - zabbix_agent_ip is not defined + - "'ansible_default_ipv4' in hostvars[inventory_hostname]" + +- name: "Get Total Private IP Addresses" + set_fact: + total_private_ip_addresses: "{{ ansible_all_ipv4_addresses | ipaddr('private') | length }}" + when: + - ansible_all_ipv4_addresses is defined + - not zabbix_agent_dont_detect_ip + +- name: "Set first public ip address for zabbix_agent_ip" + set_fact: + zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ipaddr('public') | first }}" + zabbix_agent_server: "{{ zabbix_agent_server_public_ip | default(zabbix_agent_server) }}" + zabbix_agent_serveractive: "{{ zabbix_agent_serveractive_public_ip | default(zabbix_agent_serveractive) }}" + when: + - zabbix_agent_ip is not defined + - total_private_ip_addresses is defined + - total_private_ip_addresses == '0' + +- name: "Set first private ip address for zabbix_agent_ip" + set_fact: + zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ipaddr('private') | first }}" + when: + - zabbix_agent_ip is not defined + - total_private_ip_addresses is defined + - total_private_ip_addresses != '0' + +- name: "Fail invalid specified agent_listeninterface" + fail: + msg: "The specified network interface does not exist" + when: + - zabbix_agent_listeninterface | bool + - (zabbix_agent_listeninterface not in ansible_all_ipv4_addresses) + tags: + - zabbix-agent + - config + +- name: "Set network interface" + set_fact: + network_interface: ansible_{{ zabbix_agent_listeninterface }} + when: + - zabbix_agent_listeninterface | bool + - not zabbix_agent_listenip + +- name: "Get IP of agent_listeninterface when no agent_listenip specified" + set_fact: + zabbix_agent_listenip: "{{ hostvars[inventory_hostname][network_interface]['ipv4'].address | default('0.0.0.0') }}" + zabbix_agent_ip: "{{ hostvars[inventory_hostname][network_interface]['ipv4'].address | default('0.0.0.0') }}" + when: + - zabbix_agent_listeninterface | bool + - not zabbix_agent_listenip + tags: + - zabbix-agent + - config + - api + +- name: "Default agent_listenip to all when not specified" + set_fact: + zabbix_agent_listenip: '0.0.0.0' + when: + - not zabbix_agent_listenip + tags: + - zabbix-agent + - config + +- name: "Fail invalid specified agent_listenip" + fail: + msg: "The agent_listenip does not exist" + when: + - zabbix_agent_listenip != '0.0.0.0' + - zabbix_agent_listenip != '127.0.0.1' + - (zabbix_agent_listenip not in ansible_all_ipv4_addresses) + tags: + - zabbix-agent + - config + +- name: "Configure SELinux when enabled" + include: selinux.yml + when: + - zabbix_selinux | bool + +- name: "Adding zabbix group" + group: + name: zabbix + state: present + gid: "{{ zabbix_agent_docker_user_gid | default(omit) }}" + become: yes + when: + - zabbix_agent_docker | bool + +- name: "Adding zabbix user" + user: + name: zabbix + group: zabbix + state: present + create_home: False + home: /etc/zabbix + uid: "{{ zabbix_agent_docker_user_uid | default(omit) }}" + system: True + become: yes + when: + - zabbix_agent_docker | bool + +- name: "Configure zabbix-agent" + template: + src: "{{ 'zabbix_agentd.conf.j2' if not zabbix_agent2 else 'zabbix_agent2.conf.j2' }}" + dest: "/etc/zabbix/{{ zabbix_agent_conf if not zabbix_agent2 else zabbix_agent2_conf }}" + owner: root + group: root + mode: "{{ zabbix_agent_conf_mode }}" + notify: + - restart zabbix-agent + become: yes + when: + - not (zabbix_agent_docker | bool) + tags: + - zabbix-agent + - config + - init + +- name: "Create directory for PSK file if not exist." + file: + path: "{{ zabbix_agent_tlspskfile | dirname }}" + mode: 0755 + state: directory + become: yes + when: + - zabbix_agent_tlspskfile is defined + - not zabbix_agent2 + +- name: "Create directory for PSK file if not exist (zabbix-agent2)" + file: + path: "{{ zabbix_agent2_tlspskfile | dirname }}" + mode: 0755 + state: directory + become: yes + when: + - zabbix_agent2_tlspskfile is defined + - zabbix_agent2 + +- name: "Place TLS PSK File" + copy: + dest: "{{ zabbix_agent_tlspskfile }}" + content: "{{ zabbix_agent_tlspsk_secret }}" + owner: zabbix + group: zabbix + mode: 0400 + become: yes + when: + - zabbix_agent_tlspskfile is defined + - zabbix_agent_tlspsk_secret is defined + - not zabbix_agent2 + notify: + - restart zabbix-agent + +- name: "Place TLS PSK File (zabbix-agent2)" + copy: + dest: "{{ zabbix_agent2_tlspskfile }}" + content: "{{ zabbix_agent2_tlspsk_secret }}" + owner: zabbix + group: zabbix + mode: 0400 + become: yes + when: + - zabbix_agent2_tlspskfile is defined + - zabbix_agent2_tlspsk_secret is defined + - zabbix_agent2 + notify: + - restart zabbix-agent + +- name: "Create include dir zabbix-agent" + file: + path: "{{ zabbix_agent_include if not zabbix_agent2 else zabbix_agent2_include }}" + owner: root + group: zabbix + mode: "{{ zabbix_agent_include_mode if not zabbix_agent2 else zabbix_agent2_include_mode }}" + state: directory + become: yes + tags: + - config + - include + +- name: "Install the Docker container" + include: Docker.yml + when: + - zabbix_agent_docker | bool + +- name: "Configure the firewall(d|iptables)" + include: firewall.yml + when: + - (zabbix_agent_firewall_enable | bool) or (zabbix_agent_firewalld_enable | bool) + +- name: "Remove zabbix-agent installation when zabbix-agent2 is used." + include: remove.yml + when: + - zabbix_agent2 + - zabbix_agent_package_remove + +- name: "Make sure the zabbix-agent service is running" + service: + name: "{{ zabbix_agent_service }}" + state: started + enabled: yes + become: yes + when: + - not (zabbix_agent_docker | bool) + tags: + - init + - service diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/RedHat.yml new file mode 100644 index 00000000..88603cdc --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/RedHat.yml @@ -0,0 +1,133 @@ +--- +# Tasks specific for RedHat systems + +- name: "RedHat | Use EPEL package name" + set_fact: + zabbix_agent_package: "zabbix{{ zabbix_version | regex_replace('\\.', '') }}-agent" + zabbix_sender_package: "zabbix{{ zabbix_version | regex_replace('\\.', '') }}-sender" + zabbix_get_package: "zabbix{{ zabbix_version | regex_replace('\\.', '') }}-get" + when: + - zabbix_repo == "epel" + tags: + - zabbix-agent + - init + +- name: "RedHat | Set zabbix_agent_distribution_major_version to 6 when Amazon" + set_fact: + zabbix_agent_distribution_major_version: 6 + when: + - ansible_distribution == "Amazon" + - ansible_distribution_major_version == "NA" + +- name: "RedHat | Set zabbix_agent_distribution_major_version to 6 when Major Version is 2018.03" + set_fact: + zabbix_agent_distribution_major_version: 6 + when: + - ansible_distribution == "Amazon" + - ansible_distribution_major_version == "2018" + +- name: "RedHat | Set zabbix_agent_distribution_major_version to 7 when Amazon 2" + set_fact: + zabbix_agent_distribution_major_version: 7 + when: + - ansible_distribution == "Amazon" + - ansible_distribution_major_version == "2" + +- name: "Fedora | Override zabbix_agent_distribution_major_version for Fedora <= 27" + set_fact: + zabbix_agent_distribution_major_version: 7 + when: + - ansible_distribution == "Fedora" + - ansible_distribution_major_version <= "27" + +- name: "Fedora | Override zabbix_agent_distribution_major_version for Fedora >= 27" + set_fact: + zabbix_agent_distribution_major_version: 8 + when: + - ansible_distribution == "Fedora" + - ansible_distribution_major_version >= "27" + +- name: "XCP-ng | Override zabbix_agent_distribution_major_version for XCP-ng" + set_fact: + zabbix_agent_distribution_major_version: 7 + when: + - ansible_distribution == "XCP-ng" + +- name: "RedHat | Install basic repo file" + yum_repository: + name: "{{ item.name }}" + description: "{{ item.description }}" + baseurl: "{{ item.baseurl }}" + gpgcheck: "{{ item.gpgcheck }}" + gpgkey: "{{ item.gpgkey }}" + mode: "{{ item.mode | default('0644') }}" + priority: "{{ item.priority | default('99') }}" + state: "{{ item.state | default('present') }}" + proxy: "{{ zabbix_http_proxy | default(omit) }}" + with_items: "{{ zabbix_repo_yum }}" + register: yum_repo_installed + become: yes + when: + zabbix_repo == "zabbix" + notify: + - "clean repo files from proxy creds" + tags: + - zabbix-agent + +- name: "Do a yum clean" + shell: yum clean all + args: + warn: False + when: yum_repo_installed.changed + become: yes + tags: + - skip_ansible_lint + +- name: "RedHat | Installing zabbix-agent" + package: + pkg: + - "{{ zabbix_agent_package }}-{{ zabbix_agent_version }}.*" + disablerepo: "{{ '*' if (zabbix_repo_yum_enabled | length>0) else omit }}" + enablerepo: "{{ zabbix_repo_yum_enabled if zabbix_repo_yum_enabled is iterable and (zabbix_repo_yum_enabled | length>0) else omit }}" + state: "{{ zabbix_agent_package_state }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_agent_package_installed + until: zabbix_agent_package_installed is succeeded + become: yes + tags: + - init + - zabbix-agent + +- name: "RedHat | Installing zabbix-{sender,get}}" + package: + pkg: + - "{{ zabbix_sender_package }}-{{ zabbix_agent_version }}.*" + - "{{ zabbix_get_package }}-{{ zabbix_agent_version }}.*" + disablerepo: "{{ '*' if (zabbix_repo_yum_enabled | length>0) else omit }}" + enablerepo: "{{ zabbix_repo_yum_enabled if zabbix_repo_yum_enabled is iterable and (zabbix_repo_yum_enabled | length>0) else omit }}" + state: "{{ zabbix_agent_package_state }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_agent_package_installed + until: zabbix_agent_package_installed is succeeded + when: + - zabbix_repo != 'epel' + - not zabbix_agent_install_agent_only + become: yes + tags: + - init + - zabbix-agent + +- name: "RedHat | Enable the service" + service: + name: "{{ zabbix_agent_service }}" + enabled: yes + use: service + become: yes + tags: + - zabbix-agent + - init + - service diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Suse.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Suse.yml new file mode 100644 index 00000000..2045eb67 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Suse.yml @@ -0,0 +1,53 @@ +--- +# Tasks specific for OpenSuse Systems + +- name: "Include Zabbix gpg ids" + include_vars: zabbix.yml + +- name: "Install zypper repo dependency" + zypper: + name: ["python-libxml2", "python-xml"] + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + become: yes + register: zabbix_agent_package_dependency + until: zabbix_agent_package_dependency is succeeded + +- name: "Suse | Install basic repo file" + zypper_repository: + repo: "{{ suse[ansible_distribution][zabbix_agent_distribution_major_version]['url'] }}" + name: "{{ suse[ansible_distribution][zabbix_agent_distribution_major_version]['name'] }}" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + when: + - zabbix_repo == "zabbix" + become: yes + tags: + - zabbix-agent + - init + +- name: "Only install the Zabbix Agent" + set_fact: + zabbix_agent_packages: + - "{{ zabbix_agent_package }}" + when: + - zabbix_agent_install_agent_only + +- name: "Suse | Install zabbix-agent" + zypper: + name: "{{ zabbix_agent_packages }}" + state: "{{ zabbix_agent_package_state }}" + disable_gpg_check: yes + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_agent_package_installed + until: zabbix_agent_package_installed is succeeded + become: yes + tags: + - zabbix-agent + - init diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Windows.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Windows.yml new file mode 100644 index 00000000..75a248a8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Windows.yml @@ -0,0 +1,164 @@ +--- + +- name: "Set default ip address for zabbix_agent_ip" + set_fact: + zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_ip_addresses'][0] }}" + when: + - zabbix_agent_ip is not defined + - "'ansible_ip_addresses' in hostvars[inventory_hostname]" + +- name: "Windows | Set default architecture" + set_fact: + windows_arch: 32 + +- name: "Windows | Override architecture if 64-bit" + set_fact: + windows_arch: 64 + when: + - ansible_architecture == "64-bit" + +- name: "Windows | Set path to zabbix.exe" + set_fact: + zabbix_win_exe_path: '{{ zabbix_win_install_dir }}\bin\win{{ windows_arch }}\zabbix_agentd.exe' + +- name: "Windows | Set variables specific to Zabbix 4.0" + set_fact: + zabbix_win_package: zabbix_agent-{{ zabbix_version_long }}-windows-amd64.zip + zabbix_win_exe_path: '{{ zabbix_win_install_dir }}\bin\zabbix_agentd.exe' + when: + - zabbix_version_long is version('4.0.0', '>=') + +- name: "Windows | Check if Zabbix agent is present" + win_stat: + path: '{{ zabbix_win_exe_path }}' + register: agent_file_info + +- name: "Windows | Get Installed Zabbix Agent Version" + win_file_version: + path: "{{ zabbix_win_exe_path }}" + register: zabbix_win_exe_info + when: + - agent_file_info.stat.exists + +- name: "Windows | Checking Update (Set default)" + set_fact: + update_zabbix_agent: False + when: + - agent_file_info.stat.exists + +- name: "Windows | Checking Update" + set_fact: + update_zabbix_agent: True + when: + - agent_file_info.stat.exists + - zabbix_win_exe_info.win_file_version.product_version is version(zabbix_version_long, '<') + - zabbix_agent_package_state == 'latest' + +- name: "Windows | Stop Zabbix (Update)" + win_service: + name: Zabbix Agent + start_mode: auto + state: stopped + when: + - update_zabbix_agent | default(false) + - agent_file_info.stat.exists + +- name: "Windows | Uninstall Zabbix (Update)" + win_command: '"{{ zabbix_win_exe_path }}" --config "{{ zabbix_win_install_dir }}\zabbix_agentd.conf" --uninstall' + register: zabbix_windows_install + when: + - update_zabbix_agent | default(false) + - agent_file_info.stat.exists + +- name: "Windows | Removing Zabbix Directory (Update)" + win_file: + path: '{{ zabbix_win_install_dir }}' + state: absent + when: + - update_zabbix_agent | default(false) + - agent_file_info.stat.exists + +- name: "Windows | Create directory structure" + win_file: + path: "{{ item }}" + state: directory + with_items: + - "{{ zabbix_win_install_dir }}" + - "{{ zabbix_agent_win_include }}" + +- name: "Windows | Place TLS-PSK file" + win_copy: + content: "{{ zabbix_agent_tlspsk_secret }}" + dest: "{{ zabbix_agent_tlspskfile }}" + when: + - zabbix_agent_tlspskfile is defined + - zabbix_agent_tlspsk_secret is defined + notify: restart win zabbix agent + +- name: "Windows | Check if file is already downloaded" + win_stat: + path: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}' + register: file_info + +- name: "Windows | Download Zabbix Agent Zip file" + win_get_url: + url: "{{ zabbix_win_download_link }}" + dest: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}' + force: False + follow_redirects: all + proxy_url: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_agent_win_download_zip + until: zabbix_agent_win_download_zip is succeeded + +- name: "Windows | Unzip file" + win_unzip: + src: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}' + dest: "{{ zabbix_win_install_dir }}" + creates: '{{ zabbix_win_exe_path }}' + +- name: "Windows | Configure zabbix-agent" + win_template: + src: zabbix_agentd.conf.j2 + dest: '{{ zabbix_win_install_dir }}\zabbix_agentd.conf' + notify: restart win zabbix agent + +- name: "Windows | Register Service" + win_command: '"{{ zabbix_win_exe_path }}" --config "{{ zabbix_win_install_dir }}\zabbix_agentd.conf" --install' + register: zabbix_windows_install + args: + creates: '{{ zabbix_win_install_dir }}\.installed' + +- name: "Windows | Create done file so it won't register itself again" + win_file: + path: '{{ zabbix_win_install_dir }}\.installed' + state: touch + when: zabbix_windows_install is changed + +- name: "Windows | Set service startup mode to auto and ensure it is started" + win_service: + name: Zabbix Agent + start_mode: auto + state: started + +- name: "Windows | Getting Zabbix Service Recovery Settings" + win_shell: sc.exe qfailure "Zabbix Agent" 1100 + register: svc_recovery + changed_when: false + check_mode: false + when: zabbix_agent_win_svc_recovery + +- name: "Windows | Setting Zabbix Service Recovery" + win_shell: sc.exe failure "Zabbix Agent" actions= restart/5000/restart/10000/restart/20000 reset= 86400 + when: + - "'RESTART -- Delay' not in svc_recovery.stdout" + - zabbix_agent_win_svc_recovery + +- name: "Windows | Firewall rule" + win_firewall_rule: + name: Zabbix Agent + localport: "{{ zabbix_agent_listenport }}" + action: allow + direction: in + protocol: tcp + state: present + enabled: yes diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/api.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/api.yml new file mode 100644 index 00000000..af76a0d0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/api.yml @@ -0,0 +1,135 @@ +--- + +- name: "API | Installing the Zabbix-api package on localhost" + pip: + name: zabbix-api + state: present + register: zabbix_api_package_installed + until: zabbix_api_package_installed is succeeded + delegate_to: localhost + run_once: True + become: "{{ zabbix_agent_become_on_localhost }}" + when: + - zabbix_install_pip_packages | bool + - (zabbix_api_create_hostgroup | bool) or (zabbix_api_create_hosts | bool) + +- name: "API | Create hostgroups" + zabbix_group: + server_url: "{{ zabbix_url }}" + http_login_user: "{{ zabbix_api_http_user | default(omit) }}" + http_login_password: "{{ zabbix_api_http_password | default(omit) }}" + login_user: "{{ zabbix_api_user }}" + login_password: "{{ zabbix_api_pass }}" + host_group: "{{ zabbix_host_groups }}" + state: "{{ zabbix_create_hostgroup }}" + validate_certs: "{{ zabbix_validate_certs|default(omit) }}" + when: + - zabbix_api_create_hostgroup | bool + register: zabbix_api_hostgroup_created + until: zabbix_api_hostgroup_created is succeeded + delegate_to: localhost + become: no + tags: + - api + +- name: "API | Create a new host or update an existing host's info" + zabbix_host: + server_url: "{{ zabbix_url }}" + http_login_user: "{{ zabbix_api_http_user | default(omit) }}" + http_login_password: "{{ zabbix_api_http_password | default(omit) }}" + login_user: "{{ zabbix_api_user }}" + login_password: "{{ zabbix_api_pass }}" + host_name: "{{ zabbix_agent_hostname }}" + host_groups: "{{ zabbix_host_groups }}" + link_templates: "{{ zabbix_link_templates }}" + status: "{{ zabbix_host_status }}" + state: "{{ zabbix_create_host }}" + force: "{{ zabbix_update_host }}" + proxy: "{{ zabbix_proxy }}" + inventory_mode: "{{ zabbix_inventory_mode }}" + interfaces: "{{ zabbix_agent_interfaces }}" + visible_name: "{{ zabbix_visible_hostname | default(zabbix_agent_hostname) }}" + tls_psk: "{{ zabbix_agent_tlspsk_secret | default(omit) }}" + tls_psk_identity: "{{ zabbix_agent_tlspskidentity | default(omit) }}" + tls_issuer: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}" + tls_subject: "{{ zabbix_agent_tlsservercertsubject | default(omit) }}" + tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent_tlsaccept if zabbix_agent_tlsaccept else 'unencrypted'] }}" + tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect if zabbix_agent_tlsconnect else 'unencrypted'] }}" + validate_certs: "{{ zabbix_validate_certs | default(omit) }}" + description: "{{ zabbix_agent_description | default(omit) }}" + inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}" + ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}" + ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}" + ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}" + ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}" + when: + - not zabbix_agent2 + register: zabbix_api_host_created + until: zabbix_api_host_created is succeeded + delegate_to: localhost + become: no + changed_when: false + tags: + - api + +- name: "API | Create a new host using agent2 or update an existing host's info" + zabbix_host: + server_url: "{{ zabbix_url }}" + http_login_user: "{{ zabbix_api_http_user | default(omit) }}" + http_login_password: "{{ zabbix_api_http_password | default(omit) }}" + login_user: "{{ zabbix_api_user }}" + login_password: "{{ zabbix_api_pass }}" + host_name: "{{ zabbix_agent_hostname }}" + host_groups: "{{ zabbix_host_groups }}" + link_templates: "{{ zabbix_link_templates }}" + status: "{{ zabbix_host_status }}" + state: "{{ zabbix_create_host }}" + force: "{{ zabbix_update_host }}" + proxy: "{{ zabbix_proxy }}" + inventory_mode: "{{ zabbix_inventory_mode }}" + interfaces: "{{ zabbix_agent_interfaces }}" + visible_name: "{{ zabbix_visible_hostname | default(zabbix_agent_hostname) }}" + tls_psk: "{{ zabbix_agent2_tlspsk_secret | default(omit) }}" + tls_psk_identity: "{{ zabbix_agent2_tlspskidentity | default(omit) }}" + tls_issuer: "{{ zabbix_agent2_tlsservercertissuer | default(omit) }}" + tls_subject: "{{ zabbix_agent2_tlsservercertsubject | default(omit) }}" + tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsaccept if zabbix_agent2_tlsaccept else 'unencrypted'] }}" + tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsconnect if zabbix_agent2_tlsconnect else 'unencrypted'] }}" + validate_certs: "{{ zabbix_validate_certs | default(omit) }}" + description: "{{ zabbix_agent_description | default(omit) }}" + inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}" + ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}" + ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}" + ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}" + ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}" + when: + - zabbix_agent2 | bool + register: zabbix_api_host_created + until: zabbix_api_host_created is succeeded + delegate_to: localhost + become: no + changed_when: false + tags: + - api + +- name: "API | Updating host configuration with macros" + zabbix_hostmacro: + server_url: "{{ zabbix_url }}" + http_login_user: "{{ zabbix_api_http_user | default(omit) }}" + http_login_password: "{{ zabbix_api_http_password | default(omit) }}" + login_user: "{{ zabbix_api_user }}" + login_password: "{{ zabbix_api_pass }}" + host_name: "{{ zabbix_agent_hostname }}" + macro_name: "{{ item.macro_key }}" + macro_value: "{{ item.macro_value }}" + validate_certs: "{{ zabbix_validate_certs | default(omit) }}" + with_items: "{{ zabbix_macros | default([]) }}" + when: + - zabbix_macros is defined + - item.macro_key is defined + register: zabbix_api_hostmarcro_created + until: zabbix_api_hostmarcro_created is succeeded + delegate_to: localhost + become: no + tags: + - api diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/firewall.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/firewall.yml new file mode 100644 index 00000000..50fc388d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/firewall.yml @@ -0,0 +1,53 @@ +--- + +- name: "Firewall | Configure IPTables (zabbix_agent_listenport)" + iptables: + action: "{{ zabbix_agent_firewall_action }}" + destination_port: "{{ zabbix_agent_listenport | string }}" + source: "{{ zabbix_agent_firewall_source | default(omit) }}" + protocol: tcp + chain: "{{ zabbix_agent_firewall_chain }}" + jump: ACCEPT + become: yes + when: + - zabbix_agent_firewall_enable | bool + +- name: "Firewall | Configure IPTables (zabbix_agent_jmx_listenport)" + iptables: + action: "{{ zabbix_agent_firewall_action }}" + destination_port: "{{ zabbix_agent_listenport | string }}" + source: "{{ zabbix_agent_firewall_source | default(omit) }}" + protocol: tcp + chain: "{{ zabbix_agent_firewall_chain }}" + jump: ACCEPT + become: yes + when: + - zabbix_agent_firewall_enable | bool + - zabbix_agent_jmx_listenport | bool + +- name: "Firewall | Configure firewalld (zabbix_agent_listenport)" + firewalld: + rich_rule: 'rule family="ipv4" source address="{{ zabbix_agent_firewalld_source }}" port protocol="tcp" port="{{ zabbix_agent_listenport }}" accept' + zone: "{{ zabbix_agent_firewalld_zone }}" + permanent: true + state: enabled + become: yes + when: + - zabbix_agent_firewalld_enable | bool + notify: + - firewalld-reload + tags: zabbix_agent_firewalld_enable + +- name: "Firewall | Configure firewalld (zabbix_agent_jmx_listenport)" + firewalld: + rich_rule: 'rule family="ipv4" source address="{{ zabbix_agent_firewalld_source }}" port protocol="tcp" port="{{ zabbix_agent_jmx_listenport }}" accept' + zone: "{{ zabbix_agent_firewalld_zone }}" + permanent: true + state: enabled + become: yes + when: + - zabbix_agent_firewalld_enable | bool + - zabbix_agent_jmx_listenport | bool + notify: + - firewalld-reload + tags: zabbix_agent_firewalld_enable diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/macOS.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/macOS.yml new file mode 100644 index 00000000..ef73dbeb --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/macOS.yml @@ -0,0 +1,24 @@ +--- +# Tasks specific for macOS +- name: "macOS | Check installed package version" + shell: | + set -o pipefail + pkgutil --pkg-info 'com.zabbix.pkg.ZabbixAgent' | grep 'version:' | cut -d ' ' -f 2 + register: pkgutil_version + check_mode: no + changed_when: false + failed_when: pkgutil_version.rc == 2 + +- name: "macOS | Download the Zabbix package" + get_url: + url: "{{ zabbix_mac_download_link }}" + dest: "/tmp/{{ zabbix_mac_package }}" + mode: 0644 + when: pkgutil_version.stdout != zabbix_version_long + +- name: "macOS | Install the Zabbix package" + command: installer -pkg "/tmp/{{ zabbix_mac_package }}" -target / + become: true + when: pkgutil_version.stdout != zabbix_version_long + tags: + - zabbix-agent diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml new file mode 100644 index 00000000..d4b565bf --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml @@ -0,0 +1,109 @@ +--- +# tasks file for dj-wasabi.zabbix-agent + +- name: "Set variables specific for Zabbix Agent 2" + set_fact: + zabbix_agent_service: zabbix-agent2 + zabbix_agent_package: zabbix-agent2 + when: + - zabbix_agent2 is defined + - zabbix_agent2 + tags: + - always + +- name: "Fix facts for linuxmint - distribution release" + set_fact: + zabbix_agent_distribution_release: xenial + when: + - ansible_os_family == "Linuxmint" + - ansible_distribution_release == "sonya" or ansible_distribution_release == "serena" + tags: + - always + +- name: "Fix facts for linuxmint - family" + set_fact: + zabbix_agent_os_family: Debian + when: + - ansible_os_family == "Linuxmint" + tags: + - always + +- name: "Fix facts for XCP-ng - family" + set_fact: + zabbix_agent_os_family: RedHat + when: + - ansible_os_family == "XCP-ng" + +- name: "Include OS-specific variables" + include_vars: "{{ zabbix_agent_os_family }}.yml" + tags: + - always + +- name: "Install the correct repository" + include_tasks: "{{ zabbix_agent_os_family if (zabbix_agent_os_family not in ['Sangoma']) else 'RedHat' }}.yml" + when: + - not (zabbix_agent_docker | bool) + tags: + - always + +- name: "Install local python-netaddr package" + pip: + name: netaddr + state: present + register: zabbix_python_netaddr_package_installed + until: zabbix_python_netaddr_package_installed is succeeded + delegate_to: localhost + run_once: True + become: "{{ zabbix_agent_become_on_localhost }}" + when: + - zabbix_install_pip_packages | bool + - ansible_all_ipv4_addresses is defined or (zabbix_agent_ip is not defined and total_private_ip_addresses is defined) + +- name: "Encrypt with TLS PSK auto management" + include_tasks: tlspsk_auto.yml + when: + - not zabbix_agent2 + - zabbix_agent_tlspsk_auto | bool + - (zabbix_agent_tlspskfile is undefined) or (zabbix_agent_tlspskfile | length == '0') + - (zabbix_agent_tlspsk_secret is undefined) or (zabbix_agent_tlspsk_secret | length == '0') + +- name: "Encrypt with TLS PSK auto management" + include_tasks: tlspsk_auto_agent2.yml + when: + - zabbix_agent2 | bool + - zabbix_agent2_tlspsk_auto | bool + - (zabbix_agent2_tlspskfile is undefined) or (zabbix_agent2_tlspskfile | length == '0') + - (zabbix_agent2_tlspsk_secret is undefined) or (zabbix_agent2_tlspsk_secret | length == '0') + +- name: "Install the correct repository" + include_tasks: Windows.yml + when: + - zabbix_agent_os_family == "Windows" + tags: + - always + +- name: "Install the correct repository" + include_tasks: Linux.yml + when: + - (zabbix_agent_os_family != "Windows" and zabbix_agent_os_family != "Darwin") or (zabbix_agent_docker | bool) + tags: + - always + +- name: "Install the correct repository" + include_tasks: macOS.yml + when: + - zabbix_agent_os_family == "Darwin" + tags: + - always + +- name: "Run the API calls to Zabbix Server" + include_tasks: api.yml + when: + - (zabbix_api_create_hostgroup | bool) or (zabbix_api_create_hosts | bool) + +- name: "Including userparameters" + include_tasks: "userparameter.yml" + when: zabbix_agent_userparameters|length > 0 + tags: + - zabbix-agent + - userparameter diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/remove.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/remove.yml new file mode 100644 index 00000000..57851860 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/remove.yml @@ -0,0 +1,20 @@ +--- + +- name: "Remove | Make sure the \"old\" zabbix-agent service is running" + service: + name: "{{ zabbix_agent_service }}" + state: stopped + enabled: no + become: yes + +- name: "Remove | package removal" + package: + name: "zabbix-agent" + state: absent + become: yes + +- name: "Remove | Remove the agent-include-dir" + file: + path: "{{ zabbix_agent_include }}" + state: absent + become: yes diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/selinux.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/selinux.yml new file mode 100644 index 00000000..fb61bfdc --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/selinux.yml @@ -0,0 +1,102 @@ +--- + +- name: "SELinux | Debian | Install policycoreutils-python" + apt: + pkg: policycoreutils-python-utils + state: present + update_cache: yes + cache_valid_time: 0 + force_apt_get: "{{ zabbix_apt_force_apt_get }}" + install_recommends: "{{ zabbix_apt_install_recommends }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_agent_policycoreutils_installed + until: zabbix_agent_package_installed is succeeded + become: yes + when: + - zabbix_agent_os_family == "Debian" + +- name: "SELinux | RedHat | Install policycoreutils-python" + package: + name: policycoreutils-python + state: installed + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_agent_policycoreutils_installed + until: zabbix_agent_policycoreutils_installed is succeeded + when: + - zabbix_agent_os_family == "RedHat" + - (zabbix_agent_distribution_major_version == "6" or zabbix_agent_distribution_major_version == "7") + become: yes + tags: + - init + - zabbix-agent + +- name: "SELinux | RedHat | Install python3-policycoreutils on RHEL8" + package: + name: python3-policycoreutils + state: installed + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_agent_policycoreutils_installed + until: zabbix_agent_policycoreutils_installed is succeeded + when: + - zabbix_agent_os_family == "RedHat" + - ansible_distribution_major_version == "8" + become: yes + tags: + - init + - zabbix-agent + +- name: "SELinux | RedHat | Install selinux-policy-targeted" + package: + name: selinux-policy-targeted + state: installed + register: zabbix_agent_selinuxpolicytargeted_installed + until: zabbix_agent_selinuxpolicytargeted_installed is succeeded + when: + - zabbix_agent_os_family == "RedHat" + become: yes + tags: + - init + - zabbix-agent + +# straight to getenforce binary , workaround for missing python_selinux library +- name: "SELinux | Get getenforce binary" + stat: + path: /usr/sbin/getenforce + register: getenforce_bin + become: yes + +- name: "SELinux | Collect getenforce output" + command: /usr/sbin/getenforce + register: sestatus + when: 'getenforce_bin.stat.exists' + changed_when: false + become: yes + check_mode: no + +- name: "SELinux | Set zabbix_selinux to true if getenforce returns Enforcing or Permissive" + set_fact: + zabbix_selinux: "{{ true }}" + when: + - 'getenforce_bin.stat.exists and ("Enforcing" in sestatus.stdout or "Permissive" in sestatus.stdout)' + +- name: "SELinux | Allow zabbix_agent to start (SELinux)" + selinux_permissive: + name: zabbix_agent_t + permissive: true + become: yes + +- name: "SELinux | Allow zabbix to run sudo commands (SELinux)" + seboolean: + name: zabbix_run_sudo + persistent: yes + state: yes + when: + - ansible_selinux.status == "enabled" + - selinux_allow_zabbix_run_sudo|bool + tags: selinux diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/tlspsk_auto.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/tlspsk_auto.yml new file mode 100644 index 00000000..81221bd8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/tlspsk_auto.yml @@ -0,0 +1,85 @@ +--- +- name: AutoPSK | Set default path variables for Linux + set_fact: + zabbix_agent_tlspskfile: "/etc/zabbix/tls_psk_auto.secret" + zabbix_agent_tlspskidentity_file: "/etc/zabbix/tls_psk_auto.identity" + when: (zabbix_agent_os_family != "Windows") or (zabbix_agent_docker | bool) + +- name: AutoPSK | Set default path variables for Windows + set_fact: + zabbix_agent_tlspskfile: "{{ zabbix_win_install_dir }}\tls_psk_auto.secret.txt" + zabbix_agent_tlspskidentity_file: "{{ zabbix_win_install_dir }}\tls_psk_auto.identity.txt" + when: zabbix_agent_os_family == "Windows" + +- name: AutoPSK | Check for existing TLS PSK file + stat: + path: "{{ zabbix_agent_tlspskfile }}" + register: zabbix_agent_tlspskcheck + become: yes + +- name: AutoPSK | read existing TLS PSK file + slurp: + src: "{{ zabbix_agent_tlspskfile }}" + register: zabbix_agent_tlspsk_base64 + become: yes + when: zabbix_agent_tlspskcheck.stat.exists + +- name: AutoPSK | Save existing TLS PSK secret + set_fact: + zabbix_agent_tlspsk_read: "{{ zabbix_agent_tlspsk_base64['content'] | b64decode | trim }}" + when: zabbix_agent_tlspskcheck.stat.exists + +- name: AutoPSK | Use existing TLS PSK secret + set_fact: + zabbix_agent_tlspsk_secret: "{{ zabbix_agent_tlspsk_read }}" + when: zabbix_agent_tlspskcheck.stat.exists and zabbix_agent_tlspsk_read|length >= 32 + +- name: AutoPSK | Generate new TLS PSK secret + set_fact: + zabbix_agent_tlspsk_secret: "{{ lookup('password', '/dev/null chars=hexdigits length=64') }}" + when: not zabbix_agent_tlspskcheck.stat.exists or zabbix_agent_tlspsk_read|length < 32 + +- name: AutoPSK | Check for existing TLS PSK identity + stat: + path: "{{ zabbix_agent_tlspskidentity_file }}" + register: zabbix_agent_tlspskidentity_check + become: yes + +- name: AutoPSK | Read existing TLS PSK identity file + slurp: + src: "{{ zabbix_agent_tlspskidentity_file }}" + register: zabbix_agent_tlspskidentity_base64 + become: yes + when: zabbix_agent_tlspskidentity_check.stat.exists + +- name: AutoPSK | Use existing TLS PSK identity + set_fact: + zabbix_agent_tlspskidentity: "{{ zabbix_agent_tlspskidentity_base64['content'] | b64decode | trim }}" + when: zabbix_agent_tlspskidentity_check.stat.exists + +- name: AutoPSK | Generate new TLS PSK identity + set_fact: + zabbix_agent_tlspskidentity: "{{ zabbix_visible_hostname | default(zabbix_agent_hostname) + '_' + lookup('password', '/dev/null chars=hexdigits length=4') }}" + when: not zabbix_agent_tlspskidentity_check.stat.exists + +- name: AutoPSK | Template TLS PSK identity in file + copy: + dest: "{{ zabbix_agent_tlspskidentity_file }}" + content: "{{ zabbix_agent_tlspskidentity }}" + owner: zabbix + group: zabbix + mode: 0400 + become: yes + when: + - zabbix_agent_tlspskidentity_file is defined + - zabbix_agent_tlspskidentity is defined + notify: + - restart zabbix-agent + - restart win zabbix agent + - restart mac zabbix agent + +- name: AutoPSK | Default tlsaccept and tlsconnect to enforce PSK + set_fact: + zabbix_agent_tlsaccept: psk + zabbix_agent_tlsconnect: psk + when: zabbix_api_create_hosts diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml new file mode 100644 index 00000000..047048ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml @@ -0,0 +1,85 @@ +--- +- name: AutoPSK | Set default path variables for Linux + set_fact: + zabbix_agent2_tlspskfile: "/etc/zabbix/tls_psk_auto.secret" + zabbix_agent2_tlspskidentity_file: "/etc/zabbix/tls_psk_auto.identity" + when: (zabbix_agent_os_family != "Windows") or (zabbix_agent_docker | bool) + +- name: AutoPSK | Set default path variables for Windows + set_fact: + zabbix_agent2_tlspskfile: "{{ zabbix_win_install_dir }}\tls_psk_auto.secret.txt" + zabbix_agent2_tlspskidentity_file: "{{ zabbix_win_install_dir }}\tls_psk_auto.identity.txt" + when: zabbix_agent_os_family == "Windows" + +- name: AutoPSK | Check for existing TLS PSK file + stat: + path: "{{ zabbix_agent2_tlspskfile }}" + register: zabbix_agent2_tlspskcheck + become: yes + +- name: AutoPSK | read existing TLS PSK file + slurp: + src: "{{ zabbix_agent2_tlspskfile }}" + register: zabbix_agent2_tlspsk_base64 + become: yes + when: zabbix_agent2_tlspskcheck.stat.exists + +- name: AutoPSK | Save existing TLS PSK secret + set_fact: + zabbix_agent2_tlspsk_read: "{{ zabbix_agent2_tlspsk_base64['content'] | b64decode | trim }}" + when: zabbix_agent2_tlspskcheck.stat.exists + +- name: AutoPSK | Use existing TLS PSK secret + set_fact: + zabbix_agent2_tlspsk_secret: "{{ zabbix_agent2_tlspsk_read }}" + when: zabbix_agent2_tlspskcheck.stat.exists and zabbix_agent2_tlspsk_read|length >= 32 + +- name: AutoPSK | Generate new TLS PSK secret + set_fact: + zabbix_agent2_tlspsk_secret: "{{ lookup('password', '/dev/null chars=hexdigits length=64') }}" + when: not zabbix_agent2_tlspskcheck.stat.exists or zabbix_agent2_tlspsk_read|length < 32 + +- name: AutoPSK | Check for existing TLS PSK identity + stat: + path: "{{ zabbix_agent2_tlspskidentity_file }}" + register: zabbix_agent2_tlspskidentity_check + become: yes + +- name: AutoPSK | Read existing TLS PSK identity file + slurp: + src: "{{ zabbix_agent2_tlspskidentity_file }}" + register: zabbix_agent2_tlspskidentity_base64 + become: yes + when: zabbix_agent2_tlspskidentity_check.stat.exists + +- name: AutoPSK | Use existing TLS PSK identity + set_fact: + zabbix_agent2_tlspskidentity: "{{ zabbix_agent2_tlspskidentity_base64['content'] | b64decode | trim }}" + when: zabbix_agent2_tlspskidentity_check.stat.exists + +- name: AutoPSK | Generate new TLS PSK identity + set_fact: + zabbix_agent2_tlspskidentity: "{{ zabbix_visible_hostname | default(zabbix_agent_hostname) + '_' + lookup('password', '/dev/null chars=hexdigits length=4') }}" + when: not zabbix_agent2_tlspskidentity_check.stat.exists + +- name: AutoPSK | Template TLS PSK identity in file + copy: + dest: "{{ zabbix_agent2_tlspskidentity_file }}" + content: "{{ zabbix_agent2_tlspskidentity }}" + owner: zabbix + group: zabbix + mode: 0400 + become: yes + when: + - zabbix_agent2_tlspskidentity_file is defined + - zabbix_agent2_tlspskidentity is defined + notify: + - restart zabbix-agent + - restart win zabbix agent + - restart mac zabbix agent + +- name: AutoPSK | Default tlsaccept and tlsconnect to enforce PSK + set_fact: + zabbix_agent2_tlsaccept: psk + zabbix_agent2_tlsconnect: psk + when: zabbix_api_create_hosts diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/userparameter.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/userparameter.yml new file mode 100644 index 00000000..3d3d066e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/userparameter.yml @@ -0,0 +1,85 @@ +--- +- block: + - name: "Windows | Installing user-defined userparameters" + win_template: + src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2" + dest: '{{ zabbix_agent_win_include }}\{{ item.name }}.conf' + notify: + - restart win zabbix agent + with_items: "{{ zabbix_agent_userparameters }}" + + - name: "Windows | Installing user-defined scripts" + win_copy: + src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}" + dest: '{{ zabbix_win_install_dir }}\scripts\' + notify: + - restart win zabbix agent + with_items: "{{ zabbix_agent_userparameters }}" + when: item.scripts_dir is defined + + when: zabbix_agent_os_family == "Windows" + + +- block: + - name: "Installing user-defined userparameters" + template: + src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2" + dest: "{{ zabbix_agent_include }}/userparameter_{{ item.name }}.conf" + owner: zabbix + group: zabbix + mode: 0644 + notify: + - restart zabbix-agent + - restart mac zabbix agent + become: yes + with_items: "{{ zabbix_agent_userparameters }}" + + - name: "Installing user-defined scripts" + copy: + src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}" + dest: "/etc/zabbix/scripts/" + owner: zabbix + group: zabbix + mode: 0755 + notify: + - restart zabbix-agent + - restart mac zabbix agent + become: yes + with_items: "{{ zabbix_agent_userparameters }}" + when: item.scripts_dir is defined + + when: + - zabbix_agent_os_family != "Windows" + - not zabbix_agent2 + +- block: + - name: "Installing user-defined userparameters" + template: + src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2" + dest: "{{ zabbix_agent2_include }}/userparameter_{{ item.name }}.conf" + owner: zabbix + group: zabbix + mode: 0644 + notify: + - restart zabbix-agent + - restart mac zabbix agent + become: yes + with_items: "{{ zabbix_agent_userparameters }}" + + - name: "Installing user-defined scripts" + copy: + src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}" + dest: "/etc/zabbix/scripts/" + owner: zabbix + group: zabbix + mode: 0755 + notify: + - restart zabbix-agent + - restart mac zabbix agent + become: yes + with_items: "{{ zabbix_agent_userparameters }}" + when: item.scripts_dir is defined + + when: + - zabbix_agent_os_family != "Windows" + - zabbix_agent2 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/userparameters/mysql.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/userparameters/mysql.j2 new file mode 100644 index 00000000..64087779 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/userparameters/mysql.j2 @@ -0,0 +1,3 @@ +# This is an sample userparameters file. + +UserParameter=mysql.ping_to,mysqladmin -uroot ping | grep -c alive diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/userparameters/win_sample.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/userparameters/win_sample.j2 new file mode 100644 index 00000000..2a27b634 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/userparameters/win_sample.j2 @@ -0,0 +1 @@ +UserParameter=do.something, powershell -NoProfile -ExecutionPolicy Bypass -File {{ zabbix_win_install_dir }}\scripts\{{ item.name }}\doSomething.ps1 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/zabbix_agent2.conf.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/zabbix_agent2.conf.j2 new file mode 100644 index 00000000..efd749ed --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/zabbix_agent2.conf.j2 @@ -0,0 +1,453 @@ +# This is a configuration file for Zabbix agent 2 (Unix) +# To get more information about Zabbix, visit http://www.zabbix.com + +############ GENERAL PARAMETERS ################# + +### Option: PidFile +# Name of PID file. +# +# Mandatory: no +# Default: + +PidFile={{ zabbix_agent2_pidfile }} + +### Option: LogType +# Specifies where log messages are written to: +# system - syslog +# file - file specified with LogFile parameter +# console - standard output +# +# Mandatory: no +# Default: + +LogType={{ zabbix_agent2_logtype }} + +### Option: LogFile +# Log file name for LogType 'file' parameter. +# +# Mandatory: yes, if LogType is set to file, otherwise no +# Default: + +LogFile={{ zabbix_agent2_logfile }} + +### Option: LogFileSize +# Maximum size of log file in MB. +# 0 - disable automatic log rotation. +# +# Mandatory: no +# Range: 0-1024 +# Default: + +LogFileSize={{ zabbix_agent2_logfilesize }} + +### Option: DebugLevel +# Specifies debug level: +# 0 - basic information about starting and stopping of Zabbix processes +# 1 - critical information +# 2 - error information +# 3 - warnings +# 4 - for debugging (produces lots of information) +# 5 - extended debugging (produces even more information) +# +# Mandatory: no +# Range: 0-5 +# Default: +DebugLevel={{ zabbix_agent2_debuglevel }} + +### Option: SourceIP +# Source IP address for outgoing connections. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_sourceip is defined and zabbix_agent2_sourceip %} +SourceIP={{ zabbix_agent2_sourceip }} +{% endif %} + +##### Passive checks related + +### Option: Server +# List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies. +# Incoming connections will be accepted only from the hosts listed here. +# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally +# and '::/0' will allow any IPv4 or IPv6 address. +# '0.0.0.0/0' can be used to allow any IPv4 address. +# Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com +# +# Mandatory: yes, if StartAgents is not explicitly set to 0 +# Default: + +Server={{ zabbix_agent_server }} + +### Option: ListenPort +# Agent will listen on this port for connections from the server. +# +# Mandatory: no +# Range: 1024-32767 +# Default: + +ListenPort={{ zabbix_agent2_listenport }} + +### Option: ListenIP +# List of comma delimited IP addresses that the agent should listen on. +# First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_listenip is defined and zabbix_agent2_listenip !='0.0.0.0' and zabbix_agent2_listenip %} +ListenIP={{ zabbix_agent2_listenip }} +{% endif %} + +### Option: StatusPort +# Agent will listen on this port for HTTP status requests. +# +# Mandatory: no +# Range: 1024-32767 +# Default: +# StatusPort= +StatusPort={{ zabbix_agent2_statusport }} + +##### Active checks related + +### Option: ServerActive +# List of comma delimited IP:port (or DNS name:port) pairs of Zabbix servers and Zabbix proxies for active checks. +# If port is not specified, default port is used. +# IPv6 addresses must be enclosed in square brackets if port for that host is specified. +# If port is not specified, square brackets for IPv6 addresses are optional. +# If this parameter is not specified, active checks are disabled. +# Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1] +# +# Mandatory: no +# Default: +# ServerActive= + +ServerActive={{ zabbix_agent_serveractive }} + +### Option: Hostname +# Unique, case sensitive hostname. +# Required for active checks and must match hostname as configured on the server. +# Value is acquired from HostnameItem if undefined. +# +# Mandatory: no +# Default: + +{% if zabbix_agent2_hostname is defined and zabbix_agent2_hostname %} +Hostname={{ zabbix_agent2_hostname }} +{% endif %} + +### Option: HostnameItem +# Item used for generating Hostname if it is undefined. Ignored if Hostname is defined. +# Does not support UserParameters or aliases. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_hostnameitem is defined and zabbix_agent2_hostnameitem %} +HostnameItem={{ zabbix_agent2_hostnameitem }} +{% endif %} + +### Option: HostMetadata +# Optional parameter that defines host metadata. +# Host metadata is used at host auto-registration process. +# An agent will issue an error and not start if the value is over limit of 255 characters. +# If not defined, value will be acquired from HostMetadataItem. +# +# Mandatory: no +# Range: 0-255 characters +# Default: +{% if zabbix_agent2_hostmetadata is defined and zabbix_agent2_hostmetadata %} +HostMetadata={{ zabbix_agent2_hostmetadata }} +{% endif %} + +### Option: HostMetadataItem +# Optional parameter that defines an item used for getting host metadata. +# Host metadata is used at host auto-registration process. +# During an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# This option is only used when HostMetadata is not defined. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_hostmetadataitem is defined and zabbix_agent2_hostmetadataitem %} +HostMetadataItem={{ zabbix_agent2_hostmetadataitem }} +{% endif %} + +### Option: HostInterface +# Optional parameter that defines host interface. +# Host interface is used at host auto-registration process. +# An agent will issue an error and not start if the value is over limit of 255 characters. +# If not defined, value will be acquired from HostInterfaceItem. +# +# Mandatory: no +# Range: 0-255 characters +# Default: +# HostInterface= +{% if zabbix_agent2_hostinterface is defined and zabbix_agent2_hostinterface %} +HostInterface={{ zabbix_agent2_hostinterface }} +{% endif %} + +### Option: HostInterfaceItem +# Optional parameter that defines an item used for getting host interface. +# Host interface is used at host auto-registration process. +# During an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# This option is only used when HostInterface is not defined. +# +# Mandatory: no +# Default: +# HostInterfaceItem= +{% if zabbix_agent2_hostinterfaceitem is defined and zabbix_agent2_hostinterfaceitem %} +HostInterfaceItem={{ zabbix_agent2_hostinterfaceitem }} +{% endif %} + +### Option: RefreshActiveChecks +# How often list of active checks is refreshed, in seconds. +# +# Mandatory: no +# Range: 60-3600 +# Default: +RefreshActiveChecks={{ zabbix_agent2_refreshactivechecks }} + +### Option: BufferSend +# Do not keep data longer than N seconds in buffer. +# +# Mandatory: no +# Range: 1-3600 +# Default: +BufferSend={{ zabbix_agent2_buffersend }} + +### Option: BufferSize +# Maximum number of values in a memory buffer. The agent will send +# all collected data to Zabbix Server or Proxy if the buffer is full. +# Option is not valid if EnablePersistentBuffer=1 +# +# Mandatory: no +# Range: 2-65535 +# Default: +BufferSize={{ zabbix_agent2_buffersize }} + +### Option: EnablePersistentBuffer: +# 0 - disabled, in-memory buffer is used (default); 1 - use persistent buffer +# Mandatory: no +# Range: 0-1 +# Default: +{% if zabbix_agent2_enablepersistentbuffer is defined and zabbix_agent2_enablepersistentbuffer %} +EnablePersistentBuffer={{ zabbix_agent2_enablepersistentbuffer }} +{% endif %} + +### Option: PersistentBufferPeriod +# Zabbix Agent2 will keep data for this time period in case of no +# connectivity with Zabbix server or proxy. Older data will be lost. Log data will be preserved. +# Option is valid if EnablePersistentBuffer=1 +# +# Mandatory: no +# Range: 1m-365d +# Default: +{% if zabbix_agent2_persistentbufferperiod is defined and zabbix_agent2_persistentbufferperiod %} +PersistentBufferPeriod={{ zabbix_agent2_persistentbufferperiod }} +{% endif %} + +### Option: PersistentBufferFile +# full filename. Zabbix Agent2 will keep SQLite database in this file +# Option is valid if EnablePersistentBuffer=1 +# +# Mandatory: no +# Default: +# PersistentBufferFile= +{% if zabbix_agent2_persistentbufferfile is defined and zabbix_agent2_persistentbufferfile %} +PersistentBufferFile={{ zabbix_agent2_persistentbufferfile }} +{% endif %} + +############ ADVANCED PARAMETERS ################# + +### Option: Alias +# Sets an alias for an item key. It can be used to substitute long and complex item key with a smaller and simpler one. +# Multiple Alias parameters may be present. Multiple parameters with the same Alias key are not allowed. +# Different Alias keys may reference the same item key. +# For example, to retrieve the ID of user 'zabbix': +# Alias=zabbix.userid:vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1] +# Now shorthand key zabbix.userid may be used to retrieve data. +# Aliases can be used in HostMetadataItem but not in HostnameItem parameters. +# +# Mandatory: no +# Range: +# Default: +{% if zabbix_agent2_zabbix_alias is defined and zabbix_agent2_zabbix_alias %} +Alias={{ zabbix_agent2_zabbix_alias }} +{% endif %} + +### Option: Timeout +# Spend no more than Timeout seconds on processing +# +# Mandatory: no +# Range: 1-30 +# Default: +Timeout={{ zabbix_agent2_timeout }} + +### Option: Include +# You may include individual files or all files in a directory in the configuration file. +# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. +# +# Mandatory: no +# Default: + +{% if zabbix_agent_os_family == "Windows" %} +Include={{ zabbix_agent_win_include }} +{% else %} +Include={{ zabbix_agent2_include }} +{% endif %} + +####### USER-DEFINED MONITORED PARAMETERS ####### + +### Option: UnsafeUserParameters +# Allow all characters to be passed in arguments to user-defined parameters. +# The following characters are not allowed: +# \ ' " ` * ? [ ] { } ~ $ ! & ; ( ) < > | # @ +# Additionally, newline characters are not allowed. +# 0 - do not allow +# 1 - allow +# +# Mandatory: no +# Range: 0-1 +# Default: +UnsafeUserParameters={{ zabbix_agent2_unsafeuserparameters }} + +### Option: UserParameter +# User-defined parameter to monitor. There can be several user-defined parameters. +# Format: UserParameter=, +# See 'zabbix_agentd' directory for examples. +# +# Mandatory: no +# Default: + +# disabled. an configuration file should be placed on directory: {{ zabbix_agent_include }} + +### Option: ControlSocket +# The control socket, used to send runtime commands with '-R' option. +# +# Mandatory: no +# Default: +# ControlSocket= + +ControlSocket={{ zabbix_agent2_controlsocket }} + +####### TLS-RELATED PARAMETERS ####### + +### Option: TLSConnect +# How the agent should connect to server or proxy. Used for active checks. +# Only one value can be specified: +# unencrypted - connect without encryption +# psk - connect using TLS and a pre-shared key +# cert - connect using TLS and a certificate +# +# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection) +# Default: +{% if zabbix_agent2_tlsconnect is defined and zabbix_agent2_tlsconnect %} +TLSConnect={{ zabbix_agent2_tlsconnect }} +{% endif %} + +### Option: TLSAccept +# What incoming connections to accept. +# Multiple values can be specified, separated by comma: +# unencrypted - accept connections without encryption +# psk - accept connections secured with TLS and a pre-shared key +# cert - accept connections secured with TLS and a certificate +# +# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection) +# Default: +{% if zabbix_agent2_tlsaccept is defined and zabbix_agent2_tlsaccept %} +TLSAccept={{ zabbix_agent2_tlsaccept }} +{% endif %} + +### Option: TLSCAFile +# Full pathname of a file containing the top-level CA(s) certificates for +# peer certificate verification. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_tlscafile is defined and zabbix_agent2_tlscafile %} +TLSCAFile={{ zabbix_agent2_tlscafile }} +{% endif %} + +### Option: TLSCRLFile +# Full pathname of a file containing revoked certificates. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_tlscrlfile is defined and zabbix_agent2_tlscrlfile %} +TLSCRLFile={{ zabbix_agent2_tlscrlfile }} +{% endif %} + +### Option: TLSServerCertIssuer +# Allowed server certificate issuer. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_tlsservercertissuer is defined and zabbix_agent2_tlsservercertissuer %} +TLSServerCertIssuer={{ zabbix_agent2_tlsservercertissuer }} +{% endif %} + +### Option: TLSServerCertSubject +# Allowed server certificate subject. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_tlsservercertsubject is defined and zabbix_agent2_tlsservercertsubject %} +TLSServerCertSubject={{ zabbix_agent2_tlsservercertsubject }} +{% endif %} + +### Option: TLSCertFile +# Full pathname of a file containing the agent certificate or certificate chain. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_tlscertfile is defined and zabbix_agent2_tlscertfile %} +TLSCertFile={{ zabbix_agent2_tlscertfile }} +{% endif %} + +### Option: TLSKeyFile +# Full pathname of a file containing the agent private key. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_tlskeyfile is defined and zabbix_agent2_tlskeyfile %} +TLSKeyFile={{ zabbix_agent2_tlskeyfile }} +{% endif %} + +### Option: TLSPSKIdentity +# Unique, case sensitive string used to identify the pre-shared key. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_tlspskidentity is defined and zabbix_agent2_tlspskidentity %} +TLSPSKIdentity={{ zabbix_agent2_tlspskidentity }} +{% endif %} + +### Option: TLSPSKFile +# Full pathname of a file containing the pre-shared key. +# +# Mandatory: no +# Default: +{% if zabbix_agent2_tlspskfile is defined and zabbix_agent2_tlspskfile %} +TLSPSKFile={{ zabbix_agent2_tlspskfile }} +{% endif %} + +####### PLUGIN-SPECIFIC PARAMETERS ####### + +### Option: Plugins +# A plugin can have one or more plugin specific configuration parameters in format: +# Plugins..= +# Plugins..= +# +# Mandatory: no +# Range: +# Default: + +{% if zabbix_agent2_plugins is defined and zabbix_agent2_plugins is iterable %} +{% for entry in zabbix_agent2_plugins %} +{% set my_name = entry['name'] %} +{% for property in entry['options'] %} +{% set param = property['parameter'] %} +{% set value = property['value'] %} +Plugins.{{ my_name }}.{{ param }}={{ value }} +{% endfor %} +{% endfor %} +{% endif %} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/zabbix_agentd.conf.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/zabbix_agentd.conf.j2 new file mode 100644 index 00000000..00518481 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/templates/zabbix_agentd.conf.j2 @@ -0,0 +1,366 @@ +{{ ansible_managed | comment }} +# this is a config file for zabbix agent +# to get more information about zabbix, visit http://www.zabbix.com + +############ general parameters ################# + +### option: pidfile +# name of pid file. +# +{% if zabbix_agent_os_family != "Windows" %} +PidFile={{ zabbix_agent_pidfile }} +{% endif %} + +### option: logfile +# name of log file. +# if not set, syslog is used. +# +{% if zabbix_agent_os_family == "Windows" %} +LogFile={{ zabbix_agent_win_logfile }} +{% else %} +LogFile={{ zabbix_agent_logfile }} +{% endif %} + +### option: logfilesize +# maximum size of log file in mb. +# 0 - disable automatic log rotation. +# +LogFileSize={{ zabbix_agent_logfilesize }} + +### option: debuglevel +# specifies debug level +# 0 - no debug +# 1 - critical information +# 2 - error information +# 3 - warnings +# 4 - for debugging (produces lots of information) +# +DebugLevel={{ zabbix_agent_debuglevel }} + + +### option: sourceip +# source ip address for outgoing connections. +# +{% if zabbix_agent_sourceip is defined and zabbix_agent_sourceip %} +SourceIP={{ zabbix_agent_sourceip }} +{% endif %} + +### option: enableremotecommands +# whether remote commands from zabbix server are allowed. +# 0 - not allowed +# 1 - allowed +# +EnableRemoteCommands={{ zabbix_agent_enableremotecommands }} + +### option: logremotecommands +# enable logging of executed shell commands as warnings. +# 0 - disabled +# 1 - enabled +# +LogRemoteCommands={{ zabbix_agent_logremotecommands }} + +##### passive checks related + +### option: server +# list of comma delimited ip addresses (or hostnames) of zabbix servers. +# incoming connections will be accepted only from the hosts listed here. +# no spaces allowed. +# if ipv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally. +# +# mandatory: yes +# default: +# server= +Server={{ zabbix_agent_server }} + +### option: listenport +# agent will listen on this port for connections from the server. +# +ListenPort={{ zabbix_agent_listenport }} + + +### option: listenip +# list of comma delimited ip addresses that the agent should listen on. +# first ip address is sent to zabbix server if connecting to it to retrieve list of active checks. +# +{% if zabbix_agent_listenip is defined and zabbix_agent_listenip !='0.0.0.0' and zabbix_agent_listenip %} +ListenIP={{ zabbix_agent_listenip }} +{% endif %} + +### option: startagents +# number of pre-forked instances of zabbix_agentd that process passive checks. +# if set to 0, disables passive checks and the agent will not listen on any tcp port. +# +StartAgents={{ zabbix_agent_startagents }} + +##### active checks related +### option: serveractive +# list of comma delimited ip:port (or hostname:port) pairs of zabbix servers for active checks. +# if port is not specified, default port is used. +# ipv6 addresses must be enclosed in square brackets if port for that host is specified. +# if port is not specified, square brackets for ipv6 addresses are optional. +# if this parameter is not specified, active checks are disabled. +# example: serveractive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1] +# +ServerActive={{ zabbix_agent_serveractive }} + +### option: hostname +# unique, case sensitive hostname. +# required for active checks and must match hostname as configured on the server. +# value is acquired from hostnameitem if undefined. +# +{% if zabbix_agent_hostname is defined and zabbix_agent_hostname %} +Hostname={{ zabbix_agent_hostname }} +{% endif %} + +### option: hostnameitem +# item used for generating hostname if it is undefined. +# ignored if hostname is defined. +# +{% if zabbix_agent_hostnameitem is defined and zabbix_agent_hostnameitem %} +HostnameItem={{ zabbix_agent_hostnameitem }} +{% endif %} + +### option: hostmetadata +# optional parameter that defines host metadata. +# host metadata is used at host auto-registration process. +# an agent will issue an error and not start if the value is over limit of 255 characters. +# if not defined, value will be acquired from hostmetadataitem. +# +{% if zabbix_agent_hostmetadata is defined and zabbix_agent_hostmetadata %} +HostMetadata={{ zabbix_agent_hostmetadata }} +{% endif %} + +### option: hostmetadataitem +# optional parameter that defines an item used for getting host metadata. +# host metadata is used at host auto-registration process. +# during an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# this option is only used when hostmetadata is not defined. +# +{% if zabbix_agent_hostmetadataitem is defined and zabbix_agent_hostmetadataitem %} +HostMetadataItem={{ zabbix_agent_hostmetadataitem }} +{% endif %} + +### option: refreshactivechecks +# how often list of active checks is refreshed, in seconds. +# +RefreshActiveChecks={{ zabbix_agent_refreshactivechecks }} + +### option: buffersend +# do not keep data longer than n seconds in buffer. +# +BufferSend={{ zabbix_agent_buffersend }} + +### option: buffersize +# maximum number of values in a memory buffer. the agent will send +# all collected data to zabbix server or proxy if the buffer is full. +# +BufferSize={{ zabbix_agent_buffersize }} + +### option: maxlinespersecond +# maximum number of new lines the agent will send per second to zabbix server +# or proxy processing 'log' and 'logrt' active checks. +# the provided value will be overridden by the parameter 'maxlines', +# provided in 'log' or 'logrt' item keys. +# +MaxLinesPerSecond={{ zabbix_agent_maxlinespersecond }} + +############ advanced parameters ################# + +### option: alias +# sets an alias for parameter. it can be useful to substitute long and complex parameter name with a smaller and simpler one. +# +{% if zabbix_agent_zabbix_alias is defined and zabbix_agent_zabbix_alias %} +Alias={{ zabbix_agent_zabbix_alias }} +{% endif %} + +### option: timeout +# spend no more than timeout seconds on processing +# +Timeout={{ zabbix_agent_timeout }} + +{% if zabbix_agent_os_family != "Windows" %} +### option: allowroot +# allow the agent to run as 'root'. if disabled and the agent is started by 'root', the agent +# will try to switch to user 'zabbix' instead. has no effect if started under a regular user. +# 0 - do not allow +# 1 - allow +# +AllowRoot={{ zabbix_agent_allowroot }} +{% endif %} + +### Option: User +# Drop privileges to a specific, existing user on the system. +# Only has effect if run as 'root' and AllowRoot is disabled. +# +# Mandatory: no +# Default: + +{% if zabbix_agent_runas_user is defined and zabbix_agent_runas_user %} +User={{ zabbix_agent_runas_user }} +{% endif %} + +### option: include +# you may include individual files or all files in a directory in the configuration file. +# installing zabbix will create include directory in /usr/local/etc, unless modified during the compile time. +# +{% if zabbix_agent_os_family == "Windows" %} +Include={{ zabbix_agent_win_include }} +{% else %} +Include={{ zabbix_agent_include }} +{% endif %} + +####### user-defined monitored parameters ####### + +### option: unsafeuserparameters +# allow all characters to be passed in arguments to user-defined parameters. +# 0 - do not allow +# 1 - allow +# +UnsafeUserParameters={{ zabbix_agent_unsafeuserparameters }} + +### option: userparameter +# user-defined parameter to monitor. there can be several user-defined parameters. +# format: userparameter=, +# note that shell command must not return empty string or eol only. +# see 'zabbix_agentd' directory for examples. +# +# mandatory: no +# default: +# userparameter= + +# disabled. an configuration file should be placed on directory: {{ zabbix_agent_include }} + +####### LOADABLE MODULES ####### +{% if zabbix_version is version_compare('2.2', '>=') %} +### Option: LoadModulePath +# Full path to location of agent modules. +# Default depends on compilation options. +# +{% if zabbix_agent_os_family != "Windows" %} +LoadModulePath={{ zabbix_agent_loadmodulepath }} +{% endif %} +{% endif %} + +### Option: LoadModule +# Module to load at agent startup. Modules are used to extend functionality of the agent. +# Format: LoadModule= +# The modules must be located in directory specified by LoadModulePath. +# It is allowed to include multiple LoadModule parameters. +# +{% if zabbix_agent_loadmodule is defined and zabbix_agent_loadmodule %} +LoadModule={{ zabbix_agent_loadmodule }} +{% endif %} + +{% if zabbix_version is version_compare('3.0', '>=') %} +####### TLS-RELATED PARAMETERS ####### + +### Option: TLSConnect +# How the agent should connect to server or proxy. Used for active checks. +# Only one value can be specified: +# unencrypted - connect without encryption +# psk - connect using TLS and a pre-shared key +# cert - connect using TLS and a certificate +# +# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection) +# Default: +# TLSConnect=unencrypted +{% if zabbix_agent_tlsconnect is defined and zabbix_agent_tlsconnect %} +TLSConnect={{ zabbix_agent_tlsconnect }} +{% endif %} + +### Option: TLSAccept +# What incoming connections to accept. +# Multiple values can be specified, separated by comma: +# unencrypted - accept connections without encryption +# psk - accept connections secured with TLS and a pre-shared key +# cert - accept connections secured with TLS and a certificate +# +# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection) +# Default: +# TLSAccept=unencrypted +{% if zabbix_agent_tlsaccept is defined and zabbix_agent_tlsaccept %} +TLSAccept={{ zabbix_agent_tlsaccept }} +{% endif %} + +### Option: TLSCAFile +# Full pathname of a file containing the top-level CA(s) certificates for +# peer certificate verification. +# +# Mandatory: no +# Default: +# TLSCAFile= +{% if zabbix_agent_tlscafile is defined and zabbix_agent_tlscafile %} +TLSCAFile={{ zabbix_agent_tlscafile }} +{% endif %} + +### Option: TLSCRLFile +# Full pathname of a file containing revoked certificates. +# +# Mandatory: no +# Default: +# TLSCRLFile= +{% if zabbix_agent_tlscrlfile is defined and zabbix_agent_tlscrlfile %} +TLSCRLFile={{ zabbix_agent_tlscrlfile }} +{% endif %} + +### Option: TLSServerCertIssuer +# Allowed server certificate issuer. +# +# Mandatory: no +# Default: +# TLSServerCertIssuer= +{% if zabbix_agent_tlsservercertissuer is defined and zabbix_agent_tlsservercertissuer %} +TLSServerCertIssuer={{ zabbix_agent_tlsservercertissuer }} +{% endif %} + +### Option: TLSServerCertSubject +# Allowed server certificate subject. +# +# Mandatory: no +# Default: +# TLSServerCertSubject= +{% if zabbix_agent_tlsservercertsubject is defined and zabbix_agent_tlsservercertsubject %} +TLSServerCertSubject={{ zabbix_agent_tlsservercertsubject }} +{% endif %} + +### Option: TLSCertFile +# Full pathname of a file containing the agent certificate or certificate chain. +# +# Mandatory: no +# Default: +# TLSCertFile= +{% if zabbix_agent_tlscertfile is defined and zabbix_agent_tlscertfile %} +TLSCertFile={{ zabbix_agent_tlscertfile }} +{% endif %} + +### Option: TLSKeyFile +# Full pathname of a file containing the agent private key. +# +# Mandatory: no +# Default: +# TLSKeyFile= +{% if zabbix_agent_tlskeyfile is defined and zabbix_agent_tlskeyfile %} +TLSKeyFile={{ zabbix_agent_tlskeyfile }} +{% endif %} + +### Option: TLSPSKIdentity +# Unique, case sensitive string used to identify the pre-shared key. +# +# Mandatory: no +# Default: +# TLSPSKIdentity= +{% if zabbix_agent_tlspskidentity is defined and zabbix_agent_tlspskidentity %} +TLSPSKIdentity={{ zabbix_agent_tlspskidentity }} +{% endif %} + +### Option: TLSPSKFile +# Full pathname of a file containing the pre-shared key. +# +# Mandatory: no +# Default: +# TLSPSKFile= +{% if zabbix_agent_tlspskfile is defined and zabbix_agent_tlspskfile %} +TLSPSKFile={{ zabbix_agent_tlspskfile }} +{% endif %} +{% endif %} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Darwin.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Darwin.yml new file mode 100644 index 00000000..fa271bbf --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Darwin.yml @@ -0,0 +1,6 @@ +--- +# vars file for zabbix-agent (Debian) + +zabbix_agent: zabbix-agent +zabbix_agent_service: com.zabbix.zabbix_agentd +zabbix_agent_conf: zabbix_agentd.conf diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Debian.yml new file mode 100644 index 00000000..5f31e6eb --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Debian.yml @@ -0,0 +1,7 @@ +--- +# vars file for zabbix-agent (Debian) + +zabbix_agent: zabbix-agent +zabbix_agent_service: zabbix-agent +zabbix_agent_conf: zabbix_agentd.conf +zabbix_agent2_conf: zabbix_agent2.conf diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/RedHat.yml new file mode 100644 index 00000000..e24781a5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/RedHat.yml @@ -0,0 +1,7 @@ +--- +# vars file for zabbix-agent (RedHat) + +zabbix_agent: zabbix-agent +zabbix_agent_service: zabbix-agent +zabbix_agent_conf: zabbix_agentd.conf +zabbix_agent2_conf: zabbix_agent2.conf diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Sangoma.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Sangoma.yml new file mode 100644 index 00000000..96655dae --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Sangoma.yml @@ -0,0 +1,7 @@ +--- +# vars file for zabbix-agent (Sangola) + +zabbix_agent: zabbix-agent +zabbix_agent_service: zabbix-agent +zabbix_agent_conf: zabbix_agentd.conf +zabbix_agent2_conf: zabbix_agent2.conf diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Suse.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Suse.yml new file mode 100644 index 00000000..3310240d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Suse.yml @@ -0,0 +1,7 @@ +--- +# vars file for zabbix-agent (Suse) + +zabbix_agent: zabbix-agentd +zabbix_agent_service: zabbix_agentd +zabbix_agent_conf: zabbix_agentd.conf +zabbix_agent2_conf: zabbix-agent2.conf diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Windows.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Windows.yml new file mode 100644 index 00000000..1fe0d3ac --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Windows.yml @@ -0,0 +1,4 @@ +--- +# vars file for zabbix agent (Windows) + +zabbix_win_agent_service: "zabbix agent" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/zabbix.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/zabbix.yml new file mode 100644 index 00000000..ec589f9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_agent/vars/zabbix.yml @@ -0,0 +1,191 @@ +--- +sign_keys: + "52": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "50": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "44": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "42": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "40": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "34": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "32": + bionic: + sign_key: A14FE591 + sonya: + sign_key: 79EA5ED4 + serena: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "30": + bionic: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "24": + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + "22": + squeeze: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + lucid: + sign_key: 79EA5ED4 + +suse: + "openSUSE Leap": + "42": + name: server:monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_Leap_{{ ansible_distribution_version }}/ + "openSUSE": + "12": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_{{ ansible_distribution_version }} + "SLES": + "11": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/SLE_11_SP3/ + "12": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/SLE_12_SP3/ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/README.md b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/README.md new file mode 100644 index 00000000..530a663e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/README.md @@ -0,0 +1,143 @@ +# community.zabbix.zabbix_javagateway role + +![Zabbix Javagateway](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_javagateway/badge.svg) + +**Table of Contents** + +- [Overview](#overview) + * [Operating systems](#operating-systems) + * [Zabbix Versions](#zabbix-versions) +- [Role Variables](#role-variables) + * [Main variables](#main-variables) + + [Overall Zabbix](#overall-zabbix) + + [Java Gatewaty](#java-gatewaty) + + [proxy](#proxy) +- [Dependencies](#dependencies) +- [Example Playbook](#example-playbook) +- [Molecule](#molecule) +- [License](#license) +- [Author Information](#author-information) + +# Overview + +## Operating systems + +This role will work on the following operating systems: + + * Red Hat + * Debian + * Ubuntu + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +## Zabbix Versions + +See the following list of supported Operating systems with the Zabbix releases. + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | V | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +# Role Variables + +## Main variables + +The following is an overview of all available configuration default for this role. + +### Overall Zabbix + +* `zabbix_javagateway_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. +* `zabbix_javagateway_package_state`: Default: `present`. Can be overridden to `latest` to update packages when needed. +* `zabbix_javagateway_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. + +### Java Gatewaty + +* `zabbix_javagateway_pidfile`: Default: `/run/zabbix/zabbix_java_gateway.pid`. The location for the pid file. +* `zabbix_javagateway_listenip`: Default: `0.0.0.0`. The IP address to listen on. +* `zabbix_javagateway_listenport`: Default: `10052`. The port on which Java Gateway is listening on. +* `zabbix_javagateway_startpollers`: Default: `5`. The amount of pollers to start. + +### proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +# Dependencies + +The java gateway can be installed on either the zabbix-server or the zabbix-proxy machine. So one of these should be installed. You'll need to provide an parameter in your playbook for using the javagateway. + +When using the zabbix-server: +```yaml + roles: + - role: community.zabbix.zabbix_server + zabbix_server_javagateway: 192.168.1.2 +``` + +or when using the zabbix-proxy: +```yaml + roles: + - role: community.zabbix.zabbix_proxy + zabbix_server_host: 192.168.1.1 + zabbix_proxy_javagateway: 192.168.1.2 +``` + +# Example Playbook + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + +```yaml + - hosts: zabbix-server + sudo: yes + roles: + - role: community.zabbix.zabbix_server + zabbix_server_javagateway: 192.168.1.2 + - role: community.zabbix.zabbix_javagateway +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully. + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/defaults/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/defaults/main.yml new file mode 100644 index 00000000..19934588 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/defaults/main.yml @@ -0,0 +1,32 @@ +--- +# defaults file for dj-wasabi.zabbix-javagateway + +zabbix_javagateway_version: 5.2 +zabbix_version: "{{ zabbix_javagateway_version }}" +zabbix_javagateway_package_state: present +zabbix_selinux: False +zabbix_repo: zabbix +zabbix_repo_yum_schema: https +zabbix_java_gateway_conf_mode: "0644" +zabbix_repo_yum_disabled: "*" +zabbix_repo_yum_enabled: [] +zabbix_repo_yum: + - name: zabbix + description: Zabbix Official Repository - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}/rhel/{{ ansible_distribution_major_version }}/$basearch/" + gpgcheck: 0 + mode: '0644' + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + - name: zabbix-non-supported + description: Zabbix Official Repository non-supported - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/non-supported/rhel/{{ ansible_distribution_major_version }}/$basearch/" + mode: '0644' + gpgcheck: 0 + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + +zabbix_javagateway_pidfile: /run/zabbix/zabbix_java_gateway.pid +zabbix_javagateway_listenip: 0.0.0.0 +zabbix_javagateway_listenport: 10052 +zabbix_javagateway_startpollers: 5 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/files/systemd.service b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/files/systemd.service new file mode 100644 index 00000000..b4a78650 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/files/systemd.service @@ -0,0 +1,15 @@ +[Unit] +Description=Zabbix Java Gateway +After=syslog.target +After=network.target + +[Service] +Type=forking +KillMode=process +ExecStart=/usr/sbin/zabbix_java_gateway +SuccessExitStatus=143 +User=zabbix +Group=zabbix + +[Install] +WantedBy=multi-user.target diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/handlers/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/handlers/main.yml new file mode 100644 index 00000000..fab44bd6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/handlers/main.yml @@ -0,0 +1,16 @@ +--- +# handlers file for zabbix-javagateway + +- name: zabbix-java-gateway restarted + service: + name: zabbix-java-gateway + state: restarted + enabled: yes + become: yes + +- name: "clean repo files from proxy creds" + shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + become: yes + when: + - ansible_os_family == 'RedHat' + - zabbix_http_proxy is defined or zabbix_https_proxy is defined diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/meta/main.yml new file mode 100644 index 00000000..b484db2a --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/meta/main.yml @@ -0,0 +1,23 @@ +--- +galaxy_info: + author: Werner Dijkerman + description: Installing and maintaining zabbix-javagateway for RedHat/Debian/Ubuntu. + company: myCompany.Dotcom + license: license (GPLv3) + min_ansible_version: 2.4 + platforms: + - name: EL + versions: + - 6 + - 7 + - name: Ubuntu + versions: + - lucid + - precise + - trusty + - name: Debian + versions: + - squeeze + - wheezy + galaxy_tags: + - monitoring diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/Debian.yml new file mode 100644 index 00000000..913ea887 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/Debian.yml @@ -0,0 +1,73 @@ +--- + +- name: "Include Zabbix gpg ids" + include_vars: zabbix.yml + +- name: "Set some variables" + set_fact: + zabbix_short_version: "{{ zabbix_javagateway_version | regex_replace('\\.', '') }}" + +- name: "Debian | Install gpg key" + apt_key: + id: "{{ sign_keys[zabbix_short_version][ansible_distribution_release]['sign_key'] }}" + url: http://repo.zabbix.com/zabbix-official-repo.key + become: yes + +- name: "Debian | Installing repository Debian" + apt_repository: + repo: "deb http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}/debian/ {{ ansible_distribution_release }} main" + state: present + become: yes + when: + - ansible_distribution == "Debian" + - zabbix_repo == "zabbix" + +- name: "Debian | Installing repository Debian" + apt_repository: + repo: "deb-src http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}/debian/ {{ ansible_distribution_release }} main" + state: present + become: yes + when: + - ansible_distribution == "Debian" + - zabbix_repo == "zabbix" + +- name: "Debian | Installing repository Ubuntu" + apt_repository: + repo: "deb http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}/ubuntu/ {{ ansible_distribution_release }} main" + state: present + become: yes + when: + - ansible_distribution == "Ubuntu" + - zabbix_repo == "zabbix" + +- name: "Debian | Installing repository Ubuntu" + apt_repository: + repo: "deb-src http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}/ubuntu/ {{ ansible_distribution_release }} main" + state: present + become: yes + when: + - ansible_distribution == "Ubuntu" + - zabbix_repo == "zabbix" + +- name: "Debian | Installing zabbix-java-gateway" + apt: + pkg: zabbix-java-gateway + state: "{{ zabbix_javagateway_package_state }}" + update_cache: yes + force: yes + cache_valid_time: 3600 + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_java_gateway_install + until: zabbix_java_gateway_install is succeeded + become: yes + +- name: "Make sure Zabbix Java Gateway is not yet running" + systemd: + name: zabbix-java-gateway + state: stopped + enabled: yes + daemon_reload: true + when: + - zabbix_java_gateway_install.changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/RedHat.yml new file mode 100644 index 00000000..0f42f1c2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/RedHat.yml @@ -0,0 +1,34 @@ +--- +# Tasks specific for RedHat systems + +- name: "RedHat | Install basic repo file" + yum_repository: + name: "{{ item.name }}" + description: "{{ item.description }}" + baseurl: "{{ item.baseurl }}" + gpgcheck: "{{ item.gpgcheck }}" + gpgkey: "{{ item.gpgkey }}" + mode: "{{ item.mode | default('0644') }}" + priority: "{{ item.priority | default('99') }}" + state: "{{ item.state | default('present') }}" + proxy: "{{ zabbix_http_proxy | default(omit) }}" + with_items: "{{ zabbix_repo_yum }}" + register: yum_repo_installed + become: yes + when: + zabbix_repo == "zabbix" + notify: + - "clean repo files from proxy creds" + +- name: "RedHat | Installing zabbix-java-gateway" + package: + pkg: zabbix-java-gateway + state: "{{ zabbix_javagateway_package_state }}" + disablerepo: "{{ '*' if (zabbix_repo_yum_enabled | length>0) else omit }}" + enablerepo: "{{ zabbix_repo_yum_enabled if zabbix_repo_yum_enabled is iterable and (zabbix_repo_yum_enabled | length>0) else omit }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_java_gateway_install + until: zabbix_java_gateway_install is succeeded + become: yes diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/main.yml new file mode 100644 index 00000000..00f7d121 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/main.yml @@ -0,0 +1,42 @@ +--- +# tasks file for dj-wasabi.zabbix-proxy + +- name: "Install the correct repository" + include: "RedHat.yml" + when: + - ansible_os_family == "RedHat" + +- name: "Install the correct repository" + include: "Debian.yml" + when: + - ansible_os_family == "Debian" + +- name: "Place systemd unit file" + copy: + src: systemd.service + dest: /etc/systemd/system/zabbix-java-gateway.service + register: systemd_state + +- name: "Reload systemd" + shell: systemctl daemon-reload + when: + - systemd_state.changed + tags: + - skip_ansible_lint + +- name: "Configure zabbix-proxy" + template: + src: zabbix_java_gateway.conf.j2 + dest: /etc/zabbix/zabbix_java_gateway.conf + owner: zabbix + group: zabbix + mode: "{{ zabbix_java_gateway_conf_mode }}" + notify: + - zabbix-java-gateway restarted + +- name: "Make sure Zabbix Java Gateway is running" + systemd: + name: zabbix-java-gateway + state: started + enabled: yes + daemon_reload: true diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/templates/zabbix_java_gateway.conf.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/templates/zabbix_java_gateway.conf.j2 new file mode 100644 index 00000000..868f6a60 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/templates/zabbix_java_gateway.conf.j2 @@ -0,0 +1,23 @@ +# This is a configuration file for Zabbix Java Gateway. +# It is sourced by startup.sh and shutdown.sh scripts. + +### Option: zabbix.listenIP +# IP address to listen on. +# +LISTEN_IP={{ zabbix_javagateway_listenip }} + +### Option: zabbix.listenPort +# Port to listen on. +# +LISTEN_PORT={{ zabbix_javagateway_listenport }} + +### Option: zabbix.pidFile +# Name of PID file. +# If omitted, Zabbix Java Gateway is started as a console application. +# +PID_FILE={{ zabbix_javagateway_pidfile }} + +### Option: zabbix.startPollers +# Number of worker threads to start. +# +START_POLLERS={{ zabbix_javagateway_startpollers }} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/Debian.yml new file mode 100644 index 00000000..1eecc317 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/Debian.yml @@ -0,0 +1,6 @@ +--- +apache_user: www-data +apache_group: www-data +apache_log: apache2 + +mysql_create_dir: '' diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/RedHat.yml new file mode 100644 index 00000000..8c199770 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/RedHat.yml @@ -0,0 +1,6 @@ +--- +apache_user: apache +apache_group: apache +apache_log: httpd + +mysql_create_dir: create/ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/main.yml new file mode 100644 index 00000000..5be481a3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for dj-wasabi.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/zabbix.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/zabbix.yml new file mode 100644 index 00000000..1da19b60 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/zabbix.yml @@ -0,0 +1,188 @@ +--- +sign_keys: + "52": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "50": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "44": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "42": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "40": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "34": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "32": + bionic: + sign_key: A14FE591 + sonya: + sign_key: 79EA5ED4 + serena: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "30": + bionic: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "24": + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + "22": + squeeze: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + lucid: + sign_key: 79EA5ED4 + +suse: + "openSUSE Leap": + "42": + name: server:monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_Leap_{{ ansible_distribution_version }}/ + "openSUSE": + "12": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_{{ ansible_distribution_version }} + "SLES": + "11": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/SLE_11_SP3/ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/README.md b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/README.md new file mode 100644 index 00000000..29cbbf9f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/README.md @@ -0,0 +1,342 @@ +# community.zabbix.zabbix_proxy role + +![Zabbix Proxy](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_proxy/badge.svg) + +**Table of Contents** + +- [Overview](#overview) + * [Operating systems](#operating-systems) + * [Zabbix Versions](#zabbix-versions) +- [Role Variables](#role-variables) + * [Main variables](#main-variables) + + [Overall Zabbix](#overall-zabbix) + + [SElinux](#selinux) + + [Zabbix Proxy](#zabbix-proxy) + + [Database specific](#database-specific) + + [TLS Specific configuration](#tls-specific-configuration) + * [proxy](#proxy) + * [Database](#database) + + [MySQL](#mysql) + - [Local Setup](#local-setup) + - [Separate Setup](#separate-setup) + + [PostgreSQL](#postgresql) + - [Local Setup](#local-setup-1) + - [Separate Setup](#separate-setup-1) + + [SQLite3](#sqlite3) + * [Zabbix API variables](#zabbix-api-variables) +- [Example Playbook](#example-playbook) +- [Molecule](#molecule) +- [License](#license) +- [Author Information](#author-information) + +# Overview + +## Operating systems + +This role will work on the following operating systems: + + * Red Hat + * Debian + * Ubuntu + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +## Zabbix Versions + +See the following list of supported Operating systems with the Zabbix releases. + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | V | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +# Role Variables + +## Main variables + +The following is an overview of all available configuration default for this role. + +### Overall Zabbix + +* `zabbix_proxy_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. + +### SElinux + +* `zabbix_selinux`: Default: `False`. Enables an SELinux policy so that the Proxy will run. + +### Zabbix Proxy + +* `zabbix_proxy_ip`: The IP address of the host. When not provided, it will be determined via the `ansible_default_ipv4` fact. +* `zabbix_server_host`: The ip or dns name for the zabbix-server machine. +* `zabbix_server_port`: The port on which the zabbix-server is running. Default: 10051 +* `*zabbix_proxy_package_state`: Default: `present`. Can be overridden to `latest` to update packages +* `zabbix_proxy_install_database_client`: Default: `True`. False does not install database client. +* `zabbix_proxy_become_on_localhost`: Default: `True`. Set to `False` if you don't need to elevate privileges on localhost to install packages locally with pip. +* `zabbix_proxy_manage_service`: Default: `True`. When you run multiple Zabbix proxies in a High Available cluster setup (e.g. pacemaker), you don't want Ansible to manage the zabbix-proxy service, because Pacemaker is in control of zabbix-proxy service. +* `zabbix_install_pip_packages`: Default: `True`. Set to `False` if you don't want to install the required pip packages. Useful when you control your environment completely. +* `zabbix_proxy_startpreprocessors`: Number of pre-forked instances of preprocessing workers. The preprocessing manager process is automatically started when a preprocessor worker is started.This parameter is supported since Zabbix 4.2.0. +* `zabbix_proxy_username`: Default: `zabbix`. The name of the account on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_proxy_userid`: The UID of the account on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_proxy_groupname`: Default: `zabbix`. The name of the group of the user on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_proxy_groupid`: The GID of the group on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_proxy_include_mode`: Default: `0755`. The "mode" for the directory configured with `zabbix_proxy_include`. +* `zabbix_proxy_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. + +### Database specific + +* `zabbix_proxy_dbhost_run_install`: Default: `True`. When set to `True`, sql files will be executed on the host running the database. +* `zabbix_proxy_database`: Default: `pgsql`. The type of database used. Can be: `mysql`, `pgsql` or `sqlite3` +* `zabbix_proxy_database_long`: Default: `postgresql`. The type of database used, but long name. Can be: `mysql`, `postgresql` or `sqlite3` +* `zabbix_proxy_dbhost`: The hostname on which the database is running. Will be ignored when `sqlite3` is used as database. +* `zabbix_proxy_real_dbhost`: The hostname of the dbhost that is running behind a loadbalancer/VIP (loadbalancers doesn't accept ssh connections) Will be ignored when `sqlite3` is used as database. +* `zabbix_proxy_dbname`: The database name which is used by the Zabbix Proxy. +* `zabbix_proxy_dbuser`: The database username which is used by the Zabbix Proxy. Will be ignored when `sqlite3` is used as database. +* `zabbix_proxy_dbpassword`: The database user password which is used by the Zabbix Proxy. Will be ignored when `sqlite3` is used as database. +* `zabbix_proxy_dbport`: The database port which is used by the Zabbix Proxy. Will be ignored when `sqlite3` is used as database. +* `zabbix_database_creation`: Default: `True`. When you don't want to create the database including user, you can set it to False. +* `zabbix_proxy_install_database_client`: Default: `True`. False does not install database client. Default true +* `zabbix_database_sqlload`:True / False. When you don't want to load the sql files into the database, you can set it to False. +* `zabbix_proxy_dbencoding`: Default: `utf8`. The encoding for the MySQL database. +* `zabbix_proxy_dbcollation`: Default: `utf8_bin`. The collation for the MySQL database.zabbix_proxy_ + +### TLS Specific configuration + +These variables are specific for Zabbix 3.0 and higher: + +* `zabbix_proxy_tlsconnect`: How the agent should connect to server or proxy. Used for active checks. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_proxy_tlsaccept`: What incoming connections to accept. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_proxy_tlscafile`: Full pathname of a file containing the top-level CA(s) certificates for peer certificate verification. +* `zabbix_proxy_tlscrlfile`: Full pathname of a file containing revoked certificates. +* `zabbix_proxy_tlsservercertissuer`: Allowed server certificate issuer. +* `zabbix_proxy_tlsservercertsubject`: Allowed server certificate subject. +* `zabbix_proxy_tlscertfile`: Full pathname of a file containing the agent certificate or certificate chain. +* `zabbix_proxy_tlskeyfile`: Full pathname of a file containing the agent private key. +* `zabbix_proxy_dbtlsconnect`: Setting this option enforces to use TLS connection to database: + +`required` - connect using TLS +`verify_ca` - connect using TLS and verify certificate +`verify_full` - connect using TLS, verify certificate and verify that database identity specified by DBHost matches its certificate + +On `MySQL` starting from 5.7.11 and `PostgreSQL` the following values are supported: `required`, `verify`, `verify_full`. On MariaDB starting from version 10.2.6 `required` and `verify_full` values are supported. +By default not set to any option and the behaviour depends on database configuration. +This parameter is supported since Zabbix 5.0.0. + +* `zabbix_proxy_dbtlscafile`: Full pathname of a file containing the top-level CA(s) certificates for database certificate verification. This parameter is supported since Zabbix 5.0.0. +* `zabbix_proxy_dbtlscertfile`: Full pathname of file containing Zabbix Proxy certificate for authenticating to database. This parameter is supported since Zabbix 5.0.0. +* `zabbix_proxy_dbtlskeyfile`: Full pathname of file containing the private key for authenticating to database. This parameter is supported since Zabbix 5.0.0. +* `zabbix_proxy_dbtlscipher`: The list of encryption ciphers that Zabbix Proxy permits for TLS protocols up through TLSv1.2. Supported only for MySQL.This parameter is supported since Zabbix 5.0.0. +* `zabbix_proxy_dbtlscipher13`: The list of encryption ciphersuites that Zabbix Proxy permits for TLSv1.3 protocol. Supported only for MySQL, starting from version 8.0.16. This parameter is supported since Zabbix 5.0.0. + +## proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +## Database + +With Zabbix Proxy you can make use of 2 different databases: + +* `mysql` +* `postgresql` +* `SQLite3` + +In the following paragraphs we dive into both setups. + +### MySQL + +To make the Zabbix Proxy work with a `MySQL` database, there are 2 types on setup: + +1. Local setup, `MySQL` running on same host as the Zabbix Proxy; +2. Separate setup, `MySQL` running on a different host than the Zabbix Proxy. + +#### Local Setup + +We need to have the following dependencies met: + +1. Find an (Ansible) role that will install a `MySQL` instance on the host. Example: `geerlingguy.mysql` can be used, but also others can be used. Please make sure that before installing the Zabbix Proxy, you have a fully functional `MySQL` instance running. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_proxy_database: mysql +zabbix_proxy_database_long: mysql +zabbix_proxy_dbport: 3306 +zabbix_proxy_dbpassword: +``` + +Please generate a value for the `zabbix_proxy_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-proxy role will create an database and username (With the provided value for the password) in `MySQL`. +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Proxy with `MySQL` will be running. + +#### Separate Setup + +We need to have the following dependencies met: + +1. We need to either have a `MySQL` instance running somewhere in the environment. If this is the case, we need to have a username/password combination that is allowed to create a database and an user account. If there isn't one, please make sure there is one. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_proxy_database: mysql +zabbix_proxy_database_long: mysql +zabbix_proxy_dbport: 3306 +zabbix_proxy_dbhost: mysql-host +zabbix_proxy_dbhost_run_install: false +zabbix_proxy_dbpassword: +zabbix_proxy_privileged_host: '%' +zabbix_proxy_mysql_login_host: mysql-host +zabbix_proxy_mysql_login_user: root +zabbix_proxy_mysql_login_password: changeme +zabbix_proxy_mysql_login_port: 3306 +``` + +Please generate a value for the `zabbix_proxy_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-proxy role will create an database and username (With the provided value for the password) in `MySQL`. + +The `zabbix_proxy_privileged_host` can be set to the hostname/ip of the host running Zabbix Proxy for security related purposes. Also make sure that `zabbix_proxy_mysql_login_password` is set to the correct password for the user provided with `zabbix_proxy_mysql_login_host` to create a database and user in the `MySQL` instance. + +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Proxy with `MySQL` on a different host will be running. + +### PostgreSQL + +To make the Zabbix Proxy work with a `PgSQL` database, there are 2 types on setup: + +1. Local setup, `PgSQL` running on same host as the Zabbix Proxy; +2. Separate setup, `PgSQL` running on a different host than the Zabbix Proxy. + +#### Local Setup + +We need to have the following dependencies met: + +1. Find an (Ansible) role that will install a `PgSQL` instance on the host. Example: `geerlingguy.postgresql` can be used, but also others can be used. Please make sure that before installing the Zabbix Proxy, you have a fully functional `PgSQL` instance running. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_proxy_database: pgsql +zabbix_proxy_database_long: postgresql +zabbix_proxy_dbport: 5432 +zabbix_proxy_dbpassword: +``` + +Please generate a value for the `zabbix_proxy_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-proxy role will create an database and username (With the provided value for the password) in `PgSQL`. +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Proxy with `PgSQL` will be running. + +#### Separate Setup + +We need to have the following dependencies met: + +1. We need to either have a `PgSQL` instance running somewhere in the environment. If this is the case, we need to have a username/password combination that is allowed to create a database and an user account. If there isn't one, please make sure there is one. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_proxy_database: pgsql +zabbix_proxy_database_long: postgresql +zabbix_proxy_dbport: 5432 +zabbix_proxy_dbhost: pgsql-host +zabbix_proxy_dbhost_run_install: false +zabbix_proxy_dbpassword: +zabbix_proxy_privileged_host: '%' +zabbix_proxy_pgsql_login_host: pgsql-host +zabbix_proxy_pgsql_login_user: postgres +zabbix_proxy_pgsql_login_password: changeme +zabbix_proxy_pgsql_login_port: 5432 +``` + +Please generate a value for the `zabbix_proxy_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-proxy role will create an database and username (With the provided value for the password) in `PgSQL`. + +The `zabbix_proxy_privileged_host` can be set to the hostname/ip of the host running Zabbix Proxy for security related purposes. Also make sure that `zabbix_proxy_mysql_login_password` is set to the correct password for the user provided with `zabbix_proxy_mysql_login_host` to create a database and user in the `PgSQL` instance. + +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Proxy with `PgSQL` on a different host will be running.zabbix_proxy_ + +### SQLite3 + +The SQLite3 can only be used on the same host as on which the Zabbix Proxy is running. If you want to use a seperate host for running the database for the proxy, please consider going for MySQL or PostGreSQL. + +The following properties needs to be set when using `SQLite3` as the database: + +```yaml +zabbix_proxy_database: sqlite3 +zabbix_proxy_database_long: sqlite3 +zabbix_proxy_dbname: /path/to/sqlite3.db +``` + +NOTE: When using `zabbix_proxy_dbname: zabbix_proxy` (Which is default with this role), it will automatically be stored on `/var/lib/zabbix/zabbix_proxy.db` + +## Zabbix API variables + +These variables need to be overridden when you want to make use of the zabbix-api for automatically creating and or updating hosts. Host encryption configuration will be set to match agent configuration. + +When `zabbix_api_create_proxy` is set to `True`, it will install on the host executing the Ansible playbook the `zabbix-api` python module. + +* `zabbix_url`: The url on which the Zabbix webpage is available. Example: http://zabbix.example.com +* `zabbix_api_http_user`: The http user to access zabbix url with Basic Auth +* `zabbix_api_http_password`: The http password to access zabbix url with Basic Auth +* `zabbix_api_create_proxy`: When you want to enable the Zabbix API to create/delete the proxy. This has to be set to `True` if you want to make use of `zabbix_create_proxy`. Default: `False` +* `zabbix_api_user`: Username of user which has API access. +* `zabbix_api_pass`: Password for the user which has API access. +* `zabbix_create_proxy`: present (Default) if the proxy needs to be created or absent if you want to delete it. This only works when `zabbix_api_create_proxy` is set to `True`. +* `zabbix_proxy_status`: active (Default) if the proxy needs to be active or passive. + +# Example Playbook + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + +```yaml + - hosts: zabbix-proxy + roles: + - role: community.zabbix.zabbix_proxy + zabbix_server_host: 192.168.1.1 + zabbix_proxy_database: mysql + zabbix_proxy_database_long: mysql +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully. + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/defaults/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/defaults/main.yml new file mode 100644 index 00000000..849b6f2c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/defaults/main.yml @@ -0,0 +1,162 @@ +--- +# defaults file for zabbix-proxy + +zabbix_proxy_version: 5.2 +zabbix_version: "{{ zabbix_proxy_version }}" +zabbix_selinux: False + +# These variables are optional. They specify the version of Zabbix proxy package. + +# zabbix_proxy_rhel_version: 4.4.4 +# zabbix_proxy_debian_version: 1:4.4.4-1+stretch +# zabbix_proxy_ubuntu_version: 1:4.4.4-1+xenial + +zabbix_repo: zabbix +zabbix_proxy_apt_priority: +zabbix_proxy_package_state: present +zabbix_proxy_install_database_client: True +zabbix_install_pip_packages: true +zabbix_repo_yum_schema: https +zabbix_proxy_conf_mode: "0644" +zabbix_repo_yum_disabled: "*" +zabbix_repo_yum_enabled: [] +zabbix_repo_yum: + - name: zabbix + description: Zabbix Official Repository - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix/{{ zabbix_version }}/rhel/{{ ansible_distribution_major_version }}/$basearch/" + gpgcheck: 0 + mode: '0644' + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + - name: zabbix-non-supported + description: Zabbix Official Repository non-supported - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/non-supported/rhel/{{ ansible_distribution_major_version }}/$basearch/" + mode: '0644' + gpgcheck: 0 + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + +# User (EPEL specific) +zabbix_proxy_username: zabbix +zabbix_proxy_groupname: zabbix + +zabbix_server_host: 192.168.1.1 +zabbix_server_port: 10051 +zabbix_database_creation: True +zabbix_database_sqlload: True +zabbix_proxy_dbtlsconnect: +zabbix_proxy_dbtlscafile: +zabbix_proxy_dbtlscertfile: +zabbix_proxy_dbtlskeyfile: +zabbix_proxy_dbtlscipher: +zabbix_proxy_dbtlscipher13: + +# Some role specific vars +zabbix_proxy_database: mysql +zabbix_proxy_database_long: mysql +# zabbix_proxy_database: pgsql +# zabbix_proxy_database_long: postgresql +# zabbix_proxy_database: sqlite3 +# zabbix_proxy_database_long: sqlite3 + +# zabbix-proxy specifc vars +zabbix_proxy_mode: 0 +zabbix_proxy_hostname: "{{ inventory_hostname }}" +zabbix_proxy_listenport: 10051 +zabbix_proxy_sourceip: +zabbix_proxy_logfile: /var/log/zabbix/zabbix_proxy.log +zabbix_proxy_logfilesize: 10 +zabbix_proxy_enableremotecommands: 0 +zabbix_proxy_debuglevel: 3 +zabbix_proxy_pidfile: /var/run/zabbix/zabbix_proxy.pid +zabbix_proxy_socketdir: /var/run/zabbix +zabbix_proxy_dbencoding: utf8 +zabbix_proxy_dbcollation: utf8_bin +zabbix_proxy_dbhost: localhost +zabbix_proxy_dbname: zabbix_proxy +zabbix_proxy_dbschema: +zabbix_proxy_dbuser: zabbix_proxy +zabbix_proxy_dbpassword: zabbix_proxy +zabbix_proxy_dbsocket: +zabbix_proxy_dbport: 5432 +zabbix_proxy_dbhost_run_install: true +zabbix_proxy_privileged_host: localhost +zabbix_proxy_localbuffer: 0 +zabbix_proxy_offlinebuffer: 1 +zabbix_proxy_heartbeatfrequency: 60 +zabbix_proxy_configfrequency: 3600 +zabbix_proxy_datasenderfrequency: 1 +zabbix_proxy_startpollers: 5 +zabbix_proxy_startipmipollers: 0 +zabbix_proxy_startpollersunreachable: 1 +zabbix_proxy_starttrappers: 5 +zabbix_proxy_startpingers: 1 +zabbix_proxy_startdiscoverers: 1 +zabbix_proxy_starthttppollers: 1 +zabbix_proxy_startpreprocessors: 3 +zabbix_proxy_javagateway: +zabbix_proxy_javagatewayport: 10052 +zabbix_proxy_startjavapollers: 5 +zabbix_proxy_startvmwarecollector: 0 +zabbix_proxy_vmwarefrequency: 60 +zabbix_proxy_vmwarecachesize: 8 +zabbix_proxy_snmptrapperfile: /tmp/zabbix_traps.tmp +zabbix_proxy_snmptrapper: 0 +zabbix_proxy_listenip: +zabbix_proxy_housekeepingfrequency: 1 +zabbix_proxy_cachesize: 8 +zabbix_proxy_startdbsyncers: 4 +zabbix_proxy_historycachesize: 8 +zabbix_proxy_historyindexcachesize: 4 +zabbix_proxy_historytextcachesize: 16 +zabbix_proxy_timeout: 3 +zabbix_proxy_trappertimeout: 300 +zabbix_proxy_unreachableperiod: 45 +zabbix_proxy_unavaliabledelay: 60 +zabbix_proxy_unreachabedelay: 15 +zabbix_proxy_externalscripts: /usr/lib/zabbix/externalscripts +zabbix_proxy_fpinglocation: /usr/sbin/fping +zabbix_proxy_fping6location: /usr/sbin/fping6 +zabbix_proxy_sshkeylocation: +zabbix_proxy_loglowqueries: 0 +zabbix_proxy_tmpdir: /tmp +zabbix_proxy_allowroot: 0 +zabbix_proxy_include: /etc/zabbix/zabbix_proxy.conf.d +zabbix_proxy_include_mode: '0755' +zabbix_proxy_libdir: /usr/lib/zabbix +zabbix_proxy_loadmodulepath: "{{ zabbix_proxy_libdir }}/modules" +zabbix_proxy_manage_service: True + +# TLS settings +zabbix_proxy_tlsconnect: +zabbix_proxy_tlsaccept: +zabbix_proxy_tlscafile: +zabbix_proxy_tlscrlfile: +zabbix_proxy_tlsservercertissuer: +zabbix_proxy_tlsservercertsubject: +zabbix_proxy_tlscertfile: +zabbix_proxy_tlskeyfile: +zabbix_proxy_tlspskidentity: + +zabbix_proxy_tls_config: + no_encryption: 'no_encryption' + PSK: 'PSK' + certificate: 'certificate' + +# Zabbix API stuff +zabbix_url: "http://zabbix.dj-wasabi.local" +# zabbix_api_http_user: admin +# zabbix_api_http_password: admin +zabbix_api_user: Admin +zabbix_api_pass: zabbix +zabbix_api_create_proxy: False +zabbix_create_proxy: present # or absent +zabbix_proxy_status: active # or passive +zabbix_proxy: null +zabbix_useuip: 1 +zabbix_proxy_become_on_localhost: True +zabbix_proxy_interface: + useip: "{{ zabbix_useuip }}" + ip: "{{ zabbix_proxy_ip }}" + dns: "{{ ansible_fqdn }}" + port: "{{ zabbix_proxy_listenport }}" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/files/install_semodule.bsx b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/files/install_semodule.bsx new file mode 100755 index 00000000..d37320c9 Binary files /dev/null and b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/files/install_semodule.bsx differ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/handlers/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/handlers/main.yml new file mode 100644 index 00000000..a44be08e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/handlers/main.yml @@ -0,0 +1,29 @@ +--- +# handlers file for zabbix-proxy + +- name: restart zabbix-proxy + service: + name: zabbix-proxy + state: restarted + enabled: yes + become: yes + when: + - zabbix_proxy_manage_service | bool + - zabbix_repo != 'epel' + +- name: restart zabbix-proxy + service: + name: zabbix-proxy-mysql{{ zabbix_proxy_database_long }} + state: restarted + enabled: yes + become: yes + when: + - zabbix_proxy_manage_service | bool + - zabbix_repo == 'epel' + +- name: "clean repo files from proxy creds" + shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + become: yes + when: + - ansible_os_family == 'RedHat' + - zabbix_http_proxy is defined or zabbix_https_proxy is defined diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/meta/main.yml new file mode 100644 index 00000000..6f2052a5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/meta/main.yml @@ -0,0 +1,27 @@ +--- +galaxy_info: + author: Werner Dijkerman + description: Installing and maintaining zabbix-proxy for RedHat/Debian/Ubuntu. + company: myCompany.Dotcom + license: MIT + min_ansible_version: 2.4 + platforms: + - name: EL + versions: + - 6 + - 7 + - name: Ubuntu + versions: + - lucid + - precise + - trusty + - name: Debian + versions: + - squeeze + - wheezy + - stretch + galaxy_tags: + - zabbix + - monitoring + +dependencies: [] diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/requirements.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/requirements.yml new file mode 100644 index 00000000..37db26ff --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/requirements.yml @@ -0,0 +1,3 @@ +--- +- src: geerlingguy.mysql +- src: geerlingguy.postgresql diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/Debian.yml new file mode 100644 index 00000000..53b4988b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/Debian.yml @@ -0,0 +1,229 @@ +--- + +- name: "Include Zabbix gpg ids" + include_vars: zabbix.yml + +- name: "Set short version name" + set_fact: + zabbix_short_version: "{{ zabbix_version | regex_replace('\\.', '') }}" + zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}" + zabbix_underscore_version: "{{ zabbix_version | regex_replace('\\.', '_') }}" + +- name: "Debian | Set some facts" + set_fact: + apache_log: apache2 + datafiles_path: "/usr/share/zabbix-proxy-{{ zabbix_proxy_database }}" + when: + - zabbix_version is version_compare('3.0', '<') + tags: + - zabbix-proxy + - init + - config + +- name: "Debian | Set some facts for Zabbix 3.0" + set_fact: + apache_log: apache2 + datafiles_path: "/usr/share/doc/zabbix-proxy-{{ zabbix_proxy_database }}" + when: + - zabbix_version is version_compare('3.0', '>=') + tags: + - zabbix-proxy + - init + - config + +- name: "Debian | Installing gnupg" + apt: + pkg: gnupg + update_cache: yes + cache_valid_time: 3600 + force: yes + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: gnupg_installed + until: gnupg_installed is succeeded + become: yes + +- name: "Debian | Install gpg key" + apt_key: + id: "{{ sign_keys[zabbix_short_version][ansible_distribution_release]['sign_key'] }}" + url: http://repo.zabbix.com/zabbix-official-repo.key + register: are_zabbix_proxy_dependency_packages_installed + until: are_zabbix_proxy_dependency_packages_installed is succeeded + when: + - zabbix_repo == "zabbix" + become: yes + tags: + - zabbix-proxy + - init + +- name: "Debian | Installing repository {{ ansible_distribution }}" + apt_repository: + repo: "{{ item }} http://repo.zabbix.com/zabbix/{{ zabbix_version }}/{{ ansible_distribution.lower() }}/ {{ ansible_distribution_release }} main" + state: present + when: zabbix_repo == "zabbix" + become: yes + with_items: + - deb-src + - deb + tags: + - zabbix-proxy + - init + +- name: "Debian | Select Zabbix proxy version" + set_fact: + zabbix_proxy_deb_version: "{{ zabbix_proxy_debian_version }}" + cacheable: yes + when: + - ansible_distribution == "Debian" + - zabbix_proxy_debian_version is defined + +- name: "Ubuntu | Select Zabbix proxy version" + set_fact: + zabbix_proxy_deb_version: "{{ zabbix_proxy_ubuntu_version }}" + cacheable: yes + when: + - ansible_distribution == "Ubuntu" + - zabbix_proxy_ubuntu_version is defined + +- name: "Debian | Define package with version" + set_fact: + deb_pkg: "zabbix-proxy-{{ zabbix_proxy_database }}={{ zabbix_proxy_deb_version }}" + cacheable: yes + when: + zabbix_proxy_deb_version is defined + +- name: "Debian | Define package without version" + set_fact: + deb_pkg: "zabbix-proxy-{{ zabbix_proxy_database }}" + cacheable: yes + when: + zabbix_proxy_deb_version is not defined + +- name: "Debian | Create /etc/apt/preferences.d/" + file: + path: /etc/apt/preferences.d/ + state: directory + when: + - zabbix_proxy_apt_priority | int + become: yes + +- name: "Debian | Configuring the weight for APT" + copy: + dest: "/etc/apt/preferences.d/zabbix-proxy-{{ zabbix_proxy_database }}" + content: | + Package: zabbix-proxy-{{ zabbix_proxy_database }} + Pin: origin repo.zabbix.com + Pin-Priority: {{ zabbix_proxy_apt_priority }} + owner: root + when: + - zabbix_proxy_apt_priority | int + become: yes + +- name: "Debian | Installing zabbix-proxy-{{ zabbix_proxy_database }}" + apt: + pkg: "{{ deb_pkg }}" + update_cache: yes + cache_valid_time: 3600 + force: yes + state: "{{ zabbix_proxy_package_state }}" + default_release: "{{ ansible_distribution_release }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: is_zabbix_proxy_package_installed + until: is_zabbix_proxy_package_installed is succeeded + become: yes + +- name: "Debian | Install Ansible module dependencies" + apt: + name: "{{ zabbix_python_prefix }}-psycopg2" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_proxy_dependencies_installed + until: zabbix_proxy_dependencies_installed is succeeded + become: yes + when: + - zabbix_database_creation + tags: + - zabbix-server + - init + +- name: "Debian | Install Mysql Client package" + apt: + name: + - mysql-client + - "{{ zabbix_python_prefix }}-mysqldb" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_proxy_dependencies_installed + until: zabbix_proxy_dependencies_installed is succeeded + become: yes + when: + - zabbix_proxy_database == 'mysql' + - zabbix_proxy_install_database_client + - ansible_distribution_release != "buster" + tags: + - zabbix-server + - init + - database + +- name: "Debian 10 | Install Mysql Client package" + apt: + name: + - mariadb-client + - "{{ zabbix_python_prefix }}-mysqldb" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_proxy_dependencies_installed + until: zabbix_proxy_dependencies_installed is succeeded + become: yes + when: + - zabbix_proxy_database == 'mysql' + - zabbix_proxy_install_database_client + - ansible_distribution_release == "buster" + tags: + - zabbix-server + - init + - database + +- name: "Debian | Install PostgreSQL Client package" + apt: + name: postgresql-client + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: are_zabbix_proxy_dependency_packages_installed + until: are_zabbix_proxy_dependency_packages_installed is succeeded + become: yes + when: + - zabbix_database_creation or zabbix_database_sqlload + - zabbix_proxy_database == 'pgsql' + - zabbix_proxy_install_database_client + tags: + - zabbix-proxy + - init + - database + +- name: "Debian | Install sqlite3" + apt: + name: sqlite + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: are_zabbix_proxy_dependency_packages_installed + until: are_zabbix_proxy_dependency_packages_installed is succeeded + become: yes + when: + - zabbix_proxy_database == 'sqlite3' + tags: + - zabbix-proxy diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/RedHat.yml new file mode 100644 index 00000000..78de69e7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/RedHat.yml @@ -0,0 +1,243 @@ +--- +# Tasks specific for RedHat systems + +- name: "Set short version name" + set_fact: + zabbix_short_version: "{{ zabbix_version | regex_replace('\\.', '') }}" + +- name: "RedHat | Use EPEL package name" + set_fact: + zabbix_proxy_package: "zabbix{{ zabbix_version | regex_replace('\\.', '') }}-proxy" + when: + - zabbix_repo == "epel" + tags: + - zabbix-proxy + - init + +- name: "RedHat | Define package with version" + set_fact: + zabbix_proxy_package: "zabbix{{ zabbix_short_version }}-proxy-{{ zabbix_proxy_database }}" + cacheable: yes + when: + - zabbix_proxy_rhel_version is defined + - zabbix_repo != "epel" + +- name: "RedHat | Define package without version" + set_fact: + zabbix_proxy_package: "zabbix-proxy-{{ zabbix_proxy_database }}" + cacheable: yes + when: + - zabbix_proxy_rhel_version is not defined + - zabbix_repo != "epel" + +- name: "RedHat | Set some facts Zabbix < 3.0" + set_fact: + apache_log: httpd + datafiles_path: "/usr/share/doc/zabbix-proxy-{{ zabbix_proxy_database }}-{{ zabbix_version }}*/create" + when: + - zabbix_version is version_compare('3.0', '<') + tags: + - zabbix-proxy + +- name: "RedHat | Set facts for Zabbix >= 3.0" + set_fact: + apache_log: httpd + datafiles_path: "/usr/share/doc/zabbix-proxy-{{ zabbix_proxy_database }}-{{ zabbix_version }}*" + when: + - zabbix_version is version_compare('3.0', '>=') + tags: + - zabbix-proxy + +- name: "RedHat | Set facts for Zabbix >= 3.0 and RedHat 8" + set_fact: + apache_log: httpd + datafiles_path: "/usr/share/doc/zabbix-proxy-{{ zabbix_proxy_database }}" + when: + - zabbix_version is version_compare('3.0', '>=') + - ansible_distribution_major_version == '8' + tags: + - zabbix-proxy + +- name: "RedHat | Set some facts EPEL" + set_fact: + datafiles_path: "/usr/share/zabbix-{{ zabbix_proxy_database_long }}" + when: + - zabbix_repo == "epel" + tags: + - zabbix-server + +- name: "RedHat | Create 'zabbix' group (EPEL)" + group: + name: "{{ zabbix_proxy_groupname | default('zabbix') }}" + gid: "{{ zabbix_proxy_groupid | default(omit) }}" + state: present + become: yes + when: + - zabbix_repo == "epel" + +- name: "RedHat | Create 'zabbix' user (EPEL)" + user: + name: "{{ zabbix_proxy_username | default('zabbix') }}" + comment: Zabbix Monitoring System + uid: "{{ zabbix_proxy_userid | default(omit) }}" + group: zabbix + become: yes + when: + - zabbix_repo == "epel" + +- name: "Make sure old file is absent" + file: + path: /etc/yum.repos.d/zabbix-supported.repo + state: absent + become: yes + +- name: "RedHat | Install basic repo file" + yum_repository: + name: "{{ item.name }}" + description: "{{ item.description }}" + baseurl: "{{ item.baseurl }}" + gpgcheck: "{{ item.gpgcheck }}" + gpgkey: "{{ item.gpgkey }}" + mode: "{{ item.mode | default('0644') }}" + priority: "{{ item.priority | default('99') }}" + state: "{{ item.state | default('present') }}" + proxy: "{{ zabbix_http_proxy | default(omit) }}" + with_items: "{{ zabbix_repo_yum }}" + register: yum_repo_installed + become: yes + when: + - zabbix_repo == "zabbix" + notify: + - "clean repo files from proxy creds" + tags: + - zabbix-agent + +- name: "RedHat | Installing zabbix-proxy-{{ zabbix_proxy_database }}" + package: + pkg: "{{ zabbix_proxy_package }}" + state: "{{ zabbix_proxy_package_state }}" + disablerepo: "{{ '*' if (zabbix_repo_yum_enabled | length>0) else omit }}" + enablerepo: "{{ zabbix_repo_yum_enabled if zabbix_repo_yum_enabled is iterable and (zabbix_repo_yum_enabled | length>0) else omit }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + become: yes + register: is_zabbix_proxy_package_installed + until: is_zabbix_proxy_package_installed is succeeded + +- name: "RedHat | Install Ansible PostgreSQL module dependencies" + yum: + name: python-psycopg2 + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + become: yes + register: are_zabbix_proxy_dependency_packages_installed + until: are_zabbix_proxy_dependency_packages_installed is succeeded + when: + - zabbix_database_creation or zabbix_database_sqlload + - zabbix_proxy_database == 'pgsql' + - ansible_distribution_major_version == "7" or ansible_distribution_major_version == "6" + tags: + - zabbix-proxy + - init + +- name: "RedHat | Install Ansible module dependencies on RHEL8" + yum: + name: python3-psycopg2 + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_proxy_dependencies_installed + until: zabbix_proxy_dependencies_installed is succeeded + become: yes + when: + - zabbix_database_creation + - zabbix_proxy_database == 'pgsql' + - ansible_distribution_major_version == "8" + tags: + - zabbix-server + +- name: "RedHat | Install Mysql Client package RHEL7" + yum: + name: + - mariadb + - MySQL-python + state: installed + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + become: yes + register: are_zabbix_proxy_dependency_packages_installed + until: are_zabbix_proxy_dependency_packages_installed is succeeded + when: + - zabbix_database_creation or zabbix_database_sqlload + - zabbix_proxy_database == 'mysql' + - ansible_distribution_major_version == '7' + tags: + - zabbix-proxy + - init + +- name: "RedHat | Install Mysql Client package RHEL5 - 6" + yum: + name: + - mysql + - MySQL-python + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + become: yes + register: are_zabbix_proxy_dependency_packages_installed + until: are_zabbix_proxy_dependency_packages_installed is succeeded + when: + - zabbix_database_creation or zabbix_database_sqlload + - zabbix_proxy_database == 'mysql' + - ansible_distribution_major_version == "6" or ansible_distribution_major_version == "5" + - zabbix_proxy_install_database_client + tags: + - zabbix-proxy + - init + - database + +- name: "RedHat | Install PostgreSQL client package" + yum: + name: postgresql + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + become: yes + register: are_zabbix_proxy_dependency_packages_installed + until: are_zabbix_proxy_dependency_packages_installed is succeeded + when: + - zabbix_database_creation or zabbix_database_sqlload + - zabbix_proxy_database == 'pgsql' + - zabbix_proxy_install_database_client + tags: + - zabbix-proxy + - init + - database + +- name: "RedHat | Install sqlite3" + yum: + name: + - sqlite + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_proxy_dependencies_installed + until: zabbix_proxy_dependencies_installed is succeeded + become: yes + when: + - zabbix_proxy_database == 'sqlite3' + tags: + - zabbix-proxy + +- name: "Configure SELinux when enabled" + include: selinux.yml + when: + - zabbix_selinux | bool diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/main.yml new file mode 100644 index 00000000..9bcde1de --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/main.yml @@ -0,0 +1,143 @@ +--- +# tasks file for dj-wasabi.zabbix-proxy + +- name: "Set default ip address for zabbix_proxy_ip" + set_fact: + zabbix_proxy_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4'].address }}" + when: + - zabbix_proxy_ip is not defined + - "'ansible_default_ipv4' in hostvars[inventory_hostname]" + +- name: "Set OS dependent variables" + include_vars: "{{ item }}" + with_first_found: + - "../vars/{{ ansible_distribution }}.yml" + - "../vars/main.yml" + +- name: "Install the correct repository" + include: "RedHat.yml" + when: + - ansible_os_family == "RedHat" + +- name: "Install the correct repository" + include: "Debian.yml" + when: + - ansible_os_family == "Debian" + +- name: "Installing the database" + include: "{{ zabbix_proxy_database_long }}.yml" + +- name: "Create include dir zabbix-proxy" + file: + path: "{{ zabbix_proxy_include }}" + owner: zabbix + group: zabbix + mode: "{{ zabbix_proxy_include_mode }}" + state: directory + become: yes + +- name: "Create module dir zabbix-proxy" + file: + path: "{{ zabbix_proxy_loadmodulepath }}" + owner: zabbix + group: zabbix + state: directory + become: yes + +- name: "Create directory for PSK file if not exist." + file: + path: "{{ zabbix_proxy_tlspskfile | dirname }}" + mode: 0755 + state: directory + become: yes + when: + - zabbix_proxy_tlspskfile is defined + +- name: "Place TLS PSK File" + copy: + dest: "{{ zabbix_proxy_tlspskfile }}" + content: "{{ zabbix_proxy_tlspsk_secret }}" + owner: zabbix + group: zabbix + mode: 0400 + become: yes + when: + - zabbix_proxy_tlspskfile is defined + - zabbix_proxy_tlspsk_secret is defined + notify: + - restart zabbix-proxy + +- name: "Allow zabbix-proxy to open connections (SELinux)" + seboolean: + name: zabbix_can_network + persistent: yes + state: yes + become: yes + when: ansible_selinux.status == "enabled" + tags: selinux + +- name: "Allow zabbix-proxy to connect to zabbix_proxy_preprocessing.sock (SELinux)" + seboolean: + name: daemons_enable_cluster_mode + persistent: yes + state: yes + become: yes + when: ansible_selinux.status == "enabled" + tags: selinux + +- name: "Configure zabbix-proxy" + template: + src: zabbix_proxy.conf.j2 + dest: /etc/zabbix/zabbix_proxy.conf + owner: zabbix + group: zabbix + mode: "{{ zabbix_proxy_conf_mode }}" + notify: restart zabbix-proxy + become: yes + +- name: "Installing the Zabbix-api package on localhost" + pip: + name: zabbix-api + state: present + register: zabbix_api_package_installed + until: zabbix_api_package_installed is succeeded + delegate_to: localhost + become: "{{ zabbix_proxy_become_on_localhost }}" + when: + - zabbix_install_pip_packages | bool + - zabbix_api_create_proxy | bool + tags: + - api + +- name: "Create proxy" + zabbix_proxy: + server_url: "{{ zabbix_url }}" + http_login_user: "{{ zabbix_api_http_user | default(omit) }}" + http_login_password: "{{ zabbix_api_http_password | default(omit) }}" + login_user: "{{ zabbix_api_user }}" + login_password: "{{ zabbix_api_pass }}" + state: "{{ zabbix_create_proxy }}" + status: "{{ zabbix_proxy_status }}" + proxy_name: "{{ zabbix_proxy_name }}" + description: "{{ zabbix_proxy_description | default(omit) }}" + interface: "{{ zabbix_proxy_interface }}" + tls_psk: "{{ zabbix_proxy_tlspsk_secret | default(omit) }}" + tls_psk_identity: "{{ zabbix_proxy_tlspskidentity | default(omit) }}" + tls_subject: "{{ zabbix_proxy_tlsservercertsubject | default(omit) }}" + tls_accept: "{{ zabbix_proxy_tls_config[zabbix_proxy_tlsaccept if zabbix_proxy_tlsaccept else 'no_encryption'] }}" + tls_connect: "{{ zabbix_proxy_tls_config[zabbix_proxy_tlsconnect if zabbix_proxy_tlsconnect else 'no_encryption'] }}" + validate_certs: "{{ zabbix_validate_certs | default(omit) }}" + when: + - zabbix_api_create_proxy | bool + delegate_to: localhost + become: no + tags: + - api + +- name: "zabbix-proxy started" + service: + name: zabbix-proxy + state: started + enabled: yes + become: yes + when: zabbix_proxy_manage_service | bool diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/mysql.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/mysql.yml new file mode 100644 index 00000000..198c5003 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/mysql.yml @@ -0,0 +1,157 @@ +--- +# task file for mysql +- name: "Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" + set_fact: + delegated_dbhost: "{{ zabbix_proxy_dbhost if (zabbix_proxy_dbhost != 'localhost') else inventory_hostname }}" + when: + - zabbix_proxy_dbhost_run_install + +- name: "Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" + set_fact: + delegated_dbhost: "{{ inventory_hostname }}" + when: + - not zabbix_proxy_dbhost_run_install + +- name: "Override delegated_dbhost with real dbhost when dbhost is behind loadbalancer" + set_fact: + delegated_dbhost: "{{ zabbix_proxy_real_dbhost }}" + when: zabbix_proxy_real_dbhost | default(false) + +- name: "MySQL | Create database" + mysql_db: + name: "{{ zabbix_proxy_dbname }}" + encoding: "{{ zabbix_proxy_dbencoding }}" + collation: "{{ zabbix_proxy_dbcollation }}" + login_host: "{{ zabbix_proxy_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_proxy_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_proxy_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_proxy_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_proxy_mysql_login_unix_socket | default(omit) }}" + state: present + when: zabbix_database_creation + register: zabbix_database_created + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-proxy + - database + - skip_ansible_lint + +- name: "MySQL | Create database user" + mysql_user: + login_host: "{{ zabbix_proxy_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_proxy_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_proxy_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_proxy_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_proxy_mysql_login_unix_socket | default(omit) }}" + name: "{{ zabbix_proxy_dbuser }}" + password: "{{ zabbix_proxy_dbpassword }}" + priv: "{{ zabbix_proxy_dbname }}.*:ALL" + host: "{{ zabbix_proxy_privileged_host }}" + state: present + when: zabbix_database_creation + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-proxy + - database + +- name: "Get the file for schema.sql" + shell: ls -1 {{ datafiles_path }}/schema.sq* + changed_when: False + when: + - zabbix_database_sqlload + - zabbix_repo != "epel" + register: ls_output_create + tags: + - zabbix-proxy + - database + +- name: "Check if we have done files" + stat: + path: /etc/zabbix/schema.done + register: done_file + when: + - zabbix_database_sqlload + - zabbix_repo != "epel" + +- name: "MySQL | Get current value for innodb_default_row_format" + shell: | + set -euo pipefail + mysql -h {{ zabbix_proxy_dbhost }} -u{{ zabbix_proxy_dbuser }} \ + -p'{{ zabbix_proxy_dbpassword }}' \ + -e 'SHOW VARIABLES;' 2>&1 | grep innodb_default_row_format \ + | awk '{print $2}' | tr [:upper:] [:lower:] + register: mysql_innodb_default_row_format + changed_when: False + args: + executable: /bin/bash + become: true + +- name: "MySQL | Set innodb_default_row_format to dynamic" + mysql_variables: + variable: innodb_default_row_format + value: dynamic + login_host: "{{ zabbix_proxy_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_proxy_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_proxy_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_proxy_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_proxy_mysql_login_unix_socket | default(omit) }}" + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + - not done_file.stat.exists + - mysql_innodb_default_row_format.stdout != 'dynamic' + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-proxy + - database + +- name: "MySQL | Create database and import file" + mysql_db: + login_host: "{{ zabbix_proxy_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_proxy_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_proxy_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_proxy_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_proxy_mysql_login_unix_socket | default(omit) }}" + name: "{{ zabbix_proxy_dbname }}" + encoding: "{{ zabbix_proxy_dbencoding }}" + collation: "{{ zabbix_proxy_dbcollation }}" + state: import + target: "{{ ls_output_create.stdout }}" + when: + - zabbix_database_sqlload + - zabbix_repo != "epel" + - not done_file.stat.exists + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-proxy + - database + +- name: "MySQL | Revert innodb_default_row_format to previous value" + mysql_variables: + variable: innodb_default_row_format + value: '{{ mysql_innodb_default_row_format.stdout }}' + login_host: "{{ zabbix_proxy_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_proxy_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_proxy_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_proxy_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_proxy_mysql_login_unix_socket | default(omit) }}" + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + - not done_file.stat.exists + - mysql_innodb_default_row_format.stdout != 'dynamic' + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-proxy + - database + +- name: "Create done file" + file: + path: /etc/zabbix/schema.done + state: touch + when: + - zabbix_database_sqlload + - zabbix_repo != "epel" + - not done_file.stat.exists diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/postgresql.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/postgresql.yml new file mode 100644 index 00000000..35ef402d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/postgresql.yml @@ -0,0 +1,85 @@ +--- +# task file for postgresql + +- name: "Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" + set_fact: + delegated_dbhost: "{{ zabbix_proxy_dbhost if (zabbix_proxy_dbhost != 'localhost') else inventory_hostname }}" + when: + - zabbix_proxy_dbhost_run_install + +- name: "Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" + set_fact: + delegated_dbhost: "{{ inventory_hostname }}" + when: + - not zabbix_proxy_dbhost_run_install + +- name: "PostgreSQL | Delegated" + block: + - name: "PostgreSQL | Delegated | Create database" + postgresql_db: + name: "{{ zabbix_proxy_dbname }}" + port: "{{ zabbix_proxy_dbport }}" + state: present + - name: "PostgreSQL | Delegated | Create database user" + postgresql_user: + db: "{{ zabbix_proxy_dbname }}" + name: "{{ zabbix_proxy_dbuser }}" + password: "md5{{ (zabbix_proxy_dbpassword + zabbix_proxy_dbuser)|hash('md5') }}" + port: "{{ zabbix_proxy_dbport }}" + priv: ALL + state: present + encrypted: yes + become: yes + become_user: postgres + delegate_to: "{{ delegated_dbhost }}" + when: + - zabbix_database_creation + - zabbix_proxy_pgsql_login_host is not defined + tags: + - zabbix-server + - database + +- name: "PostgreSQL | Remote" + block: + - name: "PostgreSQL | Remote | Create database" + postgresql_db: + login_host: "{{ zabbix_proxy_pgsql_login_host | default(omit) }}" + login_user: "{{ zabbix_proxy_pgsql_login_user | default(omit) }}" + login_password: "{{ zabbix_proxy_pgsql_login_password | default(omit) }}" + login_unix_socket: "{{ zabbix_proxy_pgsql_login_unix_socket | default(omit) }}" + name: "{{ zabbix_proxy_dbname }}" + port: "{{ zabbix_proxy_dbport }}" + state: present + - name: "PostgreSQL | Remote | Create database user" + postgresql_user: + login_host: "{{ zabbix_proxy_pgsql_login_host | default(omit) }}" + login_user: "{{ zabbix_proxy_pgsql_login_user | default(omit) }}" + login_password: "{{ zabbix_proxy_pgsql_login_password | default(omit) }}" + db: "{{ zabbix_proxy_dbname }}" + name: "{{ zabbix_proxy_dbuser }}" + password: "md5{{ (zabbix_proxy_dbpassword + zabbix_proxy_dbuser)|hash('md5') }}" + port: "{{ zabbix_proxy_dbport }}" + priv: ALL + state: present + encrypted: yes + when: + - zabbix_database_creation + - zabbix_proxy_pgsql_login_host is defined + tags: + - zabbix-server + - database + +- name: "PostgreSQL | Importing schema file" + shell: | + cd {{ datafiles_path }} + if [ -f schema.sql.gz ] + then gunzip schema.sql.gz + fi + psql -h '{{ zabbix_proxy_dbhost }}' -U '{{ zabbix_proxy_dbuser }}' \ + -d '{{ zabbix_proxy_dbname }}' -f schema.sql && touch /etc/zabbix/schema.done + args: + creates: /etc/zabbix/schema.done + environment: + PGPASSWORD: '{{ zabbix_proxy_dbpassword }}' + when: + - zabbix_database_creation diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/selinux.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/selinux.yml new file mode 100644 index 00000000..8cbac35a --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/selinux.yml @@ -0,0 +1,50 @@ +--- + +- name: "SELinux | RedHat | Install related SELinux package to fix issues" + yum: + name: + - policycoreutils-python + - libsemanage-python + - checkpolicy + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_proxy_dependencies_installed + until: zabbix_proxy_dependencies_installed is succeeded + become: yes + when: + - ansible_os_family == "RedHat" + - ansible_distribution_major_version == "7" or ansible_distribution_major_version == "6" + tags: + - zabbix-proxy + +- name: "SELinux | RedHat | Install related SELinux package to fix issues on RHEL8" + yum: + name: + - policycoreutils + - checkpolicy + - python3-libsemanage + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_proxy_dependencies_installed + until: zabbix_proxy_dependencies_installed is succeeded + become: yes + when: + - ansible_os_family == "RedHat" + - ansible_distribution_major_version == "8" + tags: + - zabbix-proxy + +- name: "SELinux | RedHat | Add SEmodule to fix SELinux issue: zabbix_proxy_alerter.sock" + script: + cmd: files/install_semodule.bsx + args: + creates: /etc/selinux/targeted/active/modules/400/zabbix_proxy_add/cil + become: yes + when: + - ansible_os_family == "RedHat" + tags: + - zabbix-proxy diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/sqlite3.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/sqlite3.yml new file mode 100644 index 00000000..12167f0d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/sqlite3.yml @@ -0,0 +1,48 @@ +--- +# task file for sqlite3 + +- name: "Sqlite3 | Default Database Path" + set_fact: + zabbix_proxy_dbname: /var/lib/zabbix/zabbix_proxy.db + when: + - zabbix_proxy_dbname == "zabbix_proxy" + +- name: "Sqlite3 | Create database" + file: + name: "{{ zabbix_proxy_dbname | dirname }}" + owner: zabbix + group: zabbix + seuser: system_u + serole: object_r + setype: zabbix_var_lib_t + state: directory + become: yes + when: + - zabbix_database_creation + +- name: "Sqlite3 | Importing schema file" + become: yes + become_user: zabbix + shell: | + set -o pipefail + zcat {{ datafiles_path }}/schema.sql.gz | sqlite3 {{ zabbix_proxy_dbname }} + args: + creates: "{{ zabbix_proxy_dbname }}" + executable: /bin/bash + environment: + PGPASSWORD: '{{ zabbix_proxy_dbpassword }}' + when: + - zabbix_database_creation + +- name: "Fix zabbix db file permission (SELinux)" + file: + path: "{{ zabbix_proxy_dbname }}" + state: file + seuser: system_u + serole: object_r + setype: zabbix_var_lib_t + become: yes + when: + - ansible_selinux.status == "enabled" + - zabbix_database_creation + tags: selinux diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/templates/zabbix_proxy.conf.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/templates/zabbix_proxy.conf.j2 new file mode 100644 index 00000000..e335fc1c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/templates/zabbix_proxy.conf.j2 @@ -0,0 +1,604 @@ +# This is a configuration file for Zabbix Proxy process +# To get more information about Zabbix, +# visit http://www.zabbix.com + +############ GENERAL PARAMETERS ################# + +### Option: ProxyMode +# Proxy operating mode +# 0 - proxy in the active mode +# 1 - proxy in the passive mode +# +ProxyMode={{ zabbix_proxy_mode }} + +### Option: Server +# IP address (or hostname) of Zabbix server. +# Active proxy will get configuration data from the server. +# For a proxy in the passive mode this parameter will be ignored. +# +Server={{ zabbix_server_host }} + +### Option: ServerPort +# Port of Zabbix trapper on Zabbix server. +# For a proxy in the passive mode this parameter will be ignored. +# +ServerPort={{ zabbix_server_port }} + +### Option: Hostname +# Unique, case sensitive Proxy name. Make sure the Proxy name is known to the server! +# Value is acquired from HostnameItem if undefined. +# +{% if zabbix_proxy_hostname is defined and zabbix_proxy_hostname %} +Hostname={{ zabbix_proxy_hostname }} +{% endif %} + +### Option: HostnameItem +# Item used for generating Hostname if it is undefined. +# Ignored if Hostname is defined. +# +# Mandatory: no +# Default: +# HostnameItem=system.hostname +{% if zabbix_proxy_hostnameitem is defined and zabbix_proxy_hostnameitem %} +HostnameItem={{ zabbix_proxy_hostnameitem }} +{% endif %} + +### Option: ListenPort +# Listen port for trapper. +# +ListenPort={{ zabbix_proxy_listenport }} + +### Option: SourceIP +# Source IP address for outgoing connections. +# +{% if zabbix_proxy_sourceip is defined and zabbix_proxy_sourceip %} +SourceIP={{ zabbix_proxy_sourceip }} +{% endif %} + +### Option: LogFile +# Name of log file. +# If not set, syslog is used. +# +LogFile={{ zabbix_proxy_logfile }} + +### Option: LogFileSize +# Maximum size of log file in MB. +# 0 - disable automatic log rotation. +# +LogFileSize={{ zabbix_proxy_logfilesize }} + +### Option: EnableRemoteCommands +# Whether remote commands from Zabbix server are allowed. +# 0 - not allowed +# 1 - allowed +# +EnableRemoteCommands={{ zabbix_proxy_enableremotecommands }} + +### Option: DebugLevel +# Specifies debug level +# 0 - no debug +# 1 - critical information +# 2 - error information +# 3 - warnings +# 4 - for debugging (produces lots of information) +# +DebugLevel={{ zabbix_proxy_debuglevel }} + +### Option: PidFile +# Name of PID file. +# +PidFile={{ zabbix_proxy_pidfile }} +{% if zabbix_version is version('3.2', '>') %} +### Option: SocketDir +# Location of the socketfile +# +SocketDir={{ zabbix_proxy_socketdir }} +{% endif %} +### Option: DBHost +# Database host name. +# If set to localhost, socket is used for MySQL. +# If set to empty string, socket is used for PostgreSQL. +# +DBHost={{ zabbix_proxy_dbhost }} + +### Option: DBName +# Database name. +# For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored. +# Warning: do not attempt to use the same database Zabbix server is using. +# +DBName={{ zabbix_proxy_dbname }} + +### Option: DBSchema +# Schema name. Used for IBM DB2. +# +{% if zabbix_proxy_dbschema is defined and zabbix_proxy_dbschema %} +DBSchema={{ zabbix_proxy_dbschema }} +{% endif %} + +### Option: DBUser +# Database user. Ignored for SQLite. +# +DBUser={{ zabbix_proxy_dbuser }} + +### Option: DBPassword +# Database password. Ignored for SQLite. +# Comment this line if no password is used. +# +DBPassword={{ zabbix_proxy_dbpassword }} + +### Option: DBSocket +# Path to MySQL socket. +# + +# Option: DBPort +# Database port when not using local socket. Ignored for SQLite. +# +DBPort={{ zabbix_proxy_dbport }} + +######### PROXY SPECIFIC PARAMETERS ############# + +### Option: ProxyLocalBuffer +# Proxy will keep data locally for N hours, even if the data have already been synced with the server. +# This parameter may be used if local data will be used by third party applications. +# +ProxyLocalBuffer={{ zabbix_proxy_localbuffer }} + +### Option: ProxyOfflineBuffer +# Proxy will keep data for N hours in case if no connectivity with Zabbix Server. +# Older data will be lost. +# +ProxyOfflineBuffer={{ zabbix_proxy_offlinebuffer }} + +### Option: HeartbeatFrequency +# Frequency of heartbeat messages in seconds. +# Used for monitoring availability of Proxy on server side. +# 0 - heartbeat messages disabled. +# For a proxy in the passive mode this parameter will be ignored. +# +HeartbeatFrequency={{ zabbix_proxy_heartbeatfrequency }} + +### Option: ConfigFrequency +# How often proxy retrieves configuration data from Zabbix Server in seconds. +# For a proxy in the passive mode this parameter will be ignored. +# +ConfigFrequency={{ zabbix_proxy_configfrequency }} + +### Option: DataSenderFrequency +# Proxy will send collected data to the Server every N seconds. +# For a proxy in the passive mode this parameter will be ignored. +# +DataSenderFrequency={{ zabbix_proxy_datasenderfrequency }} + +############ ADVANCED PARAMETERS ################ + +### Option: StartPollers +# Number of pre-forked instances of pollers. +# +StartPollers={{ zabbix_proxy_startpollers }} + +### Option: StartIPMIPollers +# Number of pre-forked instances of IPMI pollers. +# +StartIPMIPollers={{ zabbix_proxy_startipmipollers }} + +{% if zabbix_version is version('4.2', '>=') %} +### Option: StartPreprocessors +# Number of pre-forked instances of preprocessing workers. +# The preprocessing manager process is automatically started when preprocessor worker is started. +# +# Mandatory: no +# Range: 1-1000 +# Default: +# StartPreprocessors=3 +StartPreprocessors={{ zabbix_proxy_startpreprocessors }} +{% endif %} + +### Option: StartPollersUnreachable +# Number of pre-forked instances of pollers for unreachable hosts (including IPMI). +# +StartPollersUnreachable={{ zabbix_proxy_startpollersunreachable }} + +### Option: StartTrappers +# Number of pre-forked instances of trappers. +# Trappers accept incoming connections from Zabbix sender and active agents. +# +StartTrappers={{ zabbix_proxy_starttrappers }} + +### Option: StartPingers +# Number of pre-forked instances of ICMP pingers. +# +StartPingers={{ zabbix_proxy_startpingers }} + +### Option: StartDiscoverers +# Number of pre-forked instances of discoverers. +# +StartDiscoverers={{ zabbix_proxy_startdiscoverers }} + +### Option: StartHTTPPollers +# Number of pre-forked instances of HTTP pollers. +# +StartHTTPPollers={{ zabbix_proxy_starthttppollers }} + +### Option: JavaGateway +# IP address (or hostname) of Zabbix Java gateway. +# Only required if Java pollers are started. +# +{% if zabbix_proxy_javagateway is defined and zabbix_proxy_javagateway %} +JavaGateway={{ zabbix_proxy_javagateway }} + +### Option: JavaGatewayPort +# Port that Zabbix Java gateway listens on. +# +JavaGatewayPort={{ zabbix_proxy_javagatewayport }} + +### Option: StartJavaPollers +# Number of pre-forked instances of Java pollers. +# +StartJavaPollers={{ zabbix_proxy_startjavapollers }} +{% endif %} + +{% if zabbix_version is version_compare('2.4', '>=') %} +### Option: StartVMwareCollectors +# Number of pre-forked vmware collector instances. +# +StartVMwareCollectors={{ zabbix_proxy_startvmwarecollector }} + +### Option: VMwareFrequency +# How often Zabbix will connect to VMware service to obtain a new data. +# +VMwareFrequency={{ zabbix_proxy_vmwarefrequency }} + +### Option: VMwareCacheSize +# Size of VMware cache, in bytes. +# Shared memory size for storing VMware data. +# Only used if VMware collectors are started. +# +VMwareCacheSize={{ zabbix_proxy_vmwarecachesize -}}M +{% endif %} + +### Option: SNMPTrapperFile +# Temporary file used for passing data from SNMP trap daemon to the proxy. +# Must be the same as in zabbix_trap_receiver.pl or SNMPTT configuration file. +# +SNMPTrapperFile={{ zabbix_proxy_snmptrapperfile }} + +### Option: StartSNMPTrapper +# If 1, SNMP trapper process is started. +# +StartSNMPTrapper={{ zabbix_proxy_snmptrapper }} + +### Option: ListenIP +# List of comma delimited IP addresses that the trapper should listen on. +# Trapper will listen on all network interfaces if this parameter is missing. +# +{% if zabbix_proxy_listenip is defined and zabbix_proxy_listenip %} +ListenIP={{ zabbix_proxy_listenip }} +{% endif %} + +### Option: HousekeepingFrequency +# How often Zabbix will perform housekeeping procedure (in hours). +# Housekeeping is removing unnecessary information from history, alert, and alarms tables. +# +HousekeepingFrequency={{ zabbix_proxy_housekeepingfrequency }} + +### Option: CacheSize +# Size of configuration cache, in bytes. +# Shared memory size, for storing hosts and items data. +# +CacheSize={{ zabbix_proxy_cachesize -}}M + +### Option: StartDBSyncers +# Number of pre-forked instances of DB Syncers +# +StartDBSyncers={{ zabbix_proxy_startdbsyncers }} + +### Option: HistoryCacheSize +# Size of history cache, in bytes. +# Shared memory size for storing history data. +# +HistoryCacheSize={{ zabbix_proxy_historycachesize -}}M + +{% if zabbix_version is version_compare('3.2', '>=') %} +### Option: HistoryIndexCacheSize +# Size of history index cache, in bytes. +# Shared memory size for indexing history cache. +# +# Mandatory: no +# Range: 128K-2G +# Default: +HistoryIndexCacheSize={{ zabbix_proxy_historyindexcachesize -}}M +{% endif %} + +{% if zabbix_version is version_compare('2.4', '<') %} +### Option: HistoryTextCacheSize +# Size of text history cache, in bytes. +# Shared memory size for storing character, text or log history data. +# +HistoryTextCacheSize={{ zabbix_proxy_historytextcachesize -}}M +{% endif %} + +### Option: Timeout +# Specifies how long we wait for agent, SNMP device or external check (in seconds). +# +Timeout={{ zabbix_proxy_timeout }} + +### Option: TrapperTimeout +# Specifies how many seconds trapper may spend processing new data. +# +TrapperTimeout={{ zabbix_proxy_trappertimeout }} + +### Option: UnreachablePeriod +# After how many seconds of unreachability treat a host as unavailable. +# +UnreachablePeriod={{ zabbix_proxy_unreachableperiod }} + +### Option: UnavailableDelay +# How often host is checked for availability during the unavailability period, in seconds. +# +UnavailableDelay={{ zabbix_proxy_unavaliabledelay }} + +### Option: UnreachableDelay +# How often host is checked for availability during the unreachability period, in seconds. +# +UnreachableDelay={{ zabbix_proxy_unreachabedelay }} + +### Option: ExternalScripts +# Full path to location of external scripts. +# Default depends on compilation options. +# +ExternalScripts={{ zabbix_proxy_externalscripts }} + +### Option: FpingLocation +# Location of fping. +# Make sure that fping binary has root ownership and SUID flag set. +# +FpingLocation={{ zabbix_proxy_fpinglocation }} + +### Option: Fping6Location +# Location of fping6. +# Make sure that fping6 binary has root ownership and SUID flag set. +# Make empty if your fping utility is capable to process IPv6 addresses. +# +Fping6Location={{ zabbix_proxy_fping6location }} + +### Option: SSHKeyLocation +# Location of public and private keys for SSH checks and actions. +# +{% if zabbix_proxy_sshkeylocation is defined and zabbix_proxy_sshkeylocation %} +SSHKeyLocation={{ zabbix_proxy_sshkeylocation }} +{% endif %} + +### Option: LogSlowQueries +# How long a database query may take before being logged (in milliseconds). +# Only works if DebugLevel set to 3 or 4. +# 0 - don't log slow queries. +# +LogSlowQueries={{ zabbix_proxy_loglowqueries }} + +### Option: TmpDir +# Temporary directory. +# +TmpDir={{ zabbix_proxy_tmpdir }} + +{% if zabbix_version is version_compare('2.4', '<') %} +### Option: AllowRoot +# Allow the proxy to run as 'root'. If disabled and the proxy is started by 'root', the proxy +# will try to switch to user 'zabbix' instead. Has no effect if started under a regular user. +# 0 - do not allow +# 1 - allow +# +AllowRoot={{ zabbix_proxy_allowroot }} +{% endif %} + +### Option: Include +# You may include individual files or all files in a directory in the configuration file. +# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. +# +Include={{ zabbix_proxy_include }} + +####### LOADABLE MODULES ####### + +{% if zabbix_version is version_compare('3.0', '<') %} +### Option: LoadModulePath +# Full path to location of proxy modules. +# Default depends on compilation options. +# +LoadModulePath={{ zabbix_proxy_loadmodulepath }} +{% endif %} + +### Option: LoadModule +# Module to load at proxy startup. Modules are used to extend functionality of the proxy. +# Format: LoadModule= +# The modules must be located in directory specified by LoadModulePath. +# It is allowed to include multiple LoadModule parameters. +# +{% if zabbix_proxy_loadmodule is defined and zabbix_proxy_loadmodule %} +LoadModule={{ zabbix_proxy_loadmodule }} +{% endif %} + +{% if zabbix_version is version_compare('3.0', '>=') %} +####### TLS-RELATED PARAMETERS ####### + +### Option: TLSConnect +# How the agent should connect to server or proxy. Used for active checks. +# Only one value can be specified: +# unencrypted - connect without encryption +# psk - connect using TLS and a pre-shared key +# cert - connect using TLS and a certificate +# +# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection) +# Default: +# TLSConnect=unencrypted +{% if zabbix_proxy_tlsconnect is defined and zabbix_proxy_tlsconnect %} +TLSConnect={{ zabbix_proxy_tlsconnect }} +{% endif %} + +### Option: TLSAccept +# What incoming connections to accept. +# Multiple values can be specified, separated by comma: +# unencrypted - accept connections without encryption +# psk - accept connections secured with TLS and a pre-shared key +# cert - accept connections secured with TLS and a certificate +# +# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection) +# Default: +# TLSAccept=unencrypted +{% if zabbix_proxy_tlsaccept is defined and zabbix_proxy_tlsaccept %} +TLSAccept={{ zabbix_proxy_tlsaccept }} +{% endif %} + +### Option: TLSCAFile +# Full pathname of a file containing the top-level CA(s) certificates for +# peer certificate verification. +# +# Mandatory: no +# Default: +# TLSCAFile= +{% if zabbix_proxy_tlscafile is defined and zabbix_proxy_tlscafile %} +TLSCAFile={{ zabbix_proxy_tlscafile }} +{% endif %} + +### Option: TLSCRLFile +# Full pathname of a file containing revoked certificates. +# +# Mandatory: no +# Default: +# TLSCRLFile= +{% if zabbix_proxy_tlscrlfile is defined and zabbix_proxy_tlscrlfile %} +TLSCRLFile={{ zabbix_proxy_tlscrlfile }} +{% endif %} + +### Option: TLSServerCertIssuer +# Allowed server certificate issuer. +# +# Mandatory: no +# Default: +# TLSServerCertIssuer= +{% if zabbix_proxy_tlsservercertissuer is defined and zabbix_proxy_tlsservercertissuer %} +TLSServerCertIssuer={{ zabbix_proxy_tlsservercertissuer }} +{% endif %} + +### Option: TLSServerCertSubject +# Allowed server certificate subject. +# +# Mandatory: no +# Default: +# TLSServerCertSubject= +{% if zabbix_proxy_tlsservercertsubject is defined and zabbix_proxy_tlsservercertsubject %} +TLSServerCertSubject={{ zabbix_proxy_tlsservercertsubject }} +{% endif %} + +### Option: TLSCertFile +# Full pathname of a file containing the agent certificate or certificate chain. +# +# Mandatory: no +# Default: +# TLSCertFile= +{% if zabbix_proxy_tlscertfile is defined and zabbix_proxy_tlscertfile %} +TLSCertFile={{ zabbix_proxy_tlscertfile }} +{% endif %} + +### Option: TLSKeyFile +# Full pathname of a file containing the agent private key. +# +# Mandatory: no +# Default: +# TLSKeyFile= +{% if zabbix_proxy_tlskeyfile is defined and zabbix_proxy_tlskeyfile %} +TLSKeyFile={{ zabbix_proxy_tlskeyfile }} +{% endif %} + +### Option: TLSPSKIdentity +# Unique, case sensitive string used to identify the pre-shared key. +# +# Mandatory: no +# Default: +# TLSPSKIdentity= +{% if zabbix_proxy_tlspskidentity is defined and zabbix_proxy_tlspskidentity %} +TLSPSKIdentity={{ zabbix_proxy_tlspskidentity }} +{% endif %} + +### Option: TLSPSKFile +# Full pathname of a file containing the pre-shared key. +# +# Mandatory: no +# Default: +# TLSPSKFile= +{% if zabbix_proxy_tlspskfile is defined and zabbix_proxy_tlspskfile %} +TLSPSKFile={{ zabbix_proxy_tlspskfile }} +{% endif %} +{% endif %} + +### Option: DBTLSConnect +# Setting this option enforces to use TLS connection to database. +# required - connect using TLS +# verify_ca - connect using TLS and verify certificate +# verify_full - connect using TLS, verify certificate and verify that database identity specified by DBHost +# matches its certificate +# On MySQL starting from 5.7.11 and PostgreSQL following values are supported: "required", "verify_ca" and +# "verify_full". +# On MariaDB starting from version 10.2.6 "required" and "verify_full" values are supported. +# Default is not to set any option and behavior depends on database configuration +# +# Mandatory: no +# Default: +# DBTLSConnect= +{% if zabbix_proxy_dbtlsconnect is defined and zabbix_proxy_dbtlsconnect is not none %} +DBTLSConnect={{ zabbix_proxy_dbtlsconnect }} +{% endif %} + +### Option: DBTLSCAFile +# Full pathname of a file containing the top-level CA(s) certificates for database certificate verification. +# Supported only for MySQL and PostgreSQL +# +# Mandatory: no +# (yes, if DBTLSConnect set to one of: verify_ca, verify_full) +# Default: +# DBTLSCAFile= +{% if zabbix_proxy_dbtlscafile is defined and zabbix_proxy_dbtlscafile is not none %} +DBTLSCAFile={{ zabbix_proxy_dbtlscafile }} +{% endif %} + +### Option: DBTLSCertFile +# Full pathname of file containing Zabbix proxy certificate for authenticating to database. +# Supported only for MySQL and PostgreSQL +# +# Mandatory: no +# Default: +# DBTLSCertFile= +{% if zabbix_proxy_dbtlscertfile is defined and zabbix_proxy_dbtlscertfile is not none %} +DBTLSCertFile={{ zabbix_proxy_dbtlscertfile }} +{% endif %} + +### Option: DBTLSKeyFile +# Full pathname of file containing the private key for authenticating to database. +# Supported only for MySQL and PostgreSQL +# +# Mandatory: no +# Default: +# DBTLSKeyFile= +{% if zabbix_proxy_dbtlskeyfile is defined and zabbix_proxy_dbtlskeyfile is not none %} +DBTLSKeyFile={{ zabbix_proxy_dbtlskeyfile }} +{% endif %} + +### Option: DBTLSCipher +# The list of encryption ciphers that Zabbix proxy permits for TLS protocols up through TLSv1.2 +# Supported only for MySQL +# +# Mandatory no +# Default: +# DBTLSCipher= +{% if zabbix_proxy_dbtlscipher is defined and zabbix_proxy_dbtlscipher is not none %} +DBTLSCipher={{ zabbix_proxy_dbtlscipher }} +{% endif %} + +### Option: DBTLSCipher13 +# The list of encryption ciphersuites that Zabbix proxy permits for TLSv1.3 protocol +# Supported only for MySQL, starting from version 8.0.16 +# +# Mandatory no +# Default: +# DBTLSCipher13= +{% if zabbix_proxy_dbtlscipher13 is defined and zabbix_proxy_dbtlscipher13 is not none %} +DBTLSCipher13={{ zabbix_proxy_dbtlscipher13 }} +{% endif %} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/Amazon.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/Amazon.yml new file mode 100644 index 00000000..605be389 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/Amazon.yml @@ -0,0 +1,2 @@ +--- +ansible_distribution_major_version: "6" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/main.yml new file mode 100644 index 00000000..75627d3b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for zabbix-proxy diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/zabbix.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/zabbix.yml new file mode 100644 index 00000000..1da19b60 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/zabbix.yml @@ -0,0 +1,188 @@ +--- +sign_keys: + "52": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "50": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "44": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "42": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "40": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "34": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "32": + bionic: + sign_key: A14FE591 + sonya: + sign_key: 79EA5ED4 + serena: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "30": + bionic: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "24": + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + "22": + squeeze: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + lucid: + sign_key: 79EA5ED4 + +suse: + "openSUSE Leap": + "42": + name: server:monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_Leap_{{ ansible_distribution_version }}/ + "openSUSE": + "12": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_{{ ansible_distribution_version }} + "SLES": + "11": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/SLE_11_SP3/ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/README.md b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/README.md new file mode 100644 index 00000000..61808c7c --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/README.md @@ -0,0 +1,339 @@ +# community.zabbix.zabbix_server role + +![Zabbix Server](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_server/badge.svg) + +**Table of Contents** + +- [Overview](#overview) +- [Requirements](#requirements) + * [Operating systems](#operating-systems) + * [Zabbix Versions](#zabbix-versions) +- [Installation](#installation) +- [Role Variables](#role-variables) + * [Main variables](#main-variables) + + [Overall Zabbix](#overall-zabbix) + + [SElinux](#selinux) + + [Zabbix Server](#zabbix-server) + + [Database specific](#database-specific) + + [TLS Specific configuration](#tls-specific-configuration) + + [Custom Zabbix Scripts](#custom-zabbix-scripts) + * [proxy](#proxy) + * [Database](#database) + + [MySQL](#mysql) + - [Local Setup](#local-setup) + - [Separate Setup](#separate-setup) + + [PostgreSQL](#postgresql) + - [Local Setup](#local-setup-1) + - [Separate Setup](#separate-setup-1) +- [Example Playbook](#example-playbook) +- [Molecule](#molecule) +- [License](#license) +- [Author Information](#author-information) + +# Overview + +This is a Ansible role for installing and maintaining the zabbix-server. This will only install the Zabbix Server component and not the Zabbix Web. + +# Requirements + +## Operating systems + +This role will work on the following operating systems: + + * Red Hat + * Debian + * Ubuntu + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +## Zabbix Versions + +See the following list of supported Operating systems with the Zabbix releases: + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +See https://support.zabbix.com/browse/ZBX-18790 why RHEL7 is not supported anymore. + +# Installation + +Installing this role is very simple: `ansible-galaxy install community.zabbix.zabbix_server` + +Please be aware that this role only installs the Zabbix Server and not the Zabbix Web. If you do want to have a Zabbix Web, please execute the following command: `ansible-galaxy install community.zabbix.zabbix_web` + +# Role Variables + +## Main variables + +The following is an overview of all available configuration default for this role. + +### Overall Zabbix + +* `zabbix_server_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. +* `zabbix_service_state`: Default: `started`. Can be overridden to stopped if needed +* `zabbix_service_enabled`: Default: `True` Can be overridden to `False` if needed + +### SElinux + +* `zabbix_selinux`: Default: `False`. Enables an SELinux policy so that the server will run. +* `selinux_allow_zabbix_can_network`: Default: `False`. +* `selinux_allow_zabbix_can_http`: Default: `False`. + +### Zabbix Server + +* `zabbix_server_package_state`: Default: `present`. Can be overridden to `latest` to update packages when needed. +* `zabbix_server_listenport`: Default: `10051`. On which port the Zabbix Server is available. +* `zabbix_server_install_recommends`: Default: `True`. `False` does not install the recommended packages that come with the zabbix-server install. +* `zabbix_server_manage_service`: Default: `True`. When you run multiple Zabbix servers in a High Available cluster setup (e.g. pacemaker), you don't want Ansible to manage the zabbix-server service, because Pacemaker is in control of zabbix-server service and in this case, it needs to be set to `False`. +* `zabbix_proxy_startpreprocessors`: Number of pre-forked instances of preprocessing workers. The preprocessing manager process is automatically started when a preprocessor worker is started. This parameter is supported since Zabbix 4.2.0. +* `zabbix_server_username`: Default: `zabbix`. The name of the account on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_server_userid`: The UID of the account on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_server_groupname`: Default: `zabbix`. The name of the group of the user on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_server_groupid`: The GID of the group on the host. Will only be used when `zabbix_repo: epel` is used. +* `zabbix_server_include_mode`: Default: `0755`. The "mode" for the directory configured with `zabbix_server_include`. +* `zabbix_server_conf_mode`: Default: `0640`. The "mode" for the Zabbix configuration file. + +### Database specific + +* `zabbix_server_dbhost_run_install`: Default: `True`. When set to `True`, sql files will be executed on the host running the database. +* `zabbix_server_database`: Default: `pgsql`. The type of database used. Can be: `mysql` or `pgsql` +* `zabbix_server_database_long`: Default: `postgresql`. The type of database used, but long name. Can be: `mysql` or `postgresql` +* `zabbix_server_dbhost`: The hostname on which the database is running. +* `zabbix_server_real_dbhost`: The hostname of the dbhost that is running behind a loadbalancer/VIP (loadbalancers doesn't accept ssh connections) +* `zabbix_server_dbname`: The database name which is used by the Zabbix Server. +* `zabbix_server_dbuser`: The database username which is used by the Zabbix Server. +* `zabbix_server_dbpassword`: The database user password which is used by the Zabbix Server. +* `zabbix_server_dbport`: The database port which is used by the Zabbix Server. +* `zabbix_database_creation`: Default: `True`. When you don't want to create the database including user, you can set it to False. +* `zabbix_server_install_database_client`: Default: `True`. False does not install database client. Default true +* `zabbix_database_sqlload`:True / False. When you don't want to load the sql files into the database, you can set it to False. +* `zabbix_server_dbencoding`: Default: `utf8`. The encoding for the MySQL database. +* `zabbix_server_dbcollation`: Default: `utf8_bin`. The collation for the MySQL database. + +### TLS Specific configuration + +These variables are specific for Zabbix 3.0 and higher: + +* `zabbix_server_tlsconnect`: How the agent should connect to server or proxy. Used for active checks. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_server_tlsaccept`: What incoming connections to accept. + Possible values: + * unencrypted + * psk + * cert +* `zabbix_server_tlscafile`: Full pathname of a file containing the top-level CA(s) certificates for peer certificate verification. +* `zabbix_server_tlscrlfile`: Full pathname of a file containing revoked certificates. +* `zabbix_server_tlsservercertissuer`: Allowed server certificate issuer. +* `zabbix_server_tlsservercertsubject`: Allowed server certificate subject. +* `zabbix_server_tlscertfile`: Full pathname of a file containing the agent certificate or certificate chain. +* `zabbix_server_tlskeyfile`: Full pathname of a file containing the agent private key. +* `zabbix_server_dbtlsconnect`: Setting this option enforces to use TLS connection to database: + +`required` - connect using TLS +`verify_ca` - connect using TLS and verify certificate +`verify_full` - connect using TLS, verify certificate and verify that database identity specified by DBHost matches its certificate + +On `MySQL` starting from 5.7.11 and `PostgreSQL` the following values are supported: `required`, `verify`, `verify_full`. On MariaDB starting from version 10.2.6 `required` and `verify_full` values are supported. +By default not set to any option and the behaviour depends on database configuration. +This parameter is supported since Zabbix 5.0.0. + +* `zabbix_server_dbtlscafile`: Full pathname of a file containing the top-level CA(s) certificates for database certificate verification. This parameter is supported since Zabbix 5.0.0. +* `zabbix_server_dbtlscertfile`: Full pathname of file containing Zabbix server certificate for authenticating to database. This parameter is supported since Zabbix 5.0.0. +* `zabbix_server_dbtlskeyfile`: Full pathname of file containing the private key for authenticating to database. This parameter is supported since Zabbix 5.0.0. +* `zabbix_server_dbtlscipher`: The list of encryption ciphers that Zabbix server permits for TLS protocols up through TLSv1.2. Supported only for MySQL.This parameter is supported since Zabbix 5.0.0. +* `zabbix_server_dbtlscipher13`: The list of encryption ciphersuites that Zabbix server permits for TLSv1.3 protocol. Supported only for MySQL, starting from version 8.0.16. This parameter is supported since Zabbix 5.0.0. + +### Custom Zabbix Scripts + +Define these variables to copy scripts to your respective scripts path. + +* `zabbix_server_alertscripts`: List of alertscripts to be added to `zabbix_server_alertscriptspath` +* `zabbix_server_externalscripts`: List of alertscripts to be added to `zabbix_server_externalscriptspath` + +Example: + +```yaml + zabbix_server_alertscripts: + - path: "{{ lookup('first_found', 'zabbix-scripts/somescript.php') }}" + name: "somescript.php" +``` + +## proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +## Database + +With Zabbix Server you can make use of 2 different databases: + +* `mysql` +* `postgresql` + +In the following paragraphs we dive into both setups. + +### MySQL + +To make the Zabbix Server work with a `MySQL` database, there are 2 types on setup: + +1. Local setup, `MySQL` running on same host as the Zabbix Server; +2. Separate setup, `MySQL` running on a different host than the Zabbix Server. + +#### Local Setup + +We need to have the following dependencies met: + +1. Find an (Ansible) role that will install a `MySQL` instance on the host. Example: `geerlingguy.mysql` can be used, but also others can be used. Please make sure that before installing the Zabbix Server, you have a fully functional `MySQL` instance running. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_server_database: mysql +zabbix_server_database_long: mysql +zabbix_server_dbport: 3306 +zabbix_server_dbpassword: +``` + +Please generate a value for the `zabbix_server_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-server role will create an database and username (With the provided value for the password) in `MySQL`. +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Server with `MySQL` will be running. + +#### Separate Setup + +We need to have the following dependencies met: + +1. We need to either have a `MySQL` instance running somewhere in the environment. If this is the case, we need to have a username/password combination that is allowed to create a database and an user account. If there isn't one, please make sure there is one. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_server_database: mysql +zabbix_server_database_long: mysql +zabbix_server_dbport: 3306 +zabbix_server_dbhost: mysql-host +zabbix_server_dbhost_run_install: false +zabbix_server_dbpassword: +zabbix_server_privileged_host: '%' +zabbix_server_mysql_login_host: mysql-host +zabbix_server_mysql_login_user: root +zabbix_server_mysql_login_password: changeme +zabbix_server_mysql_login_port: 3306 +``` + +Please generate a value for the `zabbix_server_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-server role will create an database and username (With the provided value for the password) in `MySQL`. + +The `zabbix_server_privileged_host` can be set to the hostname/ip of the host running Zabbix Server for security related purposes. Also make sure that `zabbix_server_mysql_login_password` is set to the correct password for the user provided with `zabbix_server_mysql_login_host` to create a database and user in the `MySQL` instance. + +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Server with `MySQL` on a different host will be running. + +### PostgreSQL + +To make the Zabbix Server work with a `PgSQL` database, there are 2 types on setup: + +1. Local setup, `PgSQL` running on same host as the Zabbix Server; +2. Separate setup, `PgSQL` running on a different host than the Zabbix Server. + +#### Local Setup + +We need to have the following dependencies met: + +1. Find an (Ansible) role that will install a `PgSQL` instance on the host. Example: `geerlingguy.postgresql` can be used, but also others can be used. Please make sure that before installing the Zabbix Server, you have a fully functional `PgSQL` instance running. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_server_database: pgsql +zabbix_server_database_long: postgresql +zabbix_server_dbport: 5432 +zabbix_server_dbpassword: +``` + +Please generate a value for the `zabbix_server_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-server role will create an database and username (With the provided value for the password) in `PgSQL`. +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Server with `PgSQL` will be running. + +#### Separate Setup + +We need to have the following dependencies met: + +1. We need to either have a `PgSQL` instance running somewhere in the environment. If this is the case, we need to have a username/password combination that is allowed to create a database and an user account. If there isn't one, please make sure there is one. +2. We need to set some variables, either as input for the playbook or set them into the `group_vars` or `host_vars` (Your preference choice). We need to set the following properties: + +```yaml +zabbix_server_database: pgsq; +zabbix_server_database_long: postgresql +zabbix_server_dbport: 5432 +zabbix_server_dbhost: pgsql-host +zabbix_server_dbhost_run_install: false +zabbix_server_dbpassword: +zabbix_server_privileged_host: '%' +zabbix_server_pgsql_login_host: pgsql-host +zabbix_server_pgsql_login_user: postgres +zabbix_server_pgsql_login_password: changeme +zabbix_server_pgsql_login_port: 5432 +``` + +Please generate a value for the `zabbix_server_dbpassword` property (Maybe use `ansible-vault` for this). The zabbix-server role will create an database and username (With the provided value for the password) in `PgSQL`. + +The `zabbix_server_privileged_host` can be set to the hostname/ip of the host running Zabbix Server for security related purposes. Also make sure that `zabbix_server_mysql_login_password` is set to the correct password for the user provided with `zabbix_server_mysql_login_host` to create a database and user in the `PgSQL` instance. + +3. Execute the role by running the Ansible playbook that calls this role. At the end of this run, the Zabbix Server with `PgSQL` on a different host will be running. + +# Example Playbook + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + +```yaml + - hosts: zabbix-server + roles: + - role: community.zabbix.zabbix_server + zabbix_server_database: mysql + zabbix_server_database_long: mysql +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via Github Actions to validate the change on a new installation. Each PR should result into a correct working Zabbix Server installation and PR's will not be merged once this process fails. + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/defaults/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/defaults/main.yml new file mode 100644 index 00000000..7c8e01ba --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/defaults/main.yml @@ -0,0 +1,145 @@ +--- +# defaults file; +# zabbix role specific + +zabbix_server_version: 5.2 +zabbix_version: "{{ zabbix_server_version }}" +zabbix_repo: zabbix + +zabbix_server_apt_priority: +zabbix_server_package_state: present +zabbix_server_install_recommends: True +zabbix_server_install_database_client: True +zabbix_server_conf_mode: 0640 + +zabbix_service_state: started +zabbix_service_enabled: True +zabbix_repo_yum_schema: https +zabbix_repo_yum_disabled: "*" +zabbix_repo_yum_enabled: [] +zabbix_repo_yum: + - name: zabbix + description: Zabbix Official Repository - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix/{{ zabbix_version }}/rhel/{{ ansible_distribution_major_version }}/$basearch/" + gpgcheck: 0 + mode: '0644' + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + - name: zabbix-non-supported + description: Zabbix Official Repository non-supported - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/non-supported/rhel/{{ ansible_distribution_major_version }}/$basearch/" + mode: '0644' + gpgcheck: 0 + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + +# User (EPEL specific) +zabbix_server_username: zabbix +zabbix_server_groupname: zabbix + +# Database +zabbix_server_database: pgsql +zabbix_server_database_long: postgresql +zabbix_database_creation: True +zabbix_database_sqlload: True +zabbix_server_dbtlsconnect: +zabbix_server_dbtlscafile: +zabbix_server_dbtlscertfile: +zabbix_server_dbtlskeyfile: +zabbix_server_dbtlscipher: +zabbix_server_dbtlscipher13: + +# zabbix-server specific vars +zabbix_server_listenport: 10051 +zabbix_server_sourceip: +zabbix_server_logtype: file +zabbix_server_logfile: /var/log/zabbix/zabbix_server.log +zabbix_server_logfilesize: 10 +zabbix_server_debuglevel: 3 +zabbix_server_pidfile: /var/run/zabbix/zabbix_server.pid +zabbix_server_socketdir: /var/run/zabbix +zabbix_server_real_dbhost: +zabbix_server_dbhost: localhost +zabbix_server_dbname: zabbix-server +zabbix_server_dbencoding: utf8 +zabbix_server_dbcollation: utf8_bin +zabbix_server_dbschema: +zabbix_server_dbuser: zabbix-server +zabbix_server_dbpassword: zabbix-server +zabbix_server_dbsocket: +zabbix_server_dbport: 5432 +zabbix_server_dbhost_run_install: true +zabbix_server_privileged_host: localhost +zabbix_server_historystorageurl: +zabbix_server_historystoragetypes: uint,dbl,str,log,text +zabbix_server_historystoragedateindex: 0 +zabbix_server_exportdir: +zabbix_server_exportfilesize: 1G +zabbix_server_startpollers: 5 +zabbix_server_startipmipollers: 0 +zabbix_server_startpollersunreachable: 1 +zabbix_server_starttrappers: 5 +zabbix_server_startpingers: 1 +zabbix_server_startdiscoverers: 1 +zabbix_server_starthttppollers: 1 +zabbix_server_startpreprocessors: 3 +zabbix_server_starttimers: 1 +zabbix_server_javagateway: +zabbix_server_javagatewayport: 10052 +zabbix_server_startjavapollers: 5 +zabbix_server_startvmwarecollectors: 0 +zabbix_server_vmwarefrequency: 60 +zabbix_server_vmwarecachesize: 8M +zabbix_server_snmptrapperfile: /tmp/zabbix_traps.tmp +zabbix_server_startsnmptrapper: 0 +zabbix_server_listenip: +zabbix_server_housekeepingfrequency: 1 +zabbix_server_maxhousekeeperdelete: 500 +zabbix_server_senderfrequency: 30 +zabbix_server_cachesize: 8M +zabbix_server_cacheupdatefrequency: 60 +zabbix_server_startdbsyncers: 4 +zabbix_server_historycachesize: 8M +zabbix_server_historyindexcachesize: 4M +zabbix_server_trendcachesize: 4M +zabbix_server_historytextcachesize: 16M +zabbix_server_valuecachesize: 8M +zabbix_server_nodenoevents: 0 +zabbix_server_nodenohistory: 0 +zabbix_server_timeout: 3 +zabbix_server_trappertimeout: 300 +zabbix_server_unreachableperiod: 45 +zabbix_server_unavailabledelay: 60 +zabbix_server_unreachabledelay: 15 +zabbix_server_alertscriptspath: /usr/lib/zabbix/alertscripts +zabbix_server_externalscriptspath: /usr/lib/zabbix/externalscripts +zabbix_server_fpinglocation: /usr/sbin/fping +zabbix_server_fping6location: /usr/sbin/fping6 +zabbix_server_sshkeylocation: +zabbix_server_logslowqueries: 0 +zabbix_server_tmpdir: /tmp +zabbix_server_startproxypollers: 1 +zabbix_server_proxyconfigfrequency: 3600 +zabbix_server_proxydatafrequency: 1 +zabbix_server_allowroot: 0 +zabbix_server_user: zabbix +zabbix_server_include: /etc/zabbix/zabbix_server.conf.d +zabbix_server_include_mode: '0755' +zabbix_server_sslcertlocation: ${datadir}/zabbix/ssl/certs +zabbix_server_sslkeylocation: ${datadir}/zabbix/ssl/keys +zabbix_server_sslcalocation: +zabbix_server_loadmodulepath: ${libdir}/modules +zabbix_server_loadmodule: +zabbix_server_tlscafile: +zabbix_server_tlscrlfile: +zabbix_server_tlscertfile: +zabbix_server_tlskeyfile: +zabbix_server_startescalators: 1 +zabbix_server_vmwareperffrequency: 60 +zabbix_server_vmwaretimeout: 10 +zabbix_server_manage_service: True + +# SELinux specific +zabbix_selinux: False +selinux_allow_zabbix_can_network: False +selinux_allow_zabbix_can_http: False diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/files/install_semodule.bsx b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/files/install_semodule.bsx new file mode 100755 index 00000000..d37320c9 Binary files /dev/null and b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/files/install_semodule.bsx differ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/handlers/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/handlers/main.yml new file mode 100644 index 00000000..c8cc9a43 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/handlers/main.yml @@ -0,0 +1,30 @@ +--- +# handlers file for wdijkerman.zabbix + +- name: zabbix-server restarted + service: + name: zabbix-server + state: restarted + enabled: yes + tags: zabbix-server + become: yes + when: + - zabbix_server_manage_service | bool + - zabbix_repo != 'epel' + +- name: zabbix-server restarted + service: + name: zabbix-proxy-mysql{{ zabbix_proxy_database_long }} + state: restarted + enabled: yes + become: yes + when: + - zabbix_proxy_manage_service | bool + - zabbix_repo == 'epel' + +- name: "clean repo files from proxy creds" + shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + become: yes + when: + - ansible_os_family == 'RedHat' + - zabbix_http_proxy is defined or zabbix_https_proxy is defined diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/meta/main.yml new file mode 100644 index 00000000..8f01938a --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/meta/main.yml @@ -0,0 +1,26 @@ +--- +galaxy_info: + author: Werner Dijkerman + description: Installing and maintaining zabbix-server for RedHat/Debian/Ubuntu. + company: myCompany.Dotcom + license: MIT + min_ansible_version: 2.4 + platforms: + - name: EL + versions: + - 6 + - 7 + - name: Ubuntu + versions: + - lucid + - precise + - trusty + - name: Debian + versions: + - squeeze + - wheezy + galaxy_tags: + - zabbix + - monitoring + +dependencies: [] diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/requirements.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/requirements.yml new file mode 100644 index 00000000..3015f430 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/requirements.yml @@ -0,0 +1,4 @@ +--- +- src: geerlingguy.apache +- src: geerlingguy.mysql +- src: geerlingguy.postgresql diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/Debian.yml new file mode 100644 index 00000000..a21cb68f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/Debian.yml @@ -0,0 +1,216 @@ +--- + +- name: "Include Zabbix gpg ids" + include_vars: zabbix.yml + +- name: "Set some variables" + set_fact: + zabbix_short_version: "{{ zabbix_version | regex_replace('\\.', '') }}" + zabbix_server_apt_repository: + - "http://repo.zabbix.com/zabbix/{{ zabbix_version }}/{{ ansible_distribution.lower() }}/" + - "{{ ansible_distribution_release }}" + - "main" + zabbix_underscore_version: "{{ zabbix_version | regex_replace('\\.', '_') }}" + zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}" + +- name: "Debian | Set some facts" + set_fact: + datafiles_path: /usr/share/zabbix-server-{{ zabbix_server_database }} + when: + - zabbix_version is version('3.0', '<') + tags: + - zabbix-server + - init + - config + +- name: "Debian | Set some facts for Zabbix 3.0" + set_fact: + datafiles_path: /usr/share/doc/zabbix-server-{{ zabbix_server_database }} + when: + - zabbix_version is version('3.0', '>=') + tags: + - zabbix-server + - init + - config + +- name: "Debian | Installing gnupg" + apt: + pkg: gnupg + update_cache: yes + cache_valid_time: 3600 + force: yes + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: gnupg_installed + until: gnupg_installed is succeeded + become: yes + +- name: "Debian | Install gpg key" + apt_key: + id: "{{ sign_keys[zabbix_short_version][ansible_distribution_release]['sign_key'] }}" + url: http://repo.zabbix.com/zabbix-official-repo.key + register: zabbix_server_repo_files_installed + until: zabbix_server_repo_files_installed is succeeded + when: + - zabbix_repo == "zabbix" + become: yes + tags: + - zabbix-server + - init + +- name: "Debian | Installing repository {{ ansible_distribution }}" + apt_repository: + repo: "{{ item }} {{ zabbix_server_apt_repository | join(' ') }}" + state: present + when: zabbix_repo == "zabbix" + become: yes + with_items: + - deb-src + - deb + tags: + - zabbix-server + - init + +- name: "Debian | Create /etc/apt/preferences.d/" + file: + path: /etc/apt/preferences.d/ + state: directory + when: + - zabbix_server_apt_priority | int + become: yes + +- name: "Debian | Configuring the weight for APT" + copy: + dest: "/etc/apt/preferences.d/zabbix_server-{{ zabbix_proxy_database }}" + content: | + Package: zabbix_server-{{ zabbix_proxy_database }} + Pin: origin repo.zabbix.com + Pin-Priority: {{ zabbix_server_apt_priority }} + owner: root + when: + - zabbix_server_apt_priority | int + become: yes + +- name: apt-get clean + shell: apt-get clean; rm -rf /tmp/*; apt-get update + args: + warn: False + changed_when: False + become: yes + tags: + - skip_ansible_lint + +# On certain 18.04 images, such as docker or lxc, dpkg is configured not to +# install files into paths /usr/share/doc/* +# Since this is where Zabbix installs its database schemas, we need to allow +# files to be installed to /usr/share/doc/zabbix* +- name: Check for the dpkg exclude line + command: grep -F 'path-exclude=/usr/share/doc/*' /etc/dpkg/dpkg.cfg.d/excludes + register: dpkg_exclude_line + failed_when: false + changed_when: false + check_mode: no + +- name: Allow Zabbix dpkg installs to /usr/share/doc/zabbix* + lineinfile: + path: /etc/dpkg/dpkg.cfg.d/excludes + line: 'path-include=/usr/share/doc/zabbix*' + become: yes + when: + - dpkg_exclude_line.rc == 0 + +- name: "Debian | Installing zabbix-server-{{ zabbix_server_database }}" + apt: + pkg: zabbix-server-{{ zabbix_server_database }} + state: "{{ zabbix_server_package_state }}" + update_cache: yes + cache_valid_time: 0 + install_recommends: "{{ zabbix_server_install_recommends }}" + default_release: "{{ ansible_distribution_release }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_package_installed + until: zabbix_server_package_installed is succeeded + become: yes + tags: + - zabbix-server + - init + +- name: "Debian | Install Ansible module dependencies" + apt: + name: "{{ zabbix_python_prefix }}-psycopg2" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - zabbix_database_creation + tags: + - zabbix-server + - init + +- name: "Debian | Install Mysql Client package" + apt: + name: + - mysql-client + - "{{ zabbix_python_prefix }}-mysqldb" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - zabbix_server_database == 'mysql' + - zabbix_server_install_database_client + - ansible_distribution_release != "buster" + tags: + - zabbix-server + - init + - database + +- name: "Debian 10 | Install Mysql Client package" + apt: + name: + - mariadb-client + - "{{ zabbix_python_prefix }}-mysqldb" + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - zabbix_server_database == 'mysql' + - zabbix_server_install_database_client + - ansible_distribution_release == "buster" + tags: + - zabbix-server + - init + - database + +- name: "Debian | Install PostgreSQL Client package" + apt: + name: postgresql-client + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - zabbix_server_database == 'pgsql' + - zabbix_server_install_database_client + tags: + - zabbix-server + - init + - database diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/RedHat.yml new file mode 100644 index 00000000..d1243581 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/RedHat.yml @@ -0,0 +1,205 @@ +--- +# Tasks specific for RedHat systems + +- name: "Set short version name" + set_fact: + zabbix_short_version: "{{ zabbix_version | regex_replace('\\.', '') }}" + +- name: "RedHat | Use Zabbix package name" + set_fact: + zabbix_server_package: "zabbix-server-{{ zabbix_server_database }}" + when: + - zabbix_repo == "zabbix" or zabbix_repo == "other" + tags: + - zabbix-server + +- name: "RedHat | Use EPEL package name" + set_fact: + zabbix_server_package: "zabbix{{ zabbix_short_version }}-server-{{ zabbix_server_database }}" + when: + - zabbix_repo == "epel" + tags: + - zabbix-server + +- name: "RedHat | Set some facts Zabbix < 3.0" + set_fact: + datafiles_path: "/usr/share/doc/zabbix-server-{{ zabbix_server_database }}-{{ zabbix_version }}*" + when: + - zabbix_version is version('3.0', '<') + tags: + - zabbix-server + +- name: "RedHat | Set facts for Zabbix >= 3.0" + set_fact: + datafiles_path: "/usr/share/doc/zabbix-server-{{ zabbix_server_database }}-{{ zabbix_version }}*" + when: + - zabbix_version is version('3.0', '>=') + tags: + - zabbix-server + +- name: "RedHat | Set facts for RHEL8" + set_fact: + datafiles_path: "/usr/share/doc/zabbix-server-{{ zabbix_server_database }}" + when: + - ansible_distribution_major_version == "8" + tags: + - zabbix-server + +- name: "RedHat | Set some facts EPEL" + set_fact: + datafiles_path: "/usr/share/zabbix-{{ zabbix_server_database_long }}" + when: + - zabbix_repo == "epel" + tags: + - zabbix-server + +- name: "RedHat | Create 'zabbix' group (EPEL)" + group: + name: "{{ zabbix_server_groupname | default('zabbix') }}" + gid: "{{ zabbix_server_groupid | default(omit) }}" + state: present + become: yes + when: + - zabbix_repo == "epel" + +- name: "RedHat | Create 'zabbix' user (EPEL)" + user: + name: "{{ zabbix_server_username | default('zabbix') }}" + comment: Zabbix Monitoring System + uid: "{{ zabbix_server_userid | default(omit) }}" + group: zabbix + become: yes + when: + - zabbix_repo == "epel" + +- name: "Make sure old file is absent" + file: + path: /etc/yum.repos.d/zabbix-supported.repo + state: absent + become: yes + +- name: "RedHat | Install basic repo file" + yum_repository: + name: "{{ item.name }}" + description: "{{ item.description }}" + baseurl: "{{ item.baseurl }}" + gpgcheck: "{{ item.gpgcheck }}" + gpgkey: "{{ item.gpgkey }}" + mode: "{{ item.mode | default('0644') }}" + priority: "{{ item.priority | default('99') }}" + state: "{{ item.state | default('present') }}" + proxy: "{{ zabbix_http_proxy | default(omit) }}" + with_items: "{{ zabbix_repo_yum }}" + register: yum_repo_installed + become: yes + when: + zabbix_repo == "zabbix" + notify: + - "clean repo files from proxy creds" + tags: + - zabbix-server + +- name: "RedHat | Installing zabbix-server-{{ zabbix_server_database }}" + package: + pkg: "{{ zabbix_server_package }}" + state: "{{ zabbix_server_package_state }}" + disablerepo: "{{ '*' if (zabbix_repo_yum_enabled | length>0) else omit }}" + enablerepo: "{{ zabbix_repo_yum_enabled if zabbix_repo_yum_enabled is iterable and (zabbix_repo_yum_enabled | length>0) else omit }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_package_installed + until: zabbix_server_package_installed is succeeded + become: yes + tags: + - zabbix-server + +- name: "RedHat | Install Ansible module dependencies" + yum: + name: python-psycopg2 + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - zabbix_database_creation + - zabbix_server_database == 'pgsql' + - ansible_distribution_major_version == "7" or ansible_distribution_major_version == "6" + tags: + - zabbix-server + +- name: "RedHat | Install Ansible module dependencies on RHEL8" + yum: + name: python3-psycopg2 + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - zabbix_database_creation + - zabbix_server_database == 'pgsql' + - ansible_distribution_major_version == "8" + tags: + - zabbix-server + +- name: "RedHat | Install Mysql Client package RHEL7" + yum: + name: + - mariadb + - MySQL-python + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - zabbix_server_database == 'mysql' + - ansible_distribution_major_version == "7" + tags: + - zabbix-server + +- name: "RedHat | Install Mysql Client package RHEL5 - 6" + yum: + name: + - mysql + - MySQL-python + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - zabbix_server_database == 'mysql' + - ansible_distribution_major_version == "6" or ansible_distribution_major_version == "5" + tags: + - zabbix-server + +- name: "RedHat | Install PostgreSQL client package" + yum: + name: postgresql + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - zabbix_server_database == 'pgsql' + tags: + - zabbix-server + +- name: "Configure SELinux when enabled" + include: selinux.yml + when: + - zabbix_selinux | bool diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/main.yml new file mode 100644 index 00000000..59559fab --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/main.yml @@ -0,0 +1,51 @@ +--- +# tasks file for wdijkerman.zabbix + +- name: "Include OS-specific variables" + include_vars: "{{ ansible_os_family }}.yml" + +- name: "Install the correct repository" + include_tasks: "{{ ansible_os_family }}.yml" + +- name: "Installing the {{ zabbix_server_database_long }} database" + include_tasks: "{{ zabbix_server_database_long }}.yml" + +- name: "Configure zabbix-server" + template: + src: zabbix_server.conf.j2 + dest: /etc/zabbix/zabbix_server.conf + owner: zabbix + group: zabbix + mode: "{{ zabbix_server_conf_mode }}" + notify: + - zabbix-server restarted + tags: + - zabbix-server + - init + - config + +- name: "Create include dir zabbix-server" + file: + path: "{{ zabbix_server_include }}" + owner: zabbix + group: zabbix + state: directory + mode: "{{ zabbix_server_include_mode }}" + tags: + - zabbix-server + - init + - config + +- name: "Add zabbix-server scripts" + include: "scripts.yml" + when: ( zabbix_server_alertscripts is defined ) or + ( zabbix_server_externalscripts is defined ) + +- name: "Zabbix-server started" + service: + name: zabbix-server + state: "{{ zabbix_service_state }}" + enabled: "{{ zabbix_service_enabled }}" + tags: + - zabbix-server + when: zabbix_server_manage_service | bool diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/mysql.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/mysql.yml new file mode 100644 index 00000000..864decbf --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/mysql.yml @@ -0,0 +1,277 @@ +--- +# task file for mysql +- name: "Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" + set_fact: + delegated_dbhost: "{{ zabbix_server_dbhost if (zabbix_server_dbhost != 'localhost') else inventory_hostname }}" + when: + - zabbix_server_dbhost_run_install + +- name: "Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" + set_fact: + delegated_dbhost: "{{ inventory_hostname }}" + when: + - not zabbix_server_dbhost_run_install + +- name: "Override delegated_dbhost with real dbhost when dbhost is behind loadbalancer" + set_fact: + delegated_dbhost: "{{ zabbix_server_real_dbhost }}" + when: zabbix_server_real_dbhost | default(false) + +- name: "MySQL | Create database" + mysql_db: + name: "{{ zabbix_server_dbname }}" + encoding: "{{ zabbix_server_dbencoding }}" + collation: "{{ zabbix_server_dbcollation }}" + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + state: present + when: zabbix_database_creation + register: zabbix_database_created + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-server + - database + - skip_ansible_lint + +- name: "MySQL | Create database user" + mysql_user: + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + name: "{{ zabbix_server_dbuser }}" + password: "{{ zabbix_server_dbpassword }}" + priv: "{{ zabbix_server_dbname }}.*:ALL" + host: "{{ zabbix_server_privileged_host }}" + state: present + when: zabbix_database_creation + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-server + - database + +- name: "Get the file for create.sql >= 3.0" + shell: ls -1 {{ datafiles_path }}/create.sq* + changed_when: False + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + register: ls_output_create + tags: + - zabbix-server + - database + +- name: "Check if we have done files >= 3.0" + stat: + path: /etc/zabbix/create.done + register: done_file + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + +- name: "MySQL | Get current value for innodb_default_row_format" + shell: | + set -euo pipefail + mysql -h {{ zabbix_server_dbhost }} -u{{ zabbix_server_dbuser }} \ + -p'{{ zabbix_server_dbpassword }}' \ + -e 'SHOW VARIABLES;' 2>&1 | grep innodb_default_row_format \ + | awk '{print $2}' | tr [:upper:] [:lower:] + register: mysql_innodb_default_row_format + args: + executable: /bin/bash + changed_when: False + become: true + +- name: "MySQL | Set innodb_default_row_format to dynamic" + mysql_variables: + variable: innodb_default_row_format + value: dynamic + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + - not done_file.stat.exists + - mysql_innodb_default_row_format.stdout != 'dynamic' + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-server + - database + +- name: "MySQL | Disable InnoDB Strict Mode" + mysql_variables: + variable: innodb_strict_mode + value: 0 + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + - not done_file.stat.exists + - ansible_distribution_release == "buster" + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-server + - database + +- name: "Fetch sql create file" + fetch: + src: "{{ ls_output_create.stdout }}" + dest: /tmp/{{ role_name }}/ + flat: yes + when: + - delegated_dbhost != inventory_hostname + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + - not done_file.stat.exists + +- name: "Copy sql create file" + copy: + src: /tmp/{{ role_name }}/ + dest: "{{ ls_output_create.stdout | dirname }}" + delegate_to: "{{ delegated_dbhost }}" + when: + - delegated_dbhost != inventory_hostname + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + - not done_file.stat.exists + +- name: "MySQL | Create database and import file >= 3.0" + mysql_db: + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + name: "{{ zabbix_server_dbname }}" + encoding: "{{ zabbix_server_dbencoding }}" + collation: "{{ zabbix_server_dbcollation }}" + state: import + target: "{{ ls_output_create.stdout }}" + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + - not done_file.stat.exists + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-server + - database + +- name: "MySQL | Revert innodb_default_row_format to previous value" + mysql_variables: + variable: innodb_default_row_format + value: '{{ mysql_innodb_default_row_format.stdout }}' + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + - not done_file.stat.exists + - mysql_innodb_default_row_format.stdout != 'dynamic' + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-server + - database + +- name: "Check if we have sql_done files >= 3.0" + file: + path: /etc/zabbix/create.done + state: touch + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload | bool + - zabbix_repo != "epel" + - not done_file.stat.exists + +- name: "Get the correct path for the SQL files < 3.0" + shell: ls -1 {{ datafiles_path }}/{{ mysql_create_dir }}{{ item }}.sql* + changed_when: False + register: ls_output_schema + with_items: + - schema + - images + - data + when: + - zabbix_version is version('3.0', '<') + - zabbix_database_sqlload | bool + tags: + - zabbix-server + - database + +- name: "Check if we have done files < 3.0" + stat: + path: /etc/zabbix/{{ item }}.done + register: done_files + with_items: + - schema + - images + - data + when: + - zabbix_version is version('3.0', '<') + - zabbix_database_sqlload | bool + tags: + - zabbix-server + - database + +- name: "Create fact if sql_done files exists" + set_fact: + sql_files_executed: "{{ sql_files_executed | default({}) | combine({item.item: item.stat}) }}" + with_items: "{{ done_files.results }}" + when: + - zabbix_version is version('3.0', '<') + - zabbix_database_sqlload | bool + tags: + - zabbix-server + - database + +- name: "MySQL | Create database and import files < 3.0" + mysql_db: + name: "{{ zabbix_server_dbname }}" + encoding: "{{ zabbix_server_dbencoding }}" + collation: "{{ zabbix_server_dbcollation }}" + state: import + target: "{{ item.stdout }}" + with_items: "{{ ls_output_schema.results }}" + when: + - zabbix_version is version('3.0', '<') + - zabbix_database_sqlload | bool + - not sql_files_executed[item.item].exists + delegate_to: "{{ delegated_dbhost }}" + tags: + - zabbix-server + - database + +- name: "Check if we have sql_done files < 3.0" + file: + path: /etc/zabbix/{{ item }}.done + state: touch + with_items: + - schema + - images + - data + when: + - zabbix_version is version('3.0', '<') + - zabbix_database_sqlload | bool + - not sql_files_executed[item].exists + tags: + - zabbix-server + - database diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/postgresql.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/postgresql.yml new file mode 100644 index 00000000..6a10b6cc --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/postgresql.yml @@ -0,0 +1,171 @@ +--- +# task file for postgresql + +- name: "Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" + set_fact: + delegated_dbhost: "{{ zabbix_server_dbhost if (zabbix_server_dbhost != 'localhost') else inventory_hostname }}" + when: + - zabbix_server_dbhost_run_install + +- name: "Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" + set_fact: + delegated_dbhost: "{{ inventory_hostname }}" + when: + - not zabbix_server_dbhost_run_install + +- name: "PostgreSQL | Delegated" + block: + - name: "PostgreSQL | Delegated | Create database" + postgresql_db: + name: "{{ zabbix_server_dbname }}" + port: "{{ zabbix_server_dbport }}" + state: present + - name: "PostgreSQL | Delegated | Create database user" + postgresql_user: + db: "{{ zabbix_server_dbname }}" + name: "{{ zabbix_server_dbuser }}" + password: "md5{{ (zabbix_server_dbpassword + zabbix_server_dbuser)|hash('md5') }}" + port: "{{ zabbix_server_dbport }}" + priv: ALL + state: present + encrypted: yes + become: yes + become_user: postgres + delegate_to: "{{ delegated_dbhost }}" + when: + - zabbix_database_creation + - zabbix_server_pgsql_login_host is not defined + tags: + - zabbix-server + - database + +- name: "PostgreSQL | Remote" + block: + - name: "PostgreSQL | Remote | Create database" + postgresql_db: + login_host: "{{ zabbix_server_pgsql_login_host | default(omit) }}" + login_user: "{{ zabbix_server_pgsql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_pgsql_login_password | default(omit) }}" + login_unix_socket: "{{ zabbix_server_pgsql_login_unix_socket | default(omit) }}" + name: "{{ zabbix_server_dbname }}" + port: "{{ zabbix_server_dbport }}" + state: present + - name: "PostgreSQL | Remote | Create database user" + postgresql_user: + login_host: "{{ zabbix_server_pgsql_login_host | default(omit) }}" + login_user: "{{ zabbix_server_pgsql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_pgsql_login_password | default(omit) }}" + db: "{{ zabbix_server_dbname }}" + name: "{{ zabbix_server_dbuser }}" + password: "md5{{ (zabbix_server_dbpassword + zabbix_server_dbuser)|hash('md5') }}" + port: "{{ zabbix_server_dbport }}" + priv: ALL + state: present + encrypted: yes + when: + - zabbix_database_creation + - zabbix_server_pgsql_login_host is defined + tags: + - zabbix-server + - database + +- name: "PostgreSQL | Create schema" + shell: > + cd {{ datafiles_path }} && + if [ -f create.sql.gz ]; then gunzip create.sql.gz ; fi && + psql -h '{{ zabbix_server_dbhost }}' + -U '{{ zabbix_server_dbuser }}' + -d '{{ zabbix_server_dbname }}' + -p '{{ zabbix_server_dbport }}' + -f create.sql && touch /etc/zabbix/schema.done + args: + creates: /etc/zabbix/schema.done + warn: no + environment: + PGPASSWORD: '{{ zabbix_server_dbpassword }}' + when: + - zabbix_version is version('3.0', '>=') + - zabbix_database_sqlload + tags: + - zabbix-server + - database + +- name: "Get complete path" + shell: ls -d {{ datafiles_path }} + register: datafiles_path_full + changed_when: False + when: + - (zabbix_version is version('3.0', '<') and zabbix_database_sqlload) or (zabbix_repo == "epel" and zabbix_database_sqlload) + tags: + - skip_ansible_lint + +- name: "Check if we have a create dir" + stat: + path: "{{ datafiles_path_full.stdout }}/create" + register: create_dir_or_not + when: + - (zabbix_version is version('3.0', '<') and zabbix_database_sqlload) or (zabbix_repo == "epel" and zabbix_database_sqlload) + +- name: "Set fact" + set_fact: + datafiles_path: "{{ datafiles_path }}/create" + when: + - (zabbix_version is version('3.0', '<') and zabbix_database_sqlload) or (zabbix_repo == "epel" and zabbix_database_sqlload) + - create_dir_or_not.stat.isdir is defined and create_dir_or_not.stat.isdir + - create_dir_or_not.stat.exists + +- name: "PostgreSQL | Importing schema file" + shell: > + cd {{ datafiles_path }} && + if [ -f schema.sql.gz ]; then gunzip schema.sql.gz ; fi && + psql -h '{{ zabbix_server_dbhost }}' + -U '{{ zabbix_server_dbuser }}' + -d '{{ zabbix_server_dbname }}' + -p '{{ zabbix_server_dbport }}' + -f schema.sql && touch /etc/zabbix/schema.done + args: + creates: /etc/zabbix/schema.done + warn: no + environment: + PGPASSWORD: '{{ zabbix_server_dbpassword }}' + when: + - (zabbix_version is version('3.0', '<') and zabbix_database_sqlload) or (zabbix_repo == "epel" and zabbix_database_sqlload) + tags: + - zabbix-server + - database + +- name: "PostgreSQL | Importing images file" + shell: > + cd {{ datafiles_path }} && + psql -h '{{ zabbix_server_dbhost }}' + -U '{{ zabbix_server_dbuser }}' + -d '{{ zabbix_server_dbname }}' + -p '{{ zabbix_server_dbport }}' + -f images.sql && touch /etc/zabbix/images.done + args: + creates: /etc/zabbix/images.done + warn: no + environment: + PGPASSWORD: '{{ zabbix_server_dbpassword }}' + when: (zabbix_version is version('3.0', '<') and zabbix_database_sqlload) or (zabbix_repo == "epel" and zabbix_database_sqlload) + tags: + - zabbix-server + - database + +- name: "PostgreSQL | Importing data file" + shell: > + cd {{ datafiles_path }} && + psql -h '{{ zabbix_server_dbhost }}' + -U '{{ zabbix_server_dbuser }}' + -d '{{ zabbix_server_dbname }}' + -p '{{ zabbix_server_dbport }}' + -f data.sql && touch /etc/zabbix/data.done + args: + creates: /etc/zabbix/data.done + warn: no + environment: + PGPASSWORD: '{{ zabbix_server_dbpassword }}' + when: (zabbix_version is version('3.0', '<') and zabbix_database_sqlload) or (zabbix_repo == "epel" and zabbix_database_sqlload) + tags: + - zabbix-server + - database diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/scripts.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/scripts.yml new file mode 100644 index 00000000..41843612 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/scripts.yml @@ -0,0 +1,20 @@ +--- +- name: "Configure zabbix-server alertscripts" + template: + src: "{{ item.path }}" + dest: "{{ zabbix_server_alertscriptspath }}/{{ item.name }}" + owner: zabbix + group: zabbix + mode: 0755 + with_items: "{{ zabbix_server_alertscripts }}" + when: zabbix_server_alertscripts is defined + +- name: "Configure zabbix-server externalscripts" + template: + src: "{{ item.path }}" + dest: "{{ zabbix_server_externalscriptspath }}/{{ item.name }}" + owner: zabbix + group: zabbix + mode: 0755 + with_items: "{{ zabbix_server_externalscripts }}" + when: zabbix_server_externalscripts is defined diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/selinux.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/selinux.yml new file mode 100644 index 00000000..80306a15 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/tasks/selinux.yml @@ -0,0 +1,124 @@ +--- + +# straight to getenforce binary , workaround for missing python_selinux library +- name: "Get getenforce binary" + stat: + path: /usr/sbin/getenforce + register: getenforce_bin + become: yes + +- name: "Collect getenforce output" + command: getenforce + register: sestatus + when: 'getenforce_bin.stat.exists' + changed_when: false + become: yes + check_mode: no + +- name: "Set zabbix_selinux to true if getenforce returns Enforcing or Permissive" + set_fact: + zabbix_selinux: "{{ true }}" + when: 'getenforce_bin.stat.exists and ("Enforcing" in sestatus.stdout or "Permissive" in sestatus.stdout)' + +- name: "SELinux | RedHat | Install related SELinux package" + yum: + name: + - libsemanage-python + - policycoreutils + - checkpolicy + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - ansible_os_family == "RedHat" + - selinux_allow_zabbix_can_network + - ansible_distribution_major_version == "7" or ansible_distribution_major_version == "6" + tags: + - zabbix-server + +- name: "SELinux | RedHat | Install related SELinux package on RHEL8" + yum: + name: + - python3-libsemanage + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - ansible_os_family == "RedHat" + - selinux_allow_zabbix_can_network + - ansible_distribution_major_version == "8" + tags: + - zabbix-server + +- name: "SELinux | RedHat | Enable httpd_can_connect_zabbix SELinux boolean" + seboolean: + name: httpd_can_connect_zabbix + state: yes + persistent: yes + become: yes + when: + - selinux_allow_zabbix_can_http + tags: + - zabbix-server + +- name: "SELinux | RedHat | Enable zabbix_can_network SELinux boolean" + seboolean: + name: zabbix_can_network + state: yes + persistent: yes + become: yes + when: + - selinux_allow_zabbix_can_network + tags: + - zabbix-server + +- name: "SELinux | RedHat | Install related SELinux package to fix issues" + yum: + name: + - policycoreutils-python + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - ansible_os_family == "RedHat" + - ansible_distribution_major_version == "7" or ansible_distribution_major_version == "6" + tags: + - zabbix-server + +- name: "SELinux | RedHat | Install related SELinux package to fix issues on RHEL8" + yum: + name: + - policycoreutils + - checkpolicy + - python3-libsemanage + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_server_dependencies_installed + until: zabbix_server_dependencies_installed is succeeded + become: yes + when: + - ansible_os_family == "RedHat" + - ansible_distribution_major_version == "8" + tags: + - zabbix-server + +- name: "SELinux | RedHat | Add SEmodule to fix SELinux issue: zabbix_server_alerter.sock" + script: + cmd: files/install_semodule.bsx + args: + creates: /etc/selinux/targeted/active/modules/400/zabbix_server_add/cil + become: yes diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/templates/zabbix_server.conf.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/templates/zabbix_server.conf.j2 new file mode 100644 index 00000000..3b2551f9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/templates/zabbix_server.conf.j2 @@ -0,0 +1,663 @@ +# this is a configuration file for zabbix server process +# to get more information about zabbix, visit http://www.zabbix.com + +############ general parameters ################# +### option: listenport +# listen port for trapper. +# +ListenPort={{ zabbix_server_listenport }} + +### option: sourceip +# source ip address for outgoing connections. +# +{% if zabbix_server_sourceip is defined and zabbix_server_sourceip %} +SourceIP={{ zabbix_server_sourceip }} +{% endif %} + +{% if zabbix_version is version('3.0', '>=') %} +### Option: LogType +# Specifies where log messages are written to: +# system - syslog +# file - file specified with LogFile parameter +# console - standard output +# +# Mandatory: no +# Default: +LogType={{ zabbix_server_logtype }} +{% endif %} + +### option: logfile +# name of log file. +# if not set, syslog is used. +# +LogFile={{ zabbix_server_logfile }} + +### option: logfilesize +# maximum size of log file in mb. +# 0 - disable automatic log rotation. +# +LogFileSize={{ zabbix_server_logfilesize }} + +### option: debuglevel +# specifies debug level +# 0 - no debug +# 1 - critical information +# 2 - error information +# 3 - warnings +# 4 - for debugging (produces lots of information) +# +DebugLevel={{ zabbix_server_debuglevel }} + +### Option: SocketDir +# IPC socket directory. +# Directory to store IPC sockets used by internal Zabbix services. +# +# Mandatory: no +# Default: +# SocketDir=/tmp + +{% if zabbix_version is version('3.4', '>=') %} +SocketDir={{ zabbix_server_socketdir }} +{% endif %} + +### option: pidfile +# name of pid file. +# +PidFile={{ zabbix_server_pidfile }} + +### option: dbhost +# database host name. +# if set to localhost, socket is used for mysql. +# if set to empty string, socket is used for postgresql. +# +DBHost={{ zabbix_server_dbhost }} + +### option: dbname +# database name. +# for sqlite3 path to database file must be provided. dbuser and dbpassword are ignored. +# +DBName={{ zabbix_server_dbname }} + +### option: dbschema +# schema name. used for ibm db2. +# +{% if zabbix_server_dbschema is defined and zabbix_server_dbschema %} +DBSchema={{ zabbix_server_dbschema }} +{% endif %} + +### option: dbuser +# database user. ignored for sqlite. +# +DBUser={{ zabbix_server_dbuser }} + +### option: dbpassword +# database password. ignored for sqlite. +# comment this line if no password is used. +# +DBPassword={{ zabbix_server_dbpassword }} + +### option: dbsocket +# path to mysql socket. +# +{% if zabbix_server_dbsocket is defined and zabbix_server_dbsocket %} +DBSocket={{ zabbix_server_dbsocket }} +{% endif %} + +### option: dbport +# database port when not using local socket. ignored for sqlite. +# +{% if zabbix_server_dbport is defined and zabbix_server_dbport %} +DBPort={{ zabbix_server_dbport }} +{% endif %} + +### Option: HistoryStorageURL +# History storage HTTP[S] URL. +# +# Mandatory: no +# Default: +{% if zabbix_server_historystorageurl is defined and zabbix_server_historystorageurl %} +HistoryStorageURL={{ zabbix_server_historystorageurl }} +{% endif %} + +{% if zabbix_version is version('3.4', '>=') %} +### Option: HistoryStorageTypes +# Comma separated list of value types to be sent to the history storage. +# +# Mandatory: no +# Default: +HistoryStorageTypes={{ zabbix_server_historystoragetypes }} +{% endif %} + +{% if zabbix_version is version('4.0', '>=') %} +### Option: HistoryStorageDateIndex +# Enable preprocessing of history values in history storage to store values in different indices based on date. +# 0 - disable +# 1 - enable +# +# Mandatory: no +# Default: +HistoryStorageDateIndex={{ zabbix_server_historystoragedateindex }} +{% endif %} + +{% if zabbix_version is version('4.0', '>=') %} +### Option: ExportDir +# Directory for real time export of events, history and trends in newline delimited JSON format. +# If set, enables real time export. +# +# Mandatory: no +# Default: +{% if zabbix_server_exportdir is defined and zabbix_server_exportdir %} +ExportDir={{ zabbix_server_exportdir }} +{% endif %} +{% endif %} + +{% if zabbix_version is version('4.0', '>=') %} +### Option: ExportFileSize +# Maximum size per export file in bytes. +# Only used for rotation if ExportDir is set. +# +# Mandatory: no +# Range: 1M-1G +# Default: +ExportFileSize={{ zabbix_server_exportfilesize }} +{% endif %} +############ advanced parameters ################ + +### option: startpollers +# number of pre-forked instances of pollers. +# +StartPollers={{ zabbix_server_startpollers }} + +### option: startipmipollers +# number of pre-forked instances of ipmi pollers. +# +StartIPMIPollers={{ zabbix_server_startipmipollers }} + +{% if zabbix_version is version('4.2', '>=') %} +### Option: StartPreprocessors +# Number of pre-forked instances of preprocessing workers. +# The preprocessing manager process is automatically started when preprocessor worker is started. +# +# Mandatory: no +# Range: 1-1000 +# Default: +# StartPreprocessors=3 +StartPreprocessors={{ zabbix_server_startpreprocessors }} +{% endif %} + +### option: startpollersunreachable +# number of pre-forked instances of pollers for unreachable hosts (including ipmi). +# +StartPollersUnreachable={{ zabbix_server_startpollersunreachable }} + +### option: starttrappers +# number of pre-forked instances of trappers. +# trappers accept incoming connections from zabbix sender, active agents, active proxies and child nodes. +# at least one trapper process must be running to display server availability in the frontend. +# +StartTrappers={{ zabbix_server_starttrappers }} + +### option: startpingers +# number of pre-forked instances of icmp pingers. +# +StartPingers={{ zabbix_server_startpingers }} + +### option: startdiscoverers +# number of pre-forked instances of discoverers. +# +StartDiscoverers={{ zabbix_server_startdiscoverers }} + +### option: starthttppollers +# number of pre-forked instances of http pollers. +# +StartHTTPPollers={{ zabbix_server_starthttppollers }} + +{% if zabbix_version is version('2.0', '>=') %} +### option: starttimers +# number of pre-forked instances of timers. +# timers process time-based trigger functions and maintenance periods. +# only the first timer process handles the maintenance periods. +# +StartTimers={{ zabbix_server_starttimers }} +{% endif %} + +{% if zabbix_version is version('3.0', '>=') %} +### Option: StartEscalators +# Number of pre-forked instances of escalators. +# +StartEscalators={{ zabbix_server_startescalators }} +{% endif %} + +### option: javagateway +# ip address (or hostname) of zabbix java gateway. +# only required if java pollers are started. +# +{% if zabbix_server_javagateway is defined and zabbix_server_javagateway %} +JavaGateway={{ zabbix_server_javagateway }} + +### option: javagatewayport +# port that zabbix java gateway listens on. +# +JavaGatewayPort={{ zabbix_server_javagatewayport }} + +### option: startjavapollers +# number of pre-forked instances of java pollers. +# +StartJavaPollers={{ zabbix_server_startjavapollers }} +{% endif %} + +{% if zabbix_version is version('2.2', '>=') %} +### option: startvmwarecollectors +# number of pre-forked vmware collector instances. +# +StartVMwareCollectors={{ zabbix_server_startvmwarecollectors }} + +### option: vmwarefrequency +# how often zabbix will connect to vmware service to obtain a new data. +# +VMwareFrequency={{ zabbix_server_vmwarefrequency }} + +{% if zabbix_version is version('3.0', '>=') %} +### Option: VMwarePerfFrequency +# How often Zabbix will connect to VMware service to obtain performance data. +# +# Mandatory: no +VMwarePerfFrequency={{ zabbix_server_vmwareperffrequency }} +{% endif %} + +### option: vmwarecachesize +# size of vmware cache, in bytes. +# shared memory size for storing vmware data. +# only used if vmware collectors are started. +# +VMwareCacheSize={{ zabbix_server_vmwarecachesize }} +{% endif %} + +{% if zabbix_version is version('3.0', '>=') %} +### Option: VMwareTimeout +# Specifies how many seconds vmware collector waits for response from VMware service. +# +VMwareTimeout={{ zabbix_server_vmwaretimeout }} +{% endif %} + +### option: snmptrapperfile +# temporary file used for passing data from snmp trap daemon to the server. +# must be the same as in zabbix_trap_receiver.pl or snmptt configuration file. +# +SNMPTrapperFile={{ zabbix_server_snmptrapperfile }} + +### option: startsnmptrapper +# if 1, snmp trapper process is started. +# +StartSNMPTrapper={{ zabbix_server_startsnmptrapper }} + +### option: listenip +# list of comma delimited ip addresses that the trapper should listen on. +# trapper will listen on all network interfaces if this parameter is missing. +# +{% if zabbix_server_listenip is defined and zabbix_server_listenip %} +ListenIP={{ zabbix_server_listenip }} +{% endif %} + +### option: housekeepingfrequency +# How often Zabbix will perform housekeeping procedure (in hours). +# Housekeeping is removing outdated information from the database. +# To prevent Housekeeper from being overloaded, no more than 4 times HousekeepingFrequency +# hours of outdated information are deleted in one housekeeping cycle, for each item. +# To lower load on server startup housekeeping is postponed for 30 minutes after server start. +# With HousekeepingFrequency=0 the housekeeper can be only executed using the runtime control option. +# In this case the period of outdated information deleted in one housekeeping cycle is 4 times the +# period since the last housekeeping cycle, but not less than 4 hours and not greater than 4 days. +# +HousekeepingFrequency={{ zabbix_server_housekeepingfrequency }} + +### option: maxhousekeeperdelete +# The table "housekeeper" contains "tasks" for housekeeping procedure in the format: +# [housekeeperid], [tablename], [field], [value]. +# No more than 'MaxHousekeeperDelete' rows (corresponding to [tablename], [field], [value]) +# will be deleted per one task in one housekeeping cycle. +# SQLite3 does not use this parameter, deletes all corresponding rows without a limit. +# If set to 0 then no limit is used at all. In this case you must know what you are doing! +# +MaxHousekeeperDelete={{ zabbix_server_maxhousekeeperdelete }} + +{% if zabbix_version is version('3.2', '<=') %} +### option: senderfrequency +# how often zabbix will try to send unsent alerts (in seconds). +# +SenderFrequency={{ zabbix_server_senderfrequency }} +{% endif %} + +### option: cachesize +# size of configuration cache, in bytes. +# shared memory size for storing host, item and trigger data. +# +CacheSize={{ zabbix_server_cachesize }} + +### option: cacheupdatefrequency +# how often zabbix will perform update of configuration cache, in seconds. +# +CacheUpdateFrequency={{ zabbix_server_cacheupdatefrequency }} + +### option: startdbsyncers +# number of pre-forked instances of db syncers +# +StartDBSyncers={{ zabbix_server_startdbsyncers }} + +### option: historycachesize +# size of history cache, in bytes. +# shared memory size for storing history data. +# +HistoryCacheSize={{ zabbix_server_historycachesize }} + +{% if zabbix_version is version('3.0', '>=') %} +### Option: HistoryIndexCacheSize +# Size of history index cache, in bytes. +# Shared memory size for indexing history cache. +# +HistoryIndexCacheSize={{ zabbix_server_historyindexcachesize }} +{% endif %} + +### option: trendcachesize +# size of trend cache, in bytes. +# shared memory size for storing trends data. +# +TrendCacheSize={{ zabbix_server_trendcachesize }} + +{% if zabbix_version is version('3.0', '<') %} + ### option: historytextcachesize +# size of text history cache, in bytes. +# shared memory size for storing character, text or log history data. +# +HistoryTextCacheSize={{ zabbix_server_historytextcachesize }} +{% endif %} + +{% if zabbix_version is version('2.2', '>=') %} +### option: valuecachesize +# size of history value cache, in bytes. +# shared memory size for caching item history data requests +# setting to 0 disables value cache. +# +ValueCacheSize={{ zabbix_server_valuecachesize }} +{% endif %} + +{% if zabbix_version is version('2.4', '<') %} +### option: nodenoevents +# if set to '1' local events won't be sent to master node. +# this won't impact ability of this node to propagate events from its child nodes. +# +NodeNoEvents={{ zabbix_server_nodenoevents }} + +### option: nodenohistory +# if set to '1' local history won't be sent to master node. +# this won't impact ability of this node to propagate history from its child nodes. +# +NodeNoHistory={{ zabbix_server_nodenohistory }} +{% endif %} + +### option: timeout +# specifies how long we wait for agent, snmp device or external check (in seconds). +# +Timeout={{ zabbix_server_timeout }} + +### option: trappertimeout +# specifies how many seconds trapper may spend processing new data. +# +TrapperTimeout={{ zabbix_server_trappertimeout }} + +### option: unreachableperiod +# after how many seconds of unreachability treat a host as unavailable. +# +UnreachablePeriod={{ zabbix_server_unreachableperiod }} + +### option: unavailabledelay +# how often host is checked for availability during the unavailability period, in seconds. +# +UnavailableDelay={{ zabbix_server_unavailabledelay }} + +### option: unreachabledelay +# how often host is checked for availability during the unreachability period, in seconds. +# +UnreachableDelay={{ zabbix_server_unreachabledelay }} + +### option: alertscriptspath +# full path to location of custom alert scripts. +# default depends on compilation options. +# +AlertScriptsPath={{ zabbix_server_alertscriptspath }} + +### option: externalscripts +# full path to location of external scripts. +# default depends on compilation options. +# +ExternalScripts={{ zabbix_server_externalscriptspath }} + +### option: fpinglocation +# location of fping. +# make sure that fping binary has root ownership and suid flag set. +# +FpingLocation={{ zabbix_server_fpinglocation }} + +### option: fping6location +# location of fping6. +# make sure that fping6 binary has root ownership and suid flag set. +# make empty if your fping utility is capable to process ipv6 addresses. +# +Fping6Location={{ zabbix_server_fping6location }} + +### option: sshkeylocation +# location of public and private keys for ssh checks and actions. +# +{% if zabbix_server_sshkeylocation is defined and zabbix_server_sshkeylocation %} +SSHKeyLocation={{ zabbix_server_sshkeylocation }} +{% endif %} + +### option: logslowqueries +# how long a database query may take before being logged (in milliseconds). +# only works if debuglevel set to 3 or 4. +# 0 - don't log slow queries. +# +LogSlowQueries={{ zabbix_server_logslowqueries }} + +### option: tmpdir +# temporary directory. +# +TmpDir={{ zabbix_server_tmpdir }} + +### option: startproxypollers +# number of pre-forked instances of pollers for passive proxies. +# +StartProxyPollers={{ zabbix_server_startproxypollers }} + +### option: proxyconfigfrequency +# how often zabbix server sends configuration data to a zabbix proxy in seconds. +# this parameter is used only for proxies in the passive mode. +# +ProxyConfigFrequency={{ zabbix_server_proxyconfigfrequency }} + +### option: proxydatafrequency +# how often zabbix server requests history data from a zabbix proxy in seconds. +# this parameter is used only for proxies in the passive mode. +# +ProxyDataFrequency={{ zabbix_server_proxydatafrequency }} + +{% if zabbix_version is version('2.2', '>=') %} +### option: allowroot +# allow the server to run as 'root'. if disabled and the server is started by 'root', the server +# will try to switch to user 'zabbix' instead. has no effect if started under a regular user. +# 0 - do not allow +# 1 - allow +# +AllowRoot={{ zabbix_server_allowroot }} +{% endif %} + +{% if zabbix_version is version('3.0', '>=') %} +### Option: User +# Drop privileges to a specific, existing user on the system. +# Only has effect if run as 'root' and AllowRoot is disabled. +# +User={{ zabbix_server_user }} +{% endif %} + +### option: include +# you may include individual files or all files in a directory in the configuration file. +# installing zabbix will create include directory in /usr/local/etc, unless modified during the compile time. +# +Include={{ zabbix_server_include }} + +{% if zabbix_version is version('3.0', '>=') %} +### Option: SSLCertLocation +# Location of SSL client certificates. +# This parameter is used only in web monitoring. +# +SSLCertLocation={{ zabbix_server_sslcertlocation }} + +### Option: SSLKeyLocation +# Location of private keys for SSL client certificates. +# This parameter is used only in web monitoring. +# +SSLKeyLocation={{ zabbix_server_sslkeylocation }} + +### Option: SSLCALocation +# Override the location of certificate authority (CA) files for SSL server certificate verification. +# If not set, system-wide directory will be used. +# This parameter is used only in web monitoring and SMTP authentication. +# +{% if zabbix_server_sslcalocation is defined and zabbix_server_sslcalocation is not none %} +SSLCALocation={{ zabbix_server_sslcalocation }} +{% endif %} +{% endif %} + +####### loadable modules ####### +{% if zabbix_version is version('2.2', '>=') %} +### option: loadmodulepath +# full path to location of server modules. +# default depends on compilation options. +# +LoadModulePath={{ zabbix_server_loadmodulepath }} +{% endif %} + +### option: loadmodule +# module to load at server startup. modules are used to extend functionality of the server. +# format: loadmodule= +# the modules must be located in directory specified by loadmodulepath. +# it is allowed to include multiple loadmodule parameters. +# +{% if zabbix_server_loadmodule is defined and zabbix_server_loadmodule %} +LoadModule = {{ loadmodule }} +{% endif %} + +{% if zabbix_version is version('3.0', '>=') %} +####### TLS-RELATED PARAMETERS ####### + +### Option: TLSCAFile +# Full pathname of a file containing the top-level CA(s) certificates for +# peer certificate verification. +# +# Mandatory: no +# Default: +{% if zabbix_server_tlscafile is defined and zabbix_server_tlscafile is not none %} +TLSCAFile={{ zabbix_server_tlscafile }} +{% endif %} + +### Option: TLSCRLFile +# Full pathname of a file containing revoked certificates. +# +# Mandatory: no +# Default: +{% if zabbix_server_tlscrlfile is defined and zabbix_server_tlscrlfile is not none %} +TLSCRLFile={{ zabbix_server_tlscrlfile }} +{% endif %} + +### Option: TLSCertFile +# Full pathname of a file containing the server certificate or certificate chain. +# +# Mandatory: no +# Default: +{% if zabbix_server_tlscertfile is defined and zabbix_server_tlscertfile is not none %} +TLSCertFile={{ zabbix_server_tlscertfile }} +{% endif %} + +### Option: TLSKeyFile +# Full pathname of a file containing the server private key. +# +# Mandatory: no +# Default: +{% if zabbix_server_tlskeyfile is defined and zabbix_server_tlskeyfile is not none %} +TLSKeyFile={{ zabbix_server_tlskeyfile }} +{% endif %} +{% endif %} + +### Option: DBTLSConnect +# Setting this option enforces to use TLS connection to database. +# required - connect using TLS +# verify_ca - connect using TLS and verify certificate +# verify_full - connect using TLS, verify certificate and verify that database identity specified by DBHost +# matches its certificate +# On MySQL starting from 5.7.11 and PostgreSQL following values are supported: "required", "verify_ca" and +# "verify_full". +# On MariaDB starting from version 10.2.6 "required" and "verify_full" values are supported. +# Default is not to set any option and behavior depends on database configuration +# +# Mandatory: no +# Default: +# DBTLSConnect= +{% if zabbix_server_dbtlsconnect is defined and zabbix_server_dbtlsconnect is not none %} +DBTLSConnect={{ zabbix_server_dbtlsconnect }} +{% endif %} + +### Option: DBTLSCAFile +# Full pathname of a file containing the top-level CA(s) certificates for database certificate verification. +# Supported only for MySQL and PostgreSQL +# +# Mandatory: no +# (yes, if DBTLSConnect set to one of: verify_ca, verify_full) +# Default: +# DBTLSCAFile= +{% if zabbix_server_dbtlscafile is defined and zabbix_server_dbtlscafile is not none %} +DBTLSCAFile={{ zabbix_server_dbtlscafile }} +{% endif %} + +### Option: DBTLSCertFile +# Full pathname of file containing Zabbix proxy certificate for authenticating to database. +# Supported only for MySQL and PostgreSQL +# +# Mandatory: no +# Default: +# DBTLSCertFile= +{% if zabbix_server_dbtlscertfile is defined and zabbix_server_dbtlscertfile is not none %} +DBTLSCertFile={{ zabbix_server_dbtlscertfile }} +{% endif %} + +### Option: DBTLSKeyFile +# Full pathname of file containing the private key for authenticating to database. +# Supported only for MySQL and PostgreSQL +# +# Mandatory: no +# Default: +# DBTLSKeyFile= +{% if zabbix_server_dbtlskeyfile is defined and zabbix_server_dbtlskeyfile is not none %} +DBTLSKeyFile={{ zabbix_server_dbtlskeyfile }} +{% endif %} + +### Option: DBTLSCipher +# The list of encryption ciphers that Zabbix proxy permits for TLS protocols up through TLSv1.2 +# Supported only for MySQL +# +# Mandatory no +# Default: +# DBTLSCipher= +{% if zabbix_server_dbtlscipher is defined and zabbix_server_dbtlscipher is not none %} +DBTLSCipher={{ zabbix_server_dbtlscipher }} +{% endif %} + +### Option: DBTLSCipher13 +# The list of encryption ciphersuites that Zabbix proxy permits for TLSv1.3 protocol +# Supported only for MySQL, starting from version 8.0.16 +# +# Mandatory no +# Default: +# DBTLSCipher13= +{% if zabbix_server_dbtlscipher13 is defined and zabbix_server_dbtlscipher13 is not none %} +DBTLSCipher13={{ zabbix_server_dbtlscipher13 }} +{% endif %} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/Debian.yml new file mode 100644 index 00000000..1eecc317 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/Debian.yml @@ -0,0 +1,6 @@ +--- +apache_user: www-data +apache_group: www-data +apache_log: apache2 + +mysql_create_dir: '' diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/RedHat.yml new file mode 100644 index 00000000..8c199770 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/RedHat.yml @@ -0,0 +1,6 @@ +--- +apache_user: apache +apache_group: apache +apache_log: httpd + +mysql_create_dir: create/ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/main.yml new file mode 100644 index 00000000..5be481a3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for dj-wasabi.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/zabbix.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/zabbix.yml new file mode 100644 index 00000000..1da19b60 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_server/vars/zabbix.yml @@ -0,0 +1,188 @@ +--- +sign_keys: + "52": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "50": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "44": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "42": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "40": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "34": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "32": + bionic: + sign_key: A14FE591 + sonya: + sign_key: 79EA5ED4 + serena: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "30": + bionic: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "24": + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + "22": + squeeze: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + lucid: + sign_key: 79EA5ED4 + +suse: + "openSUSE Leap": + "42": + name: server:monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_Leap_{{ ansible_distribution_version }}/ + "openSUSE": + "12": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_{{ ansible_distribution_version }} + "SLES": + "11": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/SLE_11_SP3/ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/README.md b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/README.md new file mode 100644 index 00000000..fab07dc1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/README.md @@ -0,0 +1,322 @@ +# community.zabbix.zabbix_web role + +![Zabbix Web](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_web/badge.svg) + +**Table of Contents** + +- [Overview](#overview) +- [Requirements](#requirements) + - [Operating Systems](#operating-systems) + - [Zabbix Versions](#zabbix-versions) +- [Installation](#installation) +- [Role Variables](#role-variables) + - [Main variables](#main-variables) + - [Overall Zabbix](#overall-zabbix) + - [Zabbix Web specific](#zabbix-web-specific) + - [Apache configuration](#apache-configuration) + - [Nginx configuration](#nginx-configuration) + - [PHP-FPM](#php-fpm) + - [Zabbix Server](#zabbix-server) + * [proxy](#proxy) +- [Example Playbook](#example-playbook) + - [Single instance](#single-instance) + - [Multi host setup](#multi-host-setup) + - [Adding Environment Variables for zabbix_web](#adding-environment-variables-for-zabbixweb) + - [Using Elasticsearch for history storage](#using-elasticsearch-for-history-storage) +- [Molecule](#molecule) +- [License](#license) +- [Author Information](#author-information) + +# Overview + +# Requirements +## Operating Systems + +This role will work on the following operating systems: + + * RedHat + * Debian + * Ubuntu + +So, you'll need one of those operating systems.. :-) +Please send Pull Requests or suggestions when you want to use this role for other Operating systems. + +## Zabbix Versions + +See the following list of supported Operating Systems with the Zabbix releases. + +| Zabbix | 5.2 | 5.0 | 4.4 | 4.0 (LTS) | 3.0 (LTS) | +|---------------------|-----|-----|-----|-----------|-----------| +| Red Hat Fam 8 | V | V | V | | | +| Red Hat Fam 7 | V | V | V | V | V | +| Red Hat Fam 6 | V | V | | | V | +| Red Hat Fam 5 | V | V | | | V | +| Fedora | | | V | V | | +| Ubuntu 20.04 focal | V | V | | | | +| Ubuntu 19.10 eoan | | | | | | +| Ubuntu 18.04 bionic | V | V | V | V | | +| Ubuntu 16.04 xenial | V | V | V | V | | +| Ubuntu 14.04 trusty | V | V | V | V | V | +| Debian 10 buster | V | V | V | | | +| Debian 9 stretch | V | V | V | V | | +| Debian 8 jessie | V | V | V | V | V | +| Debian 7 wheezy | | | | V | V | +| macOS 10.15 | | | V | V | | +| macOS 10.14 | | | V | V | | + +# Installation + +Installing this role is very simple: `ansible-galaxy install community.zabbix.zabbix_web` + +When the Zabbix Web needs to be running on the same host as the Zabbix Server, please also install the Zabbix Server by executing the following command: `ansible-galaxy install community.zabbix.zabbix_server` + +Default username/password for the Zabbix Web interface is the default. + +Username: Admin +Password: zabbix + +# Role Variables + +## Main variables + +The following is an overview of all available configuration defaults for this role. + +### Overall Zabbix + +* `zabbix_web_version`: This is the version of zabbix. Default: 5.2. Can be overridden to 5.0, 4.4, 4.0, 3.4, 3.2, 3.0, 2.4, or 2.2. Previously the variable `zabbix_version` was used directly but it could cause [some inconvenience](https://github.com/dj-wasabi/ansible-zabbix-agent/pull/303). That variable is maintained by retrocompativility. +* `zabbix_repo`: Default: `zabbix` + * `epel`: install agent from EPEL repo + * `zabbix`: (default) install agent from Zabbix repo + * `other`: install agent from pre-existing or other repo +* `zabbix_repo_yum`: A list with Yum repository configuration. +* `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository(http/https) +* `zabbix_repo_yum_disabled`: A string with repository names that should be disabled when installing Zabbix component specific packages. Is only used when `zabbix_repo_yum_enabled` contains 1 or more repositories. Default `*`. +* `zabbix_repo_yum_enabled`: A list with repository names that should be enabled when installing Zabbix component specific packages. + +* `zabbix_web_package_state`: Default: `present`. Can be overridden to `latest` to update packages when needed. +* `zabbix_web_centos_release`: Default: True. When the `centos-release-scl` repository needs to be enabled. This is required when using Zabbix 5.0 due to installation of a recent version of `PHP`. +* `zabbix_web_rhel_release`: Default: True. When the `scl-utils` repository needs to be enabled. This is required when using Zabbix 5.0 due to installation of a recent version of `PHP`. +* `zabbix_web_doubleprecision`: Default: `False`. For upgraded installations, please read database [upgrade notes](https://www.zabbix.com/documentation/current/manual/installation/upgrade_notes_500) (Paragraph "Enabling extended range of numeric (float) values") before enabling this option. +* `zabbix_web_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. + +### Zabbix Web specific + +* `zabbix_url`: This is the url on which the zabbix web interface is available. Default is zabbix.example.com, you should override it. For example, see "Example Playbook" +* `zabbix_url_aliases`: A list with Aliases for the Apache Virtual Host configuration. +* `zabbix_timezone`: Default: `Europe/Amsterdam`. This is the timezone. The Apache Virtual Host needs this parameter. +* `zabbix_vhost`: Default: `true`. When you don't want to create an Apache Virtual Host configuration, you can set it to False. +* `zabbix_web_env`: (Optional) A Dictionary of PHP Environments settings. +* `zabbix_web_conf_web_user`: When provided, the user (which should already exist on the host) will be used for ownership for web/php related processes. (Default set to either `apache` (`www-data` for Debian) or `nginx`). +* `zabbix_web_conf_web_group`: When provided, the group (which should already exist on the host) will be used for ownership for web/php related processes. (Default set to either `apache` (`www-data` for Debian) or `nginx`). +* `zabbix_web_htpasswd`: (Optional) Allow HTTP authentication at the webserver level via a htpasswd file. +* `zabbix_web_htpasswd_file`: Default: `/etc/zabbix/web/htpasswd`. Allows the change the default path to the htpasswd file. +* `zabbix_web_htpasswd_users`: (Optional) Dictionary for creating users via `htpasswd_user` and passphrases via `htpasswd_pass` in htpasswd file. +* `zabbix_web_allowlist_ips`: (Optional) Allow web access at webserver level to a list of defined IPs or CIDR. + +#### Apache configuration + +* `zabbix_apache_vhost_port`: The port on which Zabbix HTTP vhost is running. +* `zabbix_apache_vhost_tls_port`: The port on which Zabbix HTTPS vhost is running. +* `zabbix_apache_vhost_listen_ip`: On which interface the Apache Virtual Host is available. +* `zabbix_apache_can_connect_ldap`: Default: `false`. Set SELinux boolean to allow httpd to connect to LDAP. +* `zabbix_php_install`: Default: `true`. True / False. Switch for extra install of packages for PHP, currently on for Debian/Ubuntu. +* `zabbix_web_max_execution_time`: +* `zabbix_web_memory_limit`: +* `zabbix_web_post_max_size`: +* `zabbix_web_upload_max_filesize`: +* `zabbix_web_max_input_time`: +* `zabbix_apache_include_custom_fragment`: Default: `true`. Includes php_value vars max_execution_time, memory_limit, post_max_size, upload_max_filesize, max_input_time and date.timezone in vhost file.. place those in php-fpm configuration. +* `zabbix_apache_tls`: If the Apache vhost should be configured with TLS encryption or not. +* `zabbix_apache_redirect`: If a redirect should take place from HTTP to HTTPS +* `zabbix_apache_tls_crt`: The path to the TLS certificate file. +* `zabbix_apache_tls_key`: The path to the TLS key file. +* `zabbix_apache_tls_chain`: The path to the TLS certificate chain file. +* `zabbix_apache_SSLPassPhraseDialog`: Type of pass phrase dialog for encrypted private keys. +* `zabbix_apache_SSLSessionCache`: Type of the global/inter-process SSL Session Cache +* `zabbix_apache_SSLSessionCacheTimeout`: Number of seconds before an SSL session expires in the Session Cache +* `zabbix_apache_SSLCryptoDevice`: Enable use of a cryptographic hardware accelerator + +When `zabbix_apache_tls_crt`, `zabbix_apache_tls_key` and/or `zabbix_apache_tls_chain` are used, make sure that these files exists before executing this role. The Zabbix-Web role will not install the mentioned files. + +See https://httpd.apache.org/docs/current/mod/mod_ssl.html for SSL* configuration options for Apache HTTPD. + +#### Nginx configuration + +* `zabbix_nginx_vhost_port`: The port on which Zabbix HTTP vhost is running. +* `zabbix_nginx_vhost_tls_port`: The port on which Zabbix HTTPS vhost is running. +* `zabbix_nginx_tls`: If the Nginx vhost should be configured with TLS encryption or not. +* `zabbix_nginx_tls_crt`: The path to the TLS certificate file. +* `zabbix_nginx_tls_key`: The path to the TLS key file. +* `zabbix_nginx_tls_dhparam`: The path to the TLS DHParam file. +* `zabbix_nginx_tls_session_cache`: Type of the global/inter-process SSL Session Cache +* `zabbix_nginx_tls_session_timeout`: +* `zabbix_nginx_tls_session_tickets`: +* `zabbix_nginx_tls_protocols`: The TLS Protocols to accept. +* `zabbix_nginx_tls_ciphers`: The TLS Ciphers to be allowed. + +When `zabbix_nginx_tls_crt` and `zabbix_nginx_tls_key` are used, make sure that these files exists before executing this role. The Zabbix-Web role will not install the mentioned files. + +#### PHP-FPM + +The following properties are specific to Zabbix 5.0 and for the PHP(-FPM) configuration: + +* `zabbix_php_version`: Either `7.3` or `7.4` (Based on the OS Family). When you want to override the PHP Version. +* `zabbix_php_fpm_session`: The directory where sessions will be stored. If none are provided, defaults are used. +* `zabbix_php_fpm_listen`: The path to a socket file or ipaddress:port combination on which PHP-FPM needs to listen. If none are provided, defaults are used. +* `zabbix_php_fpm_conf_listen`: Default: `true`. If we want to configure the `zabbix_php_fpm_listen` in the PHP-FPM configuration file. +* `zabbix_php_fpm_conf_user`: The owner of the socket file (When `zabbix_php_fpm_listen` contains a patch to a socket file). +* `zabbix_php_fpm_conf_enable_user`: Default: `true`. If we want to configure the owner of the `zabbix_php_fpm_listen` in the PHP-FPM configuration file. +* `zabbix_php_fpm_conf_group`: The group of the owner of the socket file (When `zabbix_php_fpm_listen` contains a patch to a socket file). +* `zabbix_php_fpm_conf_enable_group`: Default: `true`. If we want to configure the group of the `zabbix_php_fpm_listen` in the PHP-FPM configuration file. +* `zabbix_php_fpm_conf_mode`: The mode for the socket file (When `zabbix_php_fpm_listen` contains a patch to a socket file). +* `zabbix_php_fpm_conf_enable_mode`: Default: `true`. If we want to configure the mode of the `zabbix_php_fpm_listen` in the PHP-FPM configuration file. +* `zabbix_php_fpm_dir_etc`: etc HOME root directory of PHP-FPM setup. +* `zabbix_php_fpm_dir_var`: Var HOME root directory of PHP-FPM setup. + +### Zabbix Server + +* `zabbix_server_name`: The name of the Zabbix Server. +* `zabbix_server_database`: The type of database used. Can be: mysql or pgsql +* `zabbix_server_database_long`: The type of database used, but long name. Can be: mysql or postgresql +* `zabbix_server_hostname`: The hostname on which the zabbix-server is running. Default set to: {{ inventory_hostname }} +* `zabbix_server_listenport`: On which port the Zabbix Server is available. Default: 10051 +* `zabbix_server_dbhost`: The hostname on which the database is running. +* `zabbix_server_dbname`: The database name which is used by the Zabbix Server. +* `zabbix_server_dbuser`: The database username which is used by the Zabbix Server. +* `zabbix_server_dbpassword`: The database user password which is used by the Zabbix Server. +* `zabbix_server_dbport`: The database port which is used by the Zabbix Server. + +The following properties are related when using Elasticsearch for history storage: + +* `zabbix_server_history_url`: String with url to the Elasticsearch server or a list if the types are stored on different Elasticsearch URLs. +* `zabbix_server_history_types`: List of history types to store in Elasticsearch. + +See the following links for more information regarding Zabbix and Elasticsearch +https://www.zabbix.com/documentation/3.4/manual/appendix/install/elastic_search_setup +https://www.zabbix.com/documentation/4.0/manual/appendix/install/elastic_search_setup + +## proxy + +When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy: + +* `zabbix_http_proxy` +* `zabbix_https_proxy` + +# Example Playbook + +There are two ways of using the zabbix-web: + +* Single instance +* Multi host setup + +## Single instance + +When there is one host running both Zabbix Server and the Zabbix Web (Running MySQL as database): + +```yaml +- hosts: zabbix-server + become: yes + roles: + - role: geerlingguy.apache + - role: community.zabbix.zabbix_server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + - role: community.zabbix.zabbix_web + zabbix_url: zabbix.mydomain.com + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 +``` + +## Multi host setup + +This is a two host setup. On one host (Named: "zabbix-server") the Zabbix Server is running, and the other host (Named: zabbix-web) runs Zabbix Web (with MySQL as database): + +```yaml +- hosts: zabbix-server + become: yes + roles: + - role: community.zabbix.zabbix_server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + +- hosts: zabbix-web + become: yes + roles: + - role: geerlingguy.apache + - role: community.zabbix.zabbix_web + zabbix_url: zabbix.mydomain.com + zabbix_server_hostname: zabbix-server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 +``` + +## Adding Environment Variables for zabbix_web + +Sometimes you need to add environment variables to your +zabbix.conf.php, for example to add LDAP CA certificates. To do this add a `zabbix_web_env` dictionary: + +```yaml +- hosts: zabbix-web + become: yes + roles: + - role: geerlingguy.apache + - role: community.zabbix.zabbix_web + zabbix_url: zabbix.mydomain.com + zabbix_server_hostname: zabbix-server + zabbix_server_database: mysql + zabbix_server_database_long: mysql + zabbix_server_dbport: 3306 + zabbix_web_env: + LDAPTLS_CACERT: /etc/ssl/certs/ourcert.pem +``` + +## Using Elasticsearch for history storage + +To use Elasticsearch for history storage you need to configure the `zabbix_server_history_url` and `zabbix_server_history_types`. You will also need to configure Elasticsearch +in the zabbix_server role. + +Zabbix can store the following history types +in Elasticsearch: +* Numeric (unsigned) - `uint` +* Numeric (float) - `dbl` +* Character - `str` +* Log - `log` +* Text - `text` + +To store all history types in the same history URL the following variables should be set (make sure history url points to your Elasticsearch cluster): + +``` +zabbix_server_history_url: "http://localhost:9200" +zabbix_server_history_types: + - 'str' + - 'text' + - 'log' + - 'uint' + - 'dbl' +``` + +# Molecule + +This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule: + +* http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/ +* http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/ +* http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/ + +With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully. + +# License + +GNU General Public License v3.0 or later + +See LICENCE to see the full text. + +# Author Information + +Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role. + +Github: https://github.com/ansible-collections/community.zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/defaults/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/defaults/main.yml new file mode 100644 index 00000000..13a3e222 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/defaults/main.yml @@ -0,0 +1,124 @@ +--- +# defaults file for zabbix-web + +zabbix_web_version: 5.2 +zabbix_version: "{{ zabbix_web_version }}" +zabbix_repo: zabbix +zabbix_web_package_state: present +zabbix_web_centos_release: true +zabbix_web_rhel_release: true +zabbix_selinux: False +zabbix_web_doubleprecision: False +zabbix_web_conf_mode: "0640" + +zabbix_url: zabbix.example.com +zabbix_websrv: apache +zabbix_websrv_servername: "{{ zabbix_url | regex_findall('(?:https?\\://)?([\\w\\-\\.]+)') | first }}" +zabbix_url_aliases: [] +zabbix_web_htpasswd: False +zabbix_web_htpasswd_file: /etc/zabbix/web/htpasswd +zabbix_timezone: Europe/Amsterdam +zabbix_vhost: True + +zabbix_php_frontend_deprecated: False +zabbix_php_fpm: False +zabbix_php_fpm_dir_etc: /etc/opt/rh/rh-php72/ +zabbix_php_fpm_dir_var: /var/opt/rh/rh-php72/ +zabbix_php_fpm_conf_listen: True +zabbix_php_fpm_conf_enable_user: true +zabbix_php_fpm_conf_enable_group: true +zabbix_php_fpm_conf_mode: "0664" +zabbix_php_fpm_conf_enable_mode: true + +zabbix_apache_vhost_port: 80 +zabbix_apache_vhost_tls_port: 443 +zabbix_apache_vhost_listen_ip: "*" +zabbix_apache_tls: False +zabbix_apache_redirect: False +zabbix_apache_tls_crt: /etc/pki/server.crt +zabbix_apache_tls_key: /etc/pki/server.key +zabbix_apache_tls_chain: +zabbix_apache_can_connect_ldap: False +zabbix_apache_include_custom_fragment: true +zabbix_apache_SSLPassPhraseDialog: exec:/usr/libexec/httpd-ssl-pass-dialog +zabbix_apache_SSLSessionCache: shmcb:/run/httpd/sslcache(512000) +zabbix_apache_SSLSessionCacheTimeout: 300 +zabbix_apache_SSLCryptoDevice: builtin + +zabbix_nginx_vhost_port: 80 +zabbix_nginx_vhost_tls_port: 443 +zabbix_nginx_tls: False +zabbix_nginx_redirect: False +zabbix_nginx_tls_session_timeout: 1d +zabbix_nginx_tls_session_cache: shared:MySSL:10m +zabbix_nginx_tls_session_tickets: !!str off +zabbix_nginx_tls_protocols: TLSv1.2 +zabbix_nginx_tls_ciphers: ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384 + +zabbix_letsencrypt: False +zabbix_letsencrypt_webroot_path: /var/www/letsencrypt + +zabbix_repo_yum_schema: https +zabbix_repo_yum_disabled: "*" +zabbix_repo_yum_enabled: [] +zabbix_repo_yum: + - name: zabbix + description: Zabbix Official Repository - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix/{{ zabbix_version }}/rhel/{{ ansible_distribution_major_version }}/$basearch/" + gpgcheck: 0 + mode: '0644' + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + - name: zabbix-non-supported + description: Zabbix Official Repository non-supported - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/non-supported/rhel/{{ ansible_distribution_major_version }}/$basearch/" + mode: '0644' + gpgcheck: 0 + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + +zabbix_5_repo_yum: + - name: zabbix-frontend + description: Zabbix Official Repository - $basearch + baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix/{{ zabbix_version }}/rhel/{{ ansible_distribution_major_version }}/$basearch/frontend/" + mode: '0644' + gpgcheck: 0 + gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX + state: present + +zabbix_php_install: true +zabbix_web_max_execution_time: 300 +zabbix_web_memory_limit: 128M +zabbix_web_post_max_size: 16M +zabbix_web_upload_max_filesize: 2M +zabbix_web_max_input_time: 300 +zabbix_web_max_input_vars: 10000 + +# Database +zabbix_server_database: pgsql +zabbix_server_database_long: postgresql +zabbix_server_name: "{{ inventory_hostname }}" +zabbix_server_hostname: "{{ inventory_hostname }}" +zabbix_server_listenport: 10051 +zabbix_server_dbhost: localhost +zabbix_server_dbname: zabbix-server +zabbix_server_dbuser: zabbix-server +zabbix_server_dbpassword: zabbix-server +zabbix_server_dbport: 5432 +zabbix_server_dbschema: + +# Elasticsearch +# zabbix_server_history_url: +# - "'uint' => 'http://localhost:9200'" +# - "'text' => 'http://localhost:9200'" +# - "'log' => 'http://localhost:9200'" +# - "'dbl' => 'http://localhost:9200'" +# - "'str' => 'http://localhost:9200'" +zabbix_server_history_types: + - 'str' + - 'text' + - 'log' + - 'uint' + - 'dbl' + +selinux_allow_zabbix_can_network: False diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/handlers/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/handlers/main.yml new file mode 100644 index 00000000..9cd7ccfc --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/handlers/main.yml @@ -0,0 +1,54 @@ +--- + +- name: restart apache + service: + name: "{{ _apache_service }}" + state: restarted + enabled: yes + become: yes + when: + - zabbix_websrv == 'apache' + +- name: test nginx config + listen: restart nginx + command: nginx -t + register: zabbix_nginx_cfg_check + notify: restart nginx tested + become: yes + when: + - zabbix_websrv == 'nginx' + +- name: restart nginx tested + service: + name: nginx + state: restarted + enabled: yes + become: yes + when: + - zabbix_websrv == 'nginx' + - zabbix_nginx_cfg_check.rc == 0 + +- name: restart php-fpm + service: + name: "{{ 'rh-php72-php-fpm' if zabbix_php_fpm else 'php-fpm' }}" + state: restarted + enabled: yes + become: yes + when: + - zabbix_version is version('5.0', '>=') + +- name: restart php-fpm-version + service: + name: php{{ zabbix_php_version }}-fpm + state: restarted + enabled: yes + become: yes + when: + - zabbix_version is version('5.0', '>=') + +- name: "clean repo files from proxy creds" + shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + become: yes + when: + - ansible_os_family == 'RedHat' + - zabbix_http_proxy is defined or zabbix_https_proxy is defined diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/meta/main.yml new file mode 100644 index 00000000..907a3c86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/meta/main.yml @@ -0,0 +1,28 @@ +--- +galaxy_info: + author: Werner Dijkerman + description: Installing and maintaining zabbix-web for RedHat/Debian/Ubuntu. + company: myCompany.Dotcom + license: license (GPLv3) + min_ansible_version: 2.4 + platforms: + - name: EL + versions: + - 6 + - 7 + - name: Ubuntu + versions: + - lucid + - precise + - trusty + - name: Debian + versions: + - squeeze + - wheezy + - jessie + - stretch + galaxy_tags: + - monitoring + - zabbix + +dependencies: [] diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/Debian.yml new file mode 100644 index 00000000..97b75c34 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/Debian.yml @@ -0,0 +1,91 @@ +--- + +- name: "Include Zabbix gpg ids" + include_vars: zabbix.yml + +- name: "Set short version name" + set_fact: + zabbix_short_version: "{{ zabbix_version | regex_replace('\\.', '') }}" + +- name: "Debian | Install gpg key" + apt_key: + id: "{{ sign_keys[zabbix_short_version][ansible_distribution_release]['sign_key'] }}" + url: http://repo.zabbix.com/zabbix-official-repo.key + when: + - zabbix_repo == "zabbix" + become: yes + tags: + - zabbix-web + - init + - config + +- name: "Debian | Installing repository {{ ansible_distribution }}" + apt_repository: + repo: "{{ item }} http://repo.zabbix.com/zabbix/{{ zabbix_version }}/{{ ansible_distribution.lower() }}/ {{ ansible_distribution_release }} main" + state: present + become: yes + when: + - zabbix_repo == "zabbix" + with_items: + - deb-src + - deb + tags: + - zabbix-web + - init + - config + +- name: "Debian | Install PHP apart from zabbix-frontend-php deps" + include_tasks: "php_Debian.yml" + when: zabbix_php_install + +- name: "Debian | Install zabbix-web" + apt: + pkg: "zabbix-frontend-php{{ '-deprecated' if zabbix_php_frontend_deprecated else '' }}" + state: "{{ zabbix_web_package_state }}" + update_cache: yes + cache_valid_time: 0 + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_web_package_install + until: zabbix_web_package_install is succeeded + become: yes + tags: + - zabbix-web + - init + - config + +- name: "Debian | Link graphfont.ttf (workaround ZBX-10467)" + file: + src: '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf' + path: '/usr/share/zabbix/fonts/graphfont.ttf' + state: link + tags: + - zabbix-web + - init + - config + +- name: "Debian | Install PHP" + template: + src: php-fpm.conf.j2 + dest: "{{ zabbix_php_fpm_dir }}/zabbix.conf" + owner: "{{ _apache_user }}" + group: "{{ _apache_group }}" + mode: 0644 + become: yes + when: + - zabbix_vhost + notify: + - restart php-fpm-version + +- name: "Including Apache Configuration" + include_tasks: apache_Debian.yml + vars: + zabbix_apache_servername: "{{ zabbix_websrv_servername }}" + when: + - zabbix_websrv == 'apache' + +- name: "Configure SELinux when enabled" + include: selinux.yml + when: + - zabbix_selinux | bool diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/RedHat.yml new file mode 100644 index 00000000..16b176e4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/RedHat.yml @@ -0,0 +1,170 @@ +--- +# Tasks specific for RedHat systems + +- name: "RedHat | Install basic repo file" + yum_repository: + name: "{{ item.name }}" + description: "{{ item.description }}" + baseurl: "{{ item.baseurl }}" + gpgcheck: "{{ item.gpgcheck }}" + gpgkey: "{{ item.gpgkey }}" + mode: "{{ item.mode | default('0644') }}" + priority: "{{ item.priority | default('99') }}" + state: "{{ item.state | default('present') }}" + proxy: "{{ zabbix_http_proxy | default(omit) }}" + with_items: "{{ zabbix_repo_yum }}" + register: yum_repo_installed + become: yes + when: + zabbix_repo == "zabbix" + notify: + - "clean repo files from proxy creds" + tags: + - zabbix-web + +- name: "RedHat | Install basic repo file (Zabbix 5.x)" + yum_repository: + name: "{{ item.name }}" + description: "{{ item.description }}" + baseurl: "{{ item.baseurl }}" + gpgcheck: "{{ item.gpgcheck }}" + gpgkey: "{{ item.gpgkey }}" + mode: "{{ item.mode | default('0644') }}" + priority: "{{ item.priority | default('99') }}" + state: "{{ item.state | default('present') }}" + proxy: "{{ zabbix_http_proxy | default(omit) }}" + with_items: "{{ zabbix_5_repo_yum }}" + become: yes + when: + - zabbix_repo == "zabbix" + - zabbix_version is version('5.0', '>=') + - ansible_distribution_major_version != '8' + notify: + - "clean repo files from proxy creds" + tags: + - zabbix-web + +- name: "RedHat | Install zabbix-web dependency (Zabbix 5.x) (CentOS)" + yum: + pkg: + - centos-release-scl + state: "{{ zabbix_web_package_state }}" + update_cache: yes + disablerepo: "{{ '*' if (zabbix_repo_yum_enabled | length>0) else omit }}" + enablerepo: "{{ zabbix_repo_yum_enabled if zabbix_repo_yum_enabled is iterable and (zabbix_repo_yum_enabled | length>0) else omit }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_web_dependency_package_install + until: zabbix_web_dependency_package_install is succeeded + become: yes + when: + - zabbix_version is version('5.0', '>=') + - zabbix_web_centos_release + - ansible_distribution_major_version != '8' + - ansible_distribution == "CentOS" + tags: + - zabbix-web + +- name: "RedHat | Install zabbix-web dependency (Zabbix 5.x) (RHEL)" + yum: + pkg: + - scl-utils + - scl-utils-build + state: "{{ zabbix_web_package_state }}" + update_cache: yes + disablerepo: "{{ '*' if (zabbix_repo_yum_enabled | length>0) else omit }}" + enablerepo: "{{ zabbix_repo_yum_enabled if zabbix_repo_yum_enabled is iterable and (zabbix_repo_yum_enabled | length>0) else omit }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_web_dependency_package_install + until: zabbix_web_dependency_package_install is succeeded + become: yes + when: + - zabbix_version is version('5.0', '>=') + - zabbix_web_centos_release + - ansible_distribution_major_version != '8' + - ansible_distribution == "RedHat" + tags: + - zabbix-web + +- name: "RedHat | Install zabbix-web (Zabbix 5.x)" + yum: + pkg: + - zabbix-apache-conf-scl + state: "{{ zabbix_web_package_state }}" + update_cache: yes + disablerepo: "{{ '*' if (zabbix_repo_yum_enabled | length>0) else omit }}" + enablerepo: "{{ zabbix_repo_yum_enabled if zabbix_repo_yum_enabled is iterable and (zabbix_repo_yum_enabled | length>0) else omit }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_web_package_install + until: zabbix_web_package_install is succeeded + become: yes + when: + - zabbix_version is version('5.0', '>=') + - ansible_distribution_major_version != '8' + - zabbix_websrv == 'apache' + tags: + - zabbix-web + +- name: "RedHat | Install zabbix-web-{{ zabbix_server_database }}" + yum: + pkg: zabbix-web-{{ zabbix_server_database }}{{ '-scl' if zabbix_version is version('5.0', '>=') and ansible_distribution_major_version != '8' else '' }} + state: "{{ zabbix_web_package_state }}" + update_cache: yes + disablerepo: "{{ '*' if (zabbix_repo_yum_enabled | length>0) else omit }}" + enablerepo: "{{ zabbix_repo_yum_enabled if zabbix_repo_yum_enabled is iterable and (zabbix_repo_yum_enabled | length>0) else omit }}" + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_web_package_install + until: zabbix_web_package_install is succeeded + become: yes + tags: + - zabbix-web + +- name: "RedHat | Install PHP" + template: + src: php-fpm.conf.j2 + dest: "{{ zabbix_php_fpm_dir }}/zabbix.conf" + owner: "{{ zabbix_web_conf_web_user }}" + group: "{{ zabbix_web_conf_web_group }}" + mode: 0644 + become: yes + when: + - zabbix_vhost + notify: + - restart php-fpm + +- include_tasks: apache_RedHat.yml + vars: + zabbix_apache_servername: "{{ zabbix_websrv_servername }}" + when: + - zabbix_websrv == 'apache' + +- name: "RedHat | Install Nginx vhost" + template: + src: nginx_vhost.conf.j2 + dest: /etc/nginx/conf.d/zabbix.conf + owner: root + group: root + mode: 0644 + when: + - zabbix_vhost + - zabbix_websrv == 'nginx' + become: yes + notify: + - restart nginx + tags: + - zabbix-web + - init + - config + - nginx + +- name: "Configure SELinux when enabled" + include: selinux.yml + when: + - zabbix_selinux | bool diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/access.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/access.yml new file mode 100644 index 00000000..5094d2c5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/access.yml @@ -0,0 +1,32 @@ +--- +- name: "htpasswd | check Python version to set prefix variable" + set_fact: + zabbix_python_prefix: "python{% if ansible_python_version is version_compare('3', '>=') %}3{% endif %}" + when: + - zabbix_web_htpasswd is defined + - zabbix_web_htpasswd + - zabbix_web_htpasswd_users is defined + +- name: "htpasswd | install passlib for Python interpreter" + package: + name: "{{ zabbix_python_prefix }}-passlib" + state: present + when: + - zabbix_web_htpasswd is defined + - zabbix_web_htpasswd + - zabbix_web_htpasswd_users is defined + +- name: "htpasswd | manage HTTP authentication controls" + htpasswd: + path: "{{ zabbix_web_htpasswd_file }}" + name: "{{ item.value.htpasswd_user }}" + password: "{{ item.value.htpasswd_pass }}" + group: www-data + state: present + loop_control: + label: "{{ item.value.htpasswd_user }}" + with_dict: "{{ zabbix_web_htpasswd_users }}" + when: + - zabbix_web_htpasswd is defined + - zabbix_web_htpasswd + - zabbix_web_htpasswd_users is defined diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache.yml new file mode 100644 index 00000000..f95fbdf7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache.yml @@ -0,0 +1,35 @@ +--- +- name: "Apache | Get Apache version" + shell: | + PATH=/usr/sbin:$PATH + set -o pipefail + apachectl -v | grep 'version' | awk -F '/' '{ print $2 }'| awk '{ print $1 }' | cut -c 1-3 + changed_when: False + register: apachectl_version + check_mode: no + args: + executable: /bin/bash + tags: + - zabbix-web + +- name: "Apache | Set correct apache_version" + set_fact: + apache_version: "{{ apachectl_version.stdout }}" + tags: + - zabbix-web + +- name: "Set some" + set_fact: + _zabbix_web_apache_php_addition: True + when: + - zabbix_version is version('4.4', '<=') + tags: + - zabbix-web + +- name: "Set some" + set_fact: + _zabbix_web_apache_php_addition: True + when: + - ansible_os_family == "Debian" + tags: + - zabbix-web diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache_Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache_Debian.yml new file mode 100644 index 00000000..9a48d3e8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache_Debian.yml @@ -0,0 +1,53 @@ +--- +- name: "Debian | Install legacy PHP integration for Apache" + apt: + state: present + update_cache: yes + cache_valid_time: 3600 + name: + - libapache2-mod-php + become: yes + +- name: "Debian | install apache vhost" + template: + src: apache_vhost.conf.j2 + dest: /etc/apache2/sites-available/zabbix.conf + owner: "{{ zabbix_web_conf_web_user }}" + group: "{{ zabbix_web_conf_web_group }}" + mode: 0644 + when: zabbix_vhost + become: yes + notify: + - restart apache + tags: + - zabbix-web + - init + - config + - apache + +- name: "Debian | Remove provided zabbix.conf files" + file: + path: "{{ item }}" + state: absent + when: zabbix_vhost + become: yes + with_items: + - /etc/apache2/conf-available/zabbix.conf + - /etc/apache2/conf-enabled/zabbix.conf + +- name: "Debian | enable apache vhost" + file: + src: /etc/apache2/sites-available/zabbix.conf + dest: /etc/apache2/sites-enabled/zabbix.conf + owner: "{{ zabbix_web_conf_web_user }}" + group: "{{ zabbix_web_conf_web_group }}" + state: link + when: zabbix_vhost + become: yes + notify: + - restart apache + tags: + - zabbix-server + - init + - config + - apache diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache_RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache_RedHat.yml new file mode 100644 index 00000000..34f06ea2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/apache_RedHat.yml @@ -0,0 +1,15 @@ +--- + +- name: "RedHat | Install apache vhost" + template: + src: apache_vhost.conf.j2 + dest: /etc/httpd/conf.d/zabbix.conf + owner: "{{ zabbix_web_conf_web_user }}" + group: "{{ zabbix_web_conf_web_group }}" + mode: 0644 + when: zabbix_vhost + become: yes + notify: + - restart apache + tags: + - zabbix-server diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/main.yml new file mode 100644 index 00000000..0081cd89 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/main.yml @@ -0,0 +1,99 @@ +--- +# tasks file for wdijkerman.zabbix-web + +- name: "Include OS-specific variables" + include_vars: "{{ ansible_os_family }}.yml" + tags: + - always + +- name: "Include distribution and version-specific vars" + include_vars: "{{ item }}" + with_first_found: + - files: + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml" + - "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml" + +- name: "Set some versions" + set_fact: + zabbix_short_version: "{{ zabbix_version | regex_replace('\\.', '') }}" + zabbix_php_version: "{{ zabbix_php_version if zabbix_php_version is defined else _zabbix_php_version }}" + tags: + - always + +- name: "Set default PHP-FPM variables" + set_fact: + zabbix_php_fpm_dir: "{{ zabbix_php_fpm_dir if zabbix_php_fpm_dir is defined else _php_fpm_dir }}" + zabbix_php_fpm_session: "{{ zabbix_php_fpm_session if zabbix_php_fpm_session is defined else _php_fpm_session }}" + zabbix_php_fpm_listen: "{{ zabbix_php_fpm_listen if zabbix_php_fpm_listen is defined else _php_fpm_listen }}" + when: + - not zabbix_php_fpm + +- name: "Set default PHP-FPM variables specific RH provided" + set_fact: + zabbix_php_fpm_dir: "{{ zabbix_php_fpm_dir if zabbix_php_fpm_dir is defined else _php_fpm_dir }}" + zabbix_php_fpm_session: "{{ zabbix_php_fpm_session if zabbix_php_fpm_session is defined else _zabbix_php_fpm_session }}" + zabbix_php_fpm_listen: "{{ zabbix_php_fpm_listen if zabbix_php_fpm_listen is defined else _zabbix_php_fpm_listen }}" + when: + - zabbix_php_fpm + - ansible_os_family == "RedHat" + +- name: "Set websrv specific variables (Apache)" + set_fact: + zabbix_web_conf_web_user: "{{ zabbix_web_conf_web_user if zabbix_web_conf_web_user is defined else _apache_user }}" + zabbix_web_conf_web_group: "{{ zabbix_web_conf_web_group if zabbix_web_conf_web_group is defined else _apache_group }}" + when: + - zabbix_websrv == 'apache' + +- include_tasks: apache.yml + when: + - zabbix_websrv == 'apache' + +- include_tasks: nginx.yml + when: + - zabbix_websrv == 'nginx' + +- name: "Install the correct repository" + include: "RedHat.yml" + when: ansible_os_family == "RedHat" + tags: + - zabbix-web + +- name: "Install the correct repository" + include: "Debian.yml" + when: ansible_os_family == "Debian" + tags: + - zabbix-web + +- name: "Create zabbix-web directory" + file: + path: /etc/zabbix/web + owner: "{{ zabbix_web_conf_web_user }}" + group: "{{ zabbix_web_conf_web_group }}" + state: directory + mode: 0755 + tags: + - zabbix-web + - init + - config + +- name: "Configure zabbix-web" + template: + src: zabbix.conf.php.j2 + dest: /etc/zabbix/web/zabbix.conf.php + owner: "{{ zabbix_web_conf_web_user }}" + group: "{{ zabbix_web_conf_web_group }}" + mode: "{{ zabbix_web_conf_mode }}" + notify: + - restart apache + tags: + - zabbix-web + - init + - config + +- include_tasks: access.yml + when: + - zabbix_web_htpasswd + tags: + - zabbix-web + - init + - config diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/nginx.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/nginx.yml new file mode 100644 index 00000000..5f01c2eb --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/nginx.yml @@ -0,0 +1,144 @@ +--- +- name: "Nginx | Set websrv specific variables" + set_fact: + zabbix_web_conf_web_user: "{{ zabbix_web_conf_web_user if zabbix_web_conf_web_user is defined else _nginx_user }}" + zabbix_web_conf_web_group: "{{ zabbix_web_conf_web_group if zabbix_web_conf_web_group is defined else _nginx_group }}" + zabbix_nginx_config_path: "{{ zabbix_nginx_config_path if zabbix_nginx_config_path is defined else _nginx_config_path }}" + zabbix_nginx_log_path: "{{ zabbix_nginx_log_path if zabbix_nginx_log_path is defined else _nginx_log_path }}" + zabbix_nginx_service: "{{ zabbix_nginx_service if zabbix_nginx_service is defined else _nginx_service }}" + zabbix_nginx_tls_crt: "{{ zabbix_nginx_tls_crt if zabbix_nginx_tls_crt is defined else _nginx_tls_crt }}" + zabbix_nginx_tls_key: "{{ zabbix_nginx_tls_key if zabbix_nginx_tls_key is defined else _nginx_tls_key }}" + zabbix_nginx_tls_dhparam: "{{ zabbix_nginx_tls_dhparam if zabbix_nginx_tls_dhparam is defined else _nginx_tls_dhparam }}" + zabbix_apache_service: "{{ zabbix_apache_service if zabbix_apache_service is defined else _apache_service }}" + +- name: "Nginx | Check Apache service if same ports" + command: systemctl status "{{ zabbix_apache_service }}" + failed_when: false + register: zabbix_apache_service_check + changed_when: zabbix_apache_service_check.rc == 0 + check_mode: no + when: + - zabbix_apache_vhost_port == zabbix_nginx_vhost_port + - zabbix_apache_vhost_tls_port == zabbix_nginx_vhost_tls_port + +- name: "Nginx | Stop Apache running on same ports" + service: + name: "{{ zabbix_apache_service }}" + state: stopped + enabled: no + tags: + - zabbix-web + when: + - zabbix_apache_vhost_port == zabbix_nginx_vhost_port + - zabbix_apache_vhost_tls_port == zabbix_nginx_vhost_tls_port + - zabbix_apache_service_check.rc == 0 + +- name: "Nginx | Debian | Install Nginx and ssl-cert packages" + # README don't go for HTTP2 with nginx-full yet due to: + # https://support.zabbix.com/browse/ZBXNEXT-4670 + apt: + state: present + name: + - nginx-light + - ssl-cert + when: ansible_os_family == "Debian" + +- name: "Nginx | RedHat | Install Nginx packages" + yum: + state: present + name: + - nginx + when: ansible_os_family == "RedHat" + +- name: "Nginx | Start and enable service" + service: + name: "{{ zabbix_nginx_service }}" + state: started + enabled: yes + +- name: "Nginx | Install OpenSSL package for DH parameters" + package: + name: openssl + state: present + +- name: "Nginx | Generate SSL DH parameters" + command: "openssl dhparam -out {{ zabbix_nginx_tls_dhparam }} {{ zabbix_nginx_tls_dhparam_bits | default('2048') }}" + args: + creates: "{{ zabbix_nginx_tls_dhparam }}" + +- name: "Let's Encrypt | check for certificate created by certbot" + stat: + path: "/etc/letsencrypt/live/{{ zabbix_websrv_servername }}/fullchain.pem" + register: zabbix_letsencrypt_cert + failed_when: false + when: zabbix_letsencrypt + +- name: "Nginx | Install vhost in conf.d" + template: + src: nginx_vhost.conf.j2 + dest: "{{ zabbix_nginx_config_path }}/zabbix.conf" + owner: root + group: root + mode: 0644 + when: + - zabbix_vhost + become: yes + notify: + - restart nginx + +- name: "Let's Encrypt | Check if zabbix_websrv_servername is resolvable" + set_fact: + zabbix_websrv_servername_ip: "{{ lookup('dig', 'qtype=A', '{{ zabbix_websrv_servername }}')}}" + changed_when: zabbix_websrv_servername_ip != ansible_default_ipv4.address + register: zabbix_letsencrypt_resolve + when: zabbix_letsencrypt + +- name: "Let's Encrypt | check if certbot CLI is present" + shell: "certbot --version" + register: zabbix_cerbot_check + changed_when: zabbix_cerbot_check.rc != 0 + check_mode: no + when: zabbix_letsencrypt + +- name: "Let's Encrypt | flash all handlers before certbot" + meta: flush_handlers + when: + - zabbix_letsencrypt + - zabbix_letsencrypt_resolve is not changed + - zabbix_cerbot_check.rc == 0 + +- name: "Let's Encrypt | generate certs with certbot CLI" + command: > + certbot --non-interactive certonly --expand + -a webroot --webroot-path={{ zabbix_letsencrypt_webroot_path }} + --email {{ zabbix_letsencrypt_account_email }} --agree-tos + --cert-name {{ zabbix_websrv_servername }} + -d {{ zabbix_websrv_servername }} + args: + creates: "/etc/letsencrypt/live/{{ zabbix_websrv_servername }}/fullchain.pem" + when: + - zabbix_letsencrypt + - zabbix_letsencrypt_resolve is not changed + - zabbix_cerbot_check.rc == 0 + +- name: "Let's Encrypt | Check for certificate created by certbot" + stat: + path: "/etc/letsencrypt/live/{{ zabbix_websrv_servername }}/fullchain.pem" + register: zabbix_letsencrypt_cert + failed_when: false + when: zabbix_letsencrypt + +- name: "Let's Encrypt | Reinstall Nginx vhost" + template: + src: nginx_vhost.conf.j2 + dest: /etc/nginx/conf.d/zabbix.conf + owner: root + group: root + mode: 0644 + when: + - zabbix_letsencrypt + - zabbix_letsencrypt_resolve is not changed + - zabbix_cerbot_check.rc == 0 + become: yes + notify: + - restart nginx diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/php_Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/php_Debian.yml new file mode 100644 index 00000000..53cb41aa --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/php_Debian.yml @@ -0,0 +1,44 @@ +--- +- name: "Debian | Install legacy php5 packages on old distros" + apt: + state: present + update_cache: yes + cache_valid_time: 3600 + name: + - php5-{{ zabbix_server_database }} + - php5-bcmath + - php5-mbstring + - php5-ldap + - php5-xml + - php5-gd + register: zabbix_web_php_dependency_install + until: zabbix_web_php_dependency_install is succeeded + become: yes + when: > + ( ansible_distribution == 'Ubuntu' and (ansible_distribution_version is version_compare('16.04', '<'))) + or ( ansible_distribution == 'Debian' and (ansible_distribution_version is version_compare('9', '<')) ) + tags: + - zabbix-web + - init + +- name: "Debian | Install modern php packages on current distros" + apt: + state: present + update_cache: yes + cache_valid_time: 3600 + name: + - php-{{ zabbix_server_database }} + - php-bcmath + - php-mbstring + - php-ldap + - php-xml + - php-gd + register: zabbix_web_php_dependency_install + until: zabbix_web_php_dependency_install is succeeded + become: yes + when: > + ( ansible_distribution == 'Ubuntu' and (ansible_distribution_version is version_compare('16.04', '>='))) + or ( ansible_distribution == 'Debian' and (ansible_distribution_version is version_compare('9', '>=')) ) + tags: + - zabbix-server + - init diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/selinux.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/selinux.yml new file mode 100644 index 00000000..b95256fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/tasks/selinux.yml @@ -0,0 +1,81 @@ +--- + +- name: "SELinux | RedHat | Install related SELinux package" + yum: + name: + - libsemanage-python + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_web_dependencies_installed + until: zabbix_web_dependencies_installed is succeeded + become: yes + when: + - ansible_os_family == "RedHat" + - selinux_allow_zabbix_can_network + - ansible_distribution_major_version == "7" or ansible_distribution_major_version == "6" + tags: + - zabbix-web + +- name: "SELinux | RedHat | Install related SELinux package on RHEL8" + yum: + name: + - python3-libsemanage + state: present + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" + register: zabbix_web_dependencies_installed + until: zabbix_web_dependencies_installed is succeeded + become: yes + when: + - ansible_os_family == "RedHat" + - selinux_allow_zabbix_can_network + tags: + - zabbix-web + +- name: "SELinux | RedHat | Enable zabbix_can_network SELinux boolean" + seboolean: + name: zabbix_can_network + state: yes + persistent: yes + become: yes + when: + - ansible_os_family == "RedHat" + - selinux_allow_zabbix_can_network + tags: + - zabbix-web + +- name: "SELinux | Allow httpd to connect to db (SELinux)" + seboolean: + name: httpd_can_network_connect_db + persistent: yes + state: yes + become: yes + when: + - ansible_selinux.status == "enabled" + - selinux_allow_zabbix_can_network + tags: selinux + +- name: "SELinux | Allow httpd to connect to zabbix (SELinux)" + seboolean: + name: httpd_can_connect_zabbix + persistent: yes + state: yes + become: yes + when: + - ansible_selinux.status == "enabled" + - selinux_allow_zabbix_can_network + tags: selinux + +- name: "SELinux | Allow httpd to connect to ldap (SELinux)" + seboolean: + name: httpd_can_connect_ldap + persistent: yes + state: yes + become: yes + when: + - ansible_selinux.status == "enabled" + - zabbix_apache_can_connect_ldap | bool + tags: selinux \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/apache_vhost.conf.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/apache_vhost.conf.j2 new file mode 100644 index 00000000..2f1bb5d1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/apache_vhost.conf.j2 @@ -0,0 +1,187 @@ + + ServerName {{ zabbix_apache_servername }} + {% for alias in zabbix_url_aliases %} + ServerAlias {{ alias }} + {% endfor %} + + ## Vhost docroot + DocumentRoot "/usr/share/zabbix" + +{% if zabbix_apache_redirect and zabbix_apache_tls %} + RewriteEngine On + RewriteCond %{HTTPS} !=on + RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] +{% endif %} + +{% set directory_paths = ['/usr/share/zabbix/conf', '/usr/share/zabbix/app', '/usr/share/zabbix/include', '/usr/share/zabbix/include/classes'] %} + + + {% if apache_version|string() == '2.4' %} + Options FollowSymLinks + AllowOverride None + Require all granted + {% else %} + AllowOverride None + Order Allow,Deny + Allow from all + {% endif %} + + + DirectoryIndex index.php + + +{% if ansible_os_family == "RedHat" %} + + SetHandler "proxy:unix:{{ zabbix_php_fpm_listen }}|fcgi://localhost" + +{% endif %} + + + +{% for my_path in directory_paths %} + + {% if apache_version|string() == '2.4' %} + Require all denied + {% else %} + AllowOverride None + Order Deny,Allow + Deny from all + {% endif %} + + +{% endfor %} + ## Logging + ErrorLog "/var/log/{{ _apache_log }}/{{ zabbix_apache_servername }}_error.log" + ServerSignature Off + CustomLog "/var/log/{{ _apache_log }}/{{ zabbix_apache_servername }}_access.log" combined + + ## Rewrite rules + RewriteEngine On + RewriteRule ^$ /index.php [L] + +{% if _zabbix_web_apache_php_addition | default(false) %} +{% if zabbix_apache_include_custom_fragment | default(true) %} + ## Custom fragment + {% if zabbix_php_fpm %} + ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/usr/share/zabbix/$1 + ProxyTimeout 1800 + {% else %} + php_value max_execution_time {{ zabbix_web_max_execution_time | default('300') }} + php_value memory_limit {{ zabbix_web_memory_limit | default('128M') }} + php_value post_max_size {{ zabbix_web_post_max_size | default('16M') }} + php_value upload_max_filesize {{ zabbix_web_upload_max_filesize | default('2M') }} + php_value max_input_time {{ zabbix_web_max_input_time | default('300') }} + + {% if zabbix_version is version('5.0', '>=') %} + php_value max_input_vars {{ zabbix_web_max_input_vars | default('10000') }} + {% endif %} + + # Set correct timezone. + php_value date.timezone {{ zabbix_timezone }} + {% endif %} +{% endif %} +{% endif %} + + +{# Set up TLS vhosts #} +{% if zabbix_apache_tls and zabbix_apache_vhost_tls_port %} + +SSLPassPhraseDialog {{ zabbix_apache_SSLPassPhraseDialog }} +SSLSessionCache {{ zabbix_apache_SSLSessionCache }} +SSLSessionCacheTimeout {{ zabbix_apache_SSLSessionCacheTimeout }} +SSLRandomSeed startup file:/dev/urandom 256 +SSLRandomSeed connect builtin +SSLCryptoDevice {{ zabbix_apache_SSLCryptoDevice }} + + + ServerName {{ zabbix_apache_servername }} + {% for alias in zabbix_url_aliases %} + ServerAlias {{ alias }} + {% endfor %} + + ## Vhost docroot + DocumentRoot "/usr/share/zabbix" + + SSLEngine on + SSLCipherSuite {{ apache_ssl_cipher_suite }} + SSLProtocol {{ apache_ssl_protocol }} + SSLHonorCipherOrder On +{% if apache_vhosts_version == "2.4" %} + SSLCompression off +{% endif %} + SSLCertificateFile {{ zabbix_apache_tls_crt }} + SSLCertificateKeyFile {{ zabbix_apache_tls_key }} +{% if zabbix_apache_tls_chain %} + SSLCertificateChainFile {{ zabbix_apache_tls_chain }} +{% endif %} + +{% set directory_paths = ['/usr/share/zabbix/conf', '/usr/share/zabbix/app', '/usr/share/zabbix/include', '/usr/share/zabbix/include/classes'] %} + + + {% if apache_version|string() == '2.4' %} + Options FollowSymLinks + AllowOverride None + Require all granted + {% else %} + AllowOverride None + Order Allow,Deny + Allow from all + {% endif %} + + + DirectoryIndex index.php + + +{% if ansible_os_family == "RedHat" %} + + SetHandler "proxy:unix:{{ zabbix_php_fpm_listen }}|fcgi://localhost" + +{% endif %} + + + +{% for my_path in directory_paths %} + + {% if apache_version|string() == '2.4' %} + Require all granted + {% else %} + AllowOverride None + Order Deny,Allow + Deny from all + {% endif %} + + +{% endfor %} + ## Logging + ErrorLog "/var/log/{{ _apache_log }}/{{ zabbix_apache_servername }}_tls_error.log" + ServerSignature Off + CustomLog "/var/log/{{ _apache_log }}/{{ zabbix_apache_servername }}_tls_access.log" combined + + ## Rewrite rules + RewriteEngine On + RewriteRule ^$ /index.php [L] + +{% if _zabbix_web_apache_php_addition | default(false) %} +{% if zabbix_apache_include_custom_fragment | default(true) %} + ## Custom fragment + {% if zabbix_php_fpm %} + ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/usr/share/zabbix/$1 + ProxyTimeout 1800 + {% else %} + php_value max_execution_time {{ zabbix_web_max_execution_time | default('300') }} + php_value memory_limit {{ zabbix_web_memory_limit | default('128M') }} + php_value post_max_size {{ zabbix_web_post_max_size | default('16M') }} + php_value upload_max_filesize {{ zabbix_web_upload_max_filesize | default('2M') }} + php_value max_input_time {{ zabbix_web_max_input_time | default('300') }} + + {% if zabbix_version is version('5.0', '>=') %} + php_value max_input_vars {{ zabbix_web_max_input_vars | default('10000') }} + {% endif %} + + # Set correct timezone. + php_value date.timezone {{ zabbix_timezone }} + {% endif %} +{% endif %} +{% endif %} + +{% endif %} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/nginx_vhost.conf.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/nginx_vhost.conf.j2 new file mode 100644 index 00000000..8a6caa6f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/nginx_vhost.conf.j2 @@ -0,0 +1,109 @@ +# Nginx configuration for Zabbix Web + +server { +{% if not zabbix_nginx_tls %} + listen 80; +{% else %} +{% if zabbix_letsencrypt %} + server_tokens off; + server_name {{ zabbix_websrv_servername }} {% for alias in zabbix_url_aliases -%}{{ alias -}} {% endfor %}; + location ^~ /.well-known/acme-challenge { + root {{ zabbix_letsencrypt_webroot | default('/var/www/letsencrypt') }}; + # disables IP restrictions and HTTP auth + allow all; + default_type text/plain; + try_files $uri =404; + } + location / { return 301 https://$host$request_uri; } +} + +server { +{% endif %} + listen 443 ssl; +{% if zabbix_letsencrypt and zabbix_letsencrypt_cert.stat.exists %} + ssl_certificate /etc/letsencrypt/live/{{ zabbix_websrv_servername }}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/{{ zabbix_websrv_servername }}/privkey.pem; +{% else %} + ssl_certificate {{ zabbix_nginx_tls_crt }}; + ssl_certificate_key {{ zabbix_nginx_tls_key }}; +{% endif %} + ssl_session_timeout {{ zabbix_nginx_tls_session_timeout }}; + ssl_session_cache {{ zabbix_nginx_tls_session_cache }}; + ssl_session_tickets {{ zabbix_nginx_tls_session_tickets }}; + ssl_dhparam {{ zabbix_nginx_tls_dhparam }}; + + ssl_protocols {{ zabbix_nginx_tls_protocols }}; + ssl_ciphers {{ zabbix_nginx_tls_ciphers }}; + ssl_prefer_server_ciphers off; + +{% endif %} + server_tokens off; + server_name {{ zabbix_websrv_servername }} {% for alias in zabbix_url_aliases -%}{{ alias -}} {% endfor %}; + +{% if zabbix_web_allowlist_ips is defined and zabbix_web_allowlist_ips %} + # Allow list IPs via zabbix_web_allowlist_ips + satisfy any; +{% for ip in zabbix_web_allowlist_ips | ipaddr %} + allow {{ ip }}; +{% endfor %} + deny all; + +{% endif %} +{% if zabbix_web_htpasswd is defined and zabbix_web_htpasswd %} + # HTTP authentication via zabbix_web_htpasswd + auth_basic "Restricted"; + auth_basic_user_file {{ zabbix_web_htpasswd_file }}; + +{% endif %} + root /usr/share/zabbix; + + index index.php; + + location = /favicon.ico { + log_not_found off; + } + + location / { + try_files $uri $uri/ =404; + } + + location /assets { + access_log off; + expires 10d; + } + + location ~ /\.ht { + deny all; + } + + location ~ /(api\/|conf[^\.]|include|locale) { + deny all; + return 404; + } + + location ~ [^/]\.php(/|$) { + fastcgi_pass unix:{{ zabbix_php_fpm_listen }}; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + + fastcgi_param DOCUMENT_ROOT /usr/share/zabbix; + fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name; + fastcgi_param PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name; + + include fastcgi_params; + fastcgi_param QUERY_STRING $query_string; + fastcgi_param REQUEST_METHOD $request_method; + fastcgi_param CONTENT_TYPE $content_type; + fastcgi_param CONTENT_LENGTH $content_length; + + fastcgi_intercept_errors on; + fastcgi_ignore_client_abort off; + fastcgi_connect_timeout 60; + fastcgi_send_timeout 180; + fastcgi_read_timeout 180; + fastcgi_buffer_size 128k; + fastcgi_buffers 4 256k; + fastcgi_busy_buffers_size 256k; + fastcgi_temp_file_write_size 256k; + } +} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/php-fpm.conf.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/php-fpm.conf.j2 new file mode 100644 index 00000000..2748cbd4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/php-fpm.conf.j2 @@ -0,0 +1,35 @@ +[zabbix] +user = {{ zabbix_php_fpm_conf_user if zabbix_php_fpm_conf_user is defined else zabbix_web_conf_web_user }} +group = {{ zabbix_php_fpm_conf_group if zabbix_php_fpm_conf_group is defined else zabbix_web_conf_web_group }} + +listen = {{ zabbix_php_fpm_listen }} +{% if zabbix_php_fpm_conf_listen and ansible_os_family != 'Debian' %} +listen.acl_users = {{ zabbix_php_fpm_conf_user if zabbix_php_fpm_conf_user is defined else zabbix_web_conf_web_user }} +{% endif %} +{% if zabbix_php_fpm_conf_enable_user is defined %} +listen.owner = {{ zabbix_php_fpm_conf_user if zabbix_php_fpm_conf_user is defined else zabbix_web_conf_web_user }} +{% endif %} +{% if zabbix_php_fpm_conf_enable_group %} +listen.group = {{ zabbix_php_fpm_conf_group if zabbix_php_fpm_conf_group is defined else zabbix_web_conf_web_group }} +{% endif %} +{% if zabbix_php_fpm_conf_enable_mode %} +listen.mode = {{ zabbix_php_fpm_conf_mode }} +{% endif %} +listen.allowed_clients = 127.0.0.1 + +pm = dynamic +pm.max_children = 50 +pm.start_servers = 5 +pm.min_spare_servers = 5 +pm.max_spare_servers = 35 + +php_value[session.save_handler] = files +php_value[session.save_path] = {{ zabbix_php_fpm_session }} + +php_value[max_execution_time] = {{ zabbix_web_max_execution_time | default('300') }} +php_value[memory_limit] = {{ zabbix_web_memory_limit | default('128M') }} +php_value[post_max_size] = {{ zabbix_web_post_max_size | default('16M') }} +php_value[upload_max_filesize] = {{ zabbix_web_upload_max_filesize | default('2M') }} +php_value[max_input_time] = {{ zabbix_web_max_input_time | default('300') }} +php_value[max_input_vars] = {{ zabbix_web_max_input_vars | default('10000') }} +php_value[date.timezone] = {{ zabbix_timezone }} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/zabbix.conf.php.j2 b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/zabbix.conf.php.j2 new file mode 100644 index 00000000..07be35b3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/templates/zabbix.conf.php.j2 @@ -0,0 +1,42 @@ + diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-10.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-10.yml new file mode 100644 index 00000000..9d28ef9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-10.yml @@ -0,0 +1,3 @@ +--- + +_zabbix_php_version: 7.4 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-8.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-8.yml new file mode 100644 index 00000000..b4537abd --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-8.yml @@ -0,0 +1,3 @@ +--- + +_zabbix_php_version: 7.3 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-9.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-9.yml new file mode 100644 index 00000000..9d28ef9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian-9.yml @@ -0,0 +1,3 @@ +--- + +_zabbix_php_version: 7.4 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian.yml new file mode 100644 index 00000000..a8b5f570 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian.yml @@ -0,0 +1,20 @@ +--- +_apache_user: www-data +_apache_group: www-data +_apache_log: apache2 +_apache_service: apache2 + +_php_fpm_dir: /etc/php/{{ _zabbix_php_version }}/fpm/pool.d +_php_fpm_session: /tmp +_php_fpm_listen: /run/php/zabbix.sock +_zabbix_php_fpm_mode: '0666' +_zabbix_php_fpm_allowed_clients: 127.0.0.1 + +_nginx_user: www-data +_nginx_group: www-data +_nginx_config_path: /etc/nginx/conf.d +_nginx_log_path: /var/log/nginx +_nginx_service: nginx +_nginx_tls_crt: /etc/ssl/certs/ssl-cert-snakeoil.pem +_nginx_tls_key: /etc/ssl/private/ssl-cert-snakeoil.key +_nginx_tls_dhparam: /etc/ssl/private/dhparams.pem diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat-7.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat-7.yml new file mode 100644 index 00000000..84aa70c8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat-7.yml @@ -0,0 +1,8 @@ +--- +_php_fpm_dir: /etc/opt/rh/rh-php72/php-fpm.d/ +_php_fpm_session: /var/lib/php/session +_php_fpm_listen: "/run/php-fpm/zabbix.sock" + +_zabbix_php_version: 7.3 +_zabbix_php_fpm_session: /var/opt/rh/rh-php72/lib/php/session/ +_zabbix_php_fpm_listen: /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat-8.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat-8.yml new file mode 100644 index 00000000..c5024f88 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat-8.yml @@ -0,0 +1,8 @@ +--- +_php_fpm_dir: /etc/php-fpm.d +_php_fpm_session: /var/lib/php/session +_php_fpm_listen: "/run/php-fpm/zabbix.sock" + +_zabbix_php_version: 7.3 +_zabbix_php_fpm_session: /var/opt/rh/rh-php72/lib/php/session/ +_zabbix_php_fpm_listen: /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat.yml new file mode 100644 index 00000000..045002d3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/RedHat.yml @@ -0,0 +1,18 @@ +--- +_apache_user: apache +_apache_group: apache +_apache_log: httpd +_apache_service: httpd + +_php_fpm_dir: /etc/php-fpm.d +_php_fpm_session: /var/opt/rh/rh-php72/lib/php/session/ +_php_fpm_listen: /run/php-fpm/zabbix.sock + +_nginx_user: nginx +_nginx_group: nginx +_nginx_config_path: /etc/nginx/conf.d +_nginx_log_path: /var/log/nginx +_nginx_service: nginx +_nginx_tls_crt: /etc/pki/server.crt +_nginx_tls_key: /etc/pki/server.key +_nginx_tls_dhparam: /etc/pki/dhparam-server.pem diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Ubuntu-18.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Ubuntu-18.yml new file mode 100644 index 00000000..9d28ef9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Ubuntu-18.yml @@ -0,0 +1,3 @@ +--- + +_zabbix_php_version: 7.4 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Ubuntu-20.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Ubuntu-20.yml new file mode 100644 index 00000000..9d28ef9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/Ubuntu-20.yml @@ -0,0 +1,3 @@ +--- + +_zabbix_php_version: 7.4 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/zabbix.yml b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/zabbix.yml new file mode 100644 index 00000000..1da19b60 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/roles/zabbix_web/vars/zabbix.yml @@ -0,0 +1,188 @@ +--- +sign_keys: + "52": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "50": + buster: + sign_key: E709712C + stretch: + sign_key: E709712C + jessie: + sign_key: E709712C + focal: + sign_key: E709712C + bionic: + sign_key: E709712C + xenial: + sign_key: E709712C + trusty: + sign_key: E709712C + tricia: + sign_key: E709712C + "44": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "42": + focal: + sign_key: A14FE591 + eoan: + sign_key: A14FE591 + cosmic: + sign_key: A14FE591 + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "40": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "34": + bionic: + sign_key: A14FE591 + sonya: + sign_key: A14FE591 + serena: + sign_key: A14FE591 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: A14FE591 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "32": + bionic: + sign_key: A14FE591 + sonya: + sign_key: 79EA5ED4 + serena: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "30": + bionic: + sign_key: A14FE591 + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + stretch: + sign_key: A14FE591 + buster: + sign_key: A14FE591 + trusty: + sign_key: 79EA5ED4 + xenial: + sign_key: E709712C + "24": + wheezy: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + "22": + squeeze: + sign_key: 79EA5ED4 + jessie: + sign_key: 79EA5ED4 + precise: + sign_key: 79EA5ED4 + trusty: + sign_key: 79EA5ED4 + lucid: + sign_key: 79EA5ED4 + +suse: + "openSUSE Leap": + "42": + name: server:monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_Leap_{{ ansible_distribution_version }}/ + "openSUSE": + "12": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_{{ ansible_distribution_version }} + "SLES": + "11": + name: server_monitoring + url: http://download.opensuse.org/repositories/server:/monitoring/SLE_11_SP3/ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/scripts/inventory/zabbix.ini b/collections-debian-merged/ansible_collections/community/zabbix/scripts/inventory/zabbix.ini new file mode 100644 index 00000000..ead19b62 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/scripts/inventory/zabbix.ini @@ -0,0 +1,20 @@ +# Ansible Zabbix external inventory script settings +# + +[zabbix] + +# Server location +server = http://zabbix.example.com/zabbix + +# Login +username = admin +password = zabbix + +# Verify the server's SSL certificate +validate_certs = True + +# Read zabbix inventory per host +read_host_inventory = True + +# Set ansible_ssh_host based on first interface settings +use_host_interface = True \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/scripts/inventory/zabbix.py b/collections-debian-merged/ansible_collections/community/zabbix/scripts/inventory/zabbix.py new file mode 100644 index 00000000..e455a376 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/scripts/inventory/zabbix.py @@ -0,0 +1,196 @@ +#!/usr/bin/env python + +# (c) 2013, Greg Buehler +# (c) 2018, Filippo Ferrazini +# +# This file is part of Ansible, +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +###################################################################### + +""" +Zabbix Server external inventory script. +======================================== + +Returns hosts and hostgroups from Zabbix Server. +If you want to run with --limit against a host group with space in the +name, use asterisk. For example --limit="Linux*servers". + +Configuration is read from `zabbix.ini`. + +Tested with Zabbix Server 2.0.6, 3.2.3 and 3.4. +""" + +from __future__ import print_function + +import os +import sys +import argparse +from ansible.module_utils.six.moves import configparser + +try: + from zabbix_api import ZabbixAPI +except Exception: + print("Error: Zabbix API library must be installed: pip install zabbix-api.", + file=sys.stderr) + sys.exit(1) + +import json + + +class ZabbixInventory(object): + + def read_settings(self): + config = configparser.ConfigParser() + conf_path = './zabbix.ini' + if not os.path.exists(conf_path): + conf_path = os.path.dirname(os.path.realpath(__file__)) + '/zabbix.ini' + if os.path.exists(conf_path): + config.read(conf_path) + # server + if config.has_option('zabbix', 'server'): + self.zabbix_server = config.get('zabbix', 'server') + + # login + if config.has_option('zabbix', 'username'): + self.zabbix_username = config.get('zabbix', 'username') + if config.has_option('zabbix', 'password'): + self.zabbix_password = config.get('zabbix', 'password') + # ssl certs + if config.has_option('zabbix', 'validate_certs'): + if config.get('zabbix', 'validate_certs') in ['false', 'False', False]: + self.validate_certs = False + # host inventory + if config.has_option('zabbix', 'read_host_inventory'): + if config.get('zabbix', 'read_host_inventory') in ['true', 'True', True]: + self.read_host_inventory = True + # host interface + if config.has_option('zabbix', 'use_host_interface'): + if config.get('zabbix', 'use_host_interface') in ['false', 'False', False]: + self.use_host_interface = False + + def read_cli(self): + parser = argparse.ArgumentParser() + parser.add_argument('--host') + parser.add_argument('--list', action='store_true') + self.options = parser.parse_args() + + def hoststub(self): + return { + 'hosts': [] + } + + def get_host(self, api, name): + api_query = {'output': 'extend', 'selectGroups': 'extend', "filter": {"host": [name]}} + if self.use_host_interface: + api_query['selectInterfaces'] = ['useip', 'ip', 'dns'] + if self.read_host_inventory: + api_query['selectInventory'] = "extend" + + data = {'ansible_ssh_host': name} + if self.use_host_interface or self.read_host_inventory: + try: + hosts_data = api.host.get(api_query)[0] + if 'interfaces' in hosts_data: + # use first interface only + if hosts_data['interfaces'][0]['useip'] == 0: + data['ansible_ssh_host'] = hosts_data['interfaces'][0]['dns'] + else: + data['ansible_ssh_host'] = hosts_data['interfaces'][0]['ip'] + if ('inventory' in hosts_data) and (hosts_data['inventory']): + data.update(hosts_data['inventory']) + except IndexError: + # Host not found in zabbix + pass + return data + + def get_list(self, api): + api_query = {'output': 'extend', 'selectGroups': 'extend'} + if self.use_host_interface: + api_query['selectInterfaces'] = ['useip', 'ip', 'dns'] + if self.read_host_inventory: + api_query['selectInventory'] = "extend" + + hosts_data = api.host.get(api_query) + data = {'_meta': {'hostvars': {}}} + + data[self.defaultgroup] = self.hoststub() + for host in hosts_data: + hostname = host['name'] + hostvars = dict() + data[self.defaultgroup]['hosts'].append(hostname) + + for group in host['groups']: + groupname = group['name'] + + if groupname not in data: + data[groupname] = self.hoststub() + + data[groupname]['hosts'].append(hostname) + if 'interfaces' in host: + # use first interface only + if host['interfaces'][0]['useip'] == 0: + hostvars['ansible_ssh_host'] = host['interfaces'][0]['dns'] + else: + hostvars['ansible_ssh_host'] = host['interfaces'][0]['ip'] + if ('inventory' in host) and (host['inventory']): + hostvars.update(host['inventory']) + data['_meta']['hostvars'][hostname] = hostvars + + return data + + def __init__(self): + + self.defaultgroup = 'group_all' + self.zabbix_server = None + self.zabbix_username = None + self.zabbix_password = None + self.validate_certs = True + self.read_host_inventory = False + self.use_host_interface = True + + self.meta = {} + + self.read_settings() + self.read_cli() + + if self.zabbix_server and self.zabbix_username: + try: + api = ZabbixAPI(server=self.zabbix_server, validate_certs=self.validate_certs) + api.login(user=self.zabbix_username, password=self.zabbix_password) + # zabbix_api tries to exit if it cannot parse what the zabbix server returned + # so we have to use SystemExit here + except (Exception, SystemExit) as e: + print("Error: Could not login to Zabbix server. Check your zabbix.ini.", file=sys.stderr) + sys.exit(1) + + if self.options.host: + data = self.get_host(api, self.options.host) + print(json.dumps(data, indent=2)) + + elif self.options.list: + data = self.get_list(api) + print(json.dumps(data, indent=2)) + + else: + print("usage: --list ..OR.. --host ", file=sys.stderr) + sys.exit(1) + + else: + print("Error: Configuration of server and credentials are required. See zabbix.ini.", file=sys.stderr) + sys.exit(1) + + +ZabbixInventory() diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/defaults/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/defaults/main.yml new file mode 100644 index 00000000..85e8c620 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/defaults/main.yml @@ -0,0 +1,4 @@ +--- +zabbix_server_url: http://127.0.0.1:8080 +zabbix_login_user: Admin +zabbix_login_password: zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml new file mode 100644 index 00000000..b790ea1f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml @@ -0,0 +1,40 @@ +--- +- name: check login to zabbix + uri: + url: "{{ zabbix_server_url }}/api_jsonrpc.php" + method: POST + body: + jsonrpc: "2.0" + method: "user.login" + params: + user: "{{ zabbix_login_user }}" + password: "{{ zabbix_login_password }}" + id: "1" + body_format: json + status_code: 200 + retries: 60 + delay: 5 + until: check_login_result is defined and 'json' in check_login_result and 'result' in check_login_result.json + register: check_login_result + +- name: get zabbix version + uri: + url: "{{ zabbix_server_url }}/api_jsonrpc.php" + method: POST + body: + jsonrpc: "2.0" + method: "apiinfo.version" + params: [] + id: "1" + body_format: json + status_code: 200 + register: zabbix_version_result + +- name: set zabbix_version variable + set_fact: + zabbix_version: >- + {{ [0,1] + | map('extract', zabbix_version_result.json.result.split('.')) + | list + | join('.') + }} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml new file mode 100644 index 00000000..df91f321 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml @@ -0,0 +1,1169 @@ +--- +- name: test - do not run tests for Zabbix 3.0 + meta: end_play + when: zabbix_version is version('3.0', '=') + +- name: test - prepare example template for zabbix_action module + zabbix_template: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForActionModule + template_groups: + - Templates + state: present + register: zbxaction_prep_template + +- name: test - prepare example mediatype for zabbix_action module + zabbix_mediatype: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleMediaTypeForActionModule + smtp_email: zabbix@example.com + type: email + state: present + register: zbxaction_prep_mediatype + +- name: test - simple actions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleTriggerAction + event_source: trigger + esc_period: 60 + conditions: + - type: trigger_severity + operator: '>=' + value: Information + operations: + - type: send_message + subject: ExampleSubject + message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + + block: + - name: test - create new action + zabbix_action: + register: zbxaction_new + + - assert: + that: zbxaction_new.changed is sameas True + + - name: test - create new action (again) + zabbix_action: + register: zbxaction_new + + - assert: + that: zbxaction_new.changed is sameas False + + - when: zabbix_version is version('3.4', '>=') + block: + - name: test - update action with esc_period as string + zabbix_action: + esc_period: 2m + register: zbxaction_escperiod_str + + - assert: + that: zbxaction_escperiod_str.changed is sameas True + + - name: test - update action with esc_period as string (again) + zabbix_action: + esc_period: 2m + register: zbxaction_escperiod_str + + - assert: + that: zbxaction_escperiod_str.changed is sameas False + + - name: test - update action with esc_period as macro + zabbix_action: + esc_period: '{$MYMACRO}' + register: zbxaction_escperiod_macro + + - assert: + that: zbxaction_escperiod_macro.changed is sameas True + + - name: test - update action with esc_period as macro (again) + zabbix_action: + esc_period: '{$MYMACRO}' + register: zbxaction_escperiod_macro + + - assert: + that: zbxaction_escperiod_macro.changed is sameas False + + - name: test - update action with esc_period + zabbix_action: + esc_period: 120 + register: zbxaction_escperiod + + - assert: + that: zbxaction_escperiod.changed is sameas True + + - name: test - update action with esc_period (again) + zabbix_action: + esc_period: 120 + register: zbxaction_escperiod + + - assert: + that: zbxaction_escperiod.changed is sameas False + + - name: test - update action with pause_in_maintenance + zabbix_action: + esc_period: 120 + pause_in_maintenance: False + register: zbxaction_maintpause + + - assert: + that: zbxaction_maintpause.changed is sameas True + + - name: test - update action with pause_in_maintenance (again) + zabbix_action: + esc_period: 120 + pause_in_maintenance: False + register: zbxaction_maintpause + + - assert: + that: zbxaction_maintpause.changed is sameas False + + - name: test - reset action to default + zabbix_action: + register: zbxaction_reset + + - assert: + that: zbxaction_reset.changed is sameas True + + - when: zabbix_version is version('5.0', '<') + block: + - name: test - update action with default_subject and default_message + zabbix_action: + default_subject: Example default subject + default_message: Example default message + register: zbxaction_def_msgsubj + + - assert: + that: zbxaction_def_msgsubj.changed is sameas True + + - name: test - update action with default_subject and default_message (again) + zabbix_action: + default_subject: Example default subject + default_message: Example default message + register: zbxaction_def_msgsubj + + - assert: + that: zbxaction_def_msgsubj.changed is sameas False + + - when: + - zabbix_version is version('3.2', '>=') + - zabbix_version is version('5.0', '<') + block: + - name: test - update action with recovery_default_subject and recovery_default_message + zabbix_action: + default_subject: Example default subject + default_message: Example default message + recovery_default_subject: Example recovery subject + recovery_default_message: Example recovery message + register: zbxaction_rec_msgsubj + + - assert: + that: zbxaction_rec_msgsubj.changed is sameas True + + - name: test - update action with recovery_default_subject and recovery_default_message (again) + zabbix_action: + default_subject: Example default subject + default_message: Example default message + recovery_default_subject: Example recovery subject + recovery_default_message: Example recovery message + register: zbxaction_rec_msgsubj + + - assert: + that: zbxaction_rec_msgsubj.changed is sameas False + + - when: + - zabbix_version is version('3.4', '>=') + - zabbix_version is version('5.0', '<') + block: + - name: test - update action with acknowledge_default_subject and acknowledge_default_message + zabbix_action: + default_subject: Example default subject + default_message: Example default message + recovery_default_subject: Example recovery subject + recovery_default_message: Example recovery message + acknowledge_default_subject: Example acknowledge subject + acknowledge_default_message: Example acknowledge message + register: zbxaction_ack_msgsubj + + - assert: + that: zbxaction_ack_msgsubj.changed is sameas True + + - name: test - update action with acknowledge_default_subject and acknowledge_default_message (again) + zabbix_action: + default_subject: Example default subject + default_message: Example default message + recovery_default_subject: Example recovery subject + recovery_default_message: Example recovery message + acknowledge_default_subject: Example acknowledge subject + acknowledge_default_message: Example acknowledge message + register: zbxaction_ack_msgsubj + + - assert: + that: zbxaction_ack_msgsubj.changed is sameas False + + - name: test - reset action to default + zabbix_action: + register: zbxaction_reset + + - assert: + that: zbxaction_reset.changed is sameas True + + - name: test - disable action + zabbix_action: + status: disabled + register: zbxaction_disable + + - assert: + that: zbxaction_disable.changed is sameas True + + - name: test - disable action (again) + zabbix_action: + status: disabled + register: zbxaction_disable + + - assert: + that: zbxaction_disable.changed is sameas False + + - name: test - delete action + zabbix_action: + state: absent + register: zbxaction_delete + + - assert: + that: zbxaction_delete.changed is sameas True + + - name: test - delete action (again) + zabbix_action: + state: absent + register: zbxaction_delete + + - assert: + that: zbxaction_delete.changed is sameas False + +- name: test - trigger actions with conditions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleTriggerActionConditions + event_source: trigger + esc_period: 60 + operations: + - type: send_message + subject: ExampleSubject + message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + + block: + - name: test - create new action with multiple conditions + zabbix_action: + conditions: + - type: host_group + operator: '=' + value: Linux servers + - type: trigger_severity + operator: '>=' + value: Average + - type: application + operator: like + value: AnsibleTest + - type: event_tag_value + value: MyTag + operator: '=' + value2: MyTagValue + - type: time_period + operator: not in + value: 6-7,00:00-24:00 + register: zbxaction_conditions + + - assert: + that: zbxaction_conditions.changed is sameas True + + - name: test - create new action with multiple conditions (again) + zabbix_action: + conditions: + - type: host_group + operator: '=' + value: Linux servers + - type: trigger_severity + operator: '>=' + value: Average + - type: application + operator: like + value: AnsibleTest + - type: event_tag_value + value: MyTag + operator: '=' + value2: MyTagValue + - type: time_period + operator: not in + value: 6-7,00:00-24:00 + register: zbxaction_conditions + + - assert: + that: zbxaction_conditions.changed is sameas False + + - name: test - create new action with multiple conditions (reorder) + zabbix_action: + conditions: + - type: host_group + operator: '=' + value: Linux servers + - type: application + operator: like + value: AnsibleTest + - type: event_tag_value + value: MyTag + operator: '=' + value2: MyTagValue + - type: trigger_severity + operator: '>=' + value: Average + - type: time_period + operator: not in + value: 6-7,00:00-24:00 + register: zbxaction_conditions_reorder + + - assert: + that: zbxaction_conditions_reorder.changed is sameas True + + - name: test - update action with multiple conditions by removing one condition + zabbix_action: + conditions: + - type: host_group + operator: '=' + value: Linux servers + - type: application + operator: like + value: AnsibleTest + - type: event_tag_value + value: MyTag + operator: '=' + value2: MyTagValue + - type: trigger_severity + operator: '>=' + value: Average + register: zbxaction_conditions_delone + + - assert: + that: zbxaction_conditions_delone.changed is sameas True + + - name: test - update action with multiple conditions by changing operators + zabbix_action: + conditions: + - type: host_group + operator: '<>' + value: Linux servers + - type: application + operator: not like + value: AnsibleTest + - type: event_tag_value + value: MyTag + operator: '<>' + value2: MyTagValue + - type: trigger_severity + operator: '<=' + value: Average + register: zbxaction_conditions_operators + + - assert: + that: zbxaction_conditions_operators.changed is sameas True + + - name: test - update action with multiple conditions and evaltype + zabbix_action: + conditions: + - type: host_group + operator: '<>' + value: Linux servers + - type: application + operator: not like + value: AnsibleTest + - type: event_tag_value + value: MyTag + operator: '<>' + value2: MyTagValue + - type: trigger_severity + operator: '<=' + value: Average + eval_type: and + register: zbxaction_conditions_eval + + - assert: + that: zbxaction_conditions_eval.changed is sameas True + + - name: test - update action with multiple conditions and evaltype (again) + zabbix_action: + conditions: + - type: host_group + operator: '<>' + value: Linux servers + - type: application + operator: not like + value: AnsibleTest + - type: event_tag_value + value: MyTag + operator: '<>' + value2: MyTagValue + - type: trigger_severity + operator: '<=' + value: Average + eval_type: and + register: zbxaction_conditions_eval + + - assert: + that: zbxaction_conditions_eval.changed is sameas False + + - name: test - update action with reduced conditions and formula + zabbix_action: + conditions: + - type: host_group + operator: '=' + value: Linux servers + formulaid: A + - type: trigger_severity + operator: '>=' + value: Average + formulaid: B + - type: event_tag_value + value: MyTag + operator: '<>' + value2: MyTagValue + formulaid: C + formula: A and (B or C) + register: zbxaction_conditions_formula + + - assert: + that: zbxaction_conditions_formula.changed is sameas True + + - name: test - update formula used in action with reduced conditions + zabbix_action: + conditions: + - type: host_group + operator: '=' + value: Linux servers + formulaid: A + - type: trigger_severity + operator: '>=' + value: Average + formulaid: B + - type: event_tag_value + value: MyTag + operator: '<>' + value2: MyTagValue + formulaid: C + formula: (A or B) or C + register: zbxaction_conditions_formula + + - assert: + that: zbxaction_conditions_formula.changed is sameas True + + - name: test - update formula used in action with reduced conditions (again) + zabbix_action: + conditions: + - type: host_group + operator: '=' + value: Linux servers + formulaid: A + - type: trigger_severity + operator: '>=' + value: Average + formulaid: B + - type: event_tag_value + value: MyTag + operator: '<>' + value2: MyTagValue + formulaid: C + formula: (A or B) or C + register: zbxaction_conditions_formula + + - assert: + that: zbxaction_conditions_formula.changed is sameas False + + - name: test - delete action + zabbix_action: + state: absent + register: zbxaction_delete + + - assert: + that: zbxaction_delete.changed is sameas True + +- name: test - trigger actions with operations + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleTriggerActionOperations + event_source: trigger + esc_period: 60 + conditions: + - type: trigger_severity + operator: '>=' + value: Average + + block: + - name: test - create new action with send_message operations + zabbix_action: + operations: + - type: send_message + send_to_users: + - Admin + subject: test_subject + message: test_message + media_type: ExampleMediaTypeForActionModule + operation_condition: not_acknowledged + esc_step_from: 1 + esc_step_to: 2 + - type: send_message + send_to_users: + - Admin + subject: test_subject + message: test_message + media_type: SMS + operation_condition: not_acknowledged + esc_step_from: 2 + esc_step_to: 0 + esc_period: 300 + register: zbxaction_ops + + - assert: + that: zbxaction_ops.changed is sameas True + + - name: test - create new action with send_message operations (again) + zabbix_action: + operations: + - type: send_message + send_to_users: + - Admin + subject: test_subject + message: test_message + media_type: ExampleMediaTypeForActionModule + operation_condition: not_acknowledged + esc_step_from: 1 + esc_step_to: 2 + - type: send_message + send_to_users: + - Admin + subject: test_subject + message: test_message + media_type: SMS + operation_condition: not_acknowledged + esc_step_from: 2 + esc_step_to: 0 + esc_period: 300 + register: zbxaction_ops + + - assert: + that: zbxaction_ops.changed is sameas False + + - name: test - create new action with remote_command operations + zabbix_action: + operations: + - type: remote_command + command_type: custom_script + command: /usr/local/bin/do_something.sh + execute_on: agent + run_on_hosts: 0 + - type: remote_command + command_type: ssh + command: /usr/local/bin/do_something.sh + run_on_hosts: 0 + ssh_auth_type: password + username: root + password: zabbix + - type: remote_command + command_type: global_script + script_name: Ping + run_on_hosts: 0 + register: zbxaction_rmtcmd + + - assert: + that: zbxaction_rmtcmd.changed is sameas True + + - name: test - create new action with remote_command operations (again) + zabbix_action: + operations: + - type: remote_command + command_type: custom_script + command: /usr/local/bin/do_something.sh + execute_on: agent + run_on_hosts: 0 + - type: remote_command + command_type: ssh + command: /usr/local/bin/do_something.sh + run_on_hosts: 0 + ssh_auth_type: password + username: root + password: zabbix + - type: remote_command + command_type: global_script + script_name: Ping + run_on_hosts: 0 + register: zbxaction_rmtcmd + + - assert: + that: zbxaction_rmtcmd.changed is sameas False + + - name: test - update ssh remote_command auth in action with remote_command operations + zabbix_action: + operations: + - type: remote_command + command_type: custom_script + command: /usr/local/bin/do_something.sh + execute_on: agent + run_on_hosts: 0 + - type: remote_command + command_type: ssh + command: /usr/local/bin/do_something.sh + run_on_hosts: 0 + ssh_auth_type: public_key + username: root + ssh_privatekey_file: /etc/zabbix/.ssh/id_test + ssh_publickey_file: /etc/zabbix/.ssh/id_test.pub + - type: remote_command + command_type: global_script + script_name: Ping + run_on_hosts: 0 + register: zbxaction_rmtcmd + + - assert: + that: zbxaction_rmtcmd.changed is sameas True + + - name: test - delete action + zabbix_action: + state: absent + register: zbxaction_delete + + - assert: + that: zbxaction_delete.changed is sameas True + +- name: test - discovery actions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleDiscoveryActionOperations + event_source: discovery + esc_period: 60 + + block: + - name: test - create new discovery action + zabbix_action: + conditions: + - type: host_IP + operator: '=' + value: '192.168.0.1-127' + - type: discovery_object + operator: '=' + value: host + - type: discovery_status + operator: '=' + value: 'discovered' + - type: uptime_or_downtime_duration + operator: '>=' + value: 1800 + operations: + - type: add_host + - type: add_to_host_group + host_groups: + - Linux servers + - type: link_to_template + templates: + - ExampleTemplateForActionModule + - type: enable_host + - type: set_host_inventory_mode + inventory: automatic + register: zbxaction_discovery + + - assert: + that: zbxaction_discovery.changed is sameas True + + - name: test - create new discovery action (again) + zabbix_action: + conditions: + - type: host_IP + operator: '=' + value: '192.168.0.1-127' + - type: discovery_object + operator: '=' + value: host + - type: discovery_status + operator: '=' + value: 'discovered' + - type: uptime_or_downtime_duration + operator: '>=' + value: 1800 + operations: + - type: add_host + - type: add_to_host_group + host_groups: + - Linux servers + - type: link_to_template + templates: + - ExampleTemplateForActionModule + - type: enable_host + - type: set_host_inventory_mode + inventory: automatic + register: zbxaction_discovery + + - assert: + that: zbxaction_discovery.changed is sameas False + + - name: test - update discovery action conditions and operations + zabbix_action: + conditions: + - type: host_IP + operator: '=' + value: '192.168.1.1-127' + - type: discovery_object + operator: '=' + value: host + - type: discovery_status + operator: '=' + value: 'discovered' + - type: uptime_or_downtime_duration + operator: '>=' + value: 2200 + operations: + - type: add_host + - type: add_to_host_group + host_groups: + - Linux servers + - Discovered hosts + - type: link_to_template + templates: + - ExampleTemplateForActionModule + - type: enable_host + - type: send_message + send_to_users: + - Admin + subject: test_subject + message: test_message + media_type: ExampleMediaTypeForActionModule + operation_condition: not_acknowledged + esc_step_from: 1 + esc_step_to: 2 + register: zbxaction_discovery_update + + - assert: + that: zbxaction_discovery_update.changed is sameas True + + - name: test - update discovery action conditions and operations (again) + zabbix_action: + conditions: + - type: host_IP + operator: '=' + value: '192.168.1.1-127' + - type: discovery_object + operator: '=' + value: host + - type: discovery_status + operator: '=' + value: 'discovered' + - type: uptime_or_downtime_duration + operator: '>=' + value: 2200 + operations: + - type: add_host + - type: add_to_host_group + host_groups: + - Linux servers + - Discovered hosts + - type: link_to_template + templates: + - ExampleTemplateForActionModule + - type: enable_host + - type: send_message + send_to_users: + - Admin + subject: test_subject + message: test_message + media_type: ExampleMediaTypeForActionModule + operation_condition: not_acknowledged + esc_step_from: 1 + esc_step_to: 2 + register: zbxaction_discovery_update + + - assert: + that: zbxaction_discovery_update.changed is sameas False + + - name: test - delete action + zabbix_action: + state: absent + register: zbxaction_delete + + - assert: + that: zbxaction_delete.changed is sameas True + +- name: test - auto registration actions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleAutoRegActionOperations + event_source: auto_registration + esc_period: 60 + + block: + - name: test - create new auto registration action + zabbix_action: + conditions: + - type: host_name + operator: like + value: zabbix + - type: host_metadata + operator: not like + value: somemetadata + operations: + - type: add_host + register: zbxaction_autoreg + + - assert: + that: zbxaction_autoreg.changed is sameas True + + - name: test - create new auto registration action (again) + zabbix_action: + conditions: + - type: host_name + operator: like + value: zabbix + - type: host_metadata + operator: not like + value: somemetadata + operations: + - type: add_host + register: zbxaction_autoreg + + - assert: + that: zbxaction_autoreg.changed is sameas False + + - name: test - update auto registration action + zabbix_action: + conditions: + - type: host_name + operator: like + value: zabbix + - type: host_metadata + operator: not like + value: somemetadata + - type: host_metadata + operator: like + value: somemetadata2 + operations: + - type: add_host + register: zbxaction_autoreg_update + + - assert: + that: zbxaction_autoreg_update.changed is sameas True + + - name: test - update auto registration action (again) + zabbix_action: + conditions: + - type: host_name + operator: like + value: zabbix + - type: host_metadata + operator: not like + value: somemetadata + - type: host_metadata + operator: like + value: somemetadata2 + operations: + - type: add_host + register: zbxaction_autoreg_update + + - assert: + that: zbxaction_autoreg_update.changed is sameas False + + - name: test - delete action + zabbix_action: + state: absent + register: zbxaction_delete + + - assert: + that: zbxaction_delete.changed is sameas True + +- name: test - internal actions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleInternalActionOperations + event_source: internal + esc_period: 60 + operations: + - type: send_message + send_to_users: + - Admin + subject: test_subject + message: test_message + media_type: ExampleMediaTypeForActionModule + + block: + - name: test - create new internal action + zabbix_action: + conditions: + - type: application + operator: like + value: zabbix + - type: host_template + operator: '=' + value: ExampleTemplateForActionModule + - type: event_type + operator: '=' + value: item in not supported state + register: zbxaction_internal + + - assert: + that: zbxaction_internal.changed is sameas True + + - name: test - create new internal action (again) + zabbix_action: + conditions: + - type: application + operator: like + value: zabbix + - type: host_template + operator: '=' + value: ExampleTemplateForActionModule + - type: event_type + operator: '=' + value: item in not supported state + register: zbxaction_internal + + - assert: + that: zbxaction_internal.changed is sameas False + + - name: test - update internal action conditions + zabbix_action: + conditions: + - type: application + operator: like + value: zabbix + - type: host_template + operator: '=' + value: ExampleTemplateForActionModule + - type: event_type + operator: '=' + value: item in not supported state + - type: event_type + operator: '=' + value: trigger in unknown state + register: zbxaction_internal_update + + - assert: + that: zbxaction_internal_update.changed is sameas True + + - name: test - update internal action conditions (again) + zabbix_action: + conditions: + - type: application + operator: like + value: zabbix + - type: host_template + operator: '=' + value: ExampleTemplateForActionModule + - type: event_type + operator: '=' + value: item in not supported state + - type: event_type + operator: '=' + value: trigger in unknown state + register: zbxaction_internal_update + + - assert: + that: zbxaction_internal_update.changed is sameas False + + - name: test - delete action + zabbix_action: + state: absent + register: zbxaction_delete + + - assert: + that: zbxaction_delete.changed is sameas True + +- name: test - actions with recovery and acknowledge operations + when: + - zabbix_version is version('3.4', '>=') + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleTriggerActionRecAckOps + event_source: trigger + esc_period: 60 + conditions: + - type: trigger_severity + operator: '>=' + value: Information + operations: + - type: send_message + subject: ExampleSubject + message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + + block: + - name: test - create new action with recovery and acknowledge operations + zabbix_action: + recovery_operations: + - type: send_message + subject: ExampleSubject + message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + - type: remote_command + command_type: custom_script + command: /usr/local/bin/do_something.sh + execute_on: agent + run_on_hosts: 0 + - type: remote_command + command_type: ssh + command: /usr/local/bin/do_something.sh + run_on_hosts: 0 + ssh_auth_type: password + username: root + password: zabbix + - type: notify_all_involved + subject: RecoverySubject + message: RecoveryMessage + acknowledge_operations: + - type: send_message + subject: ExampleSubject + message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + - type: remote_command + command_type: ssh + command: /usr/local/bin/do_something.sh + run_on_hosts: 0 + ssh_auth_type: public_key + username: root + ssh_privatekey_file: /etc/zabbix/.ssh/id_test + ssh_publickey_file: /etc/zabbix/.ssh/id_test.pub + - type: remote_command + command_type: global_script + script_name: Ping + run_on_hosts: 0 + - type: notify_all_involved + subject: RecoverySubject + message: RecoveryMessage + media_type: ExampleMediaTypeForActionModule + register: zbxaction_recack_new + + - assert: + that: zbxaction_recack_new.changed is sameas True + + - name: test - create new action with recovery and acknowledge operations (again) + zabbix_action: + recovery_operations: + - type: send_message + subject: ExampleSubject + message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + - type: remote_command + command_type: custom_script + command: /usr/local/bin/do_something.sh + execute_on: agent + run_on_hosts: 0 + - type: remote_command + command_type: ssh + command: /usr/local/bin/do_something.sh + run_on_hosts: 0 + ssh_auth_type: password + username: root + password: zabbix + - type: notify_all_involved + subject: RecoverySubject + message: RecoveryMessage + acknowledge_operations: + - type: send_message + subject: ExampleSubject + message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + - type: remote_command + command_type: ssh + command: /usr/local/bin/do_something.sh + run_on_hosts: 0 + ssh_auth_type: public_key + username: root + ssh_privatekey_file: /etc/zabbix/.ssh/id_test + ssh_publickey_file: /etc/zabbix/.ssh/id_test.pub + - type: remote_command + command_type: global_script + script_name: Ping + run_on_hosts: 0 + - type: notify_all_involved + subject: RecoverySubject + message: RecoveryMessage + media_type: ExampleMediaTypeForActionModule + register: zbxaction_recack_new + + - assert: + that: zbxaction_recack_new.changed is sameas False + + - name: test - delete action + zabbix_action: + state: absent + register: zbxaction_delete + + - assert: + that: zbxaction_delete.changed is sameas True + +- name: test - cleanup example template for zabbix_action module + zabbix_template: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForActionModule + state: absent + register: zbxaction_prep_template + +- name: test - cleanup example mediatype for zabbix_action module + zabbix_mediatype: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleMediaTypeForActionModule + type: email + state: absent + register: zbxaction_prep_mediatype diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml new file mode 100644 index 00000000..5f31d48d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml @@ -0,0 +1,295 @@ +--- +- name: test - do not run tests for Zabbix 3.0 + meta: end_play + when: zabbix_version is version('3.0', '=') + +- name: test - Zabbix discovery rule + module_defaults: + zabbix_discovery_rule: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ACME + state: present + iprange: 192.168.1.1-255 + dchecks: + - type: ICMP + delay: "{{ 3600 if zabbix_version is version('3.4', '<=') else omit }}" + + block: + - name: test - create new Zabbix discovery rule (checkmode) + zabbix_discovery_rule: + check_mode: True + register: drule_new_checkmode + + - name: assert that drule will be created (checkmode) + assert: + that: drule_new_checkmode is changed + + - name: test - create new Zabbix discovery rule + zabbix_discovery_rule: + register: drule_new + + - name: assert that drule was created + assert: + that: drule_new is changed + + - name: test - create same Zabbix discovery rule + zabbix_discovery_rule: + register: drule_exists + + - name: assert that nothing has been changed + assert: + that: not drule_exists is changed + + - name: test - update Zabbix discovery rule iprange (checkmode) + zabbix_discovery_rule: + iprange: + - 192.168.1.1-255 + - 10.0.0.1-255 + check_mode: True + register: drule_iprange_update_checkmode + + - name: assert that iprange will be changed + assert: + that: drule_iprange_update_checkmode is changed + + - name: test - update Zabbix discovery rule iprange + zabbix_discovery_rule: + iprange: + - 192.168.1.1-255 + - 10.0.0.1-255 + register: drule_iprange_update + + - name: assert that iprange has been changed + assert: + that: drule_iprange_update is changed + + - name: test - reset Zabbix discovery rule to default + zabbix_discovery_rule: + register: drule_reset + + - name: assert that iprange has been changed + assert: + that: drule_reset is changed + + - name: test - update Zabbix discovery rule status + zabbix_discovery_rule: + status: disabled + register: drule_status_update + + - name: assert that iprange has been changed + assert: + that: drule_status_update is changed + + - name: test - reset Zabbix discovery rule to default + zabbix_discovery_rule: + register: drule_reset + + - name: assert that iprange has been changed + assert: + that: drule_reset is changed + + - name: test - update Zabbix discovery rule dchecks + zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: Zabbix + key: "system.hostname" + ports: "10050" + uniq: yes + host_source: discovery + register: drule_dchecks_update + + - name: assert that dcheck has been changed + assert: + that: drule_dchecks_update is changed + + - name: test - update Zabbix discovery rule dchecks ssh + zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + register: drule_dchecks_ssh_update + + - name: assert that dcheck has been changed + assert: + that: drule_dchecks_ssh_update is changed + + - name: test - update Zabbix discovery rule dchecks ldap + zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + - type: LDAP + ports: "389" + register: drule_dchecks_ldap_update + + - name: assert that dcheck has been changed + assert: + that: drule_dchecks_ldap_update is changed + + - name: test - update Zabbix discovery rule dchecks smtp + zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + - type: LDAP + ports: "389" + - type: SMTP + ports: 25,465,587 + register: drule_dchecks_smtp_update + + - name: assert that dcheck has been changed + assert: + that: drule_dchecks_smtp_update is changed + + - name: test - update Zabbix discovery rule dchecks http + zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + - type: LDAP + ports: "389" + - type: SMTP + ports: 25,465,587 + - type: HTTP + ports: 80,8080 + register: drule_dchecks_http_update + + - name: assert that dcheck has been changed + assert: + that: drule_dchecks_http_update is changed + + - name: test - remove Zabbix discovery rule dchecks + zabbix_discovery_rule: + dchecks: + - type: ICMP + register: drule_dchecks_remove_update + + - name: assert that dcheck has been changed + assert: + that: drule_dchecks_remove_update is changed + + - name: test - update Zabbix discovery rule snmp dcheck + zabbix_discovery_rule: + dchecks: + - type: SNMPv2 + snmp_community: CUSTOMER@snmp-readonly + ports: "161" + key: iso.3.6.1.2.1.1.1.0 + uniq: no + host_source: discovery + name_source: discovery + register: drule_snmp_update + + - name: assert that snmp dcheck has been changed + assert: + that: drule_snmp_update is changed + + - name: test - update Zabbix discovery rule snmp3 dcheck + zabbix_discovery_rule: + dchecks: + - type: SNMPv3 + snmp_community: CUSTOMER@snmp3-readonly + ports: "161" + key: iso.3.6.1.2.1.1.1.0 + snmpv3_contextname: "ContextName" + snmpv3_securityname: "SecurityName" + snmpv3_securitylevel: authPriv + snmpv3_authprotocol: SHA + snmpv3_authpassphrase: "SeCrEt" + snmpv3_privprotocol: AES + snmpv3_privpassphrase: "TopSecret" + uniq: no + host_source: DNS + name_source: None + register: drule_snmp3_update + + - name: assert that snmp3 dcheck has been changed + assert: + that: drule_snmp3_update is changed + + - name: test - reset Zabbix discovery rule to default + zabbix_discovery_rule: + register: drule_reset + + - name: assert that iprange has been changed + assert: + that: drule_reset is changed + + - name: test - create new active Zabbix proxy server + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: ACME_proxy + status: active + state: present + register: zbxproxy_active + + - name: assert that proxy was created + assert: + that: zbxproxy_active is changed + + - name: test - update Zabbix discovery rule proxy + zabbix_discovery_rule: + proxy: ACME_proxy + register: drule_proxy_update + + - name: assert that proxy has been changed + assert: + that: drule_proxy_update is changed + + - name: test - update Zabbix discovery rule proxy (again) + zabbix_discovery_rule: + proxy: ACME_proxy + register: drule_proxy_update_again + + - name: assert that nothing has been changed + assert: + that: not drule_proxy_update_again is changed + +- name: test - delete Zabbix discovery rule + zabbix_discovery_rule: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ACME + state: absent + register: drule_delete + +- name: assert that proxy has been deleted + assert: + that: drule_delete is changed + +- name: test - delete Zabbix discovery rule (again) + zabbix_discovery_rule: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ACME + state: absent + register: drule_delete_again + +- name: assert that nothing has been changed + assert: + that: not drule_delete_again is changed + +# Cleanup +- name: delete active Zabbix proxy server + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: ACME_proxy + state: absent + register: zbxproxy_delete + +- name: assert that proxy has been deleted + assert: + that: zbxproxy_delete is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml new file mode 100644 index 00000000..f4021709 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml @@ -0,0 +1,112 @@ +--- +- name: test - create new Zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: present + register: zbxgrp_new + +- name: assert that group was created + assert: + that: zbxgrp_new is changed + +- name: test - create simple zabbix host to assign to group + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbxgrp_example_host01 + host_groups: + - zbxgrp_example_group01 + interfaces: + - type: agent + main: 1 + dns: zbxgrp_example_host01 + state: present + register: zbxgrp_host_assignement + +- name: assert that host was assigned successfully + assert: + that: zbxgrp_host_assignement is changed + +- name: test - create same Zabbix group once again + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: present + register: zbxgrp_existing + +- name: assert that nothing has been changed + assert: + that: not zbxgrp_existing is changed + +- name: test - attempt to create new Zabbix group matching name of default Zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - Linux servers + state: present + register: zbxgrp_default_existing + +- name: assert that nothing has been changed + assert: + that: not zbxgrp_default_existing is changed + +- name: test - attempt to delete host group while its only group host has assigned + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: absent + register: zbxgrp_existing_delete_failed + ignore_errors: True + +- name: assert that group deletion failed + assert: + that: zbxgrp_existing_delete_failed is failed + +- name: delete helper zabbix host + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbxgrp_example_host01 + state: absent + +- name: test - attempt to delete previously created zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: absent + register: zbxgrp_existing_delete + +- name: assert that group was deleted + assert: + that: zbxgrp_existing_delete is changed + +- name: test - attempt to delete non-existing zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: absent + register: zbxgrp_missing_delete + +- name: assert that nothing has been changed + assert: + that: not zbxgrp_missing_delete is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml new file mode 100644 index 00000000..599b626e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml @@ -0,0 +1,62 @@ +--- +- name: test - create new Zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + - zbxgrp_example_group02 + state: present + register: zbxgrp_new + +- name: assert that group was created + assert: + that: zbxgrp_new is changed + +- name: test - get one hostgroup info + zabbix_group_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + hostgroup_name: + - zbxgrp_example_group01 + register: get_hostgorup_info_result + +- name: assert that one group was get + assert: + that: + - get_hostgorup_info_result.host_groups | length == 1 + - get_hostgorup_info_result.host_groups.0.name == 'zbxgrp_example_group01' + +- name: test - get two hostgroup info + zabbix_group_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + hostgroup_name: + - zbxgrp_example_group01 + - zbxgrp_example_group02 + register: get_hostgorup_info_result + +- name: assert that two group was get + assert: + that: + - get_hostgorup_info_result.host_groups | length == 2 + - get_hostgorup_info_result.host_groups.0.name == 'zbxgrp_example_group01' + - get_hostgorup_info_result.host_groups.1.name == 'zbxgrp_example_group02' + +- name: test - delete Zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + - zbxgrp_example_group02 + state: absent + register: delete_zbxgrp + +- name: assert that group was deleted + assert: + that: delete_zbxgrp is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml new file mode 100644 index 00000000..f7aeefab --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml @@ -0,0 +1,12 @@ +--- +# setup stuff not testing zabbix_host +- include: zabbix_host_setup.yml + +# zabbix_host module tests +- include: zabbix_host_tests.yml + +# documentation example tests +- include: zabbix_host_doc.yml + +# tear down stuff set up earlier +- include: zabbix_host_teardown.yml diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml new file mode 100644 index 00000000..1710f750 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml @@ -0,0 +1,83 @@ +--- +# These two tests are close to documentation example + +- name: Create a new host or update an existing host's info + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost1 + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - Linux servers + - Zabbix servers + link_templates: + - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" + - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + ipmi_authtype: 2 + ipmi_privilege: 4 + ipmi_username: username + ipmi_password: password + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + macros: + - macro: '{$EXAMPLEMACRO}' + value: ExampleMacroValue + - macro: EXAMPLEMACRO2 + value: ExampleMacroValue2 + description: Example desc that work only with Zabbix 4.4 and higher + tags: + - tag: ExampleHostsTag + - tag: ExampleHostsTag2 + value: ExampleTagValue + register: zabbix_host1 + +- name: Update an existing host's tls settings + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost2 + visible_name: ExampleName2 + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.2 + dns: "" + port: "10050" + host_groups: + - Linux servers + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + register: zabbix_host2 + +- name: expect both to succeed + assert: + that: + - "zabbix_host1 is changed" + - "zabbix_host2 is changed" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml new file mode 100644 index 00000000..498a725f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml @@ -0,0 +1,20 @@ +--- +# set up a zabbix proxy to test zabbix_host with + +- name: Create a new proxy + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: ExampleProxy + description: ExampleProxy + status: active + state: present + interface: + type: 0 + main: 1 + useip: 1 + ip: 10.5.6.7 + dns: "" + port: 10050 + register: zabbix_proxy diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml new file mode 100644 index 00000000..1d76c516 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml @@ -0,0 +1,10 @@ +--- +# remove zabbix_proxy (hopefully) created earlier + +- name: remove proxy + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: ExampleProxy + state: absent diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml new file mode 100644 index 00000000..bf701471 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml @@ -0,0 +1,1488 @@ +--- +- name: "test: create host with many options set" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - Linux servers + - Zabbix servers + link_templates: + - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" + - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 1 + main: 0 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "{$MACRO}" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + proxy: ExampleProxy + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + macros: + - macro: MACRO1 + value: test1 + - macro: '{$MACRO2}' + value: test2 + tags: + - tag: Tag1 + - tag: Tag2 + value: test2 + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: try to create the same host with the same settings" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - Linux servers + - Zabbix servers + link_templates: + - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" + - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 1 + main: 0 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "{$MACRO}" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + proxy: ExampleProxy + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + macros: + - macro: MACRO1 + value: test1 + - macro: '{$MACRO2}' + value: test2 + tags: + - tag: Tag1 + - tag: Tag2 + value: test2 + register: zabbix_host1 + +- name: updating with same values should be idempotent + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: try to create the same host with the same settings and force false" + zabbix_host: + force: false + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - Linux servers + - Zabbix servers + link_templates: + - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" + - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 1 + main: 0 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "{$MACRO}" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + proxy: ExampleProxy + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + register: zabbix_host1 + +- name: updating with same values and force false should be idempotent + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: try to create the same host changing one parameter in the inventory with force false" + zabbix_host: + force: false + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - Linux servers + - Zabbix servers + link_templates: + - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" + - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw-modified + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 1 + main: 0 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "{$MACRO}" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + proxy: ExampleProxy + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + register: zabbix_host1 + +- name: changing the value of an already defined inventory should work and mark task as changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change visible_name" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: "ExampleName Changed" + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change visible_name (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: "ExampleName Changed" + register: zabbix_host1 + +- name: updating with same values should be idempotent + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change description" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + description: "My ExampleHost Description Changed" + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change description (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + description: "My ExampleHost Description Changed" + register: zabbix_host1 + +- name: updating with same values should be idempotent + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host groups (adding one group)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - Linux servers + - Zabbix servers + - Virtual machines + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host groups (remove one group)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - Linux servers + - Zabbix servers + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host groups (add one group using force=no)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - Virtual machines + force: no + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + + +- name: "test: change host groups (check whether we are at three groups)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - Linux servers + - Zabbix servers + - Virtual machines + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host groups (attempt to remove all host groups)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - + register: zabbix_host1 + ignore_errors: yes + +- name: expect to fail + assert: + that: + - "zabbix_host1 is failed" + +- name: "test: change host linked templates (same as before)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + link_templates: + - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" + - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host linked templates (add one template)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + link_templates: + - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" + - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + - "{{ 'HTTP Service' if zabbix_version | float >= 5.2 else 'Template App HTTP Service' }}" + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host linked templates (add one template, using force=no)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + link_templates: + - "{{ 'LDAP Service' if zabbix_version | float >= 5.2 else 'Template App LDAP Service' }}" + force: no + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host linked templates (make sure we are at 4 templates)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + link_templates: + - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" + - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + - "{{ 'HTTP Service' if zabbix_version | float >= 5.2 else 'Template App HTTP Service' }}" + - "{{ 'LDAP Service' if zabbix_version | float >= 5.2 else 'Template App LDAP Service' }}" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host linked templates (remove all templates)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + link_templates: + - + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host linked templates (check we have no templates left)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + link_templates: + - + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host status" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + status: disabled + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host status (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + status: disabled + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host inventory mode" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_mode: automatic + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host inventory mode" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_mode: automatic + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host inventory data (one field)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_zabbix: + tag: test-tag-two + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host inventory data (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_zabbix: + tag: test-tag-two + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: remove host proxy" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + proxy: '' + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add host proxy" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + proxy: ExampleProxy + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add host proxy (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + proxy: ExampleProxy + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change tls settings" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tls_psk_identity: test2 + tls_connect: 4 + tls_accept: 7 + tls_psk: 123456789abcdef123456789abcdef13 + tls_issuer: AcmeCorp + tls_subject: AcmeCorpServer + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change tls settings (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tls_psk_identity: test2 + tls_connect: 4 + tls_accept: 7 + tls_psk: 123456789abcdef123456789abcdef13 + tls_issuer: AcmeCorp + tls_subject: AcmeCorpServer + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change interface settings (remove one)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change interface settings (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change interface settings (add one interface using force=no)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + force: no + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change interface settings (verify that we are at two interfaces)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: configure interface to useip=1 but provide no ip" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + port: "10050" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "12345" + register: zabbix_host1 + ignore_errors: yes + +- name: expect to fail + assert: + that: + - "zabbix_host1 is failed" + +- name: "test: configure interface to useip=0 but provide no dns" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 0 + ip: 10.1.1.1 + port: "10050" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "12345" + register: zabbix_host1 + ignore_errors: yes + +- name: expect to fail + assert: + that: + - "zabbix_host1 is failed" + +- when: zabbix_version is version("5.0", ">=") + block: + - name: "test: configure SNMPv2 interface without details (fail)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + register: zabbix_host1 + ignore_errors: True + + - name: expect to fail + assert: + that: + - "zabbix_host1 is failed" + + - name: "test: configure details for SNMPv2 interface" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 2 + community: Community String + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + + - name: "test: configure details for SNMPv2 interface (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 2 + community: Community String + register: zabbix_host1 + + - name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + + - name: "test: update details for SNMPv2 interface with bulk sub option" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 2 + community: Community String + bulk: 0 + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + + - name: "test: configure details for SNMPv3 interface" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 3 + contextname: snmp_context + securityname: SNMP3 sec name + securitylevel: 0 + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + + - name: "test: configure details for SNMPv3 interface (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 3 + contextname: snmp_context + securityname: SNMP3 sec name + securitylevel: 0 + register: zabbix_host1 + + - name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + + - name: "test: update details for SNMPv3 interface" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 3 + contextname: snmp_context + securityname: SNMP3 sec name + securitylevel: 2 + authprotocol: 0 + authpassphrase: secret_auth_passphrase + privprotocol: 0 + privpassphrase: secret_priv_passphrase + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add IPMI settings" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + ipmi_authtype: 2 + ipmi_privilege: 4 + ipmi_username: username + ipmi_password: password + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add IPMI settings again" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + ipmi_authtype: 2 + ipmi_privilege: 4 + ipmi_username: username + ipmi_password: password + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: verify that an empty change is idempotent" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: IPMI set default values" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + ipmi_authtype: -1 + ipmi_privilege: 2 + ipmi_username: "" + ipmi_password: "" + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: IPMI set default values (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + ipmi_authtype: -1 + ipmi_privilege: 2 + ipmi_username: "" + ipmi_password: "" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: change host inventory mode to disabled" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_mode: disabled + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host inventory mode to manual" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_mode: manual + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add new set of user macros to the host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACRO1}' + value: test123 + - macro: NEWMACRO2 + value: abc + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add new set of user macros to the host (again - lowercase)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$newmacro1}' + value: test123 + - macro: newmacro2 + value: abc + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: update one of the user macros present on the host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACRO1}' + value: test1234 + - macro: NEWMACRO2 + value: abc + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +# The description of tag is available since Zabbix version 4.4 +- when: zabbix_version is version("4.4", ">=") + block: + - name: "test: update one of the user macros with description" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACRO1}' + value: test1234 + description: Example Description + - macro: NEWMACRO2 + value: abc + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + + - name: "test: update one of the user macros with description (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACRO1}' + value: test1234 + description: Example Description + - macro: NEWMACRO2 + value: abc + register: zabbix_host1 + + - name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + + - name: "test: update one of the user macros by removing description" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACRO1}' + value: test1234 + - macro: NEWMACRO2 + value: abc + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add user macro while keeping previous ones with force=no" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + force: no + macros: + - macro: '{$NEWMACRO3}' + value: testing + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add the same user macros (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACRO1}' + value: test1234 + - macro: NEWMACRO2 + value: abc + - macro: '{$NEWMACRO3}' + value: testing + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +# type for macros added in 5.0 +- when: zabbix_version is version("5.0", ">=") + block: + - name: "test: add new user macro with type secret" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACROSECRET}' + value: secretvalue + type: secret + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + + - name: "test: add new user macro with type secret (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACROSECRET}' + value: secretvalue + type: secret + register: zabbix_host1 + + - name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: wipe out all of the user macros" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: [] + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: wipe out all of the user macros (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: [] + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +# The tag function is available since Zabbix version 4.4 +- when: zabbix_version is version("4.4", ">=") + block: + - name: "test: add new set of tags to the host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tags: + - tag: NEWTAG1 + - tag: NewTag2 + value: abc + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + + - name: "test: add new set of tags to the host (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tags: + - tag: NEWTAG1 + - tag: NewTag2 + value: abc + register: zabbix_host1 + + - name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + + - name: "test: update one of the tags present on the host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tags: + - tag: NEWTAG1 + - tag: NewTag2 + value: abcd + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + + - name: "test: add tag while keeping previous ones with force=no" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + force: no + tags: + - tag: newtag3 + value: testing + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + + - name: "test: add the same tags (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tags: + - tag: NEWTAG1 + - tag: NewTag2 + value: abcd + - tag: newtag3 + value: testing + register: zabbix_host1 + + - name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + + - name: "test: wipe out all of the tags" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tags: [] + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: wipe out all of the tags (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tags: [] + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: attempt to delete host created earlier" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + state: absent + register: zabbix_host1 + +- name: deleting a host is a change, right? + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: attempt deleting a non-existant host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + state: absent + register: zabbix_host1 + +- name: deleting a non-existant host is not a change, right? + assert: + that: + - "not zabbix_host1 is changed" + +- when: zabbix_version is version('5.2', '>=') + block: + - name: "test: create host without host interfaces" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - Linux servers + status: disabled + state: present + register: zbx_host_create_interfaceless + + - name: verify host was created without interfaces + assert: + that: zbx_host_create_interfaceless is changed + + - name: "cleanup" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + state: absent diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml new file mode 100644 index 00000000..9f072a9f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml @@ -0,0 +1,159 @@ +--- +- name: "test - Prepare host for zabbix_host_info module" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHostForHostInfoModule + visible_name: ExampleHostForHostInfoModuleName + description: Test Host + host_groups: + - Linux servers + - Hypervisors + link_templates: + - "{{ 'Zabbix Server' if zabbix_version | float >= 5.2 else 'Template App Zabbix Server' }}" + status: enabled + inventory_mode: manual + inventory_zabbix: + tag: tag1 + os: Linux + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 192.168.0.1 + dns: "" + port: 10050 + state: present + register: prepare_host_result + +- assert: + that: + - prepare_host_result.changed is sameas true + +- name: "test - Set default parameters to zabbix_host_info" + module_defaults: + zabbix_host_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHostForHostInfoModule + + block: + - name: "test - Gather all facts of zabbix host" + zabbix_host_info: + register: gather_all_facts_result + + - when: zabbix_version is version('4.0', '<=') + assert: + that: + - gather_all_facts_result.hosts | length == 1 + - gather_all_facts_result.hosts.0.host == "ExampleHostForHostInfoModule" + - gather_all_facts_result.hosts.0.name == "ExampleHostForHostInfoModuleName" + - gather_all_facts_result.hosts.0.description == "Test Host" + - gather_all_facts_result.hosts.0.groups.0.name == "Linux servers" + - gather_all_facts_result.hosts.0.groups.1.name == "Hypervisors" + - gather_all_facts_result.hosts.0.parentTemplates.0.name == "Template App Zabbix Server" + - gather_all_facts_result.hosts.0.status == "0" + - gather_all_facts_result.hosts.0.inventory.inventory_mode == "0" + - gather_all_facts_result.hosts.0.inventory.tag == "tag1" + - gather_all_facts_result.hosts.0.inventory.os == "Linux" + - gather_all_facts_result.hosts.0.hostinterfaces.0.dns == "" + - gather_all_facts_result.hosts.0.hostinterfaces.0.ip == "192.168.0.1" + - gather_all_facts_result.hosts.0.hostinterfaces.0.main == "1" + - gather_all_facts_result.hosts.0.hostinterfaces.0.port == "10050" + - gather_all_facts_result.hosts.0.hostinterfaces.0.type == "1" + - gather_all_facts_result.hosts.0.hostinterfaces.0.useip == "1" + + - when: zabbix_version is version('4.4', '>=') and zabbix_version is version('5.0', '<=') + assert: + that: + - gather_all_facts_result.hosts | length == 1 + - gather_all_facts_result.hosts.0.host == "ExampleHostForHostInfoModule" + - gather_all_facts_result.hosts.0.name == "ExampleHostForHostInfoModuleName" + - gather_all_facts_result.hosts.0.description == "Test Host" + - gather_all_facts_result.hosts.0.groups.0.name == "Linux servers" + - gather_all_facts_result.hosts.0.groups.1.name == "Hypervisors" + - gather_all_facts_result.hosts.0.parentTemplates.0.name == "Template App Zabbix Server" + - gather_all_facts_result.hosts.0.status == "0" + - gather_all_facts_result.hosts.0.inventory_mode == "0" + - gather_all_facts_result.hosts.0.inventory.tag == "tag1" + - gather_all_facts_result.hosts.0.inventory.os == "Linux" + - gather_all_facts_result.hosts.0.hostinterfaces.0.dns == "" + - gather_all_facts_result.hosts.0.hostinterfaces.0.ip == "192.168.0.1" + - gather_all_facts_result.hosts.0.hostinterfaces.0.main == "1" + - gather_all_facts_result.hosts.0.hostinterfaces.0.port == "10050" + - gather_all_facts_result.hosts.0.hostinterfaces.0.type == "1" + - gather_all_facts_result.hosts.0.hostinterfaces.0.useip == "1" + + - when: zabbix_version is version('5.2', '>=') + assert: + that: + - gather_all_facts_result.hosts | length == 1 + - gather_all_facts_result.hosts.0.host == "ExampleHostForHostInfoModule" + - gather_all_facts_result.hosts.0.name == "ExampleHostForHostInfoModuleName" + - gather_all_facts_result.hosts.0.description == "Test Host" + - gather_all_facts_result.hosts.0.groups.0.name == "Linux servers" + - gather_all_facts_result.hosts.0.groups.1.name == "Hypervisors" + - gather_all_facts_result.hosts.0.parentTemplates.0.name == "Zabbix Server" + - gather_all_facts_result.hosts.0.status == "0" + - gather_all_facts_result.hosts.0.inventory_mode == "0" + - gather_all_facts_result.hosts.0.inventory.tag == "tag1" + - gather_all_facts_result.hosts.0.inventory.os == "Linux" + - gather_all_facts_result.hosts.0.hostinterfaces.0.dns == "" + - gather_all_facts_result.hosts.0.hostinterfaces.0.ip == "192.168.0.1" + - gather_all_facts_result.hosts.0.hostinterfaces.0.main == "1" + - gather_all_facts_result.hosts.0.hostinterfaces.0.port == "10050" + - gather_all_facts_result.hosts.0.hostinterfaces.0.type == "1" + - gather_all_facts_result.hosts.0.hostinterfaces.0.useip == "1" + + - name: "test - Gather facts of zabbix host with host_inventory" + zabbix_host_info: + host_inventory: + - tag + - os + register: gather_facts_with_host_inventory_result + + - when: zabbix_version is version('3.4', '<=') + assert: + that: + - gather_facts_with_host_inventory_result.hosts.0.inventory | length == 3 + - gather_facts_with_host_inventory_result.hosts.0.inventory.tag == "tag1" + - gather_facts_with_host_inventory_result.hosts.0.inventory.os == "Linux" + + - when: zabbix_version is version('4.0', '>=') + assert: + that: + - gather_facts_with_host_inventory_result.hosts.0.inventory | length == 2 + - gather_facts_with_host_inventory_result.hosts.0.inventory.tag == "tag1" + - gather_facts_with_host_inventory_result.hosts.0.inventory.os == "Linux" + + - name: "test - Partial match of zabbix host name" + zabbix_host_info: + host_name: HostForHostInfo + exact_match: no + register: partial_match_result + + - assert: + that: + - partial_match_result.hosts | length == 1 + + - name: "test - Exact match of zabbix host name" + zabbix_host_info: + exact_match: yes + register: exact_match_result + + - assert: + that: + - exact_match_result.hosts | length == 1 + + - name: "test - Exact match of zabbix host name(expectations - host not found)" + zabbix_host_info: + host_name: HostForHostInfo + exact_match: yes + register: exact_match_host_not_found_result + ignore_errors: yes + + - assert: + that: + - exact_match_host_not_found_result.failed is sameas true diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml new file mode 100644 index 00000000..3c24e8ad --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml @@ -0,0 +1,160 @@ +--- +- name: create helper zabbix host + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + host_groups: + - Linux servers + interfaces: + - type: agent + main: 1 + dns: zbx_hmacro_host01 + +- name: test - attempt to create new host macro + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + macro_value: 123 + register: zbxhmacro_new + +- name: assert that macro was created + assert: + that: zbxhmacro_new is changed + +- name: test - attempt to create same host macro + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + macro_value: 123 + register: zbxhmacro_existing + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_existing is changed + +- name: test - attempt to create same host macro in zabbix native format + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: "{$ZBXHMACRO_TEST01}" + macro_value: 123 + register: zbxhmacro_existing_native + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_existing_native is changed + +- name: test - attempt to create new host macro in zabbix native format + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: "{$ZBXHMACRO_TEST02}" + macro_value: abcd + register: zbxhmacro_new_native + +- name: assert that nothing macro was created + assert: + that: zbxhmacro_new_native is changed + +- name: test - attempt to update host macro with string value while force=no + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + macro_value: abc + force: no + register: zbxhmacro_update_noforce + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_update_noforce is changed + +- name: test - attempt to update host macro with string value + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + macro_value: abc + register: zbxhmacro_update + ignore_errors: True + +- name: assert that host macro was updated + assert: + that: zbxhmacro_update is changed + +- name: test - attempt to create host macro with context + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: low_space_limit:/home + macro_value: 10 + register: zbxhmacro_context_new + +- name: assert that macro was created + assert: + that: zbxhmacro_context_new is changed + +- name: test - attempt to create same host macro with context and verify that it was converted to uppercase + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: LOW_SPACE_LIMIT:/home + macro_value: 10 + register: zbxhmacro_context_existing + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_context_existing is changed + +- name: test - attempt to delete all host macros + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: "{{ item }}" + state: absent + loop: + - zbxhmacro_test01 + - LOW_SPACE_LIMIT:/home + - "{$ZBXHMACRO_TEST02}" + register: zbxhmacro_delete_existing + +- name: assert that all macros have been deleted + assert: + that: item.changed is sameas True + loop: "{{ zbxhmacro_delete_existing.results }}" + +- name: test - attempt to delete non-existing host macro + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + state: absent + register: zbxhmacro_delete_missing + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_delete_missing is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/aliases b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/aliases new file mode 100644 index 00000000..7a68b11d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/aliases @@ -0,0 +1 @@ +disabled diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml new file mode 100644 index 00000000..f3c8d427 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml @@ -0,0 +1,260 @@ +--- +# New host create test from here +- name: "test - Create a new host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: example + host_groups: + - Linux servers + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: 10050 + register: create_host_result + +- assert: + that: + - create_host_result.changed is sameas true + +- name: "test - Create maintenance with a host_name param" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + state: present + register: create_maintenance_host_name_result + +- assert: + that: + - create_maintenance_host_name_result.changed is sameas true + +- name: "test - Create maintenance with a host_name param(again - expectations: no change will occur)" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + state: present + register: create_maintenance_host_name_again_result + +- assert: + that: + - create_maintenance_host_name_again_result.changed is sameas false + +- name: "test - Update maintenance with a desc param" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + state: present + register: update_maintenance_desc_result + +- debug: msg="{{ update_maintenance_desc_result }}" + +- assert: + that: + - update_maintenance_desc_result.changed is sameas true + +- name: "test - Update maintenance with a desc param(again - expectations: no change will occur)" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + state: present + register: update_maintenance_desc_again_result + +- assert: + that: + - update_maintenance_desc_again_result.changed is sameas false + +- name: "test - Update maintenance with a collect_data" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + collect_data: no + state: present + register: update_maintenance_collect_data_result + +- assert: + that: + - update_maintenance_collect_data_result.changed is sameas true + +- name: "test - Update maintenance with a collect_data(again - expectations: no change will occur)" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + collect_data: no + state: present + register: update_maintenance_collect_data_again_result + +- assert: + that: + - update_maintenance_collect_data_again_result.changed is sameas false + +- name: "test - Update maintenance with a minutes param" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_minutes_result + +- assert: + that: + - update_maintenance_minutes_result.changed is sameas true + +- name: "test - Update maintenance with a minutes param(again - expectations: no change will occur)" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_minutes_again_result + +- assert: + that: + - update_maintenance_minutes_again_result.changed is sameas false + +- name: "test - Update maintenance with a host_groups param" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + host_groups: + - Linux servers + - Hypervisors + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_host_groups_result + +- assert: + that: + - update_maintenance_host_groups_result.changed is sameas true + +- name: "test - Update maintenance with a host_groups param(again - expectations: no change will occur)" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + host_groups: + - Linux servers + - Hypervisors + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_host_groups_again_result + +- assert: + that: + - update_maintenance_host_groups_again_result.changed is sameas false + +- name: "test - Update maintenance with change host_name to host_names param" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_names: + - example + - Zabbix server + host_groups: + - Linux servers + - Hypervisors + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_host_names_result + +- assert: + that: + - update_maintenance_host_names_result.changed is sameas true + +- name: "test - Update maintenance with change host_name to host_names param(again - expectations: no change will occur)" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_names: + - example + - Zabbix server + host_groups: + - Linux servers + - Hypervisors + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_host_names_again_result + +- assert: + that: + - update_maintenance_host_names_again_result.changed is sameas false + +- name: "test - Delete maintenance" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + state: absent + register: delete_maintenance_result + +- assert: + that: + - delete_maintenance_result.changed is sameas true + +- name: "test - Delete maintenance(again - expectations: no change will occur)" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + state: absent + register: delete_maintenance_again_result + +- assert: + that: + - delete_maintenance_again_result.changed is sameas false diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml new file mode 100644 index 00000000..b74a5b7d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml @@ -0,0 +1,696 @@ +--- +- name: test - email mediatypes + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example email + type: email + smtp_email: zabbix@example.com + + block: + - name: test - create new email mediatype without authentication + zabbix_mediatype: + register: zbxmediatype_new + + - assert: + that: zbxmediatype_new.changed is sameas True + + - name: test - create new email mediatype without authentication (again) + zabbix_mediatype: + register: zbxmediatype_new + + - assert: + that: zbxmediatype_new.changed is sameas False + + - name: test - update email mediatype smtp information + zabbix_mediatype: + smtp_helo: example.com + smtp_server: mail.example.com + smtp_server_port: 465 + register: zbxmediatype_smtp + + - assert: + that: zbxmediatype_smtp.changed is sameas True + + - name: test - update email mediatype smtp information (again) + zabbix_mediatype: + smtp_helo: example.com + smtp_server: mail.example.com + smtp_server_port: 465 + register: zbxmediatype_smtp + + - assert: + that: zbxmediatype_smtp.changed is sameas False + + - name: test - reset email mediatype smtp information to default + zabbix_mediatype: + register: zbxmediatype_reset + + - assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update email mediatype with authentication without credentials (fail) + zabbix_mediatype: + smtp_authentication: yes + smtp_security: STARTTLS + register: zbxmediatype_auth_fail + ignore_errors: True + + - assert: + that: zbxmediatype_auth_fail.failed is sameas True + + - name: test - update email mediatype with authentication + zabbix_mediatype: + smtp_authentication: yes + smtp_security: STARTTLS + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_auth + + - assert: + that: zbxmediatype_auth.changed is sameas True + + - name: test - update email mediatype with authentication (again) + zabbix_mediatype: + smtp_authentication: yes + smtp_security: STARTTLS + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_auth + + - assert: + that: zbxmediatype_auth.changed is sameas False + + - name: test - update email mediatype with SSL/TLS and host/peer verification + zabbix_mediatype: + smtp_authentication: yes + smtp_security: SSL/TLS + smtp_verify_host: yes + smtp_verify_peer: yes + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_verif + + - assert: + that: zbxmediatype_verif.changed is sameas True + + - name: test - update email mediatype with SSL/TLS and host/peer verification (again) + zabbix_mediatype: + smtp_authentication: yes + smtp_security: SSL/TLS + smtp_verify_host: yes + smtp_verify_peer: yes + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_verif + + - assert: + that: zbxmediatype_verif.changed is sameas False + + - when: zabbix_version is version('3.4', '>=') + block: + - name: test - reset email mediatype smtp information to default + zabbix_mediatype: + register: zbxmediatype_reset + + - assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update email mediatype concurrent settings + zabbix_mediatype: + max_sessions: 99 + max_attempts: 10 + attempt_interval: 30 + register: zbxmediatype_concur + + - assert: + that: zbxmediatype_concur.changed is sameas True + + - name: test - update email mediatype concurrent settings (again) + zabbix_mediatype: + max_sessions: 99 + max_attempts: 10 + attempt_interval: 30 + register: zbxmediatype_concur + + - assert: + that: zbxmediatype_concur.changed is sameas False + + - name: test - update email mediatype concurrent settings above range (fail) + zabbix_mediatype: + max_sessions: 102 + max_attempts: 11 + attempt_interval: 61 + register: zbxmediatype_concur_fail + ignore_errors: True + + - assert: + that: zbxmediatype_concur_fail.failed is sameas True + + - when: zabbix_version is version('5.0', '>=') + block: + - name: test - reset email mediatype smtp information to default + zabbix_mediatype: + register: zbxmediatype_reset + + - assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update email mediatype with message templates + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME}" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas True + + - name: test - update email mediatype with message templates (again) + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME}" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas False + + - name: test - update subject of message template in email mediatype + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME} - test change" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas True + + - name: test - update message of message template in email mediatype + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME} - test change" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS} - test" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas True + + - name: test - update subject and message of message template in email mediatype (again) + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME} - test change" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS} - test" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas False + + - name: test - disable email mediatype + zabbix_mediatype: + status: disabled + register: zbxmediatype_disable + + - assert: + that: zbxmediatype_disable.changed is sameas True + + - name: test - disable email mediatype (again) + zabbix_mediatype: + status: disabled + register: zbxmediatype_disable + + - assert: + that: zbxmediatype_disable.changed is sameas False + + - name: test - delete email mediatype + zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - assert: + that: zbxmediatype_delete.changed is sameas True + + - name: test - delete email mediatype (again) + zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - assert: + that: zbxmediatype_delete.changed is sameas False + +- name: test - script mediatypes + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example script + type: script + + block: + - name: test - create new script mediatype + zabbix_mediatype: + script_name: /usr/local/bin/script.sh + register: zbxmediatype_script_new + + - assert: + that: zbxmediatype_script_new.changed is sameas True + + - name: test - create new script mediatype (again) + zabbix_mediatype: + script_name: /usr/local/bin/script.sh + register: zbxmediatype_script_new + + - assert: + that: zbxmediatype_script_new.changed is sameas False + + - name: test - update script mediatype with script parameters + zabbix_mediatype: + script_name: /usr/local/bin/script.sh + script_params: + - '-p test' + - '-q' + register: zbxmediatype_script_params + + - assert: + that: zbxmediatype_script_params.changed is sameas True + + - name: test - update script mediatype with script parameters (again) + zabbix_mediatype: + script_name: /usr/local/bin/script.sh + script_params: + - '-p test' + - '-q' + register: zbxmediatype_script_params + + - assert: + that: zbxmediatype_script_params.changed is sameas False + + - name: test - remove script mediatype parameters + zabbix_mediatype: + script_name: /usr/local/bin/script.sh + register: zbxmediatype_script_params_rev + + - assert: + that: zbxmediatype_script_params_rev.changed is sameas True + + - name: test - delete script mediatype + zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - assert: + that: zbxmediatype_delete.changed is sameas True + +- name: test - sms mediatypes + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example sms + type: sms + + block: + - name: test - create new sms mediatype + zabbix_mediatype: + gsm_modem: /dev/ttyS0 + register: zbxmediatype_sms_new + + - assert: + that: zbxmediatype_sms_new.changed is sameas True + + - name: test - create new sms mediatype (again) + zabbix_mediatype: + gsm_modem: /dev/ttyS0 + register: zbxmediatype_sms_new + + - assert: + that: zbxmediatype_sms_new.changed is sameas False + + - when: zabbix_version is version('3.4', '>=') + block: + - name: test - update sms mediatype with concurrent settings + zabbix_mediatype: + gsm_modem: /dev/ttyS0 + max_sessions: 1 + max_attempts: 3 + attempt_interval: 30 + register: zbxmediatype_sms_concur + + - assert: + that: zbxmediatype_sms_concur.changed is sameas True + + - name: test - update sms mediatype with concurrent settings (again) + zabbix_mediatype: + gsm_modem: /dev/ttyS0 + max_sessions: 1 + max_attempts: 3 + attempt_interval: 30 + register: zbxmediatype_sms_concur + + - assert: + that: zbxmediatype_sms_concur.changed is sameas False + + - name: test - update sms mediatype with invalid max sessions (fail) + zabbix_mediatype: + gsm_modem: /dev/ttyS0 + max_sessions: 2 + register: zbxmediatype_sms_fail + ignore_errors: True + + - assert: + that: zbxmediatype_sms_fail.failed is sameas True + + - name: test - delete sms mediatype + zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - assert: + that: zbxmediatype_delete.changed is sameas True + +- name: test - jabber mediatypes + when: zabbix_version is version('4.2', '<=') + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example jabber + type: jabber + + block: + - name: test - create new jabber mediatype + zabbix_mediatype: + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_jabber_new + + - assert: + that: zbxmediatype_jabber_new.changed is sameas True + + - name: test - create new jabber mediatype (again) + zabbix_mediatype: + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_jabber_new + + - assert: + that: zbxmediatype_jabber_new.changed is sameas False + + - name: test - delete jabber mediatype + zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - assert: + that: zbxmediatype_delete.changed is sameas True + +- name: test - ez_texting mediatypes + when: zabbix_version is version('4.2', '<=') + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example ez_texting + type: ez_texting + + block: + - name: test - create new ez_texting mediatype + zabbix_mediatype: + username: zabbix + password: Ex4mP!3 + message_text_limit: USA + register: zbxmediatype_ez_texting_new + + - assert: + that: zbxmediatype_ez_texting_new.changed is sameas True + + - name: test - create new ez_texting mediatype (again) + zabbix_mediatype: + username: zabbix + password: Ex4mP!3 + message_text_limit: USA + register: zbxmediatype_ez_texting_new + + - assert: + that: zbxmediatype_ez_texting_new.changed is sameas False + + - name: test - update ez_texting mediatype with text limit + zabbix_mediatype: + username: zabbix + password: Ex4mP!3 + message_text_limit: Canada + register: zbxmediatype_ez_texting_update + + - assert: + that: zbxmediatype_ez_texting_update.changed is sameas True + + - name: test - delete ez_texting mediatype + zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - assert: + that: zbxmediatype_delete.changed is sameas True + +- name: test - email mediatypes + when: zabbix_version is version('4.4', '>=') + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example webhook + type: webhook + webhook_script: "return 'Hello, world!';" + + block: + - name: test - create new webhook mediatype + zabbix_mediatype: + register: zbxmediatype_webhook_new + + - assert: + that: zbxmediatype_webhook_new.changed is sameas True + + - name: test - create new webhook mediatype (again) + zabbix_mediatype: + register: zbxmediatype_webhook_new + + - assert: + that: zbxmediatype_webhook_new.changed is sameas False + + - name: test - update webhook mediatype with process_tags + zabbix_mediatype: + process_tags: True + register: zbxmediatype_webhook_tags + + - assert: + that: zbxmediatype_webhook_tags.changed is sameas True + + - name: test - update webhook mediatype with process_tags (again) + zabbix_mediatype: + process_tags: True + register: zbxmediatype_webhook_tags + + - assert: + that: zbxmediatype_webhook_tags.changed is sameas False + + # supported since 4.4 + - name: test - update webhook mediatype with description + zabbix_mediatype: + process_tags: True + description: My custom webhook mediatype + register: zbxmediatype_webhook_desc + + - assert: + that: zbxmediatype_webhook_desc.changed is sameas True + + - name: test - update webhook mediatype with description (again) + zabbix_mediatype: + process_tags: True + description: My custom webhook mediatype + register: zbxmediatype_webhook_desc + + - assert: + that: zbxmediatype_webhook_desc.changed is sameas False + + - name: test - update webhook mediatype with event_menu without name and url (fail) + zabbix_mediatype: + process_tags: True + description: My custom webhook mediatype + event_menu: True + register: zbxmediatype_webhook_eventmenu + ignore_errors: True + + - assert: + that: zbxmediatype_webhook_eventmenu.failed is sameas True + + - name: test - update webhook mediatype with event_menu + zabbix_mediatype: + process_tags: True + description: My custom webhook mediatype + event_menu: True + event_menu_name: Example entry name + event_menu_url: '{EVENT.TAGS.__message_link}' + register: zbxmediatype_webhook_eventmenu + + - assert: + that: zbxmediatype_webhook_eventmenu.changed is sameas True + + - name: test - update webhook mediatype with event_menu (again) + zabbix_mediatype: + process_tags: True + description: My custom webhook mediatype + event_menu: True + event_menu_name: Example entry name + event_menu_url: '{EVENT.TAGS.__message_link}' + register: zbxmediatype_webhook_eventmenu + + - assert: + that: zbxmediatype_webhook_eventmenu.changed is sameas False + + - name: test - reset webhook mediatype to default + zabbix_mediatype: + register: zbxmediatype_reset + + - assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update webhook mediatype with webhook_params + zabbix_mediatype: + webhook_params: + - name: param1 + value: value1 + register: zbxmediatype_webhook_params + + - assert: + that: zbxmediatype_webhook_params.changed is sameas True + + - name: test - update webhook mediatype with webhook_params (again) + zabbix_mediatype: + webhook_params: + - name: param1 + value: value1 + register: zbxmediatype_webhook_params + + - assert: + that: zbxmediatype_webhook_params.changed is sameas False + + - name: test - update webhook mediatype with webhook_params (reorder) + zabbix_mediatype: + webhook_params: + - name: z.param2 + value: xyz + - name: param1 + value: value1 + - name: b.param3 + - name: a.param4 + value: abc + register: zbxmediatype_webhook_params + + - assert: + that: zbxmediatype_webhook_params.changed is sameas True + + - name: test - update webhook mediatype with webhook_params (reorder again) + zabbix_mediatype: + webhook_params: + - name: param1 + value: value1 + - name: a.param4 + value: abc + - name: b.param3 + - name: z.param2 + value: xyz + register: zbxmediatype_webhook_params + + - assert: + that: zbxmediatype_webhook_params.changed is sameas False + + - name: test - delete webhook mediatype + zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - assert: + that: zbxmediatype_delete.changed is sameas True diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/aliases b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/aliases new file mode 100644 index 00000000..7a68b11d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/aliases @@ -0,0 +1 @@ +disabled diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml new file mode 100644 index 00000000..1b493e37 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml @@ -0,0 +1,365 @@ +--- +- name: test - create new passive Zabbix proxy server + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.2 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_new + +- name: assert that proxy was created + assert: + that: zbxproxy_new is changed + +- name: test - create same passive Zabbix proxy server + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.2 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_existing + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_existing is changed + +- name: test - update Zabbix proxy server description + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.2 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_desc_update + +- name: assert that description has been updated + assert: + that: zbxproxy_desc_update is changed + +- name: test - update Zabbix proxy server interface + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.3 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_interface_update + +- name: assert that interface has been updated + assert: + that: zbxproxy_interface_update is changed + +- name: test - update Zabbix proxy server description & interface (again) + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.3 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_desc_interface_update + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_desc_interface_update is changed + +- name: test - update Zabbix proxy server interface to use only ip + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 1 + ip: 10.1.1.3 + port: 10051 + register: zbxproxy_interface_onlyip + +- name: assert that interface has been updated + assert: + that: zbxproxy_interface_onlyip is changed + +- name: test - update Zabbix proxy server interface to use only ip again + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 1 + ip: 10.1.1.3 + port: 10051 + register: zbxproxy_interface_onlyip_again + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_interface_onlyip_again is changed + +- name: test - update Zabbix proxy server interface to use only dns + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_interface_onlydns + +- name: assert that interface has been updated + assert: + that: zbxproxy_interface_onlydns is changed + +- name: test - update Zabbix proxy server interface to use only dns again + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_interface_onlydns_again + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_interface_onlydns_again is changed + +- name: test - update Zabbix proxy server interface to fail + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 1 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_interface_fail + ignore_errors: True + +- name: assert that module has failed + assert: + that: zbxproxy_interface_fail is failed + +- name: test - update Zabbix proxy server to be active + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + register: zbxproxy_active_update + +- name: assert that proxy was updated + assert: + that: zbxproxy_active_update is changed + +- name: test - update Zabbix proxy server to be active (again) + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + register: zbxproxy_active_update_again + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_active_update_again is changed + +# proxy_address available on zabbix 4.0 and above +- block: + - name: test - update Zabbix proxy server to be active and use proxy_address + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + proxy_address: 10.1.1.0/24,zabbix.example.com + register: zbxproxy_active_proxyaddress + + - name: assert that proxy was updated + assert: + that: zbxproxy_active_proxyaddress is changed + + - name: test - update Zabbix proxy server to be active use proxy_address (again) + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + proxy_address: 10.1.1.0/24,zabbix.example.com + register: zbxproxy_active_proxyaddress_again + + - name: assert that nothing has been changed + assert: + that: not zbxproxy_active_proxyaddress_again is changed + + when: zabbix_version != "3.0" + +- name: test - update Zabbix proxy server to use encryption + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + tls_psk_identity: test + tls_connect: PSK + tls_accept: PSK + tls_psk: 123456789abcdef123456789abcdef12 + register: zbxproxy_encryption + +- name: assert that encryption has been enabled + assert: + that: zbxproxy_encryption is changed + +- name: test - update Zabbix proxy server to use encryption (again) + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + tls_psk_identity: test + tls_connect: PSK + tls_accept: PSK + tls_psk: 123456789abcdef123456789abcdef12 + register: zbxproxy_encryption_again + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_encryption_again is changed + +- name: test - update Zabbix proxy server encryption settings + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + tls_connect: certificate + tls_accept: certificate + tls_issuer: AcmeCorp + tls_subject: AcmeCorpServer + register: zbxproxy_encryption_update + +- name: assert that encryption has been updated + assert: + that: zbxproxy_encryption_update is changed + +- name: test - update Zabbix proxy server back to being passive + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.2 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_passive_update + +- name: assert that proxy was updated + assert: + that: zbxproxy_passive_update is changed + +- name: test - delete Zabbix proxy server + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + state: absent + register: zbxproxy_delete + +- name: assert that proxy has been deleted + assert: + that: zbxproxy_delete is changed + +- name: test - delete Zabbix proxy server (again) + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + state: absent + register: zbxproxy_delete_again + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_delete_again is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml new file mode 100644 index 00000000..2d270b76 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml @@ -0,0 +1,146 @@ +--- + +- name: ensure zabbix server is being monitored + community.zabbix.zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: Zabbix server + status: enabled + +- name: test - delete the screen again + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + state: absent + + +# ################################################# +# Test screen creation +# ################################################# + +- name: test - Create a new screen + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + host_group: Zabbix servers + state: present + graph_names: + - 'Zabbix cache usage, % used' + - 'Zabbix internal process busy %' + graph_width: 200 + graph_height: 100 + graphs_in_row: 5 + register: result + +- assert: + that: + - result.changed + +- name: test - Create a new screen again + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + host_group: Zabbix servers + state: present + graph_names: + - 'Zabbix cache usage, % used' + - 'Zabbix internal process busy %' + graph_width: 200 + graph_height: 100 + graphs_in_row: 5 + register: result + +- assert: + that: + - not result.changed + +# ################################################# +# Test screen editing +# ################################################# + +- name: test - Adding new graph + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + host_group: Zabbix servers + state: present + graph_names: + - 'Zabbix cache usage, % used' + - 'Zabbix internal process busy %' + - 'Zabbix internal queues' + - 'Zabbix server performance' + - 'Zabbix data gathering process busy %' + graph_width: 200 + graph_height: 100 + graphs_in_row: 5 + register: result + +- assert: + that: + - result.changed + +- name: test - Removing graph + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + host_group: Zabbix servers + state: present + graph_names: + - 'Zabbix cache usage, % used' + - 'Zabbix internal queues' + graph_width: 200 + graph_height: 100 + graphs_in_row: 5 + register: result + +- assert: + that: + - result.changed + +# ################################################# +# Test screen deletion +# ################################################# + +- name: test - delete the screen + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + state: absent + register: result + +- assert: + that: + - result.changed + +- name: test - delete the screen again + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + state: absent + register: result + +- assert: + that: + - not result.changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml new file mode 100644 index 00000000..ae6105d9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml @@ -0,0 +1,397 @@ +--- +- name: "test - Create a new service with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.99 + state: present + check_mode: yes + register: create_service_check_mode_result + +- assert: + that: + - create_service_check_mode_result.changed is sameas true + +- name: "test - Create a new service" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.99 + state: present + register: create_service_result + +- assert: + that: + - create_service_result.changed is sameas true + +- name: "test - Create a new service (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.99 + state: present + register: create_service_idempotency_check_result + +- assert: + that: + - create_service_idempotency_check_result.changed is sameas false + +- name: "test - Update a sla with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: present + check_mode: yes + register: update_sla_check_mode_result + +- assert: + that: + - update_sla_check_mode_result.changed is sameas true + +- name: "test - Update a sla" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: present + register: update_sla_result + +- assert: + that: + - update_sla_result.changed is sameas true + +- name: "test - Update a sla (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: present + register: update_sla_idempotency_check_result + +- assert: + that: + - update_sla_idempotency_check_result.changed is sameas false + +- name: "test - Update a calculate_sla with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + state: present + check_mode: yes + register: update_calculate_sla_check_mode_result + +- assert: + that: + - update_calculate_sla_check_mode_result.changed is sameas true + +- name: "test - Update a calculate_sla" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + state: present + register: update_calculate_sla_result + +- assert: + that: + - update_calculate_sla_result.changed is sameas true + +- name: "test - Update a calculate_sla (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + state: present + register: update_calculate_sla_idempotency_check_result + +- assert: + that: + - update_calculate_sla_idempotency_check_result.changed is sameas false + +- name: "test - Update trigger_host and trigger_name with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + state: present + check_mode: yes + register: update_trigger_name_check_mode_result + +- assert: + that: + - update_trigger_name_check_mode_result.changed is sameas true + +- name: "test - Update trigger_host and trigger_name" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + state: present + register: update_trigger_name_result + +- assert: + that: + - update_trigger_name_result.changed is sameas true + +- name: "test - Update trigger_host and trigger_name (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + state: present + register: update_trigger_name_idempotency_check_result + +- assert: + that: + - update_trigger_name_idempotency_check_result.changed is sameas false + +- name: "test - Update a algorithm of service with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + state: present + check_mode: yes + register: update_algorithm_check_mode_result + +- assert: + that: + - update_algorithm_check_mode_result.changed is sameas true + +- name: "test - Update a algorithm of service" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + state: present + register: update_algorithm_result + +- assert: + that: + - update_algorithm_result.changed is sameas true + +- name: "test - Update a algorithm of service (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + state: present + register: update_algorithm_idempotency_check_result + +- assert: + that: + - update_algorithm_idempotency_check_result.changed is sameas false + +- name: "test - Create a new root service for parent test" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModuleRoot + sla: 99.99 + state: present + register: create_child_service_result + +- assert: + that: + - create_child_service_result.changed is sameas true + +- name: "test - Update a parent of child service with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + parent: ExampleServiceForServiceModuleRoot + state: present + check_mode: yes + register: create_parent_child_service_check_mode_result + +- assert: + that: + - create_parent_child_service_check_mode_result.changed is sameas true + +- name: "test - Update a parent of child service" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + parent: ExampleServiceForServiceModuleRoot + state: present + register: create_parent_child_service_result + +- assert: + that: + - create_parent_child_service_result.changed is sameas true + +- name: "test - Update a parent of child service (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + parent: ExampleServiceForServiceModuleRoot + state: present + register: create_parent_child_service_idempotency_check_result + +- assert: + that: + - create_parent_child_service_idempotency_check_result.changed is sameas false + +- name: "test - Remove ExampleServiceForServiceModule service with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: absent + check_mode: yes + register: remove_service_with_check_mode_result + +- assert: + that: + - remove_service_with_check_mode_result.changed is sameas true + +- name: "test - Remove ExampleServiceForServiceModule service" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: absent + register: remove_service_result + +- assert: + that: + - remove_service_result.changed is sameas true + +- name: "test - Remove ExampleServiceForServiceModule service (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: absent + register: remove_service_idempotency_check_result + +- assert: + that: + - remove_service_idempotency_check_result.changed is sameas false + +- name: "test - Remove ExampleServiceForServiceModuleRoot service with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModuleRoot + sla: 99.999 + state: absent + check_mode: yes + register: remove_root_service_with_check_mode_result + +- assert: + that: + - remove_root_service_with_check_mode_result.changed is sameas true + +- name: "test - Remove ExampleServiceForServiceModuleRoot service" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModuleRoot + sla: 99.999 + state: absent + register: remove_root_service_result + +- assert: + that: + - remove_root_service_result.changed is sameas true + +- name: "test - Remove ExampleServiceForServiceModuleRoot service (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModuleRoot + sla: 99.999 + state: absent + register: remove_root_service_idempotency_check_result + +- assert: + that: + - remove_root_service_idempotency_check_result.changed is sameas false diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_50_lower.json b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_50_lower.json new file mode 100644 index 00000000..8cdd460a --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_50_lower.json @@ -0,0 +1,51 @@ +{ + "zabbix_export": { + "date": "2020-05-29T15:22:11Z", + "templates": [ + { + "template": "ExampleHost", + "name": "ExampleHost", + "description": "", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ], + "macros": [ + { + "macro": "{$EXAMPLE_MACRO1}", + "value": "1000" + }, + { + "macro": "{$EXAMPLE_MACRO2}", + "value": "text" + }, + { + "macro": "{$EXAMPLE_MACRO3}", + "value": "text2" + } + ], + "templates": [ + { + "name": "Template App FTP Service" + }, + { + "name": "Template App Zabbix Proxy" + } + ] + } + ], + "version": "3.0", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ] + } +} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_52_higher.json b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_52_higher.json new file mode 100644 index 00000000..73924e5b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_52_higher.json @@ -0,0 +1,51 @@ +{ + "zabbix_export": { + "date": "2020-05-29T15:22:11Z", + "templates": [ + { + "template": "ExampleHost", + "name": "ExampleHost", + "description": "", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ], + "macros": [ + { + "macro": "{$EXAMPLE_MACRO1}", + "value": "1000" + }, + { + "macro": "{$EXAMPLE_MACRO2}", + "value": "text" + }, + { + "macro": "{$EXAMPLE_MACRO3}", + "value": "text2" + } + ], + "templates": [ + { + "name": "FTP Service" + }, + { + "name": "Zabbix Proxy" + } + ] + } + ], + "version": "3.0", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ] + } +} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_50_lower.json b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_50_lower.json new file mode 100644 index 00000000..869bc54a --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_50_lower.json @@ -0,0 +1,47 @@ +{ + "zabbix_export": { + "date": "2020-05-29T15:22:11Z", + "templates": [ + { + "template": "ExampleHost", + "name": "ExampleHost", + "description": "", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ], + "macros": [ + { + "macro": "{$EXAMPLE_MACRO1}", + "value": "1000" + }, + { + "macro": "{$EXAMPLE_MACRO2}", + "value": "text" + } + ], + "templates": [ + { + "name": "Template App FTP Service" + }, + { + "name": "Template App Zabbix Proxy" + } + ] + } + ], + "version": "3.0", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ] + } +} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_52_higher.json b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_52_higher.json new file mode 100644 index 00000000..a733758b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_52_higher.json @@ -0,0 +1,47 @@ +{ + "zabbix_export": { + "date": "2020-05-29T15:22:11Z", + "templates": [ + { + "template": "ExampleHost", + "name": "ExampleHost", + "description": "", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ], + "macros": [ + { + "macro": "{$EXAMPLE_MACRO1}", + "value": "1000" + }, + { + "macro": "{$EXAMPLE_MACRO2}", + "value": "text" + } + ], + "templates": [ + { + "name": "FTP Service" + }, + { + "name": "Zabbix Proxy" + } + ] + } + ], + "version": "3.0", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ] + } +} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml new file mode 100644 index 00000000..aec95810 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml @@ -0,0 +1,53 @@ + + + 2020-05-29T15:22:11Z + + + + 3.0 + + + Linux servers + + + Templates + + + diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_52_higher.xml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_52_higher.xml new file mode 100644 index 00000000..e8a7f1e5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_52_higher.xml @@ -0,0 +1,53 @@ + + + 2020-05-29T15:22:11Z + + + + 3.0 + + + Linux servers + + + Templates + + + diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml new file mode 100644 index 00000000..839d6974 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml @@ -0,0 +1,408 @@ +--- +- name: Create a new Zabbix template (check mode). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + state: present + register: create_zabbix_template_result + check_mode: yes + +- assert: + that: + - create_zabbix_template_result.changed is sameas true + +- name: Create a new Zabbix template. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + state: present + register: create_zabbix_template_result + +- assert: + that: + - create_zabbix_template_result.changed is sameas true + +- name: Create a new Zabbix template (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + state: present + register: create_zabbix_template_result + +- assert: + that: + - create_zabbix_template_result.changed is sameas false + +- name: Gather Zabbix template infomation. + zabbix_template_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + format: json + register: gather_template_result + +- name: "test - Set key to template_export_key variable(This deals with the key being masked)" + set_fact: + template_export_key: "{{ item }}" + loop: "{{ gather_template_result.template_json.keys() | list }}" + when: + - item | regex_search('_export') + +- assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + +- name: Add link_templates to Zabbix template. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + link_templates: + - "{{ 'Zabbix Proxy' if zabbix_version | float >= 5.2 else 'Template App Zabbix Proxy' }}" + - "{{ 'FTP Service' if zabbix_version | float >= 5.2 else 'Template App FTP Service' }}" + state: present + register: update_zabbix_template_result + +- assert: + that: + - update_zabbix_template_result.changed is sameas true + +- name: Add link_templates to Zabbix template (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + link_templates: + - "{{ 'Zabbix Proxy' if zabbix_version | float >= 5.2 else 'Template App Zabbix Proxy' }}" + - "{{ 'FTP Service' if zabbix_version | float >= 5.2 else 'Template App FTP Service' }}" + state: present + register: update_zabbix_template_result + +- assert: + that: + - update_zabbix_template_result.changed is sameas false + +- name: Gather Zabbix template infomation. + zabbix_template_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + format: json + register: gather_template_result + +- when: zabbix_version is version('5.2', '<') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'Template App FTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Template App Zabbix Proxy' + +- when: zabbix_version is version('5.2', '>=') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix Proxy' + +- name: Add macros to Zabbix template. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + link_templates: + - "{{ 'Zabbix Proxy' if zabbix_version | float >= 5.2 else 'Template App Zabbix Proxy' }}" + - "{{ 'FTP Service' if zabbix_version | float >= 5.2 else 'Template App FTP Service' }}" + macros: + - macro: '{$EXAMPLE_MACRO1}' + value: 1000 + - macro: '{$EXAMPLE_MACRO2}' + value: 'text' + state: present + register: update_zabbix_template_result + +- assert: + that: + - update_zabbix_template_result.changed is sameas true + +- name: Add macros to Zabbix template (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + link_templates: + - "{{ 'Zabbix Proxy' if zabbix_version | float >= 5.2 else 'Template App Zabbix Proxy' }}" + - "{{ 'FTP Service' if zabbix_version | float >= 5.2 else 'Template App FTP Service' }}" + macros: + - macro: '{$EXAMPLE_MACRO1}' + value: 1000 + - macro: '{$EXAMPLE_MACRO2}' + value: 'text' + state: present + register: update_zabbix_template_result + +- assert: + that: + - update_zabbix_template_result.changed is sameas false + +- name: Gather Zabbix template infomation. + zabbix_template_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + format: json + register: gather_template_result + +- when: zabbix_version is version('5.2', '<') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'Template App FTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Template App Zabbix Proxy' + - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' + - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' + +- when: zabbix_version is version('5.2', '>=') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix Proxy' + - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' + - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' + +- when: zabbix_version is version('5.2', '<') + block: + - name: Import Zabbix template from JSON file with matching values (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_json: "{{ lookup('file', 'template1_50_lower.json') }}" + state: present + register: import_template_json + + - assert: + that: + - import_template_json.changed is sameas false + +- when: zabbix_version is version('5.2', '>=') + block: + - name: Import Zabbix template from JSON file with matching values (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_json: "{{ lookup('file', 'template1_52_higher.json') }}" + state: present + register: import_template_json + + - assert: + that: + - import_template_json.changed is sameas false + +- when: zabbix_version is version('5.2', '<') + block: + - name: Import Zabbix template from JSON file with updated values. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_json: "{{ lookup('file', 'template1-changed_50_lower.json') }}" + state: present + register: import_template_json + + - assert: + that: + - import_template_json.changed is sameas true + +- when: zabbix_version is version('5.2', '>=') + block: + - name: Import Zabbix template from JSON file with updated values. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_json: "{{ lookup('file', 'template1-changed_52_higher.json') }}" + state: present + register: import_template_json + + - assert: + that: + - import_template_json.changed is sameas true + +- name: Gather Zabbix template infomation. + zabbix_template_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + format: json + register: gather_template_result + +- assert: + that: + - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' + - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' + - gather_template_result.template_json[template_export_key].templates.0.macros.2.macro == '{$EXAMPLE_MACRO3}' + - gather_template_result.template_json[template_export_key].templates.0.macros.2.value == 'text2' + +- when: zabbix_version is version('5.2', '<') + block: + - name: Import Zabbix template from XML file with updated values. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_xml: "{{ lookup('file', 'template2_50_lower.xml') }}" + state: present + register: import_template_xml + + - assert: + that: + - import_template_xml.changed is sameas true + +- when: zabbix_version is version('5.2', '>=') + block: + - name: Import Zabbix template from XML file with updated values. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_xml: "{{ lookup('file', 'template2_52_higher.xml') }}" + state: present + register: import_template_xml + + - assert: + that: + - import_template_xml.changed is sameas true + +- name: Gather Zabbix template infomation. + zabbix_template_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + format: json + register: gather_template_result + +# zabbix returns values sorted alphabetically so HTTP Service template comes before Zabbix Proxy template +- when: zabbix_version is version('5.2', '<') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'Template App FTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Template App HTTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.2.name == 'Template App Zabbix Proxy' + +- when: zabbix_version is version('5.2', '>=') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'HTTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.2.name == 'Zabbix Proxy' + +- name: Dump Zabbix template to XML format. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + dump_format: xml + state: dump + register: template_dump_result + +- assert: + that: + - template_dump_result.deprecations is defined + - template_dump_result.deprecations.0.version == '3.0.0' + +- name: Dump Zabbix template to JSON format. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + dump_format: json + state: dump + register: template_dump_result + +- assert: + that: + - template_dump_result.deprecations is defined + - template_dump_result.deprecations.0.version == '3.0.0' + +- name: Delete Zabbix template. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + state: absent + register: delete_zabbix_template_result + +- assert: + that: + - delete_zabbix_template_result.changed is sameas true + +- name: Delete Zabbix template (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + state: absent + register: delete_zabbix_template_result + +- assert: + that: + - delete_zabbix_template_result.changed is sameas false diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml new file mode 100644 index 00000000..b66f8a0b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml @@ -0,0 +1,86 @@ +--- +- name: "test - Prepare integration tests for zabbix_template_info module" + zabbix_template: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForTempleteInfoModule + template_groups: + - Templates + state: present + register: prepare_result + +- assert: + that: + - prepare_result.changed is sameas true + +- name: "test - Fetch template info as a JSON format from Zabbix Server" + zabbix_template_info: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForTempleteInfoModule + format: json + register: fetch_template_json_format_result + +- name: "test - Set key to template_export_key variable(This deals with the key being masked)" + set_fact: + template_export_key: "{{ item }}" + loop: "{{ fetch_template_json_format_result.template_json.keys() | list }}" + when: + - item | regex_search('_export') + +- assert: + that: + - fetch_template_json_format_result.template_json[template_export_key].date is defined + - fetch_template_json_format_result.template_json[template_export_key].groups.0.name == "Templates" + - fetch_template_json_format_result.template_json[template_export_key].templates.0.name == "ExampleTemplateForTempleteInfoModule" + - fetch_template_json_format_result.template_json[template_export_key].templates.0.template == "ExampleTemplateForTempleteInfoModule" + +- name: "test - Fetch template info as a JSON format with omit_date parameter from Zabbix Server" + zabbix_template_info: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForTempleteInfoModule + format: json + omit_date: yes + register: fetch_template_json_format_omit_date_result + +- assert: + that: + - fetch_template_json_format_omit_date_result.template_json[template_export_key].date is not defined + - fetch_template_json_format_omit_date_result.template_json[template_export_key].groups.0.name == "Templates" + - fetch_template_json_format_omit_date_result.template_json[template_export_key].templates.0.name == "ExampleTemplateForTempleteInfoModule" + - fetch_template_json_format_omit_date_result.template_json[template_export_key].templates.0.template == "ExampleTemplateForTempleteInfoModule" + +- name: "test - Fetch template info as a XML format from Zabbix Server" + zabbix_template_info: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForTempleteInfoModule + format: xml + register: fetch_template_xml_format_result + +- assert: + that: + - fetch_template_xml_format_result.template_xml | regex_search('.*') is defined + - fetch_template_xml_format_result.template_xml | regex_search('Templates') is defined + - fetch_template_xml_format_result.template_xml | regex_search('') is defined + +- name: "test - Fetch template info as a XML format with omit_date parameter from Zabbix Server" + zabbix_template_info: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForTempleteInfoModule + format: xml + omit_date: yes + register: fetch_template_xml_format_omit_date_result + +- assert: + that: + - fetch_template_xml_format_omit_date_result.template_xml | regex_search('.*') is none + - fetch_template_xml_format_omit_date_result.template_xml | regex_search('Templates') is defined + - fetch_template_xml_format_omit_date_result.template_xml | regex_search('') is defined diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml new file mode 100644 index 00000000..88ccbe22 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml @@ -0,0 +1,1020 @@ +--- +# New user create test from here +- name: test - Create a new Zabbix user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: password + check_mode: yes + diff: yes + register: create_zabbix_user_result + +- assert: + that: + - create_zabbix_user_result.changed is sameas true + +- name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: password + register: create_zabbix_user_result + +- assert: + that: + - create_zabbix_user_result.changed is sameas true + +- name: test - Create a new Zabbix user(again) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: password + register: create_zabbix_user_result + +- assert: + that: + - not create_zabbix_user_result.changed is sameas true + +# Parameter add test from here to existing user +- name: test - Add user group to existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: password + register: add_usergroup_to_existing_user_result + +- assert: + that: + - add_usergroup_to_existing_user_result.changed is sameas true + +- name: test - Add user medias(Email) to existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: password + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + register: add_user_medias_to_existing_user_result + +- assert: + that: + - add_user_medias_to_existing_user_result.changed is sameas true + +- name: test - Add multiple user medias(Email and SMS) to existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: password + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: add_user_medias_to_existing_user_result + +- assert: + that: + - add_user_medias_to_existing_user_result.changed is sameas true + +# Existing parameter updates test from here +- name: test - Update password parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + override_passwd: yes + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_password_parameter_existing_user_result + +- assert: + that: + - update_password_parameter_existing_user_result.changed is sameas true + +- name: test - Update autologin parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologin: yes + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_autologin_parameter_existing_user_result + +- assert: + that: + - update_autologin_parameter_existing_user_result.changed is sameas true + +- name: test - Update autologout parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_autologout_parameter_existing_user_result + +- assert: + that: + - update_autologout_parameter_existing_user_result.changed is sameas true + +- name: test - Update refresh parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_refresh_parameter_existing_user_result + +- assert: + that: + - update_refresh_parameter_existing_user_result.changed is sameas true + +- name: test - Update rows_per_page parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_rows_per_page_parameter_existing_user_result + +- assert: + that: + - update_rows_per_page_parameter_existing_user_result.changed is sameas true + +- name: test - Update after_login_url parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_after_login_url_parameter_existing_user_result + +- assert: + that: + - update_after_login_url_parameter_existing_user_result.changed is sameas true + +- name: test - Update theme parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: "{{ item }}" + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + loop: + - blue-theme + - dark-theme + register: update_theme_parameter_existing_user_result + +- assert: + that: + - item.changed is sameas true + loop: "{{ update_theme_parameter_existing_user_result.results }}" + +- name: test - Update type parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: "{{ item }}" + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + loop: + - Zabbix admin + - Zabbix super admin + register: update_type_parameter_existing_user_result + +- assert: + that: + - item.changed is sameas true + loop: "{{ update_type_parameter_existing_user_result.results }}" + +- name: test - Update lang parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: Zabbix super admin + lang: en_US + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_lang_parameter_existing_user_result + +- assert: + that: + - update_lang_parameter_existing_user_result.changed is sameas true + +- name: test - Update name and surname parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: Zabbix super admin + lang: en_US + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_name_and_surname_parameter_existing_user_result + +- assert: + that: + - update_name_and_surname_parameter_existing_user_result.changed is sameas true + +- name: test - Update lang parameter for existing user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: Zabbix super admin + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + check_mode: yes + diff: yes + register: update_lang_parameter_existing_user_with_check_mode_diff_result + +- assert: + that: + - update_lang_parameter_existing_user_with_check_mode_diff_result.changed is sameas true + +- name: test - Update lang parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: Zabbix super admin + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_lang_parameter_existing_user_result + +- assert: + that: + - update_lang_parameter_existing_user_result.changed is sameas true + +- name: test - Update lang parameter for existing user(again) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: Zabbix super admin + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_lang_parameter_existing_user_result + +- assert: + that: + - not update_lang_parameter_existing_user_result.changed is sameas true + +# Parameter delete test from here from existing user +- name: test - Delete user medias(SMS) for existing user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: Zabbix super admin + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + check_mode: yes + diff: yes + register: delete_user_medias_existing_user_result + +- assert: + that: + - delete_user_medias_existing_user_result.changed is sameas true + +- name: test - Delete user medias(SMS) for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: Zabbix super admin + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + register: delete_user_medias_existing_user_result + +- assert: + that: + - delete_user_medias_existing_user_result.changed is sameas true + +- name: test - Delete user group for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: Zabbix super admin + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + register: delete_user_group_existing_user_result + +- assert: + that: + - delete_user_group_existing_user_result.changed is sameas true + +- name: test - optional user_medias + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + type: Zabbix super admin + lang: en_GB + register: update_user_optional_user_medias_existing_user_result + +- assert: + that: + - update_user_optional_user_medias_existing_user_result.changed is sameas False + +- name: test - Delete existing user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + state: absent + check_mode: yes + diff: yes + register: delete_existing_user_result + +- assert: + that: + - delete_existing_user_result.changed is sameas true + +- name: test - Delete existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + state: absent + register: delete_existing_user_result + +- assert: + that: + - delete_existing_user_result.changed is sameas true + +- name: test - Delete existing user(again) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + state: absent + register: delete_existing_user_result + +- assert: + that: + - not delete_existing_user_result.changed is sameas true + +- when: zabbix_version is version('4.0', '<') + block: + - name: test - Create new password-less user without LDAP group (fail, <4.0) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + name: example2 + surname: testldap + usrgrps: + - Guests + register: create_zabbix_user_ldap_fail + ignore_errors: True + + - assert: + that: + - create_zabbix_user_ldap_fail.failed is sameas True + +- when: zabbix_version is version('4.0', '>=') + block: + - name: test prepare - Create LDAP user group + zabbix_usergroup: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: testLDAPgrp + gui_access: LDAP + register: zbxuser_create_ldap_group + + - assert: + that: + - zbxuser_create_ldap_group.changed is sameas True + + - name: test - Create new password-less user without LDAP group (fail) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + name: example2 + surname: testldap + usrgrps: + - Guests + register: create_zabbix_user_ldap_fail + ignore_errors: True + + - assert: + that: + - create_zabbix_user_ldap_fail.failed is sameas True + + - name: test - Create new password-less user as member in LDAP group + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + name: example2 + surname: testldap + usrgrps: + - testLDAPgrp + register: create_zabbix_user_ldap_result + + - assert: + that: + - create_zabbix_user_ldap_result.changed is sameas True + + - name: test - Create new password-less user as member in LDAP group (again) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + name: example2 + surname: testldap + usrgrps: + - testLDAPgrp + register: create_zabbix_user_ldap_result + + - assert: + that: + - create_zabbix_user_ldap_result.changed is sameas False + + - name: test - Delete existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + state: absent + register: delete_existing_user_result + + - assert: + that: + - delete_existing_user_result.changed is sameas true diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_52_higher.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_52_higher.yml new file mode 100644 index 00000000..fbffa27f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_52_higher.yml @@ -0,0 +1,1077 @@ +--- +# New user create test from here +- name: test - Create a new Zabbix user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: password + check_mode: yes + diff: yes + register: create_zabbix_user_result + +- assert: + that: + - create_zabbix_user_result.changed is sameas true + +- name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: password + register: create_zabbix_user_result + +- assert: + that: + - create_zabbix_user_result.changed is sameas true + +- name: test - Create a new Zabbix user(again) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: password + register: create_zabbix_user_result + +- assert: + that: + - not create_zabbix_user_result.changed is sameas true + +# Parameter add test from here to existing user +- name: test - Add user group to existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: password + register: add_usergroup_to_existing_user_result + +- assert: + that: + - add_usergroup_to_existing_user_result.changed is sameas true + +- name: test - Add user medias(Email) to existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: password + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + register: add_user_medias_to_existing_user_result + +- assert: + that: + - add_user_medias_to_existing_user_result.changed is sameas true + +- name: test - Add multiple user medias(Email and SMS) to existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: password + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: add_user_medias_to_existing_user_result + +- assert: + that: + - add_user_medias_to_existing_user_result.changed is sameas true + +# Existing parameter updates test from here +- name: test - Update password parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + override_passwd: yes + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_password_parameter_existing_user_result + +- assert: + that: + - update_password_parameter_existing_user_result.changed is sameas true + +- name: test - Update autologin parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologin: yes + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_autologin_parameter_existing_user_result + +- assert: + that: + - update_autologin_parameter_existing_user_result.changed is sameas true + +- name: test - Update autologout parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_autologout_parameter_existing_user_result + +- assert: + that: + - update_autologout_parameter_existing_user_result.changed is sameas true + +- name: test - Update refresh parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_refresh_parameter_existing_user_result + +- assert: + that: + - update_refresh_parameter_existing_user_result.changed is sameas true + +- name: test - Update rows_per_page parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_rows_per_page_parameter_existing_user_result + +- assert: + that: + - update_rows_per_page_parameter_existing_user_result.changed is sameas true + +- name: test - Update after_login_url parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_after_login_url_parameter_existing_user_result + +- assert: + that: + - update_after_login_url_parameter_existing_user_result.changed is sameas true + +- name: test - Update theme parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: "{{ item }}" + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + loop: + - blue-theme + - dark-theme + register: update_theme_parameter_existing_user_result + +- assert: + that: + - item.changed is sameas true + loop: "{{ update_theme_parameter_existing_user_result.results }}" + +- name: test - Update role_name parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: "{{ item }}" + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + loop: + - Guest role + - Admin role + register: update_type_parameter_existing_user_result + +- assert: + that: + - item.changed is sameas true + loop: "{{ update_type_parameter_existing_user_result.results }}" + +- name: test - Update lang parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + lang: en_US + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_lang_parameter_existing_user_result + +- assert: + that: + - update_lang_parameter_existing_user_result.changed is sameas true + +- name: test - Update timezone parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_US + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_timezone_parameter_existing_user_result + +- assert: + that: + - update_timezone_parameter_existing_user_result.changed is sameas true + +- name: test - Update name and surname parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_US + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_name_and_surname_parameter_existing_user_result + +- assert: + that: + - update_name_and_surname_parameter_existing_user_result.changed is sameas true + +- name: test - Update lang parameter for existing user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + check_mode: yes + diff: yes + register: update_lang_parameter_existing_user_with_check_mode_diff_result + +- assert: + that: + - update_lang_parameter_existing_user_with_check_mode_diff_result.changed is sameas true + +- name: test - Update lang parameter for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_lang_parameter_existing_user_result + +- assert: + that: + - update_lang_parameter_existing_user_result.changed is sameas true + +- name: test - Update lang parameter for existing user(again) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + register: update_lang_parameter_existing_user_result + +- assert: + that: + - not update_lang_parameter_existing_user_result.changed is sameas true + +# Parameter delete test from here from existing user +- name: test - Delete user medias(SMS) for existing user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + check_mode: yes + diff: yes + register: delete_user_medias_existing_user_result + +- assert: + that: + - delete_user_medias_existing_user_result.changed is sameas true + +- name: test - Delete user medias(SMS) for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + register: delete_user_medias_existing_user_result + +- assert: + that: + - delete_user_medias_existing_user_result.changed is sameas true + +- name: test - Delete user group for existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + register: delete_user_group_existing_user_result + +- assert: + that: + - delete_user_group_existing_user_result.changed is sameas true + +- name: test - optional user_medias + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example2 + surname: test2 + usrgrps: + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_GB + register: update_user_optional_user_medias_existing_user_result + +- assert: + that: + - update_user_optional_user_medias_existing_user_result.changed is sameas False + +- name: test - Delete existing user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + state: absent + check_mode: yes + diff: yes + register: delete_existing_user_result + +- assert: + that: + - delete_existing_user_result.changed is sameas true + +- name: test - Delete existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + state: absent + register: delete_existing_user_result + +- assert: + that: + - delete_existing_user_result.changed is sameas true + +- name: test - Delete existing user(again) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + state: absent + register: delete_existing_user_result + +- assert: + that: + - not delete_existing_user_result.changed is sameas true + +- when: zabbix_version is version('4.0', '<') + block: + - name: test - Create new password-less user without LDAP group (fail, <4.0) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + name: example2 + surname: testldap + usrgrps: + - Guests + register: create_zabbix_user_ldap_fail + ignore_errors: True + + - assert: + that: + - create_zabbix_user_ldap_fail.failed is sameas True + +- when: zabbix_version is version('4.0', '>=') + block: + - name: test prepare - Create LDAP user group + zabbix_usergroup: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: testLDAPgrp + gui_access: LDAP + register: zbxuser_create_ldap_group + + - assert: + that: + - zbxuser_create_ldap_group.changed is sameas True + + - name: test - Create new password-less user without LDAP group (fail) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + name: example2 + surname: testldap + usrgrps: + - Guests + register: create_zabbix_user_ldap_fail + ignore_errors: True + + - assert: + that: + - create_zabbix_user_ldap_fail.failed is sameas True + + - name: test - Create new password-less user as member in LDAP group + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + name: example2 + surname: testldap + usrgrps: + - testLDAPgrp + register: create_zabbix_user_ldap_result + + - assert: + that: + - create_zabbix_user_ldap_result.changed is sameas True + + - name: test - Create new password-less user as member in LDAP group (again) + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + name: example2 + surname: testldap + usrgrps: + - testLDAPgrp + register: create_zabbix_user_ldap_result + + - assert: + that: + - create_zabbix_user_ldap_result.changed is sameas False + + - name: test - Delete existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + state: absent + register: delete_existing_user_result + + - assert: + that: + - delete_existing_user_result.changed is sameas true diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml new file mode 100644 index 00000000..298c9b46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- name: Execute the integration test for Zabbix 5.0 and lower + include_tasks: for_zabbix_50_lower.yml + when: + - zabbix_version | float <= 5.0 + +- name: Execute the integration test for Zabbix 5.2 and higher + include_tasks: for_zabbix_52_higher.yml + when: + - zabbix_version | float >= 5.2 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml new file mode 100644 index 00000000..90f4efe1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml @@ -0,0 +1,208 @@ +--- +# New user create test from here +- when: zabbix_version is version('5.2', '<') + block: + - name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example + name: user name + surname: user surname + usrgrps: + - Guests + - Disabled + passwd: password + lang: en_GB + theme: blue-theme + autologin: no + autologout: '0' + refresh: '30' + rows_per_page: '200' + after_login_url: '' + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: no + type: Zabbix super admin + state: present + register: create_zabbix_user_result + + - assert: + that: + - create_zabbix_user_result.changed is sameas true + + - name: test - Set definition_of_results variable of Zabbix 5.0 and lower + set_fact: + definition_of_results: + - get_user_info_result[user_info_key].alias == "example" + - get_user_info_result[user_info_key].autologin is defined + - get_user_info_result[user_info_key].autologout is defined + - get_user_info_result[user_info_key].lang is defined + - get_user_info_result[user_info_key].medias.0.active is defined + - get_user_info_result[user_info_key].medias.0.mediaid is defined + - get_user_info_result[user_info_key].medias.0.period is defined + - get_user_info_result[user_info_key].medias.0.sendto is defined + - get_user_info_result[user_info_key].medias.0.severity is defined + - get_user_info_result[user_info_key].medias.0.userid is defined + - get_user_info_result[user_info_key].name is defined + - get_user_info_result[user_info_key].refresh is defined + - get_user_info_result[user_info_key].rows_per_page is defined + - get_user_info_result[user_info_key].surname is defined + - get_user_info_result[user_info_key].theme is defined + - get_user_info_result[user_info_key].type is defined + - get_user_info_result[user_info_key].url is defined + - get_user_info_result[user_info_key].userid is defined + - get_user_info_result[user_info_key].users_status is defined + - get_user_info_result[user_info_key].usrgrps | length == 2 + - get_user_info_result[user_info_key].usrgrps.0.debug_mode is defined + - get_user_info_result[user_info_key].usrgrps.0.gui_access is defined + - get_user_info_result[user_info_key].usrgrps.0.name is defined + - get_user_info_result[user_info_key].usrgrps.0.users_status is defined + - get_user_info_result[user_info_key].usrgrps.0.usrgrpid is defined + - get_user_info_result[user_info_key].usrgrps.1.debug_mode is defined + - get_user_info_result[user_info_key].usrgrps.1.gui_access is defined + - get_user_info_result[user_info_key].usrgrps.1.name is defined + - get_user_info_result[user_info_key].usrgrps.1.users_status is defined + - get_user_info_result[user_info_key].usrgrps.1.usrgrpid is defined + +- when: zabbix_version is version('5.2', '>=') + block: + - name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example + name: user name + surname: user surname + usrgrps: + - Guests + - Disabled + passwd: password + lang: en_GB + theme: blue-theme + autologin: no + autologout: '0' + refresh: '30' + rows_per_page: '200' + after_login_url: '' + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: no + role_name: Super admin role + timezone: Asia/Tokyo + state: present + register: create_zabbix_user_result + + - assert: + that: + - create_zabbix_user_result.changed is sameas true + + - name: test - Set definition_of_results variable of Zabbix 5.2 and higher + set_fact: + definition_of_results: + - get_user_info_result[user_info_key].alias == "example" + - get_user_info_result[user_info_key].autologin is defined + - get_user_info_result[user_info_key].autologout is defined + - get_user_info_result[user_info_key].lang is defined + - get_user_info_result[user_info_key].medias.0.active is defined + - get_user_info_result[user_info_key].medias.0.mediaid is defined + - get_user_info_result[user_info_key].medias.0.period is defined + - get_user_info_result[user_info_key].medias.0.sendto is defined + - get_user_info_result[user_info_key].medias.0.severity is defined + - get_user_info_result[user_info_key].medias.0.userid is defined + - get_user_info_result[user_info_key].name is defined + - get_user_info_result[user_info_key].refresh is defined + - get_user_info_result[user_info_key].rows_per_page is defined + - get_user_info_result[user_info_key].surname is defined + - get_user_info_result[user_info_key].theme is defined + - get_user_info_result[user_info_key].roleid is defined + - get_user_info_result[user_info_key].url is defined + - get_user_info_result[user_info_key].userid is defined + - get_user_info_result[user_info_key].users_status is defined + - get_user_info_result[user_info_key].timezone is defined + - get_user_info_result[user_info_key].usrgrps | length == 2 + - get_user_info_result[user_info_key].usrgrps.0.debug_mode is defined + - get_user_info_result[user_info_key].usrgrps.0.gui_access is defined + - get_user_info_result[user_info_key].usrgrps.0.name is defined + - get_user_info_result[user_info_key].usrgrps.0.users_status is defined + - get_user_info_result[user_info_key].usrgrps.0.usrgrpid is defined + - get_user_info_result[user_info_key].usrgrps.1.debug_mode is defined + - get_user_info_result[user_info_key].usrgrps.1.gui_access is defined + - get_user_info_result[user_info_key].usrgrps.1.name is defined + - get_user_info_result[user_info_key].usrgrps.1.users_status is defined + - get_user_info_result[user_info_key].usrgrps.1.usrgrpid is defined + +- name: "test - Get a zabbix user information" + zabbix_user_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example + register: get_user_info_result + +- name: "test - Set key to user_info_key variable(This deals with the key being masked)" + set_fact: + user_info_key: "{{ item }}" + loop: "{{ get_user_info_result.keys() | list }}" + when: + - item | regex_search('_user') + +- assert: + that: definition_of_results + + +- name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2 + usrgrps: + - Guests + - Disabled + passwd: password + state: present + register: create_zabbix_user_result2 + +- assert: + that: + - create_zabbix_user_result2.changed is sameas true + +- name: "test - Get a zabbix user information" + zabbix_user_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2 + register: get_user_info_result2 + +- name: "test - Set key to user_info_key variable(This deals with the key being masked)" + set_fact: + user_info_key: "{{ item }}" + loop: "{{ get_user_info_result2.keys() | list }}" + when: + - item | regex_search('_user') + +- assert: + that: + - get_user_info_result2[user_info_key].alias == "example2" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml new file mode 100644 index 00000000..5e783301 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml @@ -0,0 +1,138 @@ +--- +- name: test - do not run tests for Zabbix 3.0 + meta: end_play + when: zabbix_version is version('3.0', '=') + +- name: test - Zabbix user group + module_defaults: + zabbix_usergroup: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ACME + + block: + - name: test - create new Zabbix user group + zabbix_usergroup: + state: present + register: usergroup_new + + - name: assert that user group was created + assert: + that: usergroup_new is changed + + - name: test - create new Zabbix user group (again) + zabbix_usergroup: + state: present + register: usergroup_again + + - name: assert that user group was created + assert: + that: not usergroup_again is changed + + - name: test - update Zabbix user group with disabled gui_access + zabbix_usergroup: + gui_access: disable + register: usergroup_updated + + - name: assert that user group was updated + assert: + that: usergroup_updated is changed + + - name: test - update Zabbix user group with disabled gui_access (again) + zabbix_usergroup: + gui_access: disable + register: usergroup_updated_again + + - name: assert that user group was updated + assert: + that: not usergroup_updated_again is changed + + - name: test - reset Zabbix user group to default + zabbix_usergroup: + register: usergroup_reset + + - name: assert that user group was created + assert: + that: usergroup_reset is changed + + - name: test - update Zabbix user group with one right + zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + register: usergroup_updated_right + + - name: assert that user group was updated + assert: + that: usergroup_updated_right is changed + + - name: test - update Zabbix user group with multiple rights + zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_rights + + - name: assert that user group was updated + assert: + that: usergroup_updated_rights is changed + + - name: test - update Zabbix user group with multiple rights (again) + zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_rights_again + + - name: assert that user group was not updated + assert: + that: not usergroup_updated_rights_again is changed + + - name: test - reset Zabbix user group to default + zabbix_usergroup: + register: usergroup_reset + + - name: assert that user group was created + assert: + that: usergroup_reset is changed + + - name: test - update Zabbix user group with one tag_filter + zabbix_usergroup: + tag_filters: + - host_group: Discovered hosts + tag: Service + value: JIRA + register: usergroup_updated_tag_filter + + - name: assert that user group was updated + assert: + that: usergroup_updated_tag_filter is changed + + - name: test - update Zabbix user group with multiple tag_filters + zabbix_usergroup: + tag_filters: + - host_group: Discovered hosts + tag: Service + value: JIRA + - host_group: Discovered hosts + tag: Service + value: Zabbix + register: usergroup_updated_tag_filters + + - name: assert that user group was updated + assert: + that: usergroup_updated_tag_filters is changed + + - name: test - delete Zabbix user group + zabbix_usergroup: + state: absent + register: usergroup_delete + + - name: assert that Zabbix user group has been deleted + assert: + that: usergroup_delete is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.10.txt new file mode 100644 index 00000000..280617e4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.10.txt @@ -0,0 +1,48 @@ +scripts/inventory/zabbix.py future-import-boilerplate +scripts/inventory/zabbix.py metaclass-boilerplate +plugins/modules/zabbix_action.py validate-modules:doc-choices-do-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-default-does-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_action.py validate-modules:doc-required-mismatch +plugins/modules/zabbix_action.py validate-modules:invalid-argument-name +plugins/modules/zabbix_action.py validate-modules:missing-suboption-docs +plugins/modules/zabbix_action.py validate-modules:nonexistent-parameter-documented +plugins/modules/zabbix_action.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_action.py validate-modules:parameter-type-not-in-doc +plugins/modules/zabbix_action.py validate-modules:undocumented-parameter +plugins/modules/zabbix_group.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_group_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_maintenance.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_maintenance.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_mediatype.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_mediatype.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_template.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_template.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_user.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_user.py validate-modules:parameter-list-no-elements +plugins/doc_fragments/zabbix.py future-import-boilerplate +plugins/doc_fragments/zabbix.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py future-import-boilerplate +molecule/zabbix_javagateway/tests/test_default.py metaclass-boilerplate +molecule/zabbix_javagateway/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent2.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent.py future-import-boilerplate +molecule/zabbix_agent/tests/test_docker.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent2.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_docker.py metaclass-boilerplate +molecule/zabbix_proxy/tests/test_default.py future-import-boilerplate +molecule/zabbix_proxy/tests/test_default.py metaclass-boilerplate \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.11.txt b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.11.txt new file mode 100644 index 00000000..36d703a9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.11.txt @@ -0,0 +1,48 @@ +scripts/inventory/zabbix.py future-import-boilerplate +scripts/inventory/zabbix.py metaclass-boilerplate +plugins/modules/zabbix_action.py validate-modules:doc-choices-do-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-default-does-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_action.py validate-modules:doc-required-mismatch +plugins/modules/zabbix_action.py validate-modules:invalid-argument-name +plugins/modules/zabbix_action.py validate-modules:missing-suboption-docs +plugins/modules/zabbix_action.py validate-modules:nonexistent-parameter-documented +plugins/modules/zabbix_action.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_action.py validate-modules:parameter-type-not-in-doc +plugins/modules/zabbix_action.py validate-modules:undocumented-parameter +plugins/modules/zabbix_group.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_group_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_maintenance.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_maintenance.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_mediatype.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_mediatype.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_template.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_template.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_user.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_user.py validate-modules:parameter-list-no-elements +plugins/doc_fragments/zabbix.py future-import-boilerplate +plugins/doc_fragments/zabbix.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py future-import-boilerplate +molecule/zabbix_web/tests/test_default.py metaclass-boilerplate +molecule/zabbix_javagateway/tests/test_default.py metaclass-boilerplate +molecule/zabbix_javagateway/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent2.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent.py future-import-boilerplate +molecule/zabbix_agent/tests/test_docker.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent2.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_docker.py metaclass-boilerplate +molecule/zabbix_proxy/tests/test_default.py future-import-boilerplate +molecule/zabbix_proxy/tests/test_default.py metaclass-boilerplate \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.9.txt b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.9.txt new file mode 100644 index 00000000..f61953e5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.9.txt @@ -0,0 +1,48 @@ +scripts/inventory/zabbix.py future-import-boilerplate +scripts/inventory/zabbix.py metaclass-boilerplate +plugins/modules/zabbix_action.py validate-modules:doc-choices-do-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-default-does-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_action.py validate-modules:doc-required-mismatch +plugins/modules/zabbix_action.py validate-modules:invalid-argument-name +plugins/modules/zabbix_action.py validate-modules:missing-suboption-docs +plugins/modules/zabbix_action.py validate-modules:nonexistent-parameter-documented +plugins/modules/zabbix_action.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_action.py validate-modules:parameter-type-not-in-doc +plugins/modules/zabbix_action.py validate-modules:undocumented-parameter +plugins/modules/zabbix_group.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_group_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_maintenance.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_maintenance.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_mediatype.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_mediatype.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_template.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_template.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_user.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_user.py validate-modules:parameter-list-no-elements +plugins/doc_fragments/zabbix.py future-import-boilerplate +plugins/doc_fragments/zabbix.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py future-import-boilerplate +molecule/zabbix_javagateway/tests/test_default.py future-import-boilerplate +molecule/zabbix_javagateway/tests/test_default.py metaclass-boilerplate +molecule/zabbix_server/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent2.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent.py future-import-boilerplate +molecule/zabbix_agent/tests/test_docker.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent2.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_docker.py metaclass-boilerplate +molecule/zabbix_proxy/tests/test_default.py metaclass-boilerplate +molecule/zabbix_proxy/tests/test_default.py future-import-boilerplate \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/requirements.txt b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/requirements.txt new file mode 100644 index 00000000..3e3a9669 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/requirements.txt @@ -0,0 +1,4 @@ +packaging # needed for update-bundled and changelog +sphinx ; python_version >= '3.5' # docs build requires python 3+ +sphinx-notfound-page ; python_version >= '3.5' # docs build requires python 3+ +straight.plugin ; python_version >= '3.5' # needed for hacking/build-ansible.py which will host changelog generation and requires python 3+ diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tox.ini b/collections-debian-merged/ansible_collections/community/zabbix/tox.ini new file mode 100644 index 00000000..5c6c33ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tox.ini @@ -0,0 +1,39 @@ +[tox] +minversion = 1.4.2 +envlist = linters +skipsdist = True + +[testenv] +#deps = -r{toxinidir}/requirements.txt +# -r{toxinidir}/test-requirements.txt + +[testenv:venv] +# This env is used to push new release on Galaxy +install_command = pip install {opts} {packages} +deps = ansible +commands = {posargs} + +[testenv:linters-py2] +install_command = pip install {opts} {packages} +deps = + flake8 +commands = + flake8 plugins {posargs} + +[testenv:linters-py3] +install_command = pip install {opts} {packages} +deps = + flake8 + antsibull-changelog +commands = + flake8 plugins {posargs} + antsibull-changelog lint + +[flake8] +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125,E402,E501,E741,W503 +max-line-length = 160 +builtins = _ +exclude = .git,.tox,tests/unit/compat/ -- cgit v1.2.3