From e215196682c3fc5ad1145a1724ab91829bad4a5d Mon Sep 17 00:00:00 2001 From: Zack Date: Wed, 1 May 2024 06:11:05 -0500 Subject: [PATCH 1/3] fix issue with userparameters failing when trying to deploy a script --- changelogs/fragments/1205-fix-zabbix-agent-scripts.yml | 2 ++ roles/zabbix_agent/tasks/userparameter.yml | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/1205-fix-zabbix-agent-scripts.yml diff --git a/changelogs/fragments/1205-fix-zabbix-agent-scripts.yml b/changelogs/fragments/1205-fix-zabbix-agent-scripts.yml new file mode 100644 index 000000000..daa5ed960 --- /dev/null +++ b/changelogs/fragments/1205-fix-zabbix-agent-scripts.yml @@ -0,0 +1,2 @@ +bugfixes: + - zabbix_agent - Fixed issue to where scripts can be deployed alongside userparameters diff --git a/roles/zabbix_agent/tasks/userparameter.yml b/roles/zabbix_agent/tasks/userparameter.yml index a80be1736..d61e3899f 100644 --- a/roles/zabbix_agent/tasks/userparameter.yml +++ b/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: From 23a7ae335d74e2f9b34b6de78cf52d204ada92d8 Mon Sep 17 00:00:00 2001 From: us3241 Date: Sun, 5 May 2024 05:18:22 +0300 Subject: [PATCH 2/3] Add new zabbix_service_info module --- .../1210-add_zabbix_service_info.yml | 2 + plugins/modules/zabbix_service_info.py | 149 ++++++++++++++++++ .../test_zabbix_service_info/meta/main.yml | 3 + .../test_zabbix_service_info/tasks/main.yml | 57 +++++++ 4 files changed, 211 insertions(+) create mode 100644 changelogs/fragments/1210-add_zabbix_service_info.yml create mode 100644 plugins/modules/zabbix_service_info.py create mode 100644 tests/integration/targets/test_zabbix_service_info/meta/main.yml create mode 100644 tests/integration/targets/test_zabbix_service_info/tasks/main.yml diff --git a/changelogs/fragments/1210-add_zabbix_service_info.yml b/changelogs/fragments/1210-add_zabbix_service_info.yml new file mode 100644 index 000000000..51b006ca4 --- /dev/null +++ b/changelogs/fragments/1210-add_zabbix_service_info.yml @@ -0,0 +1,2 @@ +minor_changes: + - zabbix_service_info module added diff --git a/plugins/modules/zabbix_service_info.py b/plugins/modules/zabbix_service_info.py new file mode 100644 index 000000000..1984777d3 --- /dev/null +++ b/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:///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/tests/integration/targets/test_zabbix_service_info/meta/main.yml b/tests/integration/targets/test_zabbix_service_info/meta/main.yml new file mode 100644 index 000000000..acdb704c8 --- /dev/null +++ b/tests/integration/targets/test_zabbix_service_info/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_zabbix diff --git a/tests/integration/targets/test_zabbix_service_info/tasks/main.yml b/tests/integration/targets/test_zabbix_service_info/tasks/main.yml new file mode 100644 index 000000000..77c244df8 --- /dev/null +++ b/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 From e00ab8e68294af5c70f55e28bf9c245c3b761be4 Mon Sep 17 00:00:00 2001 From: Erik Berg Date: Mon, 6 May 2024 04:33:43 +0200 Subject: [PATCH 3/3] Update CI/CD --- .github/workflows/agent.yml | 18 +++++++++++++----- .github/workflows/javagateway.yml | 10 +++++++++- .github/workflows/proxy.yml | 10 +++++++++- .github/workflows/server.yml | 10 +++++++++- .github/workflows/web.yml | 10 +++++++++- molecule/requirements.txt | 4 ++-- molecule/zabbix_javagateway/molecule.yml | 2 +- molecule/zabbix_proxy/destroy.yml | 6 ++---- molecule/zabbix_proxy/molecule.yml | 10 +++++----- molecule/zabbix_proxy/prepare.yml | 4 ++-- molecule/zabbix_server/destroy.yml | 6 ++---- molecule/zabbix_server/molecule.yml | 10 +++++----- molecule/zabbix_server/prepare.yml | 4 ++-- molecule/zabbix_web/destroy.yml | 6 ++---- molecule/zabbix_web/molecule.yml | 12 ++++++------ molecule/zabbix_web/prepare.yml | 4 ++-- 16 files changed, 80 insertions(+), 46 deletions(-) diff --git a/.github/workflows/agent.yml b/.github/workflows/agent.yml index 810e0f8eb..55b7e1b72 100644 --- a/.github/workflows/agent.yml +++ b/.github/workflows/agent.yml @@ -29,9 +29,9 @@ jobs: - debian11 - debian10 version: - - v64 - - v62 - - v60 + - v64 + - v62 + - v60 scenario_name: - default - autopsk @@ -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/.github/workflows/javagateway.yml b/.github/workflows/javagateway.yml index de7788f3b..22bc5ede1 100644 --- a/.github/workflows/javagateway.yml +++ b/.github/workflows/javagateway.yml @@ -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/.github/workflows/proxy.yml b/.github/workflows/proxy.yml index f78d2ab5a..ad5f61b34 100644 --- a/.github/workflows/proxy.yml +++ b/.github/workflows/proxy.yml @@ -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/.github/workflows/server.yml b/.github/workflows/server.yml index f6205fc80..33f5cd5fd 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -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/.github/workflows/web.yml b/.github/workflows/web.yml index b96deb308..0541a2457 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -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/molecule/requirements.txt b/molecule/requirements.txt index 6918aaf56..9ccb5e157 100644 --- a/molecule/requirements.txt +++ b/molecule/requirements.txt @@ -3,8 +3,8 @@ 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 +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 diff --git a/molecule/zabbix_javagateway/molecule.yml b/molecule/zabbix_javagateway/molecule.yml index ee072707d..0c6de4172 100644 --- a/molecule/zabbix_javagateway/molecule.yml +++ b/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/molecule/zabbix_proxy/destroy.yml b/molecule/zabbix_proxy/destroy.yml index 54771a5a1..7ef374be5 100644 --- a/molecule/zabbix_proxy/destroy.yml +++ b/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/molecule/zabbix_proxy/molecule.yml b/molecule/zabbix_proxy/molecule.yml index 4eb173acf..4eadd60ab 100644 --- a/molecule/zabbix_proxy/molecule.yml +++ b/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/molecule/zabbix_proxy/prepare.yml b/molecule/zabbix_proxy/prepare.yml index c5e3b9e45..1ff492d62 100644 --- a/molecule/zabbix_proxy/prepare.yml +++ b/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/molecule/zabbix_server/destroy.yml b/molecule/zabbix_server/destroy.yml index 54771a5a1..7ef374be5 100644 --- a/molecule/zabbix_server/destroy.yml +++ b/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/molecule/zabbix_server/molecule.yml b/molecule/zabbix_server/molecule.yml index 2424455f4..52df5ac4e 100644 --- a/molecule/zabbix_server/molecule.yml +++ b/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/molecule/zabbix_server/prepare.yml b/molecule/zabbix_server/prepare.yml index 922b33753..86007970a 100644 --- a/molecule/zabbix_server/prepare.yml +++ b/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 diff --git a/molecule/zabbix_web/destroy.yml b/molecule/zabbix_web/destroy.yml index 54771a5a1..7ef374be5 100644 --- a/molecule/zabbix_web/destroy.yml +++ b/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/molecule/zabbix_web/molecule.yml b/molecule/zabbix_web/molecule.yml index 0aa3ab800..549b7ae16 100644 --- a/molecule/zabbix_web/molecule.yml +++ b/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/molecule/zabbix_web/prepare.yml b/molecule/zabbix_web/prepare.yml index 204eb8f56..d3dcc1ad0 100644 --- a/molecule/zabbix_web/prepare.yml +++ b/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