diff options
Diffstat (limited to '')
85 files changed, 2478 insertions, 1101 deletions
diff --git a/ansible_collections/community/zabbix/.github/workflows/agent.yml b/ansible_collections/community/zabbix/.github/workflows/agent.yml index ca04f5843..55b7e1b72 100644 --- a/ansible_collections/community/zabbix/.github/workflows/agent.yml +++ b/ansible_collections/community/zabbix/.github/workflows/agent.yml @@ -29,9 +29,9 @@ jobs: - debian11 - debian10 version: - - v64 - - v62 - - v60 + - v64 + - v62 + - v60 scenario_name: - default - autopsk @@ -46,7 +46,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.9 @@ -60,11 +60,19 @@ jobs: - name: Build the collection run: | + # Pin versions to speed up CI + sed -i 's/ansible\.windows:\s*"\*"/ansible.windows: "2.3.0"/' galaxy.yml + sed -i 's/ansible\.netcommon:\s*"\*"/ansible.netcommon: "6.1.1"/' galaxy.yml + sed -i 's/ansible\.posix:\s*"\*"/ansible.posix: "1.5.4"/' galaxy.yml + sed -i 's/community\.general:\s*"\*"/community.general: "8.6.0"/' galaxy.yml + sed -i 's/community\.mysql:\s*"\*"/community.mysql: "3.9.0"/' galaxy.yml + sed -i 's/community\.postgresql:\s*"\*"/community.postgresql: "3.4.0"/' galaxy.yml + 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 + run: ansible-galaxy collection install -vvvv $COLLECTION_FILE - name: Run role tests working-directory: molecule/zabbix_agent_tests @@ -73,4 +81,4 @@ jobs: MY_MOLECULE_IMAGE=${{ matrix.container }} MY_MOLECULE_VERSION=${{ matrix.version }} MY_MOLECULE_DOCKER_COMMAND=${{ matrix.command }} - molecule -c common/molecule.yml test -s ${{ matrix.scenario_name }}
\ No newline at end of file + molecule -c common/molecule.yml test -s ${{ matrix.scenario_name }} diff --git a/ansible_collections/community/zabbix/.github/workflows/javagateway.yml b/ansible_collections/community/zabbix/.github/workflows/javagateway.yml index bd6885ef7..22bc5ede1 100644 --- a/ansible_collections/community/zabbix/.github/workflows/javagateway.yml +++ b/ansible_collections/community/zabbix/.github/workflows/javagateway.yml @@ -47,7 +47,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.9 @@ -58,11 +58,19 @@ jobs: - name: Build the collection run: | + # Pin versions to speed up CI + sed -i 's/ansible\.windows:\s*"\*"/ansible.windows: "2.3.0"/' galaxy.yml + sed -i 's/ansible\.netcommon:\s*"\*"/ansible.netcommon: "6.1.1"/' galaxy.yml + sed -i 's/ansible\.posix:\s*"\*"/ansible.posix: "1.5.4"/' galaxy.yml + sed -i 's/community\.general:\s*"\*"/community.general: "8.6.0"/' galaxy.yml + sed -i 's/community\.mysql:\s*"\*"/community.mysql: "3.9.0"/' galaxy.yml + sed -i 's/community\.postgresql:\s*"\*"/community.postgresql: "3.4.0"/' galaxy.yml + 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 + run: ansible-galaxy collection install -vvvv $COLLECTION_FILE - name: Run server role tests run: >- diff --git a/ansible_collections/community/zabbix/.github/workflows/plugins-integration.yml b/ansible_collections/community/zabbix/.github/workflows/plugins-integration.yml index f23071a1b..644ba2ca3 100644 --- a/ansible_collections/community/zabbix/.github/workflows/plugins-integration.yml +++ b/ansible_collections/community/zabbix/.github/workflows/plugins-integration.yml @@ -41,7 +41,7 @@ jobs: path: ansible_collections/community/zabbix - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} diff --git a/ansible_collections/community/zabbix/.github/workflows/proxy.yml b/ansible_collections/community/zabbix/.github/workflows/proxy.yml index 985bb8ceb..ad5f61b34 100644 --- a/ansible_collections/community/zabbix/.github/workflows/proxy.yml +++ b/ansible_collections/community/zabbix/.github/workflows/proxy.yml @@ -51,7 +51,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.9 @@ -62,11 +62,19 @@ jobs: - name: Build the collection run: | + # Pin versions to speed up CI + sed -i 's/ansible\.windows:\s*"\*"/ansible.windows: "2.3.0"/' galaxy.yml + sed -i 's/ansible\.netcommon:\s*"\*"/ansible.netcommon: "6.1.1"/' galaxy.yml + sed -i 's/ansible\.posix:\s*"\*"/ansible.posix: "1.5.4"/' galaxy.yml + sed -i 's/community\.general:\s*"\*"/community.general: "8.6.0"/' galaxy.yml + sed -i 's/community\.mysql:\s*"\*"/community.mysql: "3.9.0"/' galaxy.yml + sed -i 's/community\.postgresql:\s*"\*"/community.postgresql: "3.4.0"/' galaxy.yml + 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 + run: ansible-galaxy collection install -vvvv $COLLECTION_FILE - name: Run role tests run: >- diff --git a/ansible_collections/community/zabbix/.github/workflows/repo-sanity.yml b/ansible_collections/community/zabbix/.github/workflows/repo-sanity.yml index 499d2f1ae..ba776e54f 100644 --- a/ansible_collections/community/zabbix/.github/workflows/repo-sanity.yml +++ b/ansible_collections/community/zabbix/.github/workflows/repo-sanity.yml @@ -19,7 +19,7 @@ jobs: path: ansible_collections/community/zabbix - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} diff --git a/ansible_collections/community/zabbix/.github/workflows/server.yml b/ansible_collections/community/zabbix/.github/workflows/server.yml index b169aa9f1..33f5cd5fd 100644 --- a/ansible_collections/community/zabbix/.github/workflows/server.yml +++ b/ansible_collections/community/zabbix/.github/workflows/server.yml @@ -55,7 +55,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.9 @@ -66,11 +66,19 @@ jobs: - name: Build the collection run: | + # Pin versions to speed up CI + sed -i 's/ansible\.windows:\s*"\*"/ansible.windows: "2.3.0"/' galaxy.yml + sed -i 's/ansible\.netcommon:\s*"\*"/ansible.netcommon: "6.1.1"/' galaxy.yml + sed -i 's/ansible\.posix:\s*"\*"/ansible.posix: "1.5.4"/' galaxy.yml + sed -i 's/community\.general:\s*"\*"/community.general: "8.6.0"/' galaxy.yml + sed -i 's/community\.mysql:\s*"\*"/community.mysql: "3.9.0"/' galaxy.yml + sed -i 's/community\.postgresql:\s*"\*"/community.postgresql: "3.4.0"/' galaxy.yml + 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 + run: ansible-galaxy collection install -vvvv $COLLECTION_FILE - name: Run server role tests run: >- diff --git a/ansible_collections/community/zabbix/.github/workflows/web.yml b/ansible_collections/community/zabbix/.github/workflows/web.yml index 79b7beb11..0541a2457 100644 --- a/ansible_collections/community/zabbix/.github/workflows/web.yml +++ b/ansible_collections/community/zabbix/.github/workflows/web.yml @@ -57,7 +57,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.9 @@ -68,11 +68,19 @@ jobs: - name: Build the collection run: | + # Pin versions to speed up CI + sed -i 's/ansible\.windows:\s*"\*"/ansible.windows: "2.3.0"/' galaxy.yml + sed -i 's/ansible\.netcommon:\s*"\*"/ansible.netcommon: "6.1.1"/' galaxy.yml + sed -i 's/ansible\.posix:\s*"\*"/ansible.posix: "1.5.4"/' galaxy.yml + sed -i 's/community\.general:\s*"\*"/community.general: "8.6.0"/' galaxy.yml + sed -i 's/community\.mysql:\s*"\*"/community.mysql: "3.9.0"/' galaxy.yml + sed -i 's/community\.postgresql:\s*"\*"/community.postgresql: "3.4.0"/' galaxy.yml + 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 + run: ansible-galaxy collection install -vvvv $COLLECTION_FILE - name: Run role tests run: >- diff --git a/ansible_collections/community/zabbix/CHANGELOG.rst b/ansible_collections/community/zabbix/CHANGELOG.rst index e6b53e476..4675d1a5a 100644 --- a/ansible_collections/community/zabbix/CHANGELOG.rst +++ b/ansible_collections/community/zabbix/CHANGELOG.rst @@ -4,6 +4,42 @@ community.zabbix Release Notes .. contents:: Topics +v2.4.0 +====== + +Minor Changes +------------- + +- Add slash at the end of the location directives, to prevent path traversal attacks. +- Added active_since and active_till in zabbix_maintenance +- Added content_type for email in zabbix_mediatypes +- Introduce flag `enable_version_check` to allow installations on non-supported platforms. +- agent, javagateway, proxy, server, and web role - added the http_proxy and https_proxy environment variables to "Debian | Download gpg key" analog to other tasks +- agent, javagateway, proxy, server, and web role - introduced default variable zabbix_repo_deb_gpg_key_url with value http://repo.zabbix.com/zabbix-official-repo.key +- agent, javagateway, proxy, server, and web role - introduced default variable zabbix_repo_deb_include_deb_src with value true +- agent, javagateway, proxy, server, and web role - removed superfluous slash in zabbix_gpg_key of the Debian vars and renamed key to zabbix-repo instead of zabbix-official-repo +- agent, javagateway, proxy, server, and web role - used variable zabbix_repo_deb_include_deb_src in "Debian | Installing repository" to determine whether deb-src should be added to /etc/apt/sources.list.d/zabbix.sources +- agent, javagateway, proxy, server, and web role - used zabbix_repo_deb_gpg_key_url in "Debian | Download gpg key" instead of hardcoded url +- zabbix_correlation module added +- zabbix_service_info module added +- zabbix_template - Add template_yaml parameter. +- zabbix_web role, Refactored zabbix_selinux variable names to correlate with selinux boolean names. + +Bugfixes +-------- + +- zabbix_agent - Fixed IPMI authentication algorithm default setting +- zabbix_agent - Fixed issue to where scripts can be deployed alongside userparameters +- zabbix_host - Don't reset IPMI setting when update inventory data of a host +- zabbix_host - Finish task with failed if host_group parameter is empty list +- zabbix_server - proper indentaion of become in selinux.yaml +- zabbix_web - Added missing semicolon to nginx vhost template. +- zabbix_web role, Add missing selinux.yml tasks. + +New Modules +----------- + +- community.zabbix.zabbix_correlation - Create/update/delete Zabbix correlation v2.3.1 ====== @@ -598,7 +634,6 @@ Release Summary | Release date: 2020-10-22 - Minor Changes ------------- @@ -625,7 +660,6 @@ Release Summary | Release date: 2020-08-16 - Minor Changes ------------- @@ -665,7 +699,6 @@ Release Summary | Release date: 2020-07-26 - Minor Changes ------------- @@ -738,7 +771,6 @@ Release Summary | Release date: 2020-06-15 - Minor Changes ------------- diff --git a/ansible_collections/community/zabbix/FILES.json b/ansible_collections/community/zabbix/FILES.json index d8e8b2611..694f37957 100644 --- a/ansible_collections/community/zabbix/FILES.json +++ b/ansible_collections/community/zabbix/FILES.json @@ -46,49 +46,49 @@ "name": ".github/workflows/agent.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1f4eaa1cf578bb1ac84173e292873c14483a3e9b0218badf5f99b949b1d19f75", + "chksum_sha256": "ab09e77c1cfb09d0ead5281bcfcd6cfb54d6eaa8380affbd53ec47c38c577855", "format": 1 }, { "name": ".github/workflows/javagateway.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "282c567de319fd40b888e0bea2b8340418acaf3e1360b1f4cd2fcec845580c4d", + "chksum_sha256": "5fece5724408d5a2170a22b1fdedf601451248c723f84066b7d1076dff06dbec", "format": 1 }, { "name": ".github/workflows/plugins-integration.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c8ab5f2a2482938905571a63bc80edb9bc421a7356526adff54978f158c998be", + "chksum_sha256": "45f764928578ae0ce15106c9470a6c9de97871904086e379b1f0fdd9d9008652", "format": 1 }, { "name": ".github/workflows/proxy.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "0b93f36762cb804aa12a46d2e15ec2b0cf4ec61198db451fb5e8d60601c4e2c7", + "chksum_sha256": "f21f654a95b514e188c7cc090b21685521112a90610fef14bc487301141b17af", "format": 1 }, { "name": ".github/workflows/repo-sanity.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "7df59ea87533f81dea79e8869b8a4074e0caafa171b62d07d24fc53ae4447af2", + "chksum_sha256": "d422174bd05376e9615660ed1f3d25d6c70cbda68a4869854d468469a562da93", "format": 1 }, { "name": ".github/workflows/server.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "20f9e0d9de9e0b5fba678c672628e0bf2900794a61e7a9b4414e16dd10eda3b3", + "chksum_sha256": "1925557e00452541d0105523033dba1edd9e3ee8ca95b3373c006c1f96973380", "format": 1 }, { "name": ".github/workflows/web.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c5e042f11aeabebedb326853b6a5712c3ef02fbc884329b26c4b38d3d942861a", + "chksum_sha256": "b8665c7b983f6b76cba7da881ab0cd450439217a5bd519ae7f30933a3ded554a", "format": 1 }, { @@ -116,14 +116,14 @@ "name": "changelogs/.plugin-cache.yaml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d64872f24dbd6423bc177cc30e44f48f8f2c008fb83d98320c86507e52bc4fd2", + "chksum_sha256": "ddbed2431f771d0b08ec1059fcfc03df63768d78c59488ffadfddae737f52028", "format": 1 }, { "name": "changelogs/changelog.yaml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "7ec8214d899a562092105e8650db5a80d38065ac6f21e8eba77ce6b31c1be9b9", + "chksum_sha256": "25653a4be548f83eb8db9059d833a8298cc278f4ff812ff3b79abaa9fcb63f1e", "format": 1 }, { @@ -158,35 +158,35 @@ "name": "docs/ZABBIX_AGENT_ROLE.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "426cdb2833f6b41fae8e6d3eceb45e5d7e53bb64fda20238a4843e1f23ce6bc5", + "chksum_sha256": "d256f34122a50d20bf5d074df98558de74774e591bb2bc309e858ab0f2c7a7b8", "format": 1 }, { "name": "docs/ZABBIX_JAVAGATEWAY_ROLE.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "950880306b5d99f842830620bcb03e3a67d487ab62b60c650421027b620824c9", + "chksum_sha256": "168aae7236576e4baf77c7b056833d5c90527c99365d7c9487f05f7af4d7281a", "format": 1 }, { "name": "docs/ZABBIX_PROXY_ROLE.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "137aa537b0643a8aba1e3b94965bd33d91a53a780a8873a398e07620a1c64ec4", + "chksum_sha256": "5fb7298372379197055d9221660fa37ec078d7b2c5aaa4545ed09a943daa7baf", "format": 1 }, { "name": "docs/ZABBIX_SERVER_ROLE.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "434d9e12ff1d20c7f2e1891e2518628eea9f8497502a5032a7f83ea488477665", + "chksum_sha256": "e7b83a2f01c4ef1388cba62476dbbe0596c483b345f4a79aabc2cd107cf16b61", "format": 1 }, { "name": "docs/ZABBIX_WEB_ROLE.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "228030e059e30b229a82e7c31b609d5d122d710338557ebd74ee151eda79c0fb", + "chksum_sha256": "c52def2249d4416ac228eb03d6b57322578e2fb5c118967fb1e11634ff66f64f", "format": 1 }, { @@ -242,7 +242,7 @@ "name": "molecule/zabbix_agent_tests/common/playbooks/prepare.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "eebc4f8c272317fba0f96c482780a2850b9474b2b992b3a80d2f3d59c3db9a52", + "chksum_sha256": "b49c8f28d430ffbe38f9a37995b5e555935108553a8cdfc624d31622a17ad7d8", "format": 1 }, { @@ -543,7 +543,7 @@ "name": "molecule/zabbix_javagateway/molecule.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "8e5003cb9d8bcd490b46fe8358affc9cc4c7f60b582c2f42a4713c7fd001768a", + "chksum_sha256": "ad23fd87f26a7f5f70b7dbbb1e82fe661052315c2b8ad0f09939d5542641a521", "format": 1 }, { @@ -585,21 +585,21 @@ "name": "molecule/zabbix_proxy/destroy.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "99cb34a22f36b18227686720c750aa70745fdd22227d5aeb08a42891998ac09a", + "chksum_sha256": "59749010b09c0790699ca54ddb18724640889b53363b8c8d3fbc8259ec9d57c7", "format": 1 }, { "name": "molecule/zabbix_proxy/molecule.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "59ff07c357b6c9d01f0337b6c6b5878c90efb396132faec46b37628680bce34d", + "chksum_sha256": "4800b75f49e7496f80ace71d84f8f07dc7b9335c8f158bc4155c44a8d8492cc1", "format": 1 }, { "name": "molecule/zabbix_proxy/prepare.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d3fde6e25ce3b39d5c70324f7db1ac9aed31e0a3106c51dc77c3be7293f55a19", + "chksum_sha256": "4495bcd19fac7b44c8d02c80133e37f554c1f66244a10c4a88e85c11ce97b814", "format": 1 }, { @@ -634,21 +634,21 @@ "name": "molecule/zabbix_server/destroy.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "99cb34a22f36b18227686720c750aa70745fdd22227d5aeb08a42891998ac09a", + "chksum_sha256": "59749010b09c0790699ca54ddb18724640889b53363b8c8d3fbc8259ec9d57c7", "format": 1 }, { "name": "molecule/zabbix_server/molecule.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "eb8ff715881d9046a2aa6d4b0ec64f68c59e7cf48bff7644236e44399570bb53", + "chksum_sha256": "7c0b54e3f4f40288f5a772263d1f56a44aebb39e70aad6ec542546b40d7653a9", "format": 1 }, { "name": "molecule/zabbix_server/prepare.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "34346df48a4e44910398adcea6030e76735f03464ea0b0415160b2c8b86297d7", + "chksum_sha256": "883f99742d21dc27b93d8c8ca8185537a7e7c1c658efd81effdce91e5f8eefee", "format": 1 }, { @@ -683,21 +683,21 @@ "name": "molecule/zabbix_web/destroy.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "99cb34a22f36b18227686720c750aa70745fdd22227d5aeb08a42891998ac09a", + "chksum_sha256": "59749010b09c0790699ca54ddb18724640889b53363b8c8d3fbc8259ec9d57c7", "format": 1 }, { "name": "molecule/zabbix_web/molecule.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "160ca8984b2f48f84e64e2d928ef1ab8a807f5cfb6c36d1c37d7920ca284efca", + "chksum_sha256": "18e071b47e76db950db04d6be9ed3e6e16ab750ca276e4e59d1f32cf0c659b89", "format": 1 }, { "name": "molecule/zabbix_web/prepare.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "46f227d436fbf62c6a18677746e4b3b2f6854473ea58ea889781d60a5d86acaa", + "chksum_sha256": "7628246084a0692187d2408ee30afc478999d24c1e08d6fc0609f59ed828b23e", "format": 1 }, { @@ -711,7 +711,7 @@ "name": "molecule/requirements.txt", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "274a2a68c3bac9fefa051ff068179fce63df05424461ff973dd44473c890382b", + "chksum_sha256": "26a9987c8545a84ddf26c2774fc1bf16c0dc68fa790dde49b46ce17a1720700e", "format": 1 }, { @@ -746,7 +746,7 @@ "name": "plugins/httpapi/zabbix.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "bef450e3b5700be1a1cc35981b229a53522a35a0e1d13f1ba715922f3ee79d2c", + "chksum_sha256": "d598e1db3a57dda9a90eaf324c066be904c91a5bab099b6c65d612b5141c96ec", "format": 1 }, { @@ -848,6 +848,13 @@ "format": 1 }, { + "name": "plugins/modules/zabbix_correlation.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "24dfd5a7cb774a9e46de4765efcacf76df880149f7a5614f64c754f8458875ee", + "format": 1 + }, + { "name": "plugins/modules/zabbix_discovery_rule.py", "ftype": "file", "chksum_type": "sha256", @@ -886,7 +893,7 @@ "name": "plugins/modules/zabbix_host.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "ce0879953bfeaac236d6329b08fd19f7573a9a172ef4fa777489d6f9f1fd6609", + "chksum_sha256": "0593dcc5f865688ab3ee51ab930d963bb688970807a0f4b3b67466bb58672481", "format": 1 }, { @@ -921,7 +928,7 @@ "name": "plugins/modules/zabbix_maintenance.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "baa73f10a75adbfc09a93d5624492aa9b2e174bf089641cfbd37e329865fe313", + "chksum_sha256": "ae2e78fa730c2954ad54c20aa7c98c3e09c077fc035f45d0f7ce906d4ce93b84", "format": 1 }, { @@ -935,7 +942,7 @@ "name": "plugins/modules/zabbix_mediatype.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "555d924fcf31e673c17917fc5f7abf1d6d8f1de17d87386f5a2626549cdab7f3", + "chksum_sha256": "d72dc3a2fc07e6ae4ddd344d3111a62098439a21d3e77f235f89783490db4644", "format": 1 }, { @@ -974,6 +981,13 @@ "format": 1 }, { + "name": "plugins/modules/zabbix_service_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5e011d9a0a3e1a15d2b1255c90989143c24be78e433351483afb0191ed7009fe", + "format": 1 + }, + { "name": "plugins/modules/zabbix_settings.py", "ftype": "file", "chksum_type": "sha256", @@ -984,7 +998,7 @@ "name": "plugins/modules/zabbix_template.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d08d3ff4e10193b5a69e3bb515c1ee00157526ab702dc4ffadca8b4adb1c2b1c", + "chksum_sha256": "9a95177cd5e385dc637bef839f94ddafbad1fd7c49b3d66f1a6a04734ef178ce", "format": 1 }, { @@ -998,7 +1012,7 @@ "name": "plugins/modules/zabbix_templategroup.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "9c8ca31207e2894422502cf15cf3e3774ce2f944e4bc403c87ab5978f360b236", + "chksum_sha256": "1d908eaf6a6ef5f9269261f3c9be63180edd805736428b95365d2cffbd94785a", "format": 1 }, { @@ -1068,7 +1082,7 @@ "name": "roles/zabbix_agent/README.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "426cdb2833f6b41fae8e6d3eceb45e5d7e53bb64fda20238a4843e1f23ce6bc5", + "chksum_sha256": "d256f34122a50d20bf5d074df98558de74774e591bb2bc309e858ab0f2c7a7b8", "format": 1 }, { @@ -1082,7 +1096,7 @@ "name": "roles/zabbix_agent/defaults/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "e86a6de88e4fb31fd47d9268557e10f71e42988e4dca09a6228497be99c1c225", + "chksum_sha256": "7465f741a1390bc62b1f30f3daf28f271ad94942c2f727fabfe576277fd4c1f3", "format": 1 }, { @@ -1208,7 +1222,7 @@ "name": "roles/zabbix_agent/molecule/with-server/prepare.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "091c8043ef580658ab2b4c93020888562cd5b3ca5a32d78f7c43892696e0f118", + "chksum_sha256": "00649fa33818851871f0305372c4d9c1205a77411b0b9b5deb1b5bfe4e09668d", "format": 1 }, { @@ -1229,7 +1243,7 @@ "name": "roles/zabbix_agent/tasks/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "6d5e5886e18c5774d89567b311e2fbd2dc4aad0b1950af22bb88fafe152a3b78", + "chksum_sha256": "97c991dcccf9ab92bad90d36caf6e2d3bdd2b9eb9461aded42696b3e76c7b1ad", "format": 1 }, { @@ -1285,7 +1299,7 @@ "name": "roles/zabbix_agent/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "978ae5731bb64fc79a4c404185da1f915480550e0a79ab8cdcc94475dc0ff86e", + "chksum_sha256": "7ceb0be05f5fb90c9d007ae64a43ca66fa855c484410df95c46e41853a44f5bd", "format": 1 }, { @@ -1362,7 +1376,7 @@ "name": "roles/zabbix_agent/tasks/userparameter.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "5248b27e7d45f14a3abdd5d93bf80e416f6e6f084f54f1cceeeba0f1ab08b9dd", + "chksum_sha256": "e2bb476b24d7e4997daa41e15959d1b70c538b8aa9eaf20d3b2e759c23534290", "format": 1 }, { @@ -1418,7 +1432,7 @@ "name": "roles/zabbix_agent/vars/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "a5da93f0d2b1f52521b40c0434ebbb78c7c13dfd63b1948689e104e86fc81a6c", + "chksum_sha256": "b3fdab5e28c143947f965aa38b670a83726994f8e6fb37b7fac24350c9471a28", "format": 1 }, { @@ -1453,7 +1467,7 @@ "name": "roles/zabbix_javagateway/README.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "950880306b5d99f842830620bcb03e3a67d487ab62b60c650421027b620824c9", + "chksum_sha256": "168aae7236576e4baf77c7b056833d5c90527c99365d7c9487f05f7af4d7281a", "format": 1 }, { @@ -1467,7 +1481,7 @@ "name": "roles/zabbix_javagateway/defaults/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "72237d44a0cfac809b0432db46974f2bb48d1a61260d80491d1c7bde73f1bf47", + "chksum_sha256": "169d719e540777e49a40c86c1ad09d21f6f408ebd346efa9e6ab926b0e85321f", "format": 1 }, { @@ -1523,7 +1537,7 @@ "name": "roles/zabbix_javagateway/tasks/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1cf7aeabb650158552dcc993e72c3aee3dd54c9d160d95ac4e603eec39d3c763", + "chksum_sha256": "44f9adfe675690b1901bf67f5c60da034bbbc4448476f3a2d69993a180f9dedc", "format": 1 }, { @@ -1537,7 +1551,7 @@ "name": "roles/zabbix_javagateway/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "67e5a9cd03529caca8af75622431ec4fe54bc256b14ad7568bedaedfd0f9206a", + "chksum_sha256": "e8857dcc83a8336f5d9103cbc0af3035d298335a2a62bbf98de4a25edff44230", "format": 1 }, { @@ -1565,7 +1579,7 @@ "name": "roles/zabbix_javagateway/vars/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "f6a87b8863fc8b0cf5dec159ecbe788b8cb1963c11d3dfcfddb6f64d3dfce77e", + "chksum_sha256": "be7796f9ccb7e43552833863142669694201bba88e396406f29f8881e28f381a", "format": 1 }, { @@ -1593,7 +1607,7 @@ "name": "roles/zabbix_proxy/README.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "137aa537b0643a8aba1e3b94965bd33d91a53a780a8873a398e07620a1c64ec4", + "chksum_sha256": "5fb7298372379197055d9221660fa37ec078d7b2c5aaa4545ed09a943daa7baf", "format": 1 }, { @@ -1607,7 +1621,7 @@ "name": "roles/zabbix_proxy/defaults/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "f3cc7cde32ae9908078b20eb97d7f25baaccbbd2f0ea4678296ae36a3fb10087", + "chksum_sha256": "33dcb508919b88bf2ef0b1c6bc5b121a67392553e54a58b55bf572bf00ea5d53", "format": 1 }, { @@ -1663,7 +1677,7 @@ "name": "roles/zabbix_proxy/tasks/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "62d366a97ff9d7a6b6f5ec20bde13cb22b447b0271f7e2e432dcad6c9b771712", + "chksum_sha256": "92c82d7303b5ec4b9e688bdb8017e5f213993f9c66007ad95846b2db30cfb414", "format": 1 }, { @@ -1677,7 +1691,7 @@ "name": "roles/zabbix_proxy/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "45ee561d3bf7df8a5067ccb625a15546b2572e202f75614b57af7143766cf63a", + "chksum_sha256": "3751caa6aaa36f2f878f60bd81a53ff4fb6dc1e45c0e9ec6c8c195fc3da765a1", "format": 1 }, { @@ -1733,7 +1747,7 @@ "name": "roles/zabbix_proxy/vars/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "66a3826d949a04140ff1fda9f008f8ef657050cb854677b4cf5c07c69a546346", + "chksum_sha256": "0c3453870dcd59ed9f69f3fdac8a1b46bf683a87ab86e87cc69b28d3951cce43", "format": 1 }, { @@ -1768,7 +1782,7 @@ "name": "roles/zabbix_server/README.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "434d9e12ff1d20c7f2e1891e2518628eea9f8497502a5032a7f83ea488477665", + "chksum_sha256": "e7b83a2f01c4ef1388cba62476dbbe0596c483b345f4a79aabc2cd107cf16b61", "format": 1 }, { @@ -1782,7 +1796,7 @@ "name": "roles/zabbix_server/defaults/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "024b79ba5eb85cb58403e606c0914e5e606a26e085795e7e7bccbf4f57d8ff66", + "chksum_sha256": "e77fe177f086c46a5fbce843360203fcd6b0bd3cb70cbce6582b73e50fb4f1d8", "format": 1 }, { @@ -1838,35 +1852,35 @@ "name": "roles/zabbix_server/tasks/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c174231cd483409e026d4b82e987ce3f2e2b30405b71ab15dab333b7c37e2f7c", + "chksum_sha256": "efdf8a1e0875c14dc97e4984063a9f775047af3e324baff629963f59139eb646", "format": 1 }, { "name": "roles/zabbix_server/tasks/RedHat.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "99bc6623e1018b3c5565d97670385a0ff3b205d3b9dccc5da0d3082f05f6f305", + "chksum_sha256": "c843b63e5dc9c44dfa748b6f6b5524f796d1b7a7bbf6151f89e7726770c399ce", "format": 1 }, { - "name": "roles/zabbix_server/tasks/main.yml", + "name": "roles/zabbix_server/tasks/initialize-mysql.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "a56f05203c959669058d2172d90f11dca5bd024c85651a75ecde52db2148f991", + "chksum_sha256": "f391750aff2b4e7c74c292036829fe7a44bb3fbfaed9bdb12393542b59132502", "format": 1 }, { - "name": "roles/zabbix_server/tasks/mysql.yml", + "name": "roles/zabbix_server/tasks/initialize-pgsql.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "aa11fd9cfc1662112ed5f321bd06ccde126f65ee7531267c4357f6e82cab540e", + "chksum_sha256": "df0005a12cc1d89f1a361f1d5f2764600a24527a567cce4b38f69490651f5541", "format": 1 }, { - "name": "roles/zabbix_server/tasks/postgresql.yml", + "name": "roles/zabbix_server/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "44146c8e7329cb92aa907a64d7c646700b8125b93dbcbbeb50716ad01f434c53", + "chksum_sha256": "ef880f7dbdcaf97b43f1c407334a0ca44304a1d6ae31089a4850f362f1bc1f04", "format": 1 }, { @@ -1880,7 +1894,7 @@ "name": "roles/zabbix_server/tasks/selinux.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "b2d30030efe386cfb08fc3f45cd4a4c1efc17c41df031f31deaf9d683f4d6a27", + "chksum_sha256": "f82baa01937f5e3e29b02be6fefd51f7c6cafcefebd44e9a3cf2a8c22d9c5e8c", "format": 1 }, { @@ -1908,14 +1922,14 @@ "name": "roles/zabbix_server/vars/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "67cb0847a5e96afd2b05a9e4db7f8383d6d0376cc4f93db206dc80c7778310eb", + "chksum_sha256": "428c1f85055c5afdccf997e4c6ab8fd4b9999760f93517dcbea2f41c88f82cb5", "format": 1 }, { "name": "roles/zabbix_server/vars/RedHat.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c27f0472596d51fd438b8d6f1c9b3bb788d7865b0c818d58c1b1456b3ec62185", + "chksum_sha256": "2650cb0aa53bf8f07b1bc2604b18c31ba88ee8ac407b6f6bb2779b0532b81781", "format": 1 }, { @@ -1943,7 +1957,7 @@ "name": "roles/zabbix_web/README.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "228030e059e30b229a82e7c31b609d5d122d710338557ebd74ee151eda79c0fb", + "chksum_sha256": "c52def2249d4416ac228eb03d6b57322578e2fb5c118967fb1e11634ff66f64f", "format": 1 }, { @@ -1957,7 +1971,7 @@ "name": "roles/zabbix_web/defaults/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "136689b650ad54e8046ca7f1f7f24cc8d528dfcde385b1027f2aa7b64ca3c26c", + "chksum_sha256": "49d8438ddfc81fa2d4c1ae65877229dbab7c2b010897013bfbb3f4486a7b96c4", "format": 1 }, { @@ -1999,14 +2013,14 @@ "name": "roles/zabbix_web/tasks/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "7c7426b9d16b6868f72eea3aa28c390217c51f5ba9aaa9afcf41caffb8072808", + "chksum_sha256": "f79cf8bd5892511d4499e72876b8ad62ddbf651236bc74acb4bc25e8b66be8ad", "format": 1 }, { "name": "roles/zabbix_web/tasks/RedHat.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "b2a875ae0deaf4facd16416db665771c03395e90879c3691e2430cf24e2f7331", + "chksum_sha256": "49891f2059325d2b9070af4c726a014e10a2120978bccaa651e47a8f27ee8a24", "format": 1 }, { @@ -2020,7 +2034,7 @@ "name": "roles/zabbix_web/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "9961406bcd8733eb9a504a8a4d2766148fdcb43ca2d5e27d007e2c041cccc4a5", + "chksum_sha256": "08eea52bde9af3a33c1c1145aac963f754498862532bffedb2a146bc662c72d9", "format": 1 }, { @@ -2034,7 +2048,7 @@ "name": "roles/zabbix_web/tasks/selinux.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "5b696169bbd552cba7f54fb7bc9f8fba7b885e0d2048cd4c56f2de57a3c560cd", + "chksum_sha256": "a88bf34858bebd60e78d8b56c0e2682e411285a56176d3165fe404937c5e3b04", "format": 1 }, { @@ -2055,7 +2069,7 @@ "name": "roles/zabbix_web/templates/nginx_vhost.conf.j2", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "4b66f5e157d4d15419a4d3e5e8580b2f50d5413ed092f026902ebed50bb431f4", + "chksum_sha256": "67d34aee35ab5e67b2b0259cfda5e7164a60272349a18661b2ef9d2252f06dff", "format": 1 }, { @@ -2083,7 +2097,7 @@ "name": "roles/zabbix_web/vars/Debian.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "61d4c2a23a9261eeeb511a5ba6e3e9d2d46856c69a390a4ff9f8fbfaad57ec50", + "chksum_sha256": "42d65bb39698381f067773966ab6605f96b6b7ced0e5d63e217ac0877d7dc7ad", "format": 1 }, { @@ -2325,6 +2339,41 @@ "format": 1 }, { + "name": "tests/integration/targets/test_zabbix_correlation", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_correlation/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_correlation/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "63ae23343a8854777c0e014be5fdd33db6a6b78f96d22a889ad78556dc0ffa81", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_correlation/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_correlation/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "41ac61f463abbb2342d912d9b3f657105290a7ee7a6862f97cc2b395e0af9171", + "format": 1 + }, + { "name": "tests/integration/targets/test_zabbix_discovery_rule", "ftype": "dir", "chksum_type": null, @@ -2573,7 +2622,7 @@ "name": "tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "10fdc4850cbc5a8c135b6010af276b1f5384d617f746ee3ef001e2f34b3cf289", + "chksum_sha256": "8d869ea43ae5374a7d7442968f0f46e2b3ea9bba5889c55f6bfc2a1e068ed8c9", "format": 1 }, { @@ -2713,7 +2762,7 @@ "name": "tests/integration/targets/test_zabbix_maintenance/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1e3c539311dc4f4c55b85931338f0693121ff1814cbc4d199fe02a689c5d298b", + "chksum_sha256": "ccdc41dfc4c4c391a480458d08af8764c7bfd45e00a9efeb7a2162628c1579fd", "format": 1 }, { @@ -2748,7 +2797,7 @@ "name": "tests/integration/targets/test_zabbix_mediatype/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c7a4f5cecfef03f695f94a47e7c663a3acb582757df2951e8af77279b2a2e797", + "chksum_sha256": "4654f230520d7e2726c0bb1d246cb0cf6ae76120a33c4acdc0a8c4b6549c2b84", "format": 1 }, { @@ -2976,6 +3025,41 @@ "format": 1 }, { + "name": "tests/integration/targets/test_zabbix_service_info", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_service_info/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_service_info/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "63ae23343a8854777c0e014be5fdd33db6a6b78f96d22a889ad78556dc0ffa81", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_service_info/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_service_info/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "81993514162d631138154fdde2e0aa9dd1896609638bf01bf59f5d6a98df8009", + "format": 1 + }, + { "name": "tests/integration/targets/test_zabbix_settings", "ftype": "dir", "chksum_type": null, @@ -3081,6 +3165,27 @@ "format": 1 }, { + "name": "tests/integration/targets/test_zabbix_template/files/template4_60_higher.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "39a95f703429d1845a04e106d1a921990a78ce220c1fd4d1af7ed9b5bc90ee06", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/files/template4_60_higher.xml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e91a1052602222dc146a54bb7b59915c951a3b6f0762162fb2aa6682839f43bb", + "format": 1 + }, + { + "name": "tests/integration/targets/test_zabbix_template/files/template4_60_higher.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "371d417e80a1380977c9d9c13f5c42c09096fbc15ef48b76e2dfad5e44004baa", + "format": 1 + }, + { "name": "tests/integration/targets/test_zabbix_template/meta", "ftype": "dir", "chksum_type": null, @@ -3105,7 +3210,7 @@ "name": "tests/integration/targets/test_zabbix_template/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "235eb7982d8a11e0e6fd68b53693d49daa89db486f91230e74497f75a0f8d2dc", + "chksum_sha256": "f86eb77c3eac1f431f59fa5f94ce07a1c4035826f1898987e4045036b19c9bb3", "format": 1 }, { @@ -3434,7 +3539,7 @@ "name": "CHANGELOG.rst", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "f963b76b08f69f8aac6b8daf732d95ce00e1670316f7e8f7bcb674f8d2e3aa6c", + "chksum_sha256": "841378afa489d7ab18a26f89a6c8a91949c1fb0c05c54b00ab5518157d83f3fa", "format": 1 }, { @@ -3476,7 +3581,7 @@ "name": "README.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "e47ca851f19b23497aa052424107b157400ef0d16cc745b1151fcff933ca2b86", + "chksum_sha256": "e78a31db573596c05c1b54e4da2ab59b53b57c8e19b41694e16fc8a600d366e8", "format": 1 }, { diff --git a/ansible_collections/community/zabbix/MANIFEST.json b/ansible_collections/community/zabbix/MANIFEST.json index 37c48a609..803b2a538 100644 --- a/ansible_collections/community/zabbix/MANIFEST.json +++ b/ansible_collections/community/zabbix/MANIFEST.json @@ -2,7 +2,7 @@ "collection_info": { "namespace": "community", "name": "zabbix", - "version": "2.3.1", + "version": "2.4.0", "authors": [ "Dusan Matejka (@D3DeFi)", "sky-joker (@sky-joker)", @@ -35,7 +35,7 @@ "name": "FILES.json", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "ed1fe1d72e38eb5978be766233f7389e444c2dcaded74877d323c41ac9712a46", + "chksum_sha256": "48923f5d0d4edaa37a77a0dda92c0f41f762a24a9d7ab4bd04c816cf9f3bd73a", "format": 1 }, "format": 1 diff --git a/ansible_collections/community/zabbix/README.md b/ansible_collections/community/zabbix/README.md index be268fc4a..889645483 100644 --- a/ansible_collections/community/zabbix/README.md +++ b/ansible_collections/community/zabbix/README.md @@ -104,7 +104,7 @@ You can also include it in a `requirements.yml` file along with other required c --- collections: - name: community.zabbix - version: 2.3.1 + version: 2.4.0 - name: ansible.posix version: 1.3.0 - name: community.general diff --git a/ansible_collections/community/zabbix/changelogs/.plugin-cache.yaml b/ansible_collections/community/zabbix/changelogs/.plugin-cache.yaml index 9ea52adc2..78da79cd3 100644 --- a/ansible_collections/community/zabbix/changelogs/.plugin-cache.yaml +++ b/ansible_collections/community/zabbix/changelogs/.plugin-cache.yaml @@ -1,12 +1,10 @@ -objects: - role: {} +objects: {} plugins: become: {} cache: {} callback: {} cliconf: {} connection: {} - filter: {} httpapi: zabbix: description: HttpApi Plugin for Zabbix @@ -39,6 +37,11 @@ plugins: name: zabbix_autoregister namespace: '' version_added: 1.6.0 + zabbix_correlation: + description: Create/update/delete Zabbix correlation + name: zabbix_correlation + namespace: '' + version_added: 2.4.0 zabbix_discovery_rule: description: Create/delete/update Zabbix discovery rules name: zabbix_discovery_rule @@ -129,6 +132,11 @@ plugins: name: zabbix_service namespace: '' version_added: null + zabbix_service_info: + description: Gather information about Zabbix service + name: zabbix_service_info + namespace: '' + version_added: null zabbix_settings: description: Update Zabbix global settings. name: zabbix_settings @@ -187,6 +195,5 @@ plugins: netconf: {} shell: {} strategy: {} - test: {} vars: {} -version: 2.3.1 +version: 2.4.0 diff --git a/ansible_collections/community/zabbix/changelogs/changelog.yaml b/ansible_collections/community/zabbix/changelogs/changelog.yaml index 600e0ab78..608160c0b 100644 --- a/ansible_collections/community/zabbix/changelogs/changelog.yaml +++ b/ansible_collections/community/zabbix/changelogs/changelog.yaml @@ -1092,3 +1092,61 @@ releases: fragments: - 1156-bugfix_zabbix_user_directory_dryrun.yml release_date: '2024-01-10' + 2.4.0: + changes: + bugfixes: + - zabbix_agent - Fixed IPMI authentication algorithm default setting + - zabbix_agent - Fixed issue to where scripts can be deployed alongside userparameters + - zabbix_host - Don't reset IPMI setting when update inventory data of a host + - zabbix_host - Finish task with failed if host_group parameter is empty list + - zabbix_server - proper indentaion of become in selinux.yaml + - zabbix_web - Added missing semicolon to nginx vhost template. + - zabbix_web role, Add missing selinux.yml tasks. + minor_changes: + - Add slash at the end of the location directives, to prevent path traversal + attacks. + - Added active_since and active_till in zabbix_maintenance + - Added content_type for email in zabbix_mediatypes + - Introduce flag `enable_version_check` to allow installations on non-supported + platforms. + - agent, javagateway, proxy, server, and web role - added the http_proxy and + https_proxy environment variables to "Debian | Download gpg key" analog to + other tasks + - agent, javagateway, proxy, server, and web role - introduced default variable + zabbix_repo_deb_gpg_key_url with value http://repo.zabbix.com/zabbix-official-repo.key + - agent, javagateway, proxy, server, and web role - introduced default variable + zabbix_repo_deb_include_deb_src with value true + - agent, javagateway, proxy, server, and web role - removed superfluous slash + in zabbix_gpg_key of the Debian vars and renamed key to zabbix-repo instead + of zabbix-official-repo + - agent, javagateway, proxy, server, and web role - used variable zabbix_repo_deb_include_deb_src + in "Debian | Installing repository" to determine whether deb-src should be + added to /etc/apt/sources.list.d/zabbix.sources + - agent, javagateway, proxy, server, and web role - used zabbix_repo_deb_gpg_key_url + in "Debian | Download gpg key" instead of hardcoded url + - zabbix_correlation module added + - zabbix_service_info module added + - zabbix_template - Add template_yaml parameter. + - zabbix_web role, Refactored zabbix_selinux variable names to correlate with + selinux boolean names. + fragments: + - 1157-add_template_yaml.yml + - 1162-do_not_update_ipmi_options.yml + - 1165-indent-become.yml + - 1168-finish-task-with-failed-if-host_group-parameter-is-empty_list.yml + - 1169-add_zabbix_correlation.yml + - 1176-content_type-in-mediatype.yml + - 1180-active_since-in-maintenance.yml + - 1183-nginx-fix-against-path-traversal.yml + - 1186-custom_gpg_key_url.yml + - 1188-agent_ipmi_authtype_fix.yml + - 1205-fix-zabbix-agent-scripts.yml + - 1206-fix-nginx-template-ssl-params.yml + - 1210-add_zabbix_service_info.yml + - 1220-refactor_selinux_tasks_and_variable_names_role_zabbix_web.yml + - 1224-enable-version-check.yml + modules: + - description: Create/update/delete Zabbix correlation + name: zabbix_correlation + namespace: '' + release_date: '2024-05-13' diff --git a/ansible_collections/community/zabbix/docs/ZABBIX_AGENT_ROLE.md b/ansible_collections/community/zabbix/docs/ZABBIX_AGENT_ROLE.md index aa73fab3a..fe4a601b3 100644 --- a/ansible_collections/community/zabbix/docs/ZABBIX_AGENT_ROLE.md +++ b/ansible_collections/community/zabbix/docs/ZABBIX_AGENT_ROLE.md @@ -102,6 +102,7 @@ See the following list of supported Operating systems with the Zabbix releases: | Debian 11 bullseye | V | V | V | | Debian 10 buster | V | V | V | +You can bypass this matrix by setting `enable_version_check: false` # Getting started @@ -136,6 +137,8 @@ The following is an overview of all available configuration default for this rol * `zabbix_agent_disable_repo`: A list of repos to disable during install. Default `epel`. * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. ### SElinux @@ -337,7 +340,7 @@ Keep in mind that using the Zabbix Agent in a Container requires changes to the ## 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_authtype`: IPMI authentication algorithm. Possible values are -1 (default), 0 (none), 1 (MD2), 2 (MD5), 4 (straight), 5 (OEM), 6 (RMCP+), with -1 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. diff --git a/ansible_collections/community/zabbix/docs/ZABBIX_JAVAGATEWAY_ROLE.md b/ansible_collections/community/zabbix/docs/ZABBIX_JAVAGATEWAY_ROLE.md index 1761c7f8b..47092a6a0 100644 --- a/ansible_collections/community/zabbix/docs/ZABBIX_JAVAGATEWAY_ROLE.md +++ b/ansible_collections/community/zabbix/docs/ZABBIX_JAVAGATEWAY_ROLE.md @@ -46,6 +46,8 @@ See the following list of supported Operating systems with the Zabbix releases. | Debian 11 bullseye | V | V | V | | Debian 10 buster | V | V | V | +You can bypass this matrix by setting `enable_version_check: false` + # Role Variables ## Main variables @@ -62,6 +64,8 @@ The `zabbix_javagateway_version` is optional. The latest available major.minor v * `zabbix_javagateway_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. ### Java Gatewaty diff --git a/ansible_collections/community/zabbix/docs/ZABBIX_PROXY_ROLE.md b/ansible_collections/community/zabbix/docs/ZABBIX_PROXY_ROLE.md index baec42155..ee558c8b7 100644 --- a/ansible_collections/community/zabbix/docs/ZABBIX_PROXY_ROLE.md +++ b/ansible_collections/community/zabbix/docs/ZABBIX_PROXY_ROLE.md @@ -89,6 +89,8 @@ See the following list of supported Operating systems with the Zabbix releases. | Debian 11 bullseye | V | V | V | | Debian 10 buster | V | V | V | +You can bypass this matrix by setting `enable_version_check: false` + # Role Variables ## Main variables @@ -133,6 +135,9 @@ The following is an overview of all available configuration default for this rol * `*zabbix_proxy_package_state`: Default: `present`. Can be overridden to `latest` to update packages * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_proxy_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. + ### SElinux * `zabbix_proxy_selinux`: Default: `False`. Enables an SELinux policy so that the Proxy will run. diff --git a/ansible_collections/community/zabbix/docs/ZABBIX_SERVER_ROLE.md b/ansible_collections/community/zabbix/docs/ZABBIX_SERVER_ROLE.md index f154f4951..9557281c3 100644 --- a/ansible_collections/community/zabbix/docs/ZABBIX_SERVER_ROLE.md +++ b/ansible_collections/community/zabbix/docs/ZABBIX_SERVER_ROLE.md @@ -86,6 +86,8 @@ See the following list of supported Operating systems with the Zabbix releases: | Debian 11 bullseye | V | V | V | | Debian 10 buster | | | V | +You can bypass this matrix by setting `enable_version_check: false` + # Installation Installing this role is very simple: `ansible-galaxy install community.zabbix.zabbix_server` @@ -109,6 +111,8 @@ The following is an overview of all available configuration default for this rol * `zabbix_service_enabled`: Default: `True` Can be overridden to `False` if needed * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_server_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. ### SElinux diff --git a/ansible_collections/community/zabbix/docs/ZABBIX_WEB_ROLE.md b/ansible_collections/community/zabbix/docs/ZABBIX_WEB_ROLE.md index 5904f8288..aac6f9dc2 100644 --- a/ansible_collections/community/zabbix/docs/ZABBIX_WEB_ROLE.md +++ b/ansible_collections/community/zabbix/docs/ZABBIX_WEB_ROLE.md @@ -16,6 +16,7 @@ - [Apache configuration](#apache-configuration) - [Nginx configuration](#nginx-configuration) - [PHP-FPM](#php-fpm) + - [SElinux](#selinux) - [Zabbix Server](#zabbix-server) * [proxy](#proxy) - [Example Playbook](#example-playbook) @@ -65,6 +66,8 @@ See the following list of supported Operating Systems with the Zabbix releases. | Debian 11 bullseye | V | V | V | | Debian 10 buster | | | V | +You can bypass this matrix by setting `enable_version_check: false` + # Installation Installing this role is very simple: `ansible-galaxy install community.zabbix.zabbix_web` @@ -94,6 +97,8 @@ The following is an overview of all available configuration defaults for this ro * `zabbix_web_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_web_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. ### Zabbix Web specific @@ -116,7 +121,6 @@ The following is an overview of all available configuration defaults for this ro * `zabbix_web_vhost_port`: The port on which Zabbix HTTP vhost is running. * `zabbix_web_vhost_tls_port`: The port on which Zabbix HTTPS vhost is running. * `zabbix_web_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_web_max_execution_time`: PHP max execution time * `zabbix_web_memory_limit`: PHP memory limit * `zabbix_web_post_max_size`: PHP maximum post size @@ -151,6 +155,13 @@ The following properties are specific to Zabbix 5.0 and for the PHP(-FPM) config * `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). +### SElinux + +* `zabbix_web_selinux`: Default: `False`. Enables an SELinux policy so that the web will run. +* `selinux_allow_httpd_can_connect_zabbix`: Default: `false`. Set SELinux boolean to allow httpd to connect to zabbix. +* `selinux_allow_httpd_can_connect_ldap`: Default: `false`. Set SELinux boolean to allow httpd to connect to LDAP. +* `selinux_allow_httpd_can_network_connect_db`: Default: `false` Set SELinux boolean to allow httpd to connect databases over the network. + ### Zabbix Server * `zabbix_server_name`: The name of the Zabbix Server. diff --git a/ansible_collections/community/zabbix/molecule/requirements.txt b/ansible_collections/community/zabbix/molecule/requirements.txt index b7cbb1138..9ccb5e157 100644 --- a/ansible_collections/community/zabbix/molecule/requirements.txt +++ b/ansible_collections/community/zabbix/molecule/requirements.txt @@ -3,9 +3,9 @@ ansible==7.0.0 ansible-compat==3.0.0 ansible-core==2.14.2 docker==6.1.3 -molecule==4.0.4 -molecule-docker==2.1.0 -netaddr==0.8.0 +molecule<5 +molecule-docker @ git+https://github.com/ansible-community/molecule-docker@main +netaddr==1.2.1 pytest==7.2.1 pytest-testinfra==7.0.0 ipaddr==2.2.0 diff --git a/ansible_collections/community/zabbix/molecule/zabbix_agent_tests/common/playbooks/prepare.yml b/ansible_collections/community/zabbix/molecule/zabbix_agent_tests/common/playbooks/prepare.yml index cf1100aab..2ad8efa3f 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_agent_tests/common/playbooks/prepare.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_agent_tests/common/playbooks/prepare.yml @@ -47,6 +47,7 @@ hosts: docker tasks: - name: "Download Docker CE repo file" + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: url: https://download.docker.com/linux/centos/docker-ce.repo dest: /etc/yum.repos.d/docker-ce.repo diff --git a/ansible_collections/community/zabbix/molecule/zabbix_javagateway/molecule.yml b/ansible_collections/community/zabbix/molecule/zabbix_javagateway/molecule.yml index ee072707d..0c6de4172 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_javagateway/molecule.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_javagateway/molecule.yml @@ -3,7 +3,7 @@ driver: name: docker platforms: - - name: zabbix-server-${MY_MOLECULE_CONTAINER:-centos} + - name: zabbix-server-${MY_MOLECULE_VERSION:-v64}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest privileged: true pre_build_image: true diff --git a/ansible_collections/community/zabbix/molecule/zabbix_proxy/destroy.yml b/ansible_collections/community/zabbix/molecule/zabbix_proxy/destroy.yml index 54771a5a1..7ef374be5 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_proxy/destroy.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_proxy/destroy.yml @@ -17,9 +17,7 @@ - name: Destroy 3rd party instance(s) docker_container: - name: '{{ item }}' + name: "{{ item.name }}-db" state: absent force_kill: true - with_items: - - mysql-host - - postgresql-host + loop: "{{ molecule_yml.platforms }}" diff --git a/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml b/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml index 4eb173acf..4eadd60ab 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml @@ -2,7 +2,7 @@ driver: name: docker platforms: - - name: zabbix-proxy-${MY_MOLECULE_CONTAINER:-centos} + - name: zabbix-proxy-${MY_MOLECULE_VERSION:-v64}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest privileged: true pre_build_image: true @@ -37,19 +37,19 @@ provisioner: zabbix_proxy_dbuser: zabbix-dbuser zabbix_proxy_database: mysql zabbix_proxy_dbport: 3306 - zabbix_proxy_dbhost: mysql-host + zabbix_proxy_dbhost: "{{ inventory_hostname }}-db" zabbix_proxy_dbhost_run_install: false zabbix_proxy_privileged_host: "%" - zabbix_proxy_mysql_login_host: mysql-host + zabbix_proxy_mysql_login_host: "{{ inventory_hostname }}-db" zabbix_proxy_mysql_login_user: root zabbix_proxy_mysql_login_password: changeme zabbix_proxy_mysql_login_port: 3306 pgsql: zabbix_proxy_database: pgsql zabbix_proxy_dbport: 5432 - zabbix_proxy_dbhost: postgresql-host + zabbix_proxy_dbhost: "{{ inventory_hostname }}-db" zabbix_proxy_dbhost_run_install: false - zabbix_proxy_pgsql_login_host: postgresql-host + zabbix_proxy_pgsql_login_host: "{{ inventory_hostname }}-db" zabbix_proxy_pgsql_login_user: postgres zabbix_proxy_pgsql_login_password: changeme zabbix_proxy_pgsql_login_port: 5432 diff --git a/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml b/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml index c5e3b9e45..1ff492d62 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml @@ -5,7 +5,7 @@ pre_tasks: - name: "Create MySQL Container" docker_container: - name: mysql-host + name: "{{ item.name }}-db" image: mysql:8.0 state: started recreate: true @@ -20,7 +20,7 @@ - name: "Create postgresql Container" docker_container: - name: postgresql-host + name: "{{ item.name }}-db" image: postgres:13 state: started recreate: true diff --git a/ansible_collections/community/zabbix/molecule/zabbix_server/destroy.yml b/ansible_collections/community/zabbix/molecule/zabbix_server/destroy.yml index 54771a5a1..7ef374be5 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_server/destroy.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_server/destroy.yml @@ -17,9 +17,7 @@ - name: Destroy 3rd party instance(s) docker_container: - name: '{{ item }}' + name: "{{ item.name }}-db" state: absent force_kill: true - with_items: - - mysql-host - - postgresql-host + loop: "{{ molecule_yml.platforms }}" diff --git a/ansible_collections/community/zabbix/molecule/zabbix_server/molecule.yml b/ansible_collections/community/zabbix/molecule/zabbix_server/molecule.yml index 2424455f4..52df5ac4e 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_server/molecule.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_server/molecule.yml @@ -2,7 +2,7 @@ driver: name: docker platforms: - - name: zabbix-server-${MY_MOLECULE_CONTAINER:-centos} + - name: zabbix-server-${MY_MOLECULE_VERSION:-v64}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest privileged: true pre_build_image: true @@ -40,19 +40,19 @@ provisioner: zabbix_server_dbuser: zabbix-dbuser zabbix_server_database: mysql zabbix_server_dbport: 3306 - zabbix_server_dbhost: mysql-host + zabbix_server_dbhost: "{{ inventory_hostname }}-db" zabbix_server_dbhost_run_install: false zabbix_server_privileged_host: "%" - zabbix_server_mysql_login_host: mysql-host + zabbix_server_mysql_login_host: "{{ inventory_hostname }}-db" zabbix_server_mysql_login_user: root zabbix_server_mysql_login_password: changeme zabbix_server_mysql_login_port: 3306 pgsql: zabbix_server_database: pgsql zabbix_server_dbport: 5432 - zabbix_server_dbhost: postgresql-host + zabbix_server_dbhost: "{{ inventory_hostname }}-db" zabbix_server_dbhost_run_install: false - zabbix_server_pgsql_login_host: postgresql-host + zabbix_server_pgsql_login_host: "{{ inventory_hostname }}-db" zabbix_server_pgsql_login_user: postgres zabbix_server_pgsql_login_password: changeme zabbix_server_pgsql_login_port: 5432 diff --git a/ansible_collections/community/zabbix/molecule/zabbix_server/prepare.yml b/ansible_collections/community/zabbix/molecule/zabbix_server/prepare.yml index 922b33753..725e6d718 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_server/prepare.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_server/prepare.yml @@ -5,7 +5,7 @@ pre_tasks: - name: "Create MySQL Container" docker_container: - name: mysql-host + name: "{{ item.name }}-db" image: mysql:8.0.32 state: started recreate: true @@ -20,7 +20,7 @@ - name: "Create postgresql Container" docker_container: - name: postgresql-host + name: "{{ item.name }}-db" image: postgres:13 state: started recreate: true @@ -109,11 +109,3 @@ state: absent when: - ansible_os_family == 'RedHat' - - - name: PyMySQL - ansible.builtin.pip: - name: PyMySQL - register: installation_dependencies - until: installation_dependencies is succeeded - when: - - inventory_hostname in groups['mysql'] diff --git a/ansible_collections/community/zabbix/molecule/zabbix_web/destroy.yml b/ansible_collections/community/zabbix/molecule/zabbix_web/destroy.yml index 54771a5a1..7ef374be5 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_web/destroy.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_web/destroy.yml @@ -17,9 +17,7 @@ - name: Destroy 3rd party instance(s) docker_container: - name: '{{ item }}' + name: "{{ item.name }}-db" state: absent force_kill: true - with_items: - - mysql-host - - postgresql-host + loop: "{{ molecule_yml.platforms }}" diff --git a/ansible_collections/community/zabbix/molecule/zabbix_web/molecule.yml b/ansible_collections/community/zabbix/molecule/zabbix_web/molecule.yml index 0aa3ab800..549b7ae16 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_web/molecule.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_web/molecule.yml @@ -10,7 +10,7 @@ dependency: driver: name: docker platforms: - - name: zabbix-web-${MY_MOLECULE_CONTAINER:-centos} + - name: zabbix-web-${MY_MOLECULE_VERSION:-v64}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest privileged: true pre_build_image: true @@ -33,7 +33,7 @@ provisioner: inventory: group_vars: all: - zabbix_api_server_url: zabbix-web-${MY_MOLECULE_CONTAINER:-centos} + zabbix_api_server_url: zabbix-web-${MY_MOLECULE_VERSION:-v64}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} python3: ansible_python_interpreter: /usr/bin/python3 python: @@ -50,19 +50,19 @@ provisioner: mysql: zabbix_server_database: mysql zabbix_server_dbport: 3306 - zabbix_server_dbhost: mysql-host + zabbix_server_dbhost: "{{ inventory_hostname }}-db" zabbix_server_dbhost_run_install: false zabbix_server_privileged_host: "%" - zabbix_server_mysql_login_host: mysql-host + zabbix_server_mysql_login_host: "{{ inventory_hostname }}-db" zabbix_server_mysql_login_user: root zabbix_server_mysql_login_password: changeme zabbix_server_mysql_login_port: 3306 pgsql: zabbix_server_database: pgsql zabbix_server_dbport: 5432 - zabbix_server_dbhost: postgresql-host + zabbix_server_dbhost: "{{ inventory_hostname }}-db" zabbix_server_dbhost_run_install: false - zabbix_server_pgsql_login_host: postgresql-host + zabbix_server_pgsql_login_host: "{{ inventory_hostname }}-db" zabbix_server_pgsql_login_user: postgres zabbix_server_pgsql_login_password: changeme zabbix_server_pgsql_login_port: 5432 diff --git a/ansible_collections/community/zabbix/molecule/zabbix_web/prepare.yml b/ansible_collections/community/zabbix/molecule/zabbix_web/prepare.yml index 204eb8f56..d3dcc1ad0 100644 --- a/ansible_collections/community/zabbix/molecule/zabbix_web/prepare.yml +++ b/ansible_collections/community/zabbix/molecule/zabbix_web/prepare.yml @@ -5,7 +5,7 @@ pre_tasks: - name: "Create MySQL Container" docker_container: - name: mysql-host + name: "{{ item.name }}-db" image: mysql:8.0 state: started recreate: true @@ -20,7 +20,7 @@ - name: "Create postgresql Container" docker_container: - name: postgresql-host + name: "{{ item.name }}-db" image: postgres:13 state: started recreate: true diff --git a/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py b/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py index 56ba0356d..2a8d8a8ae 100644 --- a/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py +++ b/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py @@ -29,7 +29,8 @@ options: zabbix_url_path: type: str description: - - Specifies path portion in Zabbix WebUI URL, e.g. for https://myzabbixfarm.com/zabbixeu zabbix_url_path=zabbixeu + - Specifies path portion in Zabbix WebUI URL, e.g. for https://myzabbixfarm.com/zabbixeu zabbix_url_path=zabbixeu. + - "If Zabbix WebUI is running at the root, i.e. https://myzabbixfarm.com/, then assign empty string to this variable C(zabbix_url_path: '')." default: zabbix env: - name: ANSIBLE_ZABBIX_URL_PATH diff --git a/ansible_collections/community/zabbix/plugins/modules/zabbix_correlation.py b/ansible_collections/community/zabbix/plugins/modules/zabbix_correlation.py new file mode 100644 index 000000000..952ef49d0 --- /dev/null +++ b/ansible_collections/community/zabbix/plugins/modules/zabbix_correlation.py @@ -0,0 +1,587 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright: (c) 2024, ONODERA Masaru <masaru-onodera@ieee.org> +# 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_correlation + +short_description: Create/update/delete Zabbix correlation + + +description: + - This module allows you to create, update and delete Zabbix correlation. + +author: + - ONODERA Masaru(@masa-orca) + +requirements: + - "python >= 3.9" + +version_added: 2.4.0 + +options: + name: + description: + - Name of this correlation + type: str + required: true + description: + description: + - Description of this correlation + type: str + operations: + description: + - A operations. + type: list + elements: dict + suboptions: + type: + description: + - Type of the operation. + type: str + choices: + - close_old_events + - close_new_event + required: true + filter: + description: + - A filter. + type: dict + suboptions: + evaltype: + description: + - An evaluation method of the filter. + type: str + choices: + - and_or + - and + - or + - custom_expression + required: true + conditions: + description: + - A condition. + type: list + elements: dict + required: true + suboptions: + type: + description: + - Type of the condition. + type: str + choices: + - old_event_tag + - new_event_tag + - new_event_host_group + - event_tag_pair + - old_event_tag_value + - new_event_tag_value + required: true + tag: + description: + - Event tag (old or new). + - This parameter is required if value of I(type) of the condition is C(old_event_tag), C(new_event_tag), + C(old_event_tag_value) or C(new_event_tag_value). + type: str + hostgroup: + description: + - A name of hostgroup name + - This parameter is required if value of I(type) of the condition is C(new_event_host_group). + type: str + oldtag: + description: + - Old event tag. + - This parameter is required if value of I(type) of the condition is C(event_tag_pair). + type: str + newtag: + description: + - New event tag. + - This parameter is required if value of I(type) of the condition is C(event_tag_pair). + type: str + value: + description: + - Event tag (old or new) value. + - This parameter is required if value of I(type) of the condition is C(old_event_tag_value) or C(new_event_tag_value). + type: str + formulaid: + description: + - Arbitrary unique ID that is used to reference the condition from a custom expression. + - This parameter's value must be only contain capital-case letters. + - This parameter is required if value of I(evaltype) of the filter is C(custom_expression). + type: str + operator: + description: + - Condition operator. + - This parameter is required if value of I(type) of the condition is C(new_event_host_group), + C(old_event_tag_value) or C(new_event_tag_value). + - You can only select C(equal) or C(not_equal) if value of I(type) of the condition is C(new_event_host_group). + type: str + choices: + - equal + - not_equal + - like + - not_like + formula: + description: + - A custom expression for the filter. + - This parameter is required if value of I(evaltype) is C(custom_expression). + type: str + status: + description: + - Status of the correlation. + choices: + - enabled + - disabled + default: enabled + type: str + state: + description: + - State of the correlation. + type: str + choices: + - present + - absent + default: present + +extends_documentation_fragment: + - community.zabbix.zabbix + +""" + +EXAMPLES = """ +# If you want to use Username and Password to be authenticated by Zabbix Server +- name: Set credentials to access Zabbix Server API + ansible.builtin.set_fact: + ansible_user: Admin + ansible_httpapi_pass: zabbix + +# If you want to use API token to be authenticated by Zabbix Server +# https://www.zabbix.com/documentation/current/en/manual/web_interface/frontend_sections/administration/general#api-tokens +- name: Set API token + ansible.builtin.set_fact: + ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 + +- name: Create correlation of 'New event tag correlation' + # set task level variables as we change ansible_connection plugin here + vars: + ansible_network_os: community.zabbix.zabbix + ansible_connection: httpapi + ansible_httpapi_port: 443 + ansible_httpapi_use_ssl: true + ansible_httpapi_validate_certs: false + ansible_zabbix_url_path: 'zabbixeu' # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu + ansible_host: zabbix-example-fqdn.org + community.zabbix.zabbix_correlation: + name: New event tag correlation + filter: + evaltype: and_or + conditions: + - type: new_event_tag + tag: ok + operations: + - type: close_old_events +""" + +RETURN = """ +msg: + description: The result of the operation + returned: success + type: str + sample: 'Successfully created correlation' +""" + + +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 Correlation(ZabbixBase): + def __init__(self, module, zbx=None, zapi_wrapper=None): + super(Correlation, self).__init__(module, zbx, zapi_wrapper) + + def get_correlations(self, correlation_name): + try: + regexps = self._zapi.correlation.get( + { + "output": "extend", + "selectFilter": "extend", + "selectOperations": "extend", + "filter": {"name": correlation_name}, + } + ) + if len(regexps) >= 2: + self._module.fail_json("Too many correlations are matched.") + return regexps + except Exception as e: + self._module.fail_json( + msg="Failed to get correlation: %s" % e + ) + + def delete_correlation(self, correlation): + try: + parameter = [correlation["correlationid"]] + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.correlation.delete(parameter) + self._module.exit_json( + changed=True, msg="Successfully deleted correlation." + ) + except Exception as e: + self._module.fail_json( + msg="Failed to delete correlation: %s" % e + ) + + def _convert_operations_to_json(self, operations): + operation_type_values = ["close_old_events", "close_new_event"] + + operations_json = [] + for operation in operations: + operation_json = {} + operation_type = zabbix_utils.helper_to_numeric_value( + operation_type_values, operation["type"] + ) + operation_json["type"] = str(operation_type) + operations_json.append(operation_json) + + return operations_json + + def _get_groupid_from_name(self, hostgroup): + groupid = self._zapi.hostgroup.get({"filter": {"name": hostgroup}}) + if not groupid or len(groupid) > 1: + self._module.fail_json("Host group '%s' cannot be found" % hostgroup) + return groupid[0]["groupid"] + + def _convert_conditions_to_json(self, filter_parameter): + condition_type_values = [ + "old_event_tag", + "new_event_tag", + "new_event_host_group", + "event_tag_pair", + "old_event_tag_value", + "new_event_tag_value" + ] + + operator_values = [ + "equal", + "not_equal", + "like", + "not_like" + ] + + conditions_json = [] + for condition in filter_parameter["conditions"]: + condition_json = {} + + condition_type = zabbix_utils.helper_to_numeric_value( + condition_type_values, condition["type"] + ) + condition_json["type"] = str(condition_type) + + if condition["tag"] is not None: + condition_json["tag"] = condition["tag"] + + if condition["hostgroup"] is not None: + condition_json["groupid"] = self._get_groupid_from_name(condition["hostgroup"]) + + if condition["oldtag"] is not None: + condition_json["oldtag"] = condition["oldtag"] + + if condition["newtag"] is not None: + condition_json["newtag"] = condition["newtag"] + + if condition["value"] is not None: + condition_json["value"] = condition["value"] + + if filter_parameter["evaltype"] == "custom_expression": + if condition["formulaid"] is not None: + if not condition["formulaid"].isupper(): + self._module.fail_json( + "A value of formulaid must be uppercase." + ) + condition_json["formulaid"] = condition["formulaid"] + else: + self._module.fail_json( + "formulaid must be defined if evaltype is 'custom_expression'." + ) + else: + if condition["formulaid"] is not None: + self._module.warn( + "A value of formulaid will be ignored because evaltype is not 'custom_expression'." + ) + + if condition["operator"] is not None: + if (condition["type"] == "new_event_host_group" + and (condition["operator"] == "like" or condition["operator"] == "not_like")): + self._module.fail_json( + "A value of operator must be equal or not_equal when condition's type is 'new_event_host_group'." + ) + operator = zabbix_utils.helper_to_numeric_value( + operator_values, condition["operator"] + ) + condition_json["operator"] = str(operator) + + conditions_json.append(condition_json) + return conditions_json + + def _convert_filter_parameter_to_json(self, filter_parameter): + evaltype_values = [ + "and_or", + "and", + "or", + "custom_expression" + ] + + filter_parameter_json = {} + + evaltype = zabbix_utils.helper_to_numeric_value( + evaltype_values, filter_parameter["evaltype"] + ) + filter_parameter_json["evaltype"] = str(evaltype) + + filter_parameter_json["conditions"] = self._convert_conditions_to_json(filter_parameter) + + if filter_parameter["formula"] is not None: + if filter_parameter["evaltype"] == "custom_expression": + filter_parameter_json["formula"] = filter_parameter["formula"] + else: + self._module.warn( + "A value of formula will be ignored because evaltype is not 'custom_expression'." + ) + + return filter_parameter_json + + def create_correlation(self, name, description, operations, filter_parameter, status): + status_values = ["enabled", "disabled"] + status_json = zabbix_utils.helper_to_numeric_value( + status_values, status + ) + + try: + correlation_json = {} + + correlation_json["name"] = name + + if description is not None: + correlation_json["description"] = description + + correlation_json["operations"] = self._convert_operations_to_json(operations) + + correlation_json["filter"] = self._convert_filter_parameter_to_json(filter_parameter) + + correlation_json["status"] = status_json + + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.correlation.create(correlation_json) + self._module.exit_json( + changed=True, msg="Successfully created correlation" + ) + except Exception as e: + self._module.fail_json( + msg="Failed to create correlation: %s" % e + ) + + def check_filter_properties(self, current_filter, future_filter): + changed = False + + if (current_filter["evaltype"] != future_filter["evaltype"]): + changed = True + + if "formula" in future_filter.keys(): + if (current_filter["eval_formula"] != future_filter["formula"]): + changed = True + + for condition in current_filter["conditions"]: + # 3 means custom expression. + if current_filter["evaltype"] != "3": + condition.pop("formulaid") + diff_conditions = [] + zabbix_utils.helper_compare_lists(current_filter["conditions"], future_filter["conditions"], diff_conditions) + if len(diff_conditions) != 0: + changed = True + + return changed + + def update_correlation(self, current_correlation, description, operations, filter_parameter, status): + status_values = ["enabled", "disabled"] + status_json = zabbix_utils.helper_to_numeric_value( + status_values, status + ) + + try: + correlation_json = {} + + if description is not None and description != current_correlation["description"]: + correlation_json["description"] = description + + if operations is not None: + future_operations = self._convert_operations_to_json(operations) + diff_operations = [] + zabbix_utils.helper_compare_lists(current_correlation["operations"], future_operations, diff_operations) + if len(diff_operations) != 0: + correlation_json["operations"] = future_operations + + if filter_parameter is not None: + future_filter = self._convert_filter_parameter_to_json(filter_parameter) + if self.check_filter_properties(current_correlation["filter"], future_filter): + correlation_json["filter"] = future_filter + + if str(status_json) != current_correlation["status"]: + correlation_json["status"] = str(status_json) + + if len(correlation_json.keys()) == 0: + self._module.exit_json(changed=False) + else: + correlation_json["correlationid"] = current_correlation["correlationid"] + if self._module.check_mode: + self._module.exit_json(changed=True) + self._zapi.correlation.update(correlation_json) + self._module.exit_json( + changed=True, msg="Successfully updated correlation" + ) + except Exception as e: + self._module.fail_json( + msg="Failed to update correlation: %s" % e + ) + + +def main(): + """Main ansible module function""" + + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update( + dict( + name=dict(type="str", required=True), + description=dict(type="str"), + operations=dict( + type="list", + elements="dict", + options=dict( + type=dict( + choices=["close_old_events", "close_new_event"], + required=True + ) + ) + ), + filter=dict( + type="dict", + options=dict( + evaltype=dict( + type="str", + required=True, + choices=[ + "and_or", + "and", + "or", + "custom_expression" + ] + ), + conditions=dict( + required=True, + type="list", + elements="dict", + options=dict( + type=dict( + type="str", + required=True, + choices=[ + "old_event_tag", + "new_event_tag", + "new_event_host_group", + "event_tag_pair", + "old_event_tag_value", + "new_event_tag_value" + ] + ), + tag=dict(type="str"), + hostgroup=dict(type="str"), + oldtag=dict(type="str"), + newtag=dict(type="str"), + value=dict(type="str"), + formulaid=dict(type="str"), + operator=dict( + type="str", + choices=[ + "equal", + "not_equal", + "like", + "not_like" + ] + ), + ), + required_if=[ + ["type", "old_event_tag", ["tag"]], + ["type", "new_event_tag", ["tag"]], + ["type", "new_event_host_group", ["hostgroup", "operator"]], + ["type", "event_tag_pair", ["oldtag", "newtag"]], + ["type", "old_event_tag_value", ["tag", "value", "operator"]], + ["type", "new_event_tag_value", ["tag", "value", "operator"]] + ], + mutually_exclusive=[ + ("tag", "hostgroup", "oldtag") + ], + required_together=[ + ('oldtag', 'newtag') + ] + ), + formula=dict(type="str"), + ), + required_if=[ + ["evaltype", "custom_expression", ["formula"]], + ] + ), + status=dict( + type="str", + required=False, + default="enabled", + choices=["enabled", "disabled"], + ), + state=dict( + type="str", + required=False, + default="present", + choices=["present", "absent"], + ) + ) + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + name = module.params["name"] + description = module.params["description"] + operations = module.params["operations"] + filter_parameter = module.params["filter"] + status = module.params["status"] + state = module.params["state"] + + correlation_class_obj = Correlation(module) + correlations = correlation_class_obj.get_correlations(name) + + if state == "absent": + if len(correlations) == 1: + correlation_class_obj.delete_correlation(correlations[0]) + else: + module.exit_json(changed=False) + else: + if len(correlations) == 1: + correlation_class_obj.update_correlation(correlations[0], description, operations, filter_parameter, status) + else: + correlation_class_obj.create_correlation(name, description, operations, filter_parameter, status) + + +if __name__ == "__main__": + main() diff --git a/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py b/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py index 22e14d17d..00c04c221 100644 --- a/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py +++ b/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py @@ -513,7 +513,7 @@ class Host(ZabbixBase): 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, discovered_host): + tls_subject, ipmi_authtype, ipmi_privilege, ipmi_username, ipmi_password, macros, tags, discovered_host, zabbix_host_obj): try: if self._module.check_mode: self._module.exit_json(changed=True) @@ -523,31 +523,31 @@ class Host(ZabbixBase): else: # A "plain" host parameters = {"hostid": host_id, "groups": group_ids, "status": status} - if proxy_id >= 0: + if (proxy_id >= 0 and proxy_id != zabbix_host_obj["proxy_hostid"]): parameters["proxy_hostid"] = proxy_id - if visible_name: + if (visible_name is not None and visible_name != zabbix_host_obj["name"]): parameters["name"] = visible_name - if tls_connect: + if (tls_connect is not None and tls_connect != zabbix_host_obj["tls_connect"]): parameters["tls_connect"] = tls_connect - if tls_accept: + if (tls_accept is not None and tls_accept != zabbix_host_obj["tls_accept"]): parameters["tls_accept"] = tls_accept if tls_psk_identity: parameters["tls_psk_identity"] = tls_psk_identity if tls_psk: parameters["tls_psk"] = tls_psk - if tls_issuer: + if (tls_issuer is not None and tls_issuer != zabbix_host_obj["tls_issuer"]): parameters["tls_issuer"] = tls_issuer - if tls_subject: + if (tls_subject is not None and tls_subject != zabbix_host_obj["tls_subject"]): parameters["tls_subject"] = tls_subject - if description: + if (description is not None and description != zabbix_host_obj["description"]): parameters["description"] = description - if ipmi_authtype: + if (ipmi_authtype is not None and ipmi_authtype != zabbix_host_obj["ipmi_authtype"]): parameters["ipmi_authtype"] = ipmi_authtype - if ipmi_privilege: + if (ipmi_privilege is not None and ipmi_privilege != zabbix_host_obj["ipmi_privilege"]): parameters["ipmi_privilege"] = ipmi_privilege - if ipmi_username: + if (ipmi_username is not None and ipmi_username != zabbix_host_obj["ipmi_username"]): parameters["ipmi_username"] = ipmi_username - if ipmi_password: + if (ipmi_password is not None and ipmi_password != zabbix_host_obj["ipmi_password"]): parameters["ipmi_password"] = ipmi_password if interfaces: parameters["interfaces"] = interfaces @@ -809,8 +809,7 @@ class Host(ZabbixBase): 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, discovered_host): + def link_or_clear_template(self, host_id, template_id_list): # get host's exist template ids exist_template_id_list = self.get_host_templates_by_host_id(host_id) @@ -821,25 +820,7 @@ class Host(ZabbixBase): # get unlink and clear templates templates_clear = exist_template_ids.difference(template_ids) templates_clear_list = list(templates_clear) - if discovered_host: - # The host was discovered via Discovery Rule - request_str = {"hostid": host_id, "templates": template_id_list, "templates_clear": templates_clear_list} - else: - # A "plain" host - request_str = {"hostid": host_id, "templates": template_id_list, "templates_clear": templates_clear_list, - "ipmi_authtype": ipmi_authtype, "ipmi_privilege": ipmi_privilege, "ipmi_username": ipmi_username, "ipmi_password": ipmi_password} - if tls_connect: - request_str["tls_connect"] = tls_connect - if tls_accept: - request_str["tls_accept"] = tls_accept - 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 + request_str = {"hostid": host_id, "templates": template_id_list, "templates_clear": templates_clear_list} try: if self._module.check_mode: self._module.exit_json(changed=True) @@ -1057,8 +1038,11 @@ def main(): group_ids = [] - if host_groups: - group_ids = host.get_group_ids_by_group_names(host_groups) + if host_groups is not None: + if len(host_groups) >= 1: + group_ids = host.get_group_ids_by_group_names(host_groups) + else: + module.fail_json(msg="host_groups must be not empty list.") interfaces, ip = host.construct_host_interfaces(interfaces) @@ -1204,11 +1188,9 @@ def main(): 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, discovered_host) + ipmi_authtype, ipmi_privilege, ipmi_username, ipmi_password, macros, tags, discovered_host, zabbix_host_obj) - 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, discovered_host) + host.link_or_clear_template(host_id, template_ids) host.update_inventory_mode(host_id, inventory_mode) host.update_inventory_zabbix(host_id, inventory_zabbix) @@ -1235,9 +1217,7 @@ def main(): 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, discovered_host) + host.link_or_clear_template(host_id, template_ids) host.update_inventory_mode(host_id, inventory_mode) host.update_inventory_zabbix(host_id, inventory_zabbix) diff --git a/ansible_collections/community/zabbix/plugins/modules/zabbix_maintenance.py b/ansible_collections/community/zabbix/plugins/modules/zabbix_maintenance.py index a2c635eb0..ce10815df 100644 --- a/ansible_collections/community/zabbix/plugins/modules/zabbix_maintenance.py +++ b/ansible_collections/community/zabbix/plugins/modules/zabbix_maintenance.py @@ -64,6 +64,20 @@ options: - I(visible_name=yes) to search by visible name, I(visible_name=no) to search by technical name. type: bool default: "yes" + active_since: + description: + - Time when the maintenance becomes active. + - The given value will be rounded down to minutes. + - Uses `datetime.datetime.now(`) if not specified. + type: "str" + default: "" + active_till: + description: + - Time when the maintenance stops being active. + - The given value will be rounded down to minutes. + - Gets calculated from I(minutes) if not specified. + type: "str" + default: "" tags: description: - List of tags to assign to the hosts in maintenance. @@ -187,6 +201,24 @@ EXAMPLES = r""" community.zabbix.zabbix_maintenance: name: Test1 state: absent + +- name: Create maintenance window by date + # set task level variables as we change ansible_connection plugin here + vars: + ansible_network_os: community.zabbix.zabbix + ansible_connection: httpapi + ansible_httpapi_port: 443 + ansible_httpapi_use_ssl: true + ansible_httpapi_validate_certs: false + ansible_zabbix_url_path: "zabbixeu" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu + ansible_host: zabbix-example-fqdn.org + community.zabbix.zabbix_maintenance: + name: TestDate + state: present + host_names: + - host.example.org + active_since: "1979-09-19 09:00" + active_till: "1979-09-19 17:00" """ import datetime @@ -342,6 +374,8 @@ def main(): desc=dict(type="str", required=False, default="Created by Ansible"), collect_data=dict(type="bool", required=False, default=True), visible_name=dict(type="bool", required=False, default=True), + active_since=dict(type="str", required=False, default=""), + active_till=dict(type="str", required=False, default=""), tags=dict( type="list", elements="dict", @@ -368,6 +402,8 @@ def main(): desc = module.params["desc"] collect_data = module.params["collect_data"] visible_name = module.params["visible_name"] + active_since = module.params["active_since"] + active_till = module.params["active_till"] tags = module.params["tags"] if collect_data: @@ -389,9 +425,9 @@ def main(): 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) + now = datetime.datetime.fromisoformat(active_since) if active_since != "" else datetime.datetime.now().replace(second=0) start_time = int(time.mktime(now.timetuple())) - period = 60 * int(minutes) # N * 60 seconds + period = int((datetime.datetime.fromisoformat(active_till) - now).total_seconds()) if active_till != "" else 60 * int(minutes) # N * 60 seconds if host_groups: (rc, group_ids, error) = maint.get_group_ids(host_groups) diff --git a/ansible_collections/community/zabbix/plugins/modules/zabbix_mediatype.py b/ansible_collections/community/zabbix/plugins/modules/zabbix_mediatype.py index 1e2514bf3..34bb1db82 100644 --- a/ansible_collections/community/zabbix/plugins/modules/zabbix_mediatype.py +++ b/ansible_collections/community/zabbix/plugins/modules/zabbix_mediatype.py @@ -155,6 +155,15 @@ options: - SSL verify peer for SMTP. - Can be specified when I(smtp_security=STARTTLS) or I(smtp_security=SSL/TLS) default: false + content_type: + type: "str" + description: + - Can be used when I(type=email). + - Message format. + choices: + - plaintext + - html + default: html message_text_limit: type: "str" description: @@ -525,6 +534,7 @@ class MediaTypeModule(ZabbixBase): 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"])), + content_type={"plaintext": "0", "html": "1"}.get(str(self._module.params["content_type"])), username=self._module.params["username"], passwd=self._module.params["password"] )) @@ -693,6 +703,7 @@ def main(): 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), + content_type=dict(type="str", choices=["plaintext", "html"], default="html", required=False), # EZ Text message_text_limit=dict(type="str", required=False, choices=["USA", "Canada"]), # Webhook diff --git a/ansible_collections/community/zabbix/plugins/modules/zabbix_service_info.py b/ansible_collections/community/zabbix/plugins/modules/zabbix_service_info.py new file mode 100644 index 000000000..1984777d3 --- /dev/null +++ b/ansible_collections/community/zabbix/plugins/modules/zabbix_service_info.py @@ -0,0 +1,149 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2021, D3DeFi +# 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_info +short_description: Gather information about Zabbix service +author: + - Kanstantsin Maksimau (@us3241) +description: + - This module allows you to obtain detailed information about configured zabbix service. +requirements: + - "python >= 3.9" +options: + service_name: + description: + - Name of the Zabbix service. + required: true + type: str +extends_documentation_fragment: +- community.zabbix.zabbix + +""" + +EXAMPLES = """ +# If you want to use Username and Password to be authenticated by Zabbix Server +- name: Set credentials to access Zabbix Server API + ansible.builtin.set_fact: + ansible_user: Admin + ansible_httpapi_pass: zabbix + +# If you want to use API token to be authenticated by Zabbix Server +# https://www.zabbix.com/documentation/current/en/manual/web_interface/frontend_sections/administration/general#api-tokens +- name: Set API token + ansible.builtin.set_fact: + ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 + +- name: Get zabbix service info + # set task level variables as we change ansible_connection plugin here + vars: + ansible_network_os: community.zabbix.zabbix + ansible_connection: httpapi + ansible_httpapi_port: 443 + ansible_httpapi_use_ssl: true + ansible_httpapi_validate_certs: false + ansible_zabbix_url_path: "zabbixeu" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu + ansible_host: zabbix-example-fqdn.org + community.zabbix.zabbix_service_info: + service_name: zbx01.example.com +""" + +RETURN = """ +zabbix_service: + description: example + returned: always + type: dict + sample: { + "algorithm": "2", + "children": [ + { + "algorithm": "0", + "created_at": "1712743194", + "description": "", + "name": "example children", + "propagation_rule": "0", + "propagation_value": "0", + "readonly": false, + "serviceid": "81", + "sortorder": "0", + "status": "-1", + "uuid": "ce6e1a3784a547b48ee6707f6e061102", + "weight": "0" + } + ], + "created_at": "1709717864", + "description": "", + "name": "example service", + "parents": [], + "problem_tags": [], + "propagation_rule": "0", + "propagation_value": "0", + "readonly": false, + "serviceid": "51", + "sortorder": "0", + "status": "-1", + "status_rules": [], + "tags": [], + "uuid": "420e48b363fe473c95288c817031447f", + "weight": "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 Service(ZabbixBase): + + def get_service(self, name): + result = {} + params = { + "filter": { + "name": name + }, + "output": "extend", + "selectParents": "extend", + "selectTags": "extend", + "selectProblemTags": "extend", + "selectChildren": "extend", + "selectStatusRules": "extend" + } + + try: + result = self._zapi.service.get(params) + except Exception as e: + self._module.fail_json(msg="Failed to get service information: %s" % e) + + return result[0] if result else {} + + +def main(): + argument_spec = zabbix_utils.zabbix_common_argument_spec() + argument_spec.update(dict( + service_name=dict(type="str", required=True), + )) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + name = module.params["service_name"] + + service = Service(module) + result = service.get_service(name) + module.exit_json(changed=False, zabbix_service=result) + + +if __name__ == "__main__": + main() diff --git a/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py b/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py index a773790aa..f2c19c33c 100644 --- a/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py +++ b/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py @@ -33,17 +33,21 @@ options: description: - JSON dump of templates to import. - Multiple templates can be imported this way. - - Mutually exclusive with I(template_name) and I(template_xml). + - Mutually exclusive with I(template_name) and I(template_xml) and I(template_yaml). 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). + - Mutually exclusive with I(template_name) and I(template_json) and I(template_yaml). + required: false + type: str + template_yaml: + description: + - Context of exported templates file to import. + - Multiple templates can be imported this way. + - Mutually exclusive with I(template_name) and I(template_json) and I(template_xml). required: false type: str template_groups: @@ -288,7 +292,6 @@ RETURN = r""" import json import traceback import re -import xml.etree.ElementTree as ET from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_native @@ -342,35 +345,84 @@ class Template(ZabbixBase): self._zapi.template.create(new_template) - def check_template_changed(self, template_ids, template_groups, link_templates, clear_templates, - template_macros, template_tags, template_content, template_type): - """Compares template parameters to already existing values if any are found. + def import_compare(self, template_content, template_type): + """template_content has same structure as Zabbix uses (e.g. it was optimally exported via Zabbix GUI or API)""" - 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 + if template_content is not None: + update_rules = { + "discoveryRules": { + "createMissing": True, + "updateExisting": True, + "deleteMissing": True + }, + "graphs": { + "createMissing": True, + "updateExisting": True, + "deleteMissing": True + }, + "host_groups": { + "createMissing": True + }, + "httptests": { + "createMissing": True, + "updateExisting": True, + "deleteMissing": True + }, + "items": { + "createMissing": True, + "updateExisting": True, + "deleteMissing": True + }, + "templates": { + "createMissing": True, + "updateExisting": True + }, + "template_groups": { + "createMissing": True + }, + "templateLinkage": { + "createMissing": True + }, + "templateScreens": { + "createMissing": True, + "updateExisting": True, + "deleteMissing": True + }, + "triggers": { + "createMissing": True, + "updateExisting": True, + "deleteMissing": True + }, + "valueMaps": { + "createMissing": True, + "updateExisting": True + } + } - return changed + try: + update_rules["templateLinkage"]["deleteMissing"] = True + update_rules["templateDashboards"] = update_rules.pop("templateScreens") + + # before Zabbix 6.2 host_groups and template_group are joined into groups parameter + if LooseVersion(self._zbx_api_version) < LooseVersion("6.2"): + update_rules["groups"] = {"createMissing": True} + update_rules.pop("host_groups", None) + update_rules.pop("template_groups", None) + importcompare = {"format": template_type, "source": template_content, "rules": update_rules} + compare_result = self._zapi.configuration.importcompare(importcompare) + if len(compare_result) != 0: + changed = True + return changed + except Exception as e: + self._module.fail_json(msg="Unable to compare template", details=to_native(e), + exception=traceback.format_exc()) + def check_template_changed(self, template_ids, template_groups, link_templates, clear_templates, + template_macros, template_tags): + """Compare template with user provided all parameters via module options""" + changed = False 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: if LooseVersion(self._zbx_api_version) >= LooseVersion("6.2"): existing_groups = [g["name"] for g in existing_template["zabbix_export"]["template_groups"]] @@ -451,81 +503,15 @@ class Template(ZabbixBase): templateids_list = [t.get("templateid") for t in templateids] self._zapi.template.delete(templateids_list) - 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"): template_ids_list = [t.get("templateid") for t in template_ids] try: dump = self._zapi.configuration.export({"format": template_type, "options": {"templates": template_ids_list}}) - if template_type == "xml": - xmlroot = ET.fromstring(dump.encode("utf-8")) - 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) + return self.load_json_template(dump) 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 - - # 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): try: jsondoc = json.loads(template_json) @@ -533,12 +519,6 @@ class Template(ZabbixBase): 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) @@ -624,6 +604,7 @@ def main(): template_name=dict(type="str", required=False), template_json=dict(type="json", required=False), template_xml=dict(type="str", required=False), + template_yaml=dict(type="str", required=False), template_groups=dict(type="list", required=False, elements="str"), link_templates=dict(type="list", required=False, elements="str"), clear_templates=dict(type="list", required=False, elements="str"), @@ -648,10 +629,10 @@ def main(): module = AnsibleModule( argument_spec=argument_spec, required_one_of=[ - ["template_name", "template_json", "template_xml"] + ["template_name", "template_json", "template_xml", "template_yaml"] ], mutually_exclusive=[ - ["template_name", "template_json", "template_xml"] + ["template_name", "template_json", "template_xml", "template_yaml"] ], required_if=[ ["state", "absent", ["template_name"]] @@ -662,6 +643,7 @@ def main(): template_name = module.params["template_name"] template_json = module.params["template_json"] template_xml = module.params["template_xml"] + template_yaml = module.params["template_yaml"] template_groups = module.params["template_groups"] link_templates = module.params["link_templates"] clear_templates = module.params["clear_templates"] @@ -673,23 +655,23 @@ def main(): # 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 + template_content, template_type, template_ids = None, 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"))) + + elif template_yaml is not None: + template_type = "yaml" + template_content = template_yaml else: template_names = [template_name] - - template_ids = template.get_template_ids(template_names) + template_ids = template.get_template_ids(template_names) if state == "absent": if not template_ids: @@ -699,58 +681,63 @@ def main(): module.exit_json(changed=True, result="Successfully deleted template %s" % template_name) 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 template_tags is not None: - for tagitem in template_tags: - for key in tagitem: - tagitem[key] = str(tagitem[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") - + if template_content is not None: + changed = template.import_compare(template_content, template_type) + if not changed: + module.exit_json(changed=changed, result="Template is up-to date") else: + if module.check_mode: + module.exit_json(changed=changed) + template.import_template(template_content, template_type) + module.exit_json(changed=changed, result="Template import successful") + else: + # 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 template_tags is not None: + for tagitem in template_tags: + for key in tagitem: + tagitem[key] = str(tagitem[key]) + + if not template_ids: + # Assume new templates are being added when no ID"s were found 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, template_tags) 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_tags, template_content, template_type) + else: + changed = template.check_template_changed(template_ids, template_groups, link_templates, clear_templates, + template_macros, template_tags) - if module.check_mode: - module.exit_json(changed=changed) + 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, template_tags) + 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, template_tags) - module.exit_json(changed=changed, result="Template successfully updated") + module.exit_json(changed=changed, result="Template successfully updated") if __name__ == "__main__": diff --git a/ansible_collections/community/zabbix/plugins/modules/zabbix_templategroup.py b/ansible_collections/community/zabbix/plugins/modules/zabbix_templategroup.py index 7ab39d8fc..a7050f226 100644 --- a/ansible_collections/community/zabbix/plugins/modules/zabbix_templategroup.py +++ b/ansible_collections/community/zabbix/plugins/modules/zabbix_templategroup.py @@ -67,7 +67,7 @@ EXAMPLES = r''' ansible_httpapi_validate_certs: false ansible_zabbix_url_path: 'zabbixeu' # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu ansible_host: zabbix-example-fqdn.org - community.zabbix.zabbix_group: + community.zabbix.zabbix_templategroup: state: present template_groups: - Example group1 @@ -84,7 +84,7 @@ EXAMPLES = r''' ansible_httpapi_validate_certs: false ansible_zabbix_url_path: 'zabbixeu' # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu ansible_host: zabbix-example-fqdn.org - community.zabbix.zabbix_group: + community.zabbix.zabbix_templategroup: state: present template_groups: - Example group1 diff --git a/ansible_collections/community/zabbix/roles/zabbix_agent/README.md b/ansible_collections/community/zabbix/roles/zabbix_agent/README.md index aa73fab3a..fe4a601b3 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_agent/README.md +++ b/ansible_collections/community/zabbix/roles/zabbix_agent/README.md @@ -102,6 +102,7 @@ See the following list of supported Operating systems with the Zabbix releases: | Debian 11 bullseye | V | V | V | | Debian 10 buster | V | V | V | +You can bypass this matrix by setting `enable_version_check: false` # Getting started @@ -136,6 +137,8 @@ The following is an overview of all available configuration default for this rol * `zabbix_agent_disable_repo`: A list of repos to disable during install. Default `epel`. * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. ### SElinux @@ -337,7 +340,7 @@ Keep in mind that using the Zabbix Agent in a Container requires changes to the ## 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_authtype`: IPMI authentication algorithm. Possible values are -1 (default), 0 (none), 1 (MD2), 2 (MD5), 4 (straight), 5 (OEM), 6 (RMCP+), with -1 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. diff --git a/ansible_collections/community/zabbix/roles/zabbix_agent/defaults/main.yml b/ansible_collections/community/zabbix/roles/zabbix_agent/defaults/main.yml index dbd5db5db..12424a6da 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_agent/defaults/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_agent/defaults/main.yml @@ -26,6 +26,9 @@ zabbix_agent2_deny_key: "{{ zabbix_agent_deny_key }}" # Selinux related vars selinux_allow_zabbix_run_sudo: false +zabbix_repo_deb_gpg_key_url: http://repo.zabbix.com/zabbix-official-repo.key +zabbix_repo_deb_include_deb_src: true + zabbix_agent_install_agent_only: false zabbix_agent_packages: - "{{ zabbix_agent_package }}" @@ -66,6 +69,7 @@ zabbix_repo_yum: gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX state: present +zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}" zabbix_repo_deb_component: main # Zabbix API stuff @@ -165,7 +169,7 @@ zabbix_agent_tls_config: cert: "4" # IPMI settings -zabbix_agent_ipmi_authtype: 2 +zabbix_agent_ipmi_authtype: -1 zabbix_agent_ipmi_password: zabbix_agent_ipmi_privilege: 2 zabbix_agent_ipmi_username: diff --git a/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/prepare.yml b/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/prepare.yml index 582006d4e..e95cc9ad7 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/prepare.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_agent/molecule/with-server/prepare.yml @@ -75,6 +75,7 @@ hosts: docker tasks: - name: "Download Docker CE repo file" + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: url: https://download.docker.com/linux/centos/docker-ce.repo dest: /etc/yum.repos.d/docker-ce.repo diff --git a/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Debian.yml index 6ded0ba03..92d56b179 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Debian.yml @@ -8,33 +8,6 @@ tags: - always -- name: "Debian | Installing lsb-release" - ansible.builtin.apt: - pkg: lsb-release - update_cache: true - cache_valid_time: 3600 - force: true - state: present - environment: - http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" - https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" - become: true - tags: - - install - -- name: "Debian | Update ansible_lsb fact" - ansible.builtin.setup: - gather_subset: - - lsb - -- name: "Debian | Repo URL" - ansible.builtin.set_fact: - zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}" - when: - - zabbix_repo_deb_url is undefined - tags: - - always - - name: "Debian | Installing gnupg" ansible.builtin.apt: pkg: gnupg @@ -65,8 +38,9 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: - url: http://repo.zabbix.com/zabbix-official-repo.key + url: "{{ zabbix_repo_deb_gpg_key_url }}" dest: "{{ zabbix_gpg_key }}" mode: "0644" force: true @@ -84,7 +58,7 @@ group: root mode: 0644 content: | - Types: deb deb-src + Types: deb{{ ' deb-src' if zabbix_repo_deb_include_deb_src }} Enabled: yes URIs: {{ zabbix_repo_deb_url }} Suites: {{ ansible_distribution_release }} diff --git a/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml b/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml index f5f87d18f..c5fd06480 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml @@ -12,16 +12,12 @@ tags: - always -- name: Set More Variables - ansible.builtin.set_fact: - zabbix_valid_version: "{{ zabbix_agent_version|float in zabbix_valid_agent_versions[ansible_distribution_major_version] }}" - tags: - - always - -- name: Stopping Install of Invalid Version - ansible.builtin.fail: - msg: Zabbix version {{ zabbix_agent_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} - when: not zabbix_valid_version +- name: Check that version is supported + when: enable_version_check | default(true) | bool + ansible.builtin.assert: + that: + - "{{ zabbix_agent_version|float in zabbix_valid_agent_versions[ansible_distribution_major_version] }}" + fail_msg: Zabbix version {{ zabbix_agent_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} tags: - always diff --git a/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/userparameter.yml b/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/userparameter.yml index a80be1736..d61e3899f 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/userparameter.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/userparameter.yml @@ -7,6 +7,7 @@ notify: - restart win zabbix agent with_items: "{{ zabbix_agent_userparameters }}" + when: item.scripts_dir is not defined - name: "Windows | Installing user-defined scripts" ansible.windows.win_copy: @@ -33,6 +34,7 @@ - restart mac zabbix agent become: true with_items: "{{ zabbix_agent_userparameters }}" + when: item.scripts_dir is not defined - name: "Installing user-defined scripts" ansible.builtin.copy: @@ -66,6 +68,7 @@ - restart mac zabbix agent become: true with_items: "{{ zabbix_agent_userparameters }}" + when: item.scripts_dir is not defined - name: "Installing user-defined scripts" ansible.builtin.copy: diff --git a/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Debian.yml index 4a65dfbeb..4a88411f1 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_agent/vars/Debian.yml @@ -44,5 +44,4 @@ zabbix_valid_agent_versions: - 6.0 debian_keyring_path: /etc/apt/keyrings/ -zabbix_gpg_key: "{{ debian_keyring_path }}/zabbix-official-repo.asc" -_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}" +zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc" diff --git a/ansible_collections/community/zabbix/roles/zabbix_javagateway/README.md b/ansible_collections/community/zabbix/roles/zabbix_javagateway/README.md index 1761c7f8b..47092a6a0 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_javagateway/README.md +++ b/ansible_collections/community/zabbix/roles/zabbix_javagateway/README.md @@ -46,6 +46,8 @@ See the following list of supported Operating systems with the Zabbix releases. | Debian 11 bullseye | V | V | V | | Debian 10 buster | V | V | V | +You can bypass this matrix by setting `enable_version_check: false` + # Role Variables ## Main variables @@ -62,6 +64,8 @@ The `zabbix_javagateway_version` is optional. The latest available major.minor v * `zabbix_javagateway_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. ### Java Gatewaty diff --git a/ansible_collections/community/zabbix/roles/zabbix_javagateway/defaults/main.yml b/ansible_collections/community/zabbix/roles/zabbix_javagateway/defaults/main.yml index 4356f61a4..d7f659648 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_javagateway/defaults/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_javagateway/defaults/main.yml @@ -25,9 +25,13 @@ zabbix_repo_yum: gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX state: present +zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}" zabbix_repo_deb_component: main zabbix_javagateway_pidfile: /run/zabbix/zabbix_java_gateway.pid zabbix_javagateway_listenip: 0.0.0.0 zabbix_javagateway_listenport: 10052 zabbix_javagateway_startpollers: 5 + +zabbix_repo_deb_gpg_key_url: http://repo.zabbix.com/zabbix-official-repo.key +zabbix_repo_deb_include_deb_src: true diff --git a/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/Debian.yml index 4c4cff06d..ad762aa3b 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/Debian.yml @@ -5,33 +5,6 @@ tags: - always -- name: "Debian | Installing lsb-release" - ansible.builtin.apt: - pkg: lsb-release - update_cache: true - cache_valid_time: 3600 - force: true - state: present - environment: - http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" - https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" - become: true - tags: - - install - -- name: "Debian | Update ansible_lsb fact" - ansible.builtin.setup: - gather_subset: - - lsb - -- name: "Debian | Repo URL" - ansible.builtin.set_fact: - zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}" - when: - - zabbix_repo_deb_url is undefined - tags: - - always - # In releases older than Debian 12 and Ubuntu 22.04, /etc/apt/keyrings does not exist by default. # It SHOULD be created with permissions 0755 if it is needed and does not already exist. # See: https://wiki.debian.org/DebianRepository/UseThirdParty @@ -46,11 +19,15 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: - url: http://repo.zabbix.com/zabbix-official-repo.key + url: "{{ zabbix_repo_deb_gpg_key_url }}" dest: "{{ zabbix_gpg_key }}" mode: "0644" force: true + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" become: true tags: - install @@ -62,7 +39,7 @@ group: root mode: 0644 content: | - Types: deb deb-src + Types: deb{{ ' deb-src' if zabbix_repo_deb_include_deb_src }} Enabled: yes URIs: {{ zabbix_repo_deb_url }} Suites: {{ ansible_distribution_release }} diff --git a/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/main.yml b/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/main.yml index 6b56d43d3..aeeecbc8f 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_javagateway/tasks/main.yml @@ -13,16 +13,12 @@ tags: - always -- name: Set More Variables - ansible.builtin.set_fact: - zabbix_valid_version: "{{ zabbix_javagateway_version|float in zabbix_valid_javagateway_versions[ansible_distribution_major_version] }}" - tags: - - always - -- name: Stopping Install of Invalid Version - ansible.builtin.fail: - msg: Zabbix version {{ zabbix_javagateway_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} - when: not zabbix_valid_version +- name: Check that version is supported + when: enable_version_check | default(true) | bool + ansible.builtin.assert: + that: + - "{{ zabbix_javagateway_version|float in zabbix_valid_javagateway_versions[ansible_distribution_major_version] }}" + fail_msg: Zabbix version {{ zabbix_javagateway_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} tags: - always diff --git a/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/Debian.yml index 2253f5b7b..7c36d2d3a 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_javagateway/vars/Debian.yml @@ -26,5 +26,4 @@ zabbix_valid_javagateway_versions: - 6.0 debian_keyring_path: /etc/apt/keyrings/ -zabbix_gpg_key: "{{ debian_keyring_path }}/zabbix-official-repo.asc" -_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}" +zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc" diff --git a/ansible_collections/community/zabbix/roles/zabbix_proxy/README.md b/ansible_collections/community/zabbix/roles/zabbix_proxy/README.md index baec42155..ee558c8b7 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_proxy/README.md +++ b/ansible_collections/community/zabbix/roles/zabbix_proxy/README.md @@ -89,6 +89,8 @@ See the following list of supported Operating systems with the Zabbix releases. | Debian 11 bullseye | V | V | V | | Debian 10 buster | V | V | V | +You can bypass this matrix by setting `enable_version_check: false` + # Role Variables ## Main variables @@ -133,6 +135,9 @@ The following is an overview of all available configuration default for this rol * `*zabbix_proxy_package_state`: Default: `present`. Can be overridden to `latest` to update packages * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_proxy_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. + ### SElinux * `zabbix_proxy_selinux`: Default: `False`. Enables an SELinux policy so that the Proxy will run. diff --git a/ansible_collections/community/zabbix/roles/zabbix_proxy/defaults/main.yml b/ansible_collections/community/zabbix/roles/zabbix_proxy/defaults/main.yml index f46c9c64e..b2b74ebec 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_proxy/defaults/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_proxy/defaults/main.yml @@ -41,6 +41,7 @@ zabbix_proxy_version_minor: "*" # Yum/APT Variables zabbix_repo_yum_schema: https zabbix_repo_yum_gpgcheck: 0 +zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_proxy_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}" zabbix_repo_deb_component: main zabbix_proxy_disable_repo: - epel @@ -61,6 +62,8 @@ zabbix_repo_yum: state: present zabbix_proxy_apt_priority: zabbix_proxy_package_state: present +zabbix_repo_deb_gpg_key_url: http://repo.zabbix.com/zabbix-official-repo.key +zabbix_repo_deb_include_deb_src: true # Proxy Configuration Variables (Only ones with role provided defaults) zabbix_proxy_allowroot: 0 diff --git a/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/Debian.yml index 8e27e7d27..bef68b27a 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/Debian.yml @@ -7,33 +7,6 @@ tags: - always -- name: "Debian | Installing lsb-release" - ansible.builtin.apt: - pkg: lsb-release - update_cache: true - cache_valid_time: 3600 - force: true - state: present - environment: - http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" - https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" - become: true - tags: - - install - -- name: "Debian | Update ansible_lsb fact" - ansible.builtin.setup: - gather_subset: - - lsb - -- name: "Debian | Repo URL" - ansible.builtin.set_fact: - zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}" - when: - - zabbix_repo_deb_url is undefined - tags: - - always - - name: "Debian | Set some facts for Zabbix" ansible.builtin.set_fact: datafiles_path: /usr/share/doc/zabbix-sql-scripts/{{ zabbix_proxy_db_long }} @@ -71,11 +44,15 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: - url: http://repo.zabbix.com/zabbix-official-repo.key + url: "{{ zabbix_repo_deb_gpg_key_url }}" dest: "{{ zabbix_gpg_key }}" mode: "0644" force: true + 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: true @@ -89,7 +66,7 @@ group: root mode: 0644 content: | - Types: deb deb-src + Types: deb{{ ' deb-src' if zabbix_repo_deb_include_deb_src }} Enabled: yes URIs: {{ zabbix_repo_deb_url }} Suites: {{ ansible_distribution_release }} diff --git a/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/main.yml b/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/main.yml index f564635b1..1e8831c35 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/main.yml @@ -15,17 +15,18 @@ - name: Set More Variables ansible.builtin.set_fact: zabbix_proxy_db_long: "{{ 'postgresql' if zabbix_proxy_database == 'pgsql' else zabbix_proxy_database }}" - zabbix_valid_version: "{{ zabbix_proxy_version|float in zabbix_valid_proxy_versions[ansible_distribution_major_version] }}" zabbix_short_version: "{{ zabbix_proxy_version | regex_replace('\\.', '') }}" zabbix_proxy_fpinglocation: "{{ zabbix_proxy_fpinglocation if zabbix_proxy_fpinglocation is defined else _zabbix_proxy_fpinglocation}}" zabbix_proxy_fping6location: "{{ zabbix_proxy_fping6location if zabbix_proxy_fping6location is defined else _zabbix_proxy_fping6location}}" tags: - always -- name: Stopping Install of Invalid Version - ansible.builtin.fail: - msg: Zabbix version {{ zabbix_proxy_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} - when: not zabbix_valid_version +- name: Check that version is supported + when: enable_version_check | default(true) | bool + ansible.builtin.assert: + that: + - "{{ zabbix_proxy_version|float in zabbix_valid_proxy_versions[ ansible_facts['distribution_major_version'] ] }}" + fail_msg: Zabbix version {{ zabbix_proxy_version }} is not supported on {{ ansible_facts['distribution'] }} {{ ansible_facts['distribution_major_version'] }} tags: - always diff --git a/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/Debian.yml index cd9527eb2..1362e557e 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_proxy/vars/Debian.yml @@ -51,7 +51,6 @@ mysql_plugin: "10": mysql_native_password debian_keyring_path: /etc/apt/keyrings/ -zabbix_gpg_key: "{{ debian_keyring_path }}/zabbix-official-repo.asc" -_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_proxy_version }}" +zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc" _zabbix_proxy_fping6location: /usr/bin/fping6 _zabbix_proxy_fpinglocation: /usr/bin/fping diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/README.md b/ansible_collections/community/zabbix/roles/zabbix_server/README.md index f154f4951..9557281c3 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_server/README.md +++ b/ansible_collections/community/zabbix/roles/zabbix_server/README.md @@ -86,6 +86,8 @@ See the following list of supported Operating systems with the Zabbix releases: | Debian 11 bullseye | V | V | V | | Debian 10 buster | | | V | +You can bypass this matrix by setting `enable_version_check: false` + # Installation Installing this role is very simple: `ansible-galaxy install community.zabbix.zabbix_server` @@ -109,6 +111,8 @@ The following is an overview of all available configuration default for this rol * `zabbix_service_enabled`: Default: `True` Can be overridden to `False` if needed * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_server_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. ### SElinux diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/defaults/main.yml b/ansible_collections/community/zabbix/roles/zabbix_server/defaults/main.yml index 6aec202dd..933e0339a 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_server/defaults/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_server/defaults/main.yml @@ -40,9 +40,8 @@ zabbix_server_version_minor: "*" zabbix_server_package_state: present zabbix_repo_yum_gpgcheck: 0 zabbix_repo_yum_schema: https +zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_server_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}" zabbix_repo_deb_component: main -zabbix_server_disable_repo: - - epel zabbix_repo_yum: - name: zabbix description: Zabbix Official Repository - $basearch @@ -59,8 +58,9 @@ zabbix_repo_yum: gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX state: present zabbix_server_apt_priority: -zabbix_server_install_recommends: true zabbix_server_conf_mode: 0640 +zabbix_repo_deb_gpg_key_url: http://repo.zabbix.com/zabbix-official-repo.key +zabbix_repo_deb_include_deb_src: true # Server Configuration Variables (Only ones with role provided defaults) zabbix_server_alertscriptspath: /usr/lib/zabbix/alertscripts diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/Debian.yml index ccfe6f121..c7b106614 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/Debian.yml @@ -3,40 +3,6 @@ ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_server_version | regex_replace('\\.', '') }}" zabbix_underscore_version: "{{ zabbix_server_version | regex_replace('\\.', '_') }}" - zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}" - tags: - - always - -- name: "Debian | Installing lsb-release" - ansible.builtin.apt: - pkg: lsb-release - update_cache: true - cache_valid_time: 3600 - force: true - state: present - environment: - http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" - https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" - become: true - tags: - - install - -- name: "Debian | Update ansible_lsb fact" - ansible.builtin.setup: - gather_subset: - - lsb - -- name: "Debian | Repo URL" - ansible.builtin.set_fact: - zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}" - when: - - zabbix_repo_deb_url is undefined - tags: - - always - -- name: "Debian | Set some facts for Zabbix" - ansible.builtin.set_fact: - datafiles_path: /usr/share/zabbix-sql-scripts/{{ 'postgresql' if zabbix_server_database == 'pgsql' else 'mysql' }} tags: - always @@ -70,11 +36,15 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: - url: http://repo.zabbix.com/zabbix-official-repo.key + url: "{{ zabbix_repo_deb_gpg_key_url }}" dest: "{{ zabbix_gpg_key }}" mode: "0644" force: true + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" register: zabbix_server_repo_files_installed until: zabbix_server_repo_files_installed is succeeded become: true @@ -88,7 +58,7 @@ group: root mode: 0644 content: | - Types: deb deb-src + Types: deb{{ ' deb-src' if zabbix_repo_deb_include_deb_src }} Enabled: yes URIs: {{ zabbix_repo_deb_url }} Suites: {{ ansible_distribution_release }} @@ -124,117 +94,3 @@ become: true tags: - install - -# 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: "Debian | Check for the dpkg exclude line" - ansible.builtin.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: false - become: true - tags: - - install - -- name: "Debian | Allow Zabbix dpkg installs to /usr/share/doc/zabbix*" - ansible.builtin.lineinfile: - path: /etc/dpkg/dpkg.cfg.d/excludes - line: "path-include=/usr/share/doc/zabbix*" - become: true - when: - - dpkg_exclude_line.rc == 0 - tags: - - install - -- name: "Debian | Installing zabbix-server-{{ zabbix_server_database }}" - ansible.builtin.apt: - pkg: zabbix-server-{{ zabbix_server_database }} - state: "{{ zabbix_server_package_state }}" - update_cache: true - 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: true - tags: - - install - -- name: "Debian | Installing zabbix-sql-scripts" - ansible.builtin.apt: - pkg: zabbix-sql-scripts - state: "{{ zabbix_server_package_state }}" - update_cache: true - 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_sql_installed - until: zabbix_server_package_sql_installed is succeeded - when: - - zabbix_server_version is version('5.4', '>=') - become: true - tags: - - install - -- name: "Debian | Install Database Client Package" - block: - - name: "Debian | Install Mysql Client package" - ansible.builtin.apt: - name: - - default-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: true - when: - - zabbix_server_database == 'mysql' - - ansible_distribution_release != "buster" - - - name: "Debian 10 | Install Mysql Client package" - ansible.builtin.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: true - when: - - zabbix_server_database == 'mysql' - - ansible_distribution_release == "buster" - - - name: "Debian | Install PostgreSQL Client package" - ansible.builtin.apt: - name: - - postgresql-client - - "{{ 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: true - when: - - zabbix_server_database == 'pgsql' - when: zabbix_server_install_database_client - tags: - - install - - database - - dependencies diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/RedHat.yml b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/RedHat.yml index fefd7e86c..77fb7cd8a 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/RedHat.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/RedHat.yml @@ -7,18 +7,6 @@ tags: - always -- name: "RedHat | Use Zabbix package name" - ansible.builtin.set_fact: - zabbix_server_package: "zabbix-server-{{ zabbix_server_database }}" - tags: - - always - -- name: "RedHat | Set facts for Zabbix" - ansible.builtin.set_fact: - datafiles_path: "/usr/share/zabbix-sql-scripts/{{ 'postgresql' if zabbix_server_database == 'pgsql' else 'mysql' }}" - tags: - - always - - name: "RedHat | Make sure old file is absent" ansible.builtin.file: path: /etc/yum.repos.d/zabbix-supported.repo @@ -46,86 +34,6 @@ tags: - install -- name: "RedHat | Installing zabbix-server-{{ zabbix_server_database }}" - ansible.builtin.package: - pkg: "{{ zabbix_server_package }}-{{ zabbix_server_version }}.{{ zabbix_server_version_minor }}" - state: "{{ zabbix_server_package_state }}" - disablerepo: "{{ zabbix_server_disable_repo | default(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: true - tags: - - install - -- name: "RedHat | Installing zabbix-sql-scripts" - ansible.builtin.package: - pkg: "zabbix-sql-scripts-{{ zabbix_server_version }}.{{ zabbix_server_version_minor }}" - state: "{{ zabbix_server_package_state }}" - disablerepo: "{{ zabbix_server_disable_repo | default(omit) }}" - environment: - http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" - https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" - register: zabbix_server_sql_package_installed - until: zabbix_server_sql_package_installed is succeeded - when: - - zabbix_server_version is version('6.0', '>=') - become: true - tags: - - install - -- name: "RedHat | Install Ansible module dependencies" - ansible.builtin.yum: - name: "{{ pgsql_depenencies[ansible_distribution_major_version] }}" - 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: true - when: - - zabbix_server_database_creation - - zabbix_server_database == 'pgsql' - tags: - - install - - dependencies - -- name: RedHat | Install Database Client Package - block: - - name: "RedHat | Install Mysql Client packages" - ansible.builtin.yum: - name: "{{ mysql_client_pkgs[ansible_distribution_major_version] }}" - 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: true - when: - - zabbix_server_database == 'mysql' - - - name: "RedHat | Install PostgreSQL client package" - ansible.builtin.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: true - when: - - zabbix_server_database == 'pgsql' - when: zabbix_server_install_database_client - tags: - - install - - dependencies - - database - - name: "RedHat | Configure SELinux when enabled" ansible.builtin.include_tasks: selinux.yml when: diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/initialize-mysql.yml b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/initialize-mysql.yml new file mode 100644 index 000000000..c3fd67c6d --- /dev/null +++ b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/initialize-mysql.yml @@ -0,0 +1,155 @@ +--- +# task file for mysql +- name: "Install MySQL dependencies" + ansible.builtin.package: + name: "{{ _zabbix_server_mysql_dependencies | select | list }}" + 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: true + tags: + - install + - database + - dependencies + +# NOTE: Upgrading system-packages with pip is generally a bad idea, but +# ubuntu-18.04 comes with pymysql==0.8.0, which seems to have a problem with +# versions 8 and above of mysql. +- name: Upgrade pymysql + when: + - ansible_facts['distribution'] == 'Ubuntu' + - ansible_facts['distribution_release'] == 'bionic' + ansible.builtin.pip: + name: "pymysql>=0.10.0,<0.11.0" + state: latest + +- name: "MySQL Database prep" + when: zabbix_server_database_creation + delegate_to: "{{ zabbix_server_real_dbhost | default(zabbix_server_dbhost_run_install | ternary(delegated_dbhost, inventory_hostname)) }}" + vars: + delegated_dbhost: "{{ (zabbix_server_dbhost == 'localhost') | ternary(inventory_hostname, zabbix_server_dbhost) }}" + tags: + - database + block: + - name: "MySQL | Create database" + community.mysql.mysql_db: + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_host: "{{ zabbix_server_mysql_login_host | 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: present + register: zabbix_database_created + + - name: "MySQL | Create database user" + community.mysql.mysql_user: + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_host: "{{ zabbix_server_mysql_login_host | 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 }}" + host: "{{ zabbix_server_privileged_host }}" + plugin: "{{ 'mysql_native_password' if (ansible_os_family == 'RedHat' and ansible_distribution_major_version == '7') else omit }}" + priv: "{{ zabbix_server_dbname }}.*:ALL" + state: present + +- name: "MySQL verify or create schema" + when: zabbix_server_database_sqlload | bool + vars: + delegated_dbhost: "{{ (zabbix_server_dbhost == 'localhost') | ternary(inventory_hostname, zabbix_server_dbhost) }}" + tags: + - database + block: + # If this check fails, then there's no dbversion table in the database, + # hence it has not been populated, and we'll create it, below. + # Otherwise, the module will succees and we could + # access the database version, for example 5000000 for Zabbix 5.0. + - name: "MySQL | Get current database version" + community.mysql.mysql_query: + login_user: "{{ zabbix_server_dbuser }}" + login_password: "{{ zabbix_server_dbpassword }}" + login_host: "{{ zabbix_server_dbhost }}" + login_port: "{{ zabbix_server_dbport }}" + login_db: "{{ zabbix_server_dbname }}" + query: 'SELECT mandatory FROM dbversion' + rescue: + - name: "MySQL | Get and set schema import overrides" + delegate_to: "{{ zabbix_server_real_dbhost | default(zabbix_server_dbhost_run_install | ternary(delegated_dbhost, inventory_hostname)) }}" + block: + - name: "MySQL | Get current value for variables" + community.mysql.mysql_variables: + variable: "{{ name }}" + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + loop: + - innodb_default_row_format + - log_bin_trust_function_creators + loop_control: + loop_var: name + register: _mysql_variable_defaults + + - name: "MySQL | Set variable overrides for schema import" + community.mysql.mysql_variables: + variable: "{{ item.name }}" + value: "{{ _mysql_schema_import_overrides[item.name] }}" + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + when: item.msg != _mysql_schema_import_overrides[item.name] + loop: "{{ _mysql_variable_defaults.results }}" + loop_control: + label: "{{ item.name }}: {{ _mysql_schema_import_overrides[item.name] }}" + vars: + _mysql_schema_import_overrides: + innodb_default_row_format: "dynamic" + log_bin_trust_function_creators: "ON" + + - name: "MySQL | Disable InnoDB Strict Mode" + when: ansible_facts['distribution_release'] == "buster" + community.mysql.mysql_variables: + variable: innodb_strict_mode + value: 0 + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + + - name: "MySQL | Import schema" + community.mysql.mysql_db: + login_user: "{{ zabbix_server_dbuser }}" + login_password: "{{ zabbix_server_dbpassword }}" + login_host: "{{ zabbix_server_dbhost }}" + login_port: "{{ zabbix_server_dbport }}" + name: "{{ zabbix_server_dbname }}" + encoding: "{{ zabbix_server_dbencoding }}" + collation: "{{ zabbix_server_dbcollation }}" + state: import + target: /usr/share/zabbix-sql-scripts/mysql/server.sql.gz + + always: + - name: "MySQL | Revert variable overrides for schema import" + delegate_to: "{{ zabbix_server_real_dbhost | default(zabbix_server_dbhost_run_install | ternary(delegated_dbhost, inventory_hostname)) }}" + community.mysql.mysql_variables: + variable: "{{ item.name }}" + value: "{{ item.msg }}" + login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}" + login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}" + login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" + login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}" + login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}" + loop: "{{ _mysql_variable_defaults.results | default([]) }}" + loop_control: + label: "{{ item.name }}: {{ item.msg }}" diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/postgresql.yml b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/initialize-pgsql.yml index 5177a55be..65bd0beec 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/postgresql.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/initialize-pgsql.yml @@ -1,126 +1,92 @@ --- # task file for postgresql - -- name: "PostgreSQL | Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" - ansible.builtin.set_fact: - delegated_dbhost: "{{ zabbix_server_dbhost if (zabbix_server_dbhost != 'localhost') else inventory_hostname }}" - when: - - zabbix_server_dbhost_run_install - tags: - - database - -- name: "PostgreSQL | Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" - ansible.builtin.set_fact: - delegated_dbhost: "{{ inventory_hostname }}" - when: - - not zabbix_server_dbhost_run_install +- name: "Install PostgreSQL dependencies" + ansible.builtin.package: + name: "{{ _zabbix_server_pgsql_dependencies | select | list }}" + 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: true tags: + - install - database + - dependencies -- name: "PostgreSQL | Delegated" - block: - - name: "PostgreSQL | Delegated | Create database" - community.postgresql.postgresql_db: - name: "{{ zabbix_server_dbname }}" - port: "{{ zabbix_server_dbport }}" - state: present - - - name: "PostgreSQL | Delegated | Create database user" - community.postgresql.postgresql_user: - db: "{{ zabbix_server_dbname }}" - name: "{{ zabbix_server_dbuser }}" - password: "{{ ('md5' + (zabbix_server_dbpassword + zabbix_server_dbuser)|hash('md5')) if zabbix_server_dbpassword_hash_method == 'md5' else zabbix_server_dbpassword }}" - port: "{{ zabbix_server_dbport }}" - priv: ALL - state: present - encrypted: true - - - name: "PostgreSQL | Delegated | Create timescaledb extension" - community.postgresql.postgresql_ext: - db: "{{ zabbix_server_dbname }}" - name: timescaledb - when: zabbix_server_database_timescaledb - become: true +- name: "PostgreSQL Database prep" + when: zabbix_server_database_creation + become: "{{ zabbix_server_dbhost_run_install }}" become_user: postgres - delegate_to: "{{ delegated_dbhost }}" - when: - - zabbix_server_database_creation - - zabbix_server_pgsql_login_host is not defined + delegate_to: "{{ zabbix_server_dbhost_run_install | ternary(delegated_dbhost, inventory_hostname) }}" + vars: + delegated_dbhost: "{{ (zabbix_server_dbhost == 'localhost') | ternary(inventory_hostname, zabbix_server_dbhost) }}" tags: - database - -- name: "PostgreSQL | Remote" block: - - name: "PostgreSQL | Remote | Create database" + - name: "PostgreSQL | Create database" community.postgresql.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_host: "{{ zabbix_server_pgsql_login_host | default(omit) }}" + port: "{{ zabbix_server_dbport }}" 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" + - name: "PostgreSQL | Create database user" community.postgresql.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 }}" + login_host: "{{ zabbix_server_pgsql_login_host | default(omit) }}" + port: "{{ zabbix_server_dbport }}" + login_unix_socket: "{{ zabbix_server_pgsql_login_unix_socket | default(omit) }}" name: "{{ zabbix_server_dbuser }}" password: "{{ ('md5' + (zabbix_server_dbpassword + zabbix_server_dbuser)|hash('md5')) if zabbix_server_dbpassword_hash_method == 'md5' else zabbix_server_dbpassword }}" - port: "{{ zabbix_server_dbport }}" + db: "{{ zabbix_server_dbname }}" priv: ALL state: present encrypted: true - - name: "PostgreSQL | Remote | Create timescaledb extension" + - name: "PostgreSQL | Create timescaledb extension" + when: zabbix_server_database_timescaledb community.postgresql.postgresql_ext: - 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_host: "{{ zabbix_server_pgsql_login_host | default(omit) }}" + port: "{{ zabbix_server_dbport }}" login_unix_socket: "{{ zabbix_server_pgsql_login_unix_socket | default(omit) }}" db: "{{ zabbix_server_dbname }}" name: timescaledb - when: zabbix_server_database_timescaledb - when: - - zabbix_server_database_creation - - zabbix_server_pgsql_login_host is defined - tags: - - database -- name: "PostgreSQL | Create schema" - ansible.builtin.shell: | - set -euxo pipefail - FILE={{ 'create.sql' if zabbix_server_version is version('6.0', '<') else 'server.sql' }} - cd {{ datafiles_path }} - if [ -f ${FILE}.gz ] - then zcat ${FILE}.gz > /tmp/create.sql - else - cp ${FILE} /tmp/create.sql - fi - cat /tmp/create.sql | psql -h '{{ zabbix_server_dbhost }}' \ - -U '{{ zabbix_server_dbuser }}' \ - -d '{{ zabbix_server_dbname }}' \ - -p '{{ zabbix_server_dbport }}' - touch /etc/zabbix/schema.done - rm -f /tmp/create.sql - args: - creates: /etc/zabbix/schema.done - executable: /bin/bash - warn: "{{ produce_warn | default(omit) }}" - environment: - PGPASSWORD: "{{ zabbix_server_dbpassword }}" - become: true - when: - - zabbix_server_database_sqlload +- name: "PostgreSQL verify or create schema" + when: zabbix_server_database_sqlload tags: - database + block: + - name: "PostgreSQL | Get current database version" + community.postgresql.postgresql_query: + login_user: "{{ zabbix_server_dbuser }}" + login_password: "{{ zabbix_server_dbpassword }}" + login_host: "{{ zabbix_server_dbhost }}" + port: "{{ zabbix_server_dbport }}" + db: "{{ zabbix_server_dbname }}" + query: 'SELECT mandatory FROM dbversion' + rescue: + - name: "PostgreSQL | Import schema" + community.postgresql.postgresql_db: + login_user: "{{ zabbix_server_dbuser }}" + login_password: "{{ zabbix_server_dbpassword }}" + login_host: "{{ zabbix_server_dbhost }}" + port: "{{ zabbix_server_dbport }}" + db: "{{ zabbix_server_dbname }}" + state: restore + target: /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz - name: "PostgreSQL | Create TimescaleDB hypertables" ansible.builtin.shell: | set -euxo pipefail - cd {{ datafiles_path }} && + cd /usr/share/zabbix-sql-scripts/postgresql && if [ -f timescaledb.sql.gz ]; then zcat timescaledb.sql.gz > /etc/timescaledb.sql ; else cp -p timescaledb.sql /etc/timescaledb.sql ; fi cat /etc/timescaledb.sql | psql -h '{{ zabbix_server_dbhost }}' \ -U '{{ zabbix_server_dbuser }}' \ diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/main.yml b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/main.yml index 62674a7ff..356403e0b 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/main.yml @@ -13,25 +13,41 @@ - name: Set More Variables ansible.builtin.set_fact: - zabbix_db_type_long: "{{ 'postgresql' if zabbix_server_database == 'pgsql' else 'mysql' }}" - zabbix_valid_version: "{{ zabbix_server_version|float in zabbix_valid_server_versions[ansible_distribution_major_version] }}" zabbix_server_fpinglocation: "{{ zabbix_server_fpinglocation if zabbix_server_fpinglocation is defined else _zabbix_server_fpinglocation}}" zabbix_server_fping6location: "{{ zabbix_server_fping6location if zabbix_server_fping6location is defined else _zabbix_server_fping6location}}" tags: - always -- name: Stopping Install of Invalid Version - ansible.builtin.fail: - msg: Zabbix version {{ zabbix_server_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} - when: not zabbix_valid_version +- name: Check that version is supported + when: enable_version_check | default(true) | bool + ansible.builtin.assert: + that: + - "{{ zabbix_server_version|float in zabbix_valid_server_versions[ ansible_facts['distribution_major_version'] ] }}" + fail_msg: Zabbix version {{ zabbix_server_version }} is not supported on {{ ansible_facts['distribution'] }} {{ ansible_facts['distribution_major_version'] }} tags: - always - name: Install the correct repository ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" -- name: Installing the {{ zabbix_db_type_long }} database - ansible.builtin.include_tasks: "{{ zabbix_db_type_long }}.yml" +- name: Install zabbix-server packages + ansible.builtin.package: + name: "{{ _zabbix_server_packages }}" + state: "{{ zabbix_server_package_state }}" + update_cache: true + disablerepo: "{{ zabbix_server_disable_repo | default(_zabbix_server_disable_repo | default(omit)) }}" + install_recommends: "{{ zabbix_server_install_recommends | default(_zabbix_server_install_recommends | default(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: true + tags: + - install + +- name: "Initialize the database" + ansible.builtin.include_tasks: "initialize-{{ zabbix_server_database }}.yml" - name: "Configure zabbix-server" ansible.builtin.template: diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/mysql.yml b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/mysql.yml deleted file mode 100644 index aad009816..000000000 --- a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/mysql.yml +++ /dev/null @@ -1,213 +0,0 @@ ---- -# task file for mysql - -- name: "MySQL | Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" - ansible.builtin.set_fact: - delegated_dbhost: "{{ zabbix_server_dbhost if (zabbix_server_dbhost != 'localhost') else inventory_hostname }}" - when: - - zabbix_server_dbhost_run_install - tags: - - database - -- name: "MySQL | Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" - ansible.builtin.set_fact: - delegated_dbhost: "{{ inventory_hostname }}" - when: - - not zabbix_server_dbhost_run_install - tags: - - database - -- name: "MySQL | Override delegated_dbhost with real dbhost when dbhost is behind loadbalancer" - ansible.builtin.set_fact: - delegated_dbhost: "{{ zabbix_server_real_dbhost }}" - when: zabbix_server_real_dbhost | default(false) - tags: - - database - -- name: "MySQL | Create database" - community.mysql.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_server_database_creation - register: zabbix_database_created - delegate_to: "{{ delegated_dbhost }}" - tags: - - database - - skip_ansible_lint - -- name: "MySQL | Create database user" - community.mysql.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 }}" - plugin: "{{ 'mysql_native_password' if (ansible_os_family == 'RedHat' and ansible_distribution_major_version == '7') else omit }}" - priv: "{{ zabbix_server_dbname }}.*:ALL" - host: "{{ zabbix_server_privileged_host }}" - state: present - when: zabbix_server_database_creation - delegate_to: "{{ delegated_dbhost }}" - tags: - - database - -- name: "MySQL | Get the file for create.sql" - ansible.builtin.shell: ls -1 {{ datafiles_path }}/{{ 'create' if zabbix_server_version is version('6.0', '<') else 'server' }}.sq* - changed_when: false - become: true - when: - - zabbix_server_database_sqlload | bool - register: ls_output_create - tags: - - database - -- name: MySQL | Get current database version - ansible.builtin.shell: | - mysql -h {{ zabbix_server_dbhost }} -u{{ zabbix_server_dbuser }} \ - -p'{{ zabbix_server_dbpassword }}' -D '{{ zabbix_server_dbname }}' \ - -e 'SELECT mandatory FROM dbversion;' - register: mysql_db_version - become: true - changed_when: false - ignore_errors: true - tags: - - database - -# If the above check failed, then there was no dbversion table in the database. -# We'll create it, below. Otherwise, we can access the database version in -# `mysql_db_version["stdout_lines"][1]`, for example 5000000 for Zabbix 5.0. -- name: MySQL | Check if database needs to be populated - ansible.builtin.set_fact: - mysql_schema_empty: "{{ mysql_db_version is failed }}" - -- name: "MySQL | Get current value for innodb_default_row_format" - community.mysql.mysql_variables: - variable: innodb_default_row_format - 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) }}" - delegate_to: "{{ delegated_dbhost }}" - register: mysql_innodb_default_row_format - tags: - - database - -- name: "MySQL | Set innodb_default_row_format to dynamic" - community.mysql.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_server_database_sqlload | bool - - mysql_schema_empty - - mysql_innodb_default_row_format.msg != 'dynamic' - delegate_to: "{{ delegated_dbhost }}" - tags: - - database - -- name: "MySQL | Disable InnoDB Strict Mode" - community.mysql.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_server_database_sqlload | bool - - mysql_schema_empty - - ansible_distribution_release == "buster" - delegate_to: "{{ delegated_dbhost }}" - tags: - - database - -- name: "MySQL | Fetch sql create file" - fetch: - src: "{{ ls_output_create.stdout }}" - dest: /tmp/{{ role_name }}/ - flat: true - become: true - when: - - delegated_dbhost != inventory_hostname - - zabbix_server_database_sqlload | bool - - mysql_schema_empty - tags: - - database - -- name: "MySQL | Copy sql create file" - ansible.builtin.copy: - src: /tmp/{{ role_name }}/ - dest: "{{ ls_output_create.stdout | dirname }}" - mode: "0640" - delegate_to: "{{ delegated_dbhost }}" - become: true - when: - - delegated_dbhost != inventory_hostname - - zabbix_server_database_sqlload | bool - - mysql_schema_empty - tags: - - database - -- name: "MySQL | Create database and import file" - community.mysql.mysql_db: - login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}" - login_user: "{{ zabbix_server_dbuser if (ansible_os_family == 'RedHat' and ansible_distribution_major_version == '7') else zabbix_server_mysql_login_user }}" - login_password: "{{ zabbix_server_dbpassword if (ansible_os_family == 'RedHat' and ansible_distribution_major_version == '7') else zabbix_server_mysql_login_password }}" - 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 }}" - use_shell: "{{ true if zabbix_server_version is version('5.0', '==') else false }}" - when: - - zabbix_server_database_sqlload | bool - - mysql_schema_empty - delegate_to: "{{ delegated_dbhost }}" - tags: - - database - -- name: "MySQL | Revert innodb_default_row_format to previous value" - community.mysql.mysql_variables: - variable: innodb_default_row_format - value: "{{ mysql_innodb_default_row_format.msg }}" - 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_server_database_sqlload | bool - - mysql_schema_empty - - mysql_innodb_default_row_format.msg != 'dynamic' - delegate_to: "{{ delegated_dbhost }}" - tags: - - database - -- name: "MySQL | Check if we have sql_done files" - ansible.builtin.file: - path: /etc/zabbix/create.done - state: touch - mode: "0644" - become: true - when: - - zabbix_server_database_sqlload | bool - - mysql_schema_empty - tags: - - database diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/selinux.yml b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/selinux.yml index fe203aed1..cd13dbbfd 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_server/tasks/selinux.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_server/tasks/selinux.yml @@ -126,6 +126,6 @@ cmd: files/install_semodule.bsx args: creates: /etc/selinux/targeted/active/modules/400/zabbix_server_add/cil - become: true + become: true tags: - config diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/vars/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_server/vars/Debian.yml index 4074869e6..75f3751c2 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_server/vars/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_server/vars/Debian.yml @@ -29,7 +29,20 @@ zabbix_valid_server_versions: - 6.0 debian_keyring_path: /etc/apt/keyrings/ -zabbix_gpg_key: "{{ debian_keyring_path }}/zabbix-official-repo.asc" -_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_server_version }}" +zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc" + +_zabbix_server_pgsql_dependencies: + - "{{ zabbix_server_install_database_client | ternary('postgresql-client', '') }}" + - python3-psycopg2 + +_zabbix_server_mysql_dependencies: + - "{{ zabbix_server_install_database_client | ternary('default-mysql-client', '') }}" + - python3-pymysql + _zabbix_server_fping6location: /usr/bin/fping6 _zabbix_server_fpinglocation: /usr/bin/fping + +_zabbix_server_packages: + - "zabbix-server-{{ zabbix_server_database }}" + - "zabbix-sql-scripts" +_zabbix_server_install_recommends: true diff --git a/ansible_collections/community/zabbix/roles/zabbix_server/vars/RedHat.yml b/ansible_collections/community/zabbix/roles/zabbix_server/vars/RedHat.yml index c2e0f14f3..fb20631f8 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_server/vars/RedHat.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_server/vars/RedHat.yml @@ -18,19 +18,19 @@ zabbix_valid_server_versions: - 6.2 - 6.0 -pgsql_depenencies: - "9": - - python3-psycopg2 - "8": - - python3-psycopg2 +_zabbix_server_pgsql_dependencies: + - "{{ zabbix_server_install_database_client | ternary('postgresql', '') }}" + - python3-psycopg2 -mysql_client_pkgs: - "9": - - mysql - - python3-PyMySQL - "8": - - mysql - - python3-PyMySQL +_zabbix_server_mysql_dependencies: + - "{{ zabbix_server_install_database_client | ternary('mysql', '') }}" + - python3-PyMySQL _zabbix_server_fping6location: /usr/sbin/fping6 _zabbix_server_fpinglocation: /usr/sbin/fping + +_zabbix_server_packages: + - "zabbix-server-{{ zabbix_server_database }}-{{ zabbix_server_version }}.{{ zabbix_server_version_minor }}" + - "zabbix-sql-scripts-{{ zabbix_server_version }}.{{ zabbix_server_version_minor }}" +_zabbix_server_disable_repo: + - epel diff --git a/ansible_collections/community/zabbix/roles/zabbix_web/README.md b/ansible_collections/community/zabbix/roles/zabbix_web/README.md index 5904f8288..aac6f9dc2 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_web/README.md +++ b/ansible_collections/community/zabbix/roles/zabbix_web/README.md @@ -16,6 +16,7 @@ - [Apache configuration](#apache-configuration) - [Nginx configuration](#nginx-configuration) - [PHP-FPM](#php-fpm) + - [SElinux](#selinux) - [Zabbix Server](#zabbix-server) * [proxy](#proxy) - [Example Playbook](#example-playbook) @@ -65,6 +66,8 @@ See the following list of supported Operating Systems with the Zabbix releases. | Debian 11 bullseye | V | V | V | | Debian 10 buster | | | V | +You can bypass this matrix by setting `enable_version_check: false` + # Installation Installing this role is very simple: `ansible-galaxy install community.zabbix.zabbix_web` @@ -94,6 +97,8 @@ The following is an overview of all available configuration defaults for this ro * `zabbix_web_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file. * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_web_version }}/{{ ansible_distribution.lower() }}` * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`. +* `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default `http://repo.zabbix.com/zabbix-official-repo.key`. +* `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`. ### Zabbix Web specific @@ -116,7 +121,6 @@ The following is an overview of all available configuration defaults for this ro * `zabbix_web_vhost_port`: The port on which Zabbix HTTP vhost is running. * `zabbix_web_vhost_tls_port`: The port on which Zabbix HTTPS vhost is running. * `zabbix_web_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_web_max_execution_time`: PHP max execution time * `zabbix_web_memory_limit`: PHP memory limit * `zabbix_web_post_max_size`: PHP maximum post size @@ -151,6 +155,13 @@ The following properties are specific to Zabbix 5.0 and for the PHP(-FPM) config * `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). +### SElinux + +* `zabbix_web_selinux`: Default: `False`. Enables an SELinux policy so that the web will run. +* `selinux_allow_httpd_can_connect_zabbix`: Default: `false`. Set SELinux boolean to allow httpd to connect to zabbix. +* `selinux_allow_httpd_can_connect_ldap`: Default: `false`. Set SELinux boolean to allow httpd to connect to LDAP. +* `selinux_allow_httpd_can_network_connect_db`: Default: `false` Set SELinux boolean to allow httpd to connect databases over the network. + ### Zabbix Server * `zabbix_server_name`: The name of the Zabbix Server. diff --git a/ansible_collections/community/zabbix/roles/zabbix_web/defaults/main.yml b/ansible_collections/community/zabbix/roles/zabbix_web/defaults/main.yml index f37bb07da..53744bab9 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_web/defaults/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_web/defaults/main.yml @@ -53,6 +53,7 @@ zabbix_web_apt_priority: zabbix_web_version_minor: "*" zabbix_repo_yum_gpgcheck: 0 zabbix_repo_yum_schema: https +zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_web_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}" zabbix_repo_deb_component: main zabbix_web_disable_repo: - epel @@ -86,9 +87,14 @@ zabbix_server_history_types: - "uint" - "dbl" -zabbix_selinux: false -# selinux_allow_zabbix_can_network: false -# zabbix_apache_can_connect_ldap: false +# SELinux specific +zabbix_web_selinux: false +selinux_allow_httpd_can_connect_ldap: false +selinux_allow_httpd_can_network_connect_db: false +selinux_allow_httpd_can_connect_zabbix: false + +zabbix_repo_deb_gpg_key_url: http://repo.zabbix.com/zabbix-official-repo.key +zabbix_repo_deb_include_deb_src: true # SAML certificates # zabbix_saml_idp_crt: diff --git a/ansible_collections/community/zabbix/roles/zabbix_web/tasks/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_web/tasks/Debian.yml index ae1c7de26..d3c12fdac 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_web/tasks/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_web/tasks/Debian.yml @@ -13,33 +13,6 @@ tags: - always -- name: "Debian | Update ansible_lsb fact" - ansible.builtin.setup: - gather_subset: - - lsb - -- name: "Debian | Installing lsb-release" - ansible.builtin.apt: - pkg: lsb-release - update_cache: true - cache_valid_time: 3600 - force: true - state: present - environment: - http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" - https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" - become: true - tags: - - install - -- name: "Debian | Repo URL" - ansible.builtin.set_fact: - zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}" - when: - - zabbix_repo_deb_url is undefined - tags: - - always - - name: "Debian | Install PHP Dependencies" ansible.builtin.apt: pkg: "{{ zabbix_web_php_dependencies }}" @@ -88,11 +61,15 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: - url: http://repo.zabbix.com/zabbix-official-repo.key + url: "{{ zabbix_repo_deb_gpg_key_url }}" dest: "{{ zabbix_gpg_key }}" mode: "0644" force: true + environment: + http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" + https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" become: true tags: - install @@ -104,7 +81,7 @@ group: root mode: 0644 content: | - Types: deb deb-src + Types: deb{{ ' deb-src' if zabbix_repo_deb_include_deb_src }} Enabled: yes URIs: {{ zabbix_repo_deb_url }} Suites: {{ ansible_distribution_release }} diff --git a/ansible_collections/community/zabbix/roles/zabbix_web/tasks/RedHat.yml b/ansible_collections/community/zabbix/roles/zabbix_web/tasks/RedHat.yml index 30871017e..8dfb2e113 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_web/tasks/RedHat.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_web/tasks/RedHat.yml @@ -57,3 +57,8 @@ - ansible_distribution_major_version == '9' tags: - install + +- name: "Configure SELinux when enabled" + ansible.builtin.include_tasks: selinux.yml + when: + - zabbix_web_selinux | bool diff --git a/ansible_collections/community/zabbix/roles/zabbix_web/tasks/main.yml b/ansible_collections/community/zabbix/roles/zabbix_web/tasks/main.yml index b82d8486b..54a313a1c 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_web/tasks/main.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_web/tasks/main.yml @@ -13,15 +13,16 @@ - name: Set More Variables ansible.builtin.set_fact: - zabbix_valid_version: "{{ zabbix_web_version|float in zabbix_valid_web_versions[ansible_distribution_major_version] }}" zabbix_db_type_long: "{{ 'postgresql' if zabbix_server_database == 'pgsql' else 'mysql' }}" tags: - always -- name: Stopping Install of Invalid Version - ansible.builtin.fail: - msg: Zabbix version {{ zabbix_web_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} - when: not zabbix_valid_version +- name: Check that version is supported + when: enable_version_check | default(true) | bool + ansible.builtin.assert: + that: + - "{{ zabbix_web_version|float in zabbix_valid_web_versions[ ansible_facts['distribution_major_version'] ] }}" + fail_msg: Zabbix version {{ zabbix_web_version }} is not supported on {{ ansible_facts['distribution'] }} {{ ansible_facts['distribution_major_version'] }} tags: - always diff --git a/ansible_collections/community/zabbix/roles/zabbix_web/tasks/selinux.yml b/ansible_collections/community/zabbix/roles/zabbix_web/tasks/selinux.yml index 56e2ae05e..df5d388db 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_web/tasks/selinux.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_web/tasks/selinux.yml @@ -12,7 +12,7 @@ become: true when: - ansible_os_family == "RedHat" - - selinux_allow_zabbix_can_network + - ansible_selinux.status == "enabled" - ansible_distribution_major_version == "7" or ansible_distribution_major_version == "6" tags: - install @@ -30,23 +30,11 @@ become: true when: - ansible_os_family == "RedHat" - - selinux_allow_zabbix_can_network + - ansible_selinux.status == "enabled" - ansible_distribution_major_version|int >= 8 tags: - install -- name: "SELinux | RedHat | Enable zabbix_can_network SELinux boolean" - ansible.posix.seboolean: - name: zabbix_can_network - state: true - persistent: true - become: true - when: - - ansible_os_family == "RedHat" - - selinux_allow_zabbix_can_network - tags: - - config - - name: "SELinux | Allow httpd to connect to db (SELinux)" ansible.posix.seboolean: name: httpd_can_network_connect_db @@ -55,7 +43,7 @@ become: true when: - ansible_selinux.status == "enabled" - - selinux_allow_zabbix_can_network + - selinux_allow_httpd_can_network_connect_db | bool tags: - config @@ -67,7 +55,7 @@ become: true when: - ansible_selinux.status == "enabled" - - selinux_allow_zabbix_can_network + - selinux_allow_httpd_can_connect_zabbix | bool tags: - config @@ -79,6 +67,6 @@ become: true when: - ansible_selinux.status == "enabled" - - zabbix_apache_can_connect_ldap | bool + - selinux_allow_httpd_can_connect_ldap | bool tags: - config diff --git a/ansible_collections/community/zabbix/roles/zabbix_web/templates/nginx_vhost.conf.j2 b/ansible_collections/community/zabbix/roles/zabbix_web/templates/nginx_vhost.conf.j2 index 7854b83ce..c04a0712c 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_web/templates/nginx_vhost.conf.j2 +++ b/ansible_collections/community/zabbix/roles/zabbix_web/templates/nginx_vhost.conf.j2 @@ -20,7 +20,7 @@ server { try_files $uri $uri/ =404; } - location /assets { + location /assets/ { access_log off; expires 10d; } @@ -70,9 +70,9 @@ server { ssl_certificate {{ zabbix_web_tls_crt }}; ssl_certificate_key {{ zabbix_web_tls_key }}; - {{ (zabbix_web_ssl_cipher_suite is defined and zabbix_web_ssl_cipher_suite is not none) | ternary('', '# ') }}ssl_ciphers {{ zabbix_web_ssl_cipher_suite | default('') }} - {{ (zabbix_web_SSLSessionCache is defined and zabbix_web_SSLSessionCache is not none) | ternary('', '# ') }}ssl_session_cache {{ zabbix_web_SSLSessionCache | default('') }} - {{ (zabbix_web_SSLSessionCacheTimeout is defined and zabbix_web_SSLSessionCacheTimeout is not none) | ternary('', '# ') }}ssl_session_timeout {{ zabbix_web_SSLSessionCacheTimeout | default('') }} + {{ (zabbix_web_ssl_cipher_suite is defined and zabbix_web_ssl_cipher_suite is not none) | ternary('', '# ') }}ssl_ciphers {{ zabbix_web_ssl_cipher_suite | default('') }}; + {{ (zabbix_web_SSLSessionCache is defined and zabbix_web_SSLSessionCache is not none) | ternary('', '# ') }}ssl_session_cache {{ zabbix_web_SSLSessionCache | default('') }}; + {{ (zabbix_web_SSLSessionCacheTimeout is defined and zabbix_web_SSLSessionCacheTimeout is not none) | ternary('', '# ') }}ssl_session_timeout {{ zabbix_web_SSLSessionCacheTimeout | default('') }}; root /usr/share/zabbix; index index.php; @@ -85,7 +85,7 @@ server { try_files $uri $uri/ =404; } - location /assets { + location /assets/ { access_log off; expires 10d; } diff --git a/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian.yml b/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian.yml index 7b60c70bd..f49b27155 100644 --- a/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian.yml +++ b/ansible_collections/community/zabbix/roles/zabbix_web/vars/Debian.yml @@ -47,5 +47,4 @@ zabbix_valid_web_versions: - 6.0 debian_keyring_path: /etc/apt/keyrings/ -zabbix_gpg_key: "{{ debian_keyring_path }}/zabbix-official-repo.asc" -_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_web_version }}" +zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc" diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_correlation/meta/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_correlation/meta/main.yml new file mode 100644 index 000000000..acdb704c8 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_correlation/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_zabbix diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_correlation/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_correlation/tasks/main.yml new file mode 100644 index 000000000..d893cbc34 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_correlation/tasks/main.yml @@ -0,0 +1,328 @@ +--- +- name: test - create simple correlation + community.zabbix.zabbix_correlation: + name: new event tag correlation + filter: + evaltype: and_or + conditions: + - type: new_event_tag + tag: ok + operations: + - type: close_old_events + register: zbxcorrelation_create + +- name: assert that correlation was created + ansible.builtin.assert: + that: + - zbxcorrelation_create.changed is sameas True + +- name: test - update simple correlation (without changes) + community.zabbix.zabbix_correlation: + name: new event tag correlation + filter: + evaltype: and_or + conditions: + - type: new_event_tag + tag: ok + operations: + - type: close_old_events + register: zbxcorrelation_create + +- name: assert that correlation was not updated + ansible.builtin.assert: + that: + - zbxcorrelation_create.changed is sameas False + +- name: test - update simple correlation + community.zabbix.zabbix_correlation: + name: new event tag correlation + filter: + evaltype: and_or + conditions: + - type: new_event_tag + tag: ng + operations: + - type: close_old_events + register: zbxcorrelation_create + +- name: assert that correlation was updated + ansible.builtin.assert: + that: + - zbxcorrelation_create.changed is sameas True + +- name: test - delete simple correlation + community.zabbix.zabbix_correlation: + name: new event tag correlation + state: absent + register: zbxcorrelation_delete + +- name: assert that correlation was deleted + ansible.builtin.assert: + that: + - zbxcorrelation_delete.changed is sameas True + +- name: prepare - create hostgroup + community.zabbix.zabbix_group: + host_groups: + - correlation_group_A + - correlation_group_B + state: present + register: zbxgroup_create + +- name: test - create custom_expression correlation + community.zabbix.zabbix_correlation: + name: new host group correlation + description: a custom description + filter: + evaltype: custom_expression + formula: A or B + conditions: + - type: new_event_host_group + hostgroup: correlation_group_A + operator: not_equal + formulaid: A + - type: new_event_host_group + hostgroup: correlation_group_B + operator: not_equal + formulaid: B + operations: + - type: close_old_events + register: zbxcorrelation_create + +- name: assert that correlation was created + ansible.builtin.assert: + that: + - zbxcorrelation_create.changed is sameas True + +- name: test - create custom_expression correlation (again) + community.zabbix.zabbix_correlation: + name: new host group correlation + description: a custom description + filter: + evaltype: custom_expression + formula: A or B + conditions: + - type: new_event_host_group + hostgroup: correlation_group_A + operator: not_equal + formulaid: A + - type: new_event_host_group + hostgroup: correlation_group_B + operator: not_equal + formulaid: B + operations: + - type: close_old_events + register: zbxcorrelation_create + +- name: assert that correlation was not updated + ansible.builtin.assert: + that: + - zbxcorrelation_create.changed is sameas False + +- name: test - delete custom_expression correlation + community.zabbix.zabbix_correlation: + name: new host group correlation + state: absent + register: zbxcorrelation_delete + +- name: assert that correlation was deleted + ansible.builtin.assert: + that: + - zbxcorrelation_delete.changed is sameas True + +- name: cleanup - delete hostgroup + community.zabbix.zabbix_group: + host_groups: + - correlation_group_A + - correlation_group_B + state: absent + register: zbxgroup_delete + +- name: test - create correlation with old_event_tag condition + community.zabbix.zabbix_correlation: + name: tag correlation + filter: + evaltype: and_or + conditions: + - type: old_event_tag + tag: old_tag + operations: + - type: close_old_events + - type: close_new_event + register: zbxcorrelation_create + +- name: assert that correlation was created + ansible.builtin.assert: + that: + - zbxcorrelation_create.changed is sameas True + +- name: test - update correlation with new_event_tag condition + community.zabbix.zabbix_correlation: + name: tag correlation + filter: + evaltype: and_or + conditions: + - type: new_event_tag + tag: new_tag + operations: + - type: close_old_events + - type: close_new_event + register: zbxcorrelation_update + +- name: assert that correlation was updated + ansible.builtin.assert: + that: + - zbxcorrelation_update.changed is sameas True + +- name: test - update correlation with event_tag_pair condition + community.zabbix.zabbix_correlation: + name: tag correlation + filter: + evaltype: and_or + conditions: + - type: event_tag_pair + oldtag: oldtag_pair + newtag: newtag_pair + operations: + - type: close_old_events + - type: close_new_event + register: zbxcorrelation_update + +- name: assert that correlation was updated + ansible.builtin.assert: + that: + - zbxcorrelation_update.changed is sameas True + +- name: test - update correlation with old_event_tag_value condition + community.zabbix.zabbix_correlation: + name: tag correlation + filter: + evaltype: and_or + conditions: + - type: old_event_tag_value + tag: old_tag_value + value: old + operator: equal + operations: + - type: close_old_events + - type: close_new_event + register: zbxcorrelation_update + +- name: assert that correlation was updated + ansible.builtin.assert: + that: + - zbxcorrelation_update.changed is sameas True + +- name: test - update correlation with new_event_tag_value condition + community.zabbix.zabbix_correlation: + name: tag correlation + filter: + evaltype: and_or + conditions: + - type: new_event_tag_value + tag: new_tag_value + value: new + operator: equal + operations: + - type: close_old_events + - type: close_new_event + register: zbxcorrelation_update + +- name: assert that correlation was updated + ansible.builtin.assert: + that: + - zbxcorrelation_update.changed is sameas True + +- name: test - delete tag correlation + community.zabbix.zabbix_correlation: + name: tag correlation + state: absent + register: zbxcorrelation_delete + +- name: assert that correlation was deleted + ansible.builtin.assert: + that: + - zbxcorrelation_delete.changed is sameas True + +- name: prepare - create hostgroup + community.zabbix.zabbix_group: + host_groups: + - correlation_group + state: present + register: zbxgroup_create + +- name: test - create host group correlation with wrong operator (like) + community.zabbix.zabbix_correlation: + name: new host group correlation + description: a custom description + filter: + evaltype: and_or + conditions: + - type: new_event_host_group + hostgroup: correlation_group + operator: like + operations: + - type: close_old_events + ignore_errors: yes + register: zbxcorrelation_create + +- name: assert that correlation was failed + ansible.builtin.assert: + that: + - zbxcorrelation_create is failed + +- name: test - create host group correlation with wrong operator (not_like) + community.zabbix.zabbix_correlation: + name: new host group correlation + description: a custom description + filter: + evaltype: and_or + conditions: + - type: new_event_host_group + hostgroup: correlation_group + operator: not_like + operations: + - type: close_old_events + ignore_errors: yes + register: zbxcorrelation_create + +- name: assert that correlation was failed + ansible.builtin.assert: + that: + - zbxcorrelation_create is failed + +- name: prepare - delete hostgroup + community.zabbix.zabbix_group: + host_groups: + - correlation_group + state: absent + register: zbxgroup_delete + +- name: test - create tag correlation with wrong formulaid + community.zabbix.zabbix_correlation: + name: new tag correlation + description: a custom description + filter: + evaltype: custom_expression + formula: a + conditions: + - type: new_event_tag_value + tag: new_tag_value + value: new + operator: equal + formulaid: a + operations: + - type: close_old_events + ignore_errors: yes + register: zbxcorrelation_create + +- name: assert that correlation was failed + ansible.builtin.assert: + that: + - zbxcorrelation_create is failed + +- name: test - delete custom_expression correlation + community.zabbix.zabbix_correlation: + name: new tag correlation + state: absent + register: zbxcorrelation_delete diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml index a4829a051..20246a16b 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml @@ -1348,6 +1348,78 @@ ansible.builtin.assert: that: zbx_host_create_interfaceless is not changed +- name: "test: attempt to delete host created earlier" + community.zabbix.zabbix_host: + host_name: ExampleHost + state: absent + register: zabbix_host1 + +- name: deleting a host is a change, right? + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + +- name: "test: create host with IPMI values" + community.zabbix.zabbix_host: + host_name: ExampleHost + host_groups: + - Linux servers + - Zabbix servers + ipmi_authtype: 1 + ipmi_privilege: 1 + ipmi_username: "test" + ipmi_password: "test" + register: zabbix_ipmi_host + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_ipmi_host is changed" + +- name: "test: update inventory of the created host" + community.zabbix.zabbix_host: + host_name: ExampleHost + inventory_mode: manual + inventory_zabbix: + notes: "Update inventory" + register: zabbix_ipmi_host + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_ipmi_host is changed" + +- name: "test: create host with IPMI values without changes" + community.zabbix.zabbix_host: + host_name: ExampleHost + ipmi_authtype: 1 + ipmi_privilege: 1 + ipmi_username: "test" + ipmi_password: "test" + register: zabbix_ipmi_host + +- name: expect to succeed and that things have not changed + ansible.builtin.assert: + that: + - "zabbix_ipmi_host is not changed" + +- name: "test: create host with host group(empty list)" + community.zabbix.zabbix_host: + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: [] + status: disabled + state: present + ignore_errors: true + register: zbx_host_create_hostgroup_empty_list + +- name: expect to fail updating + ansible.builtin.assert: + that: + - zbx_host_create_hostgroup_empty_list is failed + - zbx_host_create_hostgroup_empty_list.msg == "host_groups must be not empty list." + - name: "cleanup" community.zabbix.zabbix_host: host_name: ExampleHost diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml index 1b9c6f6bd..86d511d36 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml @@ -273,6 +273,56 @@ # that: # - update_maintenance_host_tags.changed is sameas false +- name: "test - Create maintenance with an active_since param" + community.zabbix.zabbix_maintenance: + name: maintenance + host_name: example + active_since: "1979-09-19" + state: present + register: create_maintenance_active_since_result + +- ansible.builtin.assert: + that: + - create_maintenance_active_since_result.changed is sameas true + +- name: "test - Create maintenance with a active_since param(again - expectations: false change will occur)" + community.zabbix.zabbix_maintenance: + name: maintenance + host_name: example + active_since: "1979-09-19" + state: present + register: create_maintenance_active_since_again_result + +- ansible.builtin.assert: + that: + - create_maintenance_active_since_again_result.changed is sameas false + +- name: "test - Create maintenance with an active_till param" + community.zabbix.zabbix_maintenance: + name: maintenance + host_name: example + active_since: "1979-09-19 00:00" + active_till: "1979-09-19 23:59" + state: present + register: create_maintenance_active_till_result + +- ansible.builtin.assert: + that: + - create_maintenance_active_till_result.changed is sameas true + +- name: "test - Create maintenance with a active_till param(again - expectations: false change will occur)" + community.zabbix.zabbix_maintenance: + name: maintenance + host_name: example + active_since: "1979-09-19 00:00" + active_till: "1979-09-19 23:59" + state: present + register: create_maintenance_active_till_again_result + +- ansible.builtin.assert: + that: + - create_maintenance_active_till_again_result.changed is sameas false + - name: "test - Delete maintenance" community.zabbix.zabbix_maintenance: name: maintenance diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml index a49166d37..1ba2f6669 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml @@ -114,6 +114,29 @@ - ansible.builtin.assert: that: zbxmediatype_reset.changed is sameas True + - name: test - check email mediatype content_type for html default + community.zabbix.zabbix_mediatype: + content_type: "html" + register: zbxmediatype_verif + + - ansible.builtin.assert: + that: zbxmediatype_verif.changed is sameas False + + - name: test - update email mediatype content_type to plaintext + community.zabbix.zabbix_mediatype: + content_type: "plaintext" + register: zbxmediatype_verif + + - ansible.builtin.assert: + that: zbxmediatype_verif.changed is sameas True + + - name: test - reset email mediatype content_type to default + community.zabbix.zabbix_mediatype: + register: zbxmediatype_reset + + - ansible.builtin.assert: + that: zbxmediatype_reset.changed is sameas True + - name: test - update email mediatype concurrent settings community.zabbix.zabbix_mediatype: max_sessions: 99 diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service_info/meta/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service_info/meta/main.yml new file mode 100644 index 000000000..acdb704c8 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service_info/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_zabbix diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service_info/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service_info/tasks/main.yml new file mode 100644 index 000000000..77c244df8 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service_info/tasks/main.yml @@ -0,0 +1,57 @@ +--- +- name: test - Create new Zabbix service + community.zabbix.zabbix_service: + name: ExampleService + description: ExampleService + sortorder: 0 + propagation_rule: as_is + propagation_value: not_classified + algorithm: most_crit_of_child_serv + register: create_service_result + +- ansible.builtin.assert: + that: + - create_service_result.changed is sameas true + +- name: test - Create new Zabbix child service + community.zabbix.zabbix_service: + name: ExampleChildService + description: ExampleChildService + sortorder: 0 + propagation_rule: as_is + propagation_value: not_classified + parents: ExampleService + problem_tags: + - tag: testtag + value: test + register: create_child_result + +- ansible.builtin.assert: + that: + - create_child_result.changed is sameas true + +- name: test - Get zabbix service information + community.zabbix.zabbix_service_info: + service_name: ExampleService + register: get_service_info_result + +- ansible.builtin.assert: + that: + - get_service_info_result["zabbix_service"].name == "ExampleService" + - get_service_info_result["zabbix_service"].children | length > 0 + - get_service_info_result["zabbix_service"].children[0].name == "ExampleChildService" + - get_service_info_result["zabbix_service"].propagation_rule == "0" + - get_service_info_result["zabbix_service"].propagation_value == "0" + - get_service_info_result["zabbix_service"].sortorder == "0" + +- name: test - cleanup test Zabbix child service + community.zabbix.zabbix_service: + state: absent + sortorder: 0 + name: ExampleChildService + +- name: test - cleanup test Zabbix service + community.zabbix.zabbix_service: + state: absent + sortorder: 0 + name: ExampleService diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template4_60_higher.json b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template4_60_higher.json new file mode 100644 index 000000000..7d4c37a52 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template4_60_higher.json @@ -0,0 +1,49 @@ +{ + "zabbix_export": { + "version": "6.0", + "date": "2024-01-04T18:26:37Z", + "groups": [ + { + "uuid": "7df96b18c230490a9a0a9e2307226338", + "name": "Templates" + }, + { + "uuid": "a571c0d144b14fd4a87a9d9b2aa9fcd6", + "name": "Templates/Applications" + } + ], + "templates": [ + { + "uuid": "cd837ef0edb14e4e875f409bc90af546", + "template": "ExampleTemplate", + "name": "ExampleTemplate", + "templates": [ + { + "name": "FTP Service" + }, + { + "name": "Zabbix proxy health" + } + ], + "groups": [ + { + "name": "Templates" + }, + { + "name": "Templates/Applications" + } + ], + "macros": [ + { + "macro": "{$EXAMPLE_MACRO1}", + "value": "1000" + }, + { + "macro": "{$EXAMPLE_MACRO2}", + "value": "text" + } + ] + } + ] + } +} diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template4_60_higher.xml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template4_60_higher.xml new file mode 100644 index 000000000..3d423c692 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template4_60_higher.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<zabbix_export> + <version>6.0</version> + <date>2024-01-04T18:26:29Z</date> + <groups> + <group> + <uuid>7df96b18c230490a9a0a9e2307226338</uuid> + <name>Templates</name> + </group> + <group> + <uuid>a571c0d144b14fd4a87a9d9b2aa9fcd6</uuid> + <name>Templates/Applications</name> + </group> + </groups> + <templates> + <template> + <uuid>cd837ef0edb14e4e875f409bc90af546</uuid> + <template>ExampleTemplate</template> + <name>ExampleTemplate</name> + <templates> + <template> + <name>FTP Service</name> + </template> + <template> + <name>Zabbix proxy health</name> + </template> + </templates> + <groups> + <group> + <name>Templates</name> + </group> + <group> + <name>Templates/Applications</name> + </group> + </groups> + <macros> + <macro> + <macro>{$EXAMPLE_MACRO1}</macro> + <value>1000</value> + </macro> + <macro> + <macro>{$EXAMPLE_MACRO2}</macro> + <value>text</value> + </macro> + </macros> + </template> + </templates> +</zabbix_export> diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template4_60_higher.yaml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template4_60_higher.yaml new file mode 100644 index 000000000..0112b1fc7 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template4_60_higher.yaml @@ -0,0 +1,23 @@ +zabbix_export: + version: '6.0' + date: '2024-01-04T18:26:17Z' + groups: + - uuid: 7df96b18c230490a9a0a9e2307226338 + name: Templates + - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6 + name: Templates/Applications + templates: + - uuid: cd837ef0edb14e4e875f409bc90af546 + template: ExampleTemplate + name: ExampleTemplate + templates: + - name: 'FTP Service' + - name: 'Zabbix proxy health' + groups: + - name: Templates + - name: Templates/Applications + macros: + - macro: '{$EXAMPLE_MACRO1}' + value: '1000' + - macro: '{$EXAMPLE_MACRO2}' + value: text diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml index 69aabe6b0..ce02916ee 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml @@ -370,6 +370,83 @@ - delete_zabbix_template_result.changed is sameas false # +# template_file_context parameter +# + +- name: Import Zabbix template from a file using configuration.importcompare api + block: + - name: Import Zabbix template from YAML file. + community.zabbix.zabbix_template: + template_yaml: "{{ lookup('file', 'template4_60_higher.yaml') }}" + state: present + register: import_template_yaml + + - ansible.builtin.assert: + that: + - import_template_xml.changed is sameas true + + - name: Import Zabbix same template from XML file. + community.zabbix.zabbix_template: + template_xml: "{{ lookup('file', 'template4_60_higher.xml') }}" + state: present + register: import_same_template_xml + + - ansible.builtin.assert: + that: + - import_same_template_xml.changed is sameas false + + - name: Delete Zabbix template. + community.zabbix.zabbix_template: + template_name: ExampleTemplate + state: absent + register: delete_zabbix_template_result + + - ansible.builtin.assert: + that: + - delete_zabbix_template_result.changed is sameas true + + - name: Import Zabbix same template from XML file (after deleting template). + community.zabbix.zabbix_template: + template_xml: "{{ lookup('file', 'template4_60_higher.xml') }}" + state: present + register: import_same_template_xml + + - ansible.builtin.assert: + that: + - import_same_template_xml.changed is sameas true + + - name: Import Zabbix same template from JSON file. + community.zabbix.zabbix_template: + template_json: "{{ lookup('file', 'template4_60_higher.json') }}" + state: present + register: import_same_template_json + + - ansible.builtin.assert: + that: + - import_same_template_json.changed is sameas false + + - name: Delete Zabbix template. + community.zabbix.zabbix_template: + template_name: ExampleTemplate + state: absent + register: delete_zabbix_template_result + + - ansible.builtin.assert: + that: + - delete_zabbix_template_result.changed is sameas true + + - name: Delete Zabbix template (idempotency check). + community.zabbix.zabbix_template: + template_name: ExampleTemplate + state: absent + register: delete_zabbix_template_result + + - ansible.builtin.assert: + that: + - delete_zabbix_template_result.changed is sameas false + + +# # Unicode stuff # |