diff --git a/.github/workflows/agent.yml b/.github/workflows/agent.yml index 572cc5c64..ca04f5843 100644 --- a/.github/workflows/agent.yml +++ b/.github/workflows/agent.yml @@ -43,7 +43,7 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.9 uses: actions/setup-python@v4 diff --git a/.github/workflows/javagateway.yml b/.github/workflows/javagateway.yml index 37538478a..bd6885ef7 100644 --- a/.github/workflows/javagateway.yml +++ b/.github/workflows/javagateway.yml @@ -44,7 +44,7 @@ jobs: - zabbix_javagateway steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.9 uses: actions/setup-python@v4 diff --git a/.github/workflows/plugins-integration.yml b/.github/workflows/plugins-integration.yml index 7f9079771..5955d6f73 100644 --- a/.github/workflows/plugins-integration.yml +++ b/.github/workflows/plugins-integration.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ansible_collections/community/zabbix @@ -74,6 +74,6 @@ jobs: working-directory: ./ansible_collections/community/zabbix # See the repots at https://codecov.io/gh/ansible-collections/community.zabbix - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v3 with: fail_ci_if_error: false diff --git a/.github/workflows/proxy.yml b/.github/workflows/proxy.yml index c6d7bd5e6..985bb8ceb 100644 --- a/.github/workflows/proxy.yml +++ b/.github/workflows/proxy.yml @@ -48,7 +48,7 @@ jobs: version: v62 steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.9 uses: actions/setup-python@v4 diff --git a/.github/workflows/repo-sanity.yml b/.github/workflows/repo-sanity.yml index f4c780173..4a5c5461c 100644 --- a/.github/workflows/repo-sanity.yml +++ b/.github/workflows/repo-sanity.yml @@ -14,12 +14,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: ansible_collections/community/zabbix - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} @@ -52,7 +52,7 @@ jobs: # .../ansible_collections/NAMESPACE/COLLECTION_NAME/ - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ansible_collections/community/zabbix diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index 775d40efb..b169aa9f1 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -52,7 +52,7 @@ jobs: version: v64 steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.9 uses: actions/setup-python@v4 diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index 47a1b1d11..79b7beb11 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -54,7 +54,7 @@ jobs: version: v62 steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.9 uses: actions/setup-python@v4 diff --git a/README.md b/README.md index 74a2bbe8d..9fc38bce8 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ To use a module or role from this collection, reference them with their Fully Qu ... - name: If Zabbix WebUI runs on non-default (zabbix) path, e.g. http:///zabbixeu - set_fact: + ansible.builtin.set_fact: ansible_zabbix_url_path: 'zabbixeu' - name: Using Zabbix collection to manage Zabbix Server's elements with username/password @@ -203,7 +203,7 @@ Or you include collection name `community.zabbix` in the playbook's `collections ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 tasks: - name: Ensure host is monitored by Zabbix - zabbix_host: + community.zabbix.zabbix_host: ... ``` diff --git a/changelogs/fragments/1081_fqmn.yml b/changelogs/fragments/1081_fqmn.yml new file mode 100644 index 000000000..afe9389cd --- /dev/null +++ b/changelogs/fragments/1081_fqmn.yml @@ -0,0 +1,3 @@ +minor_changes: + - various - updated to fully qualified module names + - various - updated testing modules diff --git a/molecule/zabbix_agent_tests/common/playbooks/prepare.yml b/molecule/zabbix_agent_tests/common/playbooks/prepare.yml index 3ce015db6..cf1100aab 100644 --- a/molecule/zabbix_agent_tests/common/playbooks/prepare.yml +++ b/molecule/zabbix_agent_tests/common/playbooks/prepare.yml @@ -3,7 +3,7 @@ hosts: all tasks: - name: "Installing packages on CentOS family" - package: + ansible.builtin.package: pkg: - net-tools - which @@ -14,7 +14,7 @@ - ansible_os_family == 'RedHat' - name: "Installing packages on CentOS (Sangoma) family" - package: + ansible.builtin.package: pkg: - net-tools - which @@ -25,7 +25,7 @@ - ansible_os_family == 'Sangoma' - name: "Installing packages on Debian family" - apt: + ansible.builtin.apt: name: - "{{ 'net-tools' if ansible_distribution_major_version not in ['10','18', '20'] else 'iproute2' }}" state: present @@ -36,7 +36,7 @@ - ansible_os_family == 'Debian' - name: "Installing packages on Suse family" - shell: zypper install -y python-xml python-libxml2 net-tools which + ansible.builtin.shell: zypper install -y python-xml python-libxml2 net-tools which register: zabbix_agent_prepare_packages_install until: zabbix_agent_prepare_packages_install is succeeded when: ansible_os_family == 'Suse' @@ -47,7 +47,7 @@ hosts: docker tasks: - name: "Download Docker CE repo file" - get_url: + ansible.builtin.get_url: url: https://download.docker.com/linux/centos/docker-ce.repo dest: /etc/yum.repos.d/docker-ce.repo mode: 0644 @@ -55,7 +55,7 @@ until: zabbix_agent_prepare_docker_repo is succeeded - name: "Installing Epel" - package: + ansible.builtin.package: pkg: - epel-release state: present @@ -63,7 +63,7 @@ until: zabbix_agent_prepare_docker_install is succeeded - name: "Installing Docker" - package: + ansible.builtin.package: pkg: - docker-ce - python-pip @@ -73,7 +73,7 @@ until: zabbix_agent_prepare_docker_install is succeeded - name: "Installing Docker Python" - pip: + ansible.builtin.pip: name: - docker state: present @@ -81,6 +81,6 @@ until: zabbix_agent_prepare_docker_install is succeeded - name: "Starting Docker service" - service: + ansible.builtin.service: name: docker state: started diff --git a/molecule/zabbix_javagateway/prepare.yml b/molecule/zabbix_javagateway/prepare.yml index 6faa06002..3e3db6a1b 100644 --- a/molecule/zabbix_javagateway/prepare.yml +++ b/molecule/zabbix_javagateway/prepare.yml @@ -3,11 +3,11 @@ hosts: all pre_tasks: - name: "Set short version name" - set_fact: + ansible.builtin.set_fact: zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}" - name: "Installing packages on CentOS" - yum: + ansible.builtin.yum: name: - net-tools - which @@ -19,7 +19,7 @@ - ansible_os_family == 'RedHat' - name: "Make sure the docs can be installed. (Debian)" - lineinfile: + ansible.builtin.lineinfile: path: /etc/dpkg/dpkg.cfg.d/excludes state: absent regexp: "path-exclude=/usr/share/doc/*" @@ -27,13 +27,13 @@ - ansible_os_family != 'RedHat' - name: Check if warn parameter can be used for shell module - set_fact: + ansible.builtin.set_fact: produce_warn: False when: ansible_version.full is version("2.14", "<") # https://github.com/geerlingguy/ansible-role-java/issues/64 - name: "Apt update" - shell: "apt-get update && mkdir -p /usr/share/man/man1" + ansible.builtin.shell: "apt-get update && mkdir -p /usr/share/man/man1" args: warn: "{{ produce_warn | default(omit) }}" register: installation_dependencies @@ -42,7 +42,7 @@ - ansible_os_family != 'RedHat' - name: "Installing packages on NON-CentOS" - apt: + ansible.builtin.apt: name: - net-tools - apt-utils diff --git a/molecule/zabbix_proxy/prepare.yml b/molecule/zabbix_proxy/prepare.yml index f523546ad..c5e3b9e45 100644 --- a/molecule/zabbix_proxy/prepare.yml +++ b/molecule/zabbix_proxy/prepare.yml @@ -37,7 +37,7 @@ hosts: all tasks: - name: "Set short version name" - set_fact: + ansible.builtin.set_fact: zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}" - name: "Create group for imaginary host" @@ -49,7 +49,7 @@ changed_when: false - name: "Installing packages on CentOS" - yum: + ansible.builtin.yum: name: - net-tools - which @@ -61,12 +61,12 @@ - ansible_os_family == 'RedHat' - name: Check if warn parameter can be used for shell module - set_fact: + ansible.builtin.set_fact: produce_warn: False when: ansible_version.full is version("2.14", "<") - name: "Apt update" - shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" + ansible.builtin.shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" args: warn: "{{ produce_warn | default(omit) }}" register: installation_dependencies @@ -75,7 +75,7 @@ - ansible_os_family != 'RedHat' - name: "Installing packages on NON-CentOS" - apt: + ansible.builtin.apt: name: - net-tools - apt-utils @@ -91,13 +91,13 @@ - ansible_os_family != 'RedHat' - name: "Configure SUDO." - lineinfile: + ansible.builtin.lineinfile: dest: /etc/sudoers line: "Defaults !requiretty" state: present - name: "Make sure the docs can be installed. (RedHat)" - lineinfile: + ansible.builtin.lineinfile: dest: /etc/yum.conf line: "tsflags=nodocs" state: absent @@ -105,7 +105,7 @@ - ansible_os_family == 'RedHat' - name: "Make sure the docs can be installed. (Debian)" - lineinfile: + ansible.builtin.lineinfile: path: /etc/dpkg/dpkg.cfg.d/excludes state: absent regexp: "path-exclude=/usr/share/doc/*" diff --git a/molecule/zabbix_server/prepare.yml b/molecule/zabbix_server/prepare.yml index e16fa9f3d..922b33753 100644 --- a/molecule/zabbix_server/prepare.yml +++ b/molecule/zabbix_server/prepare.yml @@ -45,7 +45,7 @@ changed_when: false - name: "Installing packages on CentOS" - yum: + ansible.builtin.yum: name: - net-tools - which @@ -57,7 +57,7 @@ - ansible_os_family == 'RedHat' - name: "Installing packages on CentOS" - yum: + ansible.builtin.yum: name: - mysql state: present @@ -68,12 +68,12 @@ - inventory_hostname in groups['mysql'] - name: Check if warn parameter can be used for shell module - set_fact: + ansible.builtin.set_fact: produce_warn: false when: ansible_version.full is version("2.14", "<") - name: "Apt update" - shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" + ansible.builtin.shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" args: warn: "{{ produce_warn | default(omit) }}" register: installation_dependencies @@ -82,7 +82,7 @@ - ansible_os_family != 'RedHat' - name: "Installing packages on NON-CentOS" - apt: + ansible.builtin.apt: name: - net-tools - apt-utils @@ -97,13 +97,13 @@ - ansible_os_family != 'RedHat' - name: "Configure SUDO." - lineinfile: + ansible.builtin.lineinfile: dest: /etc/sudoers line: "Defaults !requiretty" state: present - name: "Make sure the docs are installed." - lineinfile: + ansible.builtin.lineinfile: dest: /etc/yum.conf line: "tsflags=nodocs" state: absent @@ -111,7 +111,7 @@ - ansible_os_family == 'RedHat' - name: PyMySQL - pip: + ansible.builtin.pip: name: PyMySQL register: installation_dependencies until: installation_dependencies is succeeded diff --git a/molecule/zabbix_web/prepare.yml b/molecule/zabbix_web/prepare.yml index 6b6db5acf..204eb8f56 100644 --- a/molecule/zabbix_web/prepare.yml +++ b/molecule/zabbix_web/prepare.yml @@ -45,7 +45,7 @@ changed_when: false - name: "Installing packages on CentOS" - yum: + ansible.builtin.yum: name: - net-tools - which @@ -57,7 +57,7 @@ - ansible_os_family == 'RedHat' - name: "Installing packages (CentOS7)" - yum: + ansible.builtin.yum: name: - centos-release-scl state: present @@ -67,7 +67,7 @@ - ansible_distribution_major_version == '7' - name: "Installing MySQL on CentOS" - yum: + ansible.builtin.yum: name: - mysql state: present @@ -78,12 +78,12 @@ - inventory_hostname in groups['mysql'] - name: Check if warn parameter can be used for shell module - set_fact: + ansible.builtin.set_fact: produce_warn: false when: ansible_version.full is version("2.14", "<") - name: "Apt update" - shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" + ansible.builtin.shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" args: warn: "{{ produce_warn | default(omit) }}" register: installation_dependencies @@ -92,7 +92,7 @@ - ansible_os_family != 'RedHat' - name: "Installing packages on NON-CentOS" - apt: + ansible.builtin.apt: name: - net-tools - apt-utils @@ -108,13 +108,13 @@ - ansible_os_family != 'RedHat' - name: "Configure SUDO." - lineinfile: + ansible.builtin.lineinfile: dest: /etc/sudoers line: "Defaults !requiretty" state: present - name: "Make sure the docs are installed." - lineinfile: + ansible.builtin.lineinfile: dest: /etc/yum.conf line: "tsflags=nodocs" state: absent @@ -122,7 +122,7 @@ - ansible_os_family == 'RedHat' - name: PyMySQL - pip: + ansible.builtin.pip: name: PyMySQL register: installation_dependencies until: installation_dependencies is succeeded @@ -130,13 +130,13 @@ - inventory_hostname in groups['mysql'] - name: Enabeling PHP 7.4 - command: dnf module enable php:7.4 -y + ansible.builtin.command: dnf module enable php:7.4 -y when: - ansible_os_family == 'RedHat' - ansible_distribution_major_version == "8" - name: Set PHP packages (Centos 8+) - set_fact: + ansible.builtin.set_fact: php_packages: - php - php-cli @@ -156,14 +156,14 @@ - ansible_os_family == "RedHat" - name: Set PHP Version (Ubuntu 2204) - set_fact: + ansible.builtin.set_fact: __php_default_version_debian: "8.1" when: - ansible_distribution_major_version >= '22' - ansible_os_family == "Debian" - name: Set PHP packages (Ubuntu 2204) - set_fact: + ansible.builtin.set_fact: __php_packages: - php{{ __php_default_version_debian }}-common - php{{ __php_default_version_debian }}-cli @@ -195,7 +195,7 @@ post_tasks: - name: "Remove file" - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: diff --git a/plugins/modules/zabbix_action.py b/plugins/modules/zabbix_action.py index cd69dd995..c0123ae1f 100644 --- a/plugins/modules/zabbix_action.py +++ b/plugins/modules/zabbix_action.py @@ -656,14 +656,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 # Trigger action with only one condition diff --git a/plugins/modules/zabbix_api_info.py b/plugins/modules/zabbix_api_info.py index 5418a4f3d..5941408e9 100644 --- a/plugins/modules/zabbix_api_info.py +++ b/plugins/modules/zabbix_api_info.py @@ -32,14 +32,14 @@ EXAMPLES = ''' # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Retrieve API information @@ -52,7 +52,7 @@ 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 - zabbix_api_info: + community.zabbix.zabbix_api_info: register: zbx_api_info ''' diff --git a/plugins/modules/zabbix_authentication.py b/plugins/modules/zabbix_authentication.py index 5d6bb164d..85af67dbc 100644 --- a/plugins/modules/zabbix_authentication.py +++ b/plugins/modules/zabbix_authentication.py @@ -265,14 +265,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Update all authentication setting (Zabbix <= 6.0) @@ -285,7 +285,7 @@ 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 - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form @@ -333,7 +333,7 @@ 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 - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form @@ -375,7 +375,7 @@ 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 - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form diff --git a/plugins/modules/zabbix_autoregister.py b/plugins/modules/zabbix_autoregister.py index 4b4cf9e1f..c00f52cbe 100644 --- a/plugins/modules/zabbix_autoregister.py +++ b/plugins/modules/zabbix_autoregister.py @@ -61,14 +61,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Update autoregistration diff --git a/plugins/modules/zabbix_discovery_rule.py b/plugins/modules/zabbix_discovery_rule.py index 4d82da842..2296f3db8 100644 --- a/plugins/modules/zabbix_discovery_rule.py +++ b/plugins/modules/zabbix_discovery_rule.py @@ -181,14 +181,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 # Base create discovery rule example diff --git a/plugins/modules/zabbix_globalmacro.py b/plugins/modules/zabbix_globalmacro.py index 9dd96ac28..111c80c55 100644 --- a/plugins/modules/zabbix_globalmacro.py +++ b/plugins/modules/zabbix_globalmacro.py @@ -73,14 +73,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Create new global macro or update an existing macro's value diff --git a/plugins/modules/zabbix_group.py b/plugins/modules/zabbix_group.py index 93fea4c30..3eb39ab24 100644 --- a/plugins/modules/zabbix_group.py +++ b/plugins/modules/zabbix_group.py @@ -47,14 +47,14 @@ EXAMPLES = r''' # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 # Base create host groups example diff --git a/plugins/modules/zabbix_group_info.py b/plugins/modules/zabbix_group_info.py index c923d8d69..0974b450e 100644 --- a/plugins/modules/zabbix_group_info.py +++ b/plugins/modules/zabbix_group_info.py @@ -44,14 +44,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Get hostgroup info diff --git a/plugins/modules/zabbix_host.py b/plugins/modules/zabbix_host.py index 68605cef5..22e14d17d 100644 --- a/plugins/modules/zabbix_host.py +++ b/plugins/modules/zabbix_host.py @@ -337,14 +337,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Create a new host or rewrite an existing host's info diff --git a/plugins/modules/zabbix_host_events_info.py b/plugins/modules/zabbix_host_events_info.py index 600b8a940..6de1051e0 100644 --- a/plugins/modules/zabbix_host_events_info.py +++ b/plugins/modules/zabbix_host_events_info.py @@ -185,14 +185,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: exclude machine if alert active on it diff --git a/plugins/modules/zabbix_host_info.py b/plugins/modules/zabbix_host_info.py index dec1955ea..8713480b9 100644 --- a/plugins/modules/zabbix_host_info.py +++ b/plugins/modules/zabbix_host_info.py @@ -72,14 +72,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Get host info diff --git a/plugins/modules/zabbix_hostmacro.py b/plugins/modules/zabbix_hostmacro.py index 83ddeabf6..802a00559 100644 --- a/plugins/modules/zabbix_hostmacro.py +++ b/plugins/modules/zabbix_hostmacro.py @@ -71,14 +71,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Create new host macro or update an existing macro's value diff --git a/plugins/modules/zabbix_housekeeping.py b/plugins/modules/zabbix_housekeeping.py index 3b1e0fc59..3f6e5d733 100644 --- a/plugins/modules/zabbix_housekeeping.py +++ b/plugins/modules/zabbix_housekeeping.py @@ -134,14 +134,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Update housekeeping all parameter diff --git a/plugins/modules/zabbix_maintenance.py b/plugins/modules/zabbix_maintenance.py index 478e0664a..a2c635eb0 100644 --- a/plugins/modules/zabbix_maintenance.py +++ b/plugins/modules/zabbix_maintenance.py @@ -105,14 +105,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Create a named maintenance window for host www1 for 90 minutes diff --git a/plugins/modules/zabbix_map.py b/plugins/modules/zabbix_map.py index af5fdf2b1..a0f3cc655 100644 --- a/plugins/modules/zabbix_map.py +++ b/plugins/modules/zabbix_map.py @@ -118,14 +118,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 ### diff --git a/plugins/modules/zabbix_mediatype.py b/plugins/modules/zabbix_mediatype.py index 62c3335c6..1e2514bf3 100644 --- a/plugins/modules/zabbix_mediatype.py +++ b/plugins/modules/zabbix_mediatype.py @@ -272,14 +272,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: "Create an email mediatype with SMTP authentication" diff --git a/plugins/modules/zabbix_proxy.py b/plugins/modules/zabbix_proxy.py index ab8a59ea5..a5ddbe137 100644 --- a/plugins/modules/zabbix_proxy.py +++ b/plugins/modules/zabbix_proxy.py @@ -142,14 +142,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Create or update a proxy with proxy type active diff --git a/plugins/modules/zabbix_proxy_info.py b/plugins/modules/zabbix_proxy_info.py index ee10aebd1..c82112609 100644 --- a/plugins/modules/zabbix_proxy_info.py +++ b/plugins/modules/zabbix_proxy_info.py @@ -38,14 +38,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Get zabbix proxy info alongside the list of hosts monitored by the proxy diff --git a/plugins/modules/zabbix_regexp.py b/plugins/modules/zabbix_regexp.py index 064752c4f..fc3ccedee 100644 --- a/plugins/modules/zabbix_regexp.py +++ b/plugins/modules/zabbix_regexp.py @@ -93,14 +93,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Update regexp of 'File systems for discovery' diff --git a/plugins/modules/zabbix_script.py b/plugins/modules/zabbix_script.py index f13523c87..643851885 100644 --- a/plugins/modules/zabbix_script.py +++ b/plugins/modules/zabbix_script.py @@ -166,14 +166,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: test - Create new action operation script to execute webhook @@ -186,7 +186,7 @@ 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 - zabbix_script: + community.zabbix.zabbix_script: name: Test action operation script scope: action_operation script_type: webhook diff --git a/plugins/modules/zabbix_service.py b/plugins/modules/zabbix_service.py index cd7e045ac..8a7b9b605 100644 --- a/plugins/modules/zabbix_service.py +++ b/plugins/modules/zabbix_service.py @@ -207,14 +207,14 @@ --- # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 # Creates a new Zabbix service diff --git a/plugins/modules/zabbix_settings.py b/plugins/modules/zabbix_settings.py index 986abe484..de8ec6886 100644 --- a/plugins/modules/zabbix_settings.py +++ b/plugins/modules/zabbix_settings.py @@ -379,14 +379,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Update settings diff --git a/plugins/modules/zabbix_template.py b/plugins/modules/zabbix_template.py index bde774cb9..a773790aa 100644 --- a/plugins/modules/zabbix_template.py +++ b/plugins/modules/zabbix_template.py @@ -127,14 +127,14 @@ --- # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Create a new Zabbix template linked to groups, macros and templates diff --git a/plugins/modules/zabbix_template_info.py b/plugins/modules/zabbix_template_info.py index f517bf821..140233e1a 100644 --- a/plugins/modules/zabbix_template_info.py +++ b/plugins/modules/zabbix_template_info.py @@ -42,14 +42,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Get Zabbix template as JSON diff --git a/plugins/modules/zabbix_token.py b/plugins/modules/zabbix_token.py index 257d3df82..fc4d4c791 100644 --- a/plugins/modules/zabbix_token.py +++ b/plugins/modules/zabbix_token.py @@ -75,14 +75,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Create Zabbix token and generate token string @@ -95,7 +95,7 @@ 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 - zabbix_token: + community.zabbix.zabbix_token: name: test token description: Admin test token username: Admin diff --git a/plugins/modules/zabbix_user.py b/plugins/modules/zabbix_user.py index 51f3619e5..fcdc81660 100644 --- a/plugins/modules/zabbix_user.py +++ b/plugins/modules/zabbix_user.py @@ -213,14 +213,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: create a new zabbix user. diff --git a/plugins/modules/zabbix_user_directory.py b/plugins/modules/zabbix_user_directory.py index a02450495..dc5a2bb04 100644 --- a/plugins/modules/zabbix_user_directory.py +++ b/plugins/modules/zabbix_user_directory.py @@ -316,14 +316,14 @@ --- # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Create new user directory or update existing info (Zabbix <= 6.2) diff --git a/plugins/modules/zabbix_user_info.py b/plugins/modules/zabbix_user_info.py index e4d57cea7..c71479532 100644 --- a/plugins/modules/zabbix_user_info.py +++ b/plugins/modules/zabbix_user_info.py @@ -32,14 +32,14 @@ EXAMPLES = """ # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Get zabbix user info diff --git a/plugins/modules/zabbix_user_role.py b/plugins/modules/zabbix_user_role.py index 9ea5fe30f..3495f39e1 100644 --- a/plugins/modules/zabbix_user_role.py +++ b/plugins/modules/zabbix_user_role.py @@ -52,14 +52,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 # Create user role Operators with ui elements monitoring.hosts diff --git a/plugins/modules/zabbix_usergroup.py b/plugins/modules/zabbix_usergroup.py index 24547e978..14539d932 100644 --- a/plugins/modules/zabbix_usergroup.py +++ b/plugins/modules/zabbix_usergroup.py @@ -157,14 +157,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 # Base create user group example diff --git a/plugins/modules/zabbix_valuemap.py b/plugins/modules/zabbix_valuemap.py index b207a80cf..3d9a64954 100644 --- a/plugins/modules/zabbix_valuemap.py +++ b/plugins/modules/zabbix_valuemap.py @@ -59,14 +59,14 @@ EXAMPLES = r""" # If you want to use Username and Password to be authenticated by Zabbix Server - name: Set credentials to access Zabbix Server API - set_fact: + 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 - set_fact: + ansible.builtin.set_fact: ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 - name: Create a value map diff --git a/roles/zabbix_agent/handlers/main.yml b/roles/zabbix_agent/handlers/main.yml index 014c1c5d8..9f04b1a9b 100644 --- a/roles/zabbix_agent/handlers/main.yml +++ b/roles/zabbix_agent/handlers/main.yml @@ -2,7 +2,7 @@ # handlers file for zabbix-agent - name: restart zabbix-agent - service: + ansible.builtin.service: name: "{{ zabbix_agent_service }}" state: restarted enabled: true @@ -12,7 +12,7 @@ - ansible_os_family != "Windows" and ansible_os_family != "Darwin" - name: firewalld-reload - command: "firewall-cmd --reload" + ansible.builtin.command: "firewall-cmd --reload" become: true when: - ansible_facts.services["firewalld"] is defined @@ -26,14 +26,14 @@ - ansible_os_family == "Windows" - name: restart mac zabbix agent - command: "launchctl kickstart -k system/{{ zabbix_agent_service }}" + ansible.builtin.command: "launchctl kickstart -k system/{{ zabbix_agent_service }}" become: true when: - not zabbix_agent_docker - ansible_os_family == "Darwin" - name: "clean repo files from proxy creds" - shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + ansible.builtin.shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true become: true when: - ansible_os_family == 'RedHat' diff --git a/roles/zabbix_agent/molecule/with-server/playbook.yml b/roles/zabbix_agent/molecule/with-server/playbook.yml index e1bb7d8d4..2f0795448 100644 --- a/roles/zabbix_agent/molecule/with-server/playbook.yml +++ b/roles/zabbix_agent/molecule/with-server/playbook.yml @@ -3,7 +3,7 @@ hosts: all:!zabbix_server pre_tasks: - name: "Get IP Server" - shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1 + ansible.builtin.shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1 register: ip_address delegate_to: zabbix-server-centos changed_when: false @@ -11,7 +11,7 @@ - skip_ansible_lint - name: "Get IP hosts" - shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1 + ansible.builtin.shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1 register: ip_address_host changed_when: false tags: diff --git a/roles/zabbix_agent/molecule/with-server/prepare.yml b/roles/zabbix_agent/molecule/with-server/prepare.yml index 6722e5fea..582006d4e 100644 --- a/roles/zabbix_agent/molecule/with-server/prepare.yml +++ b/roles/zabbix_agent/molecule/with-server/prepare.yml @@ -3,14 +3,14 @@ hosts: zabbix_server pre_tasks: - name: "Installing EPEL" - yum: + ansible.builtin.yum: name: - epel-release state: present when: ansible_distribution == 'CentOS' - name: "Installing packages" - yum: + ansible.builtin.yum: name: - net-tools - which @@ -21,7 +21,7 @@ when: ansible_distribution == 'CentOS' - name: "Installing which on NON-CentOS" - apt: + ansible.builtin.apt: name: - net-tools - python-pip @@ -30,19 +30,19 @@ when: ansible_distribution != 'CentOS' - name: "Configure SUDO." - lineinfile: + ansible.builtin.lineinfile: dest: /etc/sudoers line: "Defaults !requiretty" state: present - name: "Make sure the docs are installed." - lineinfile: + ansible.builtin.lineinfile: dest: /etc/yum.conf line: "tsflags=nodocs" state: absent - name: "Installing some python dependencies" - pip: + ansible.builtin.pip: name: py-zabbix state: present @@ -55,7 +55,7 @@ hosts: all:!zabbix_server:!docker tasks: - name: "Installing packages on CentOS family" - yum: + ansible.builtin.yum: name: - net-tools - which @@ -64,7 +64,7 @@ - ansible_os_family == 'RedHat' - name: "Installing packages on Debian family" - apt: + ansible.builtin.apt: name: - net-tools state: present @@ -75,7 +75,7 @@ hosts: docker tasks: - name: "Download Docker CE repo file" - get_url: + ansible.builtin.get_url: url: https://download.docker.com/linux/centos/docker-ce.repo dest: /etc/yum.repos.d/docker-ce.repo mode: 0644 @@ -83,7 +83,7 @@ until: zabbix_agent_prepare_docker_repo is succeeded - name: "Installing Epel" - package: + ansible.builtin.package: pkg: - epel-release state: present @@ -91,7 +91,7 @@ until: zabbix_agent_prepare_docker_install is succeeded - name: "Installing Docker" - package: + ansible.builtin.package: pkg: - docker-ce - python-pip @@ -101,7 +101,7 @@ until: zabbix_agent_prepare_docker_install is succeeded - name: "Installing Docker Python" - pip: + ansible.builtin.pip: name: - docker state: present @@ -109,6 +109,6 @@ until: zabbix_agent_prepare_docker_install is succeeded - name: "Starting Docker service" - service: + ansible.builtin.service: name: docker state: started diff --git a/roles/zabbix_agent/tasks/Debian.yml b/roles/zabbix_agent/tasks/Debian.yml index 3e80e7583..229a3ab19 100644 --- a/roles/zabbix_agent/tasks/Debian.yml +++ b/roles/zabbix_agent/tasks/Debian.yml @@ -2,7 +2,7 @@ # Tasks specific for Debian/Ubuntu Systems - name: "Debian | Set some variables" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_agent_version | regex_replace('\\.', '') }}" zabbix_agent_apt_repository: - "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}/" @@ -15,7 +15,7 @@ - always - name: "Debian | Set some variables" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_agent_version | regex_replace('\\.', '') }}" zabbix_agent_apt_repository: - "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}-arm64/" @@ -28,7 +28,7 @@ - always - name: "Debian | Installing gnupg" - apt: + ansible.builtin.apt: pkg: gnupg update_cache: true cache_valid_time: 3600 @@ -70,7 +70,7 @@ - install - name: "Debian | Installing repository {{ ansible_distribution }}" - apt_repository: + ansible.builtin.apt_repository: repo: "{{ item }} [signed-by={{ zabbix_gpg_key }}] {{ zabbix_agent_apt_repository | join(' ') }}" state: present become: true @@ -81,7 +81,7 @@ - install - name: "Debian | Create /etc/apt/preferences.d/" - file: + ansible.builtin.file: path: /etc/apt/preferences.d/ state: directory mode: "0755" @@ -92,7 +92,7 @@ - install - name: "Debian | Configuring the weight for APT" - copy: + ansible.builtin.copy: dest: "/etc/apt/preferences.d/zabbix-agent-{{ zabbix_underscore_version }}" content: | Package: {{ zabbix_agent_package }} @@ -107,7 +107,7 @@ - install - name: "Debian | apt-get clean" - shell: apt-get clean; apt-get update + ansible.builtin.shell: apt-get clean; apt-get update args: warn: "{{ produce_warn | default(omit) }}" changed_when: false @@ -117,7 +117,7 @@ - install - name: "Debian | Installing zabbix-agent" - apt: + ansible.builtin.apt: pkg: "{{ zabbix_agent_package }}" state: "{{ zabbix_agent_package_state }}" update_cache: true @@ -134,7 +134,7 @@ - install - name: "Debian | Installing zabbix-{sender,get}" - apt: + ansible.builtin.apt: pkg: - "{{ zabbix_sender_package }}" - "{{ zabbix_get_package }}" @@ -156,7 +156,7 @@ - install - name: "Debian | Enable the service" - service: + ansible.builtin.service: name: "{{ zabbix_agent_service }}" enabled: true use: service diff --git a/roles/zabbix_agent/tasks/Docker.yml b/roles/zabbix_agent/tasks/Docker.yml index cbbef204d..031a5fe61 100644 --- a/roles/zabbix_agent/tasks/Docker.yml +++ b/roles/zabbix_agent/tasks/Docker.yml @@ -1,7 +1,6 @@ --- - - name: "Create volume mount string" - set_fact: + ansible.builtin.set_fact: volume_mount: "{{ zabbix_agent_tlspskfile }}:/var/lib/zabbix/enc/tlspskfile" tls_key: ZBX_TLSPSKFILE: tlspskfile @@ -9,7 +8,7 @@ - zabbix_agent_tlspskfile is defined - name: "Add zabbix_agent_tlspskfile to volume mount" - set_fact: + ansible.builtin.set_fact: zabbix_agent_docker_volumes: "{{ zabbix_agent_docker_volumes + [ volume_mount ] }}" zabbix_agent_docker_env: "{{ zabbix_agent_docker_env | combine(tls_key) }}" when: diff --git a/roles/zabbix_agent/tasks/Linux.yml b/roles/zabbix_agent/tasks/Linux.yml index eb4f2e251..c4c8fc401 100644 --- a/roles/zabbix_agent/tasks/Linux.yml +++ b/roles/zabbix_agent/tasks/Linux.yml @@ -1,6 +1,6 @@ --- - name: "Set default ip address for zabbix_agent_ip" - set_fact: + ansible.builtin.set_fact: zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4'].address }}" when: - zabbix_agent_ip is not defined @@ -9,7 +9,7 @@ - config - name: "Get Total Private IP Addresses" - set_fact: + ansible.builtin.set_fact: total_private_ip_addresses: "{{ ansible_all_ipv4_addresses | ansible.utils.ipaddr('private') | length }}" when: - ansible_all_ipv4_addresses is defined @@ -18,7 +18,7 @@ - config - name: "Set first public ip address for zabbix_agent_ip" - set_fact: + ansible.builtin.set_fact: zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ansible.netcommon.ipaddr('public') | first }}" zabbix_agent_server: "{{ zabbix_agent_server_public_ip | default(zabbix_agent_server) }}" zabbix_agent_serveractive: "{{ zabbix_agent_serveractive_public_ip | default(zabbix_agent_serveractive) }}" @@ -32,7 +32,7 @@ - config - name: "Set first private ip address for zabbix_agent_ip" - set_fact: + ansible.builtin.set_fact: zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ansible.netcommon.ipaddr('private') | first }}" when: - zabbix_agent_ip is not defined @@ -42,7 +42,7 @@ - config - name: "Fail invalid specified agent_listeninterface" - fail: + ansible.builtin.fail: msg: "The specified network interface does not exist" when: - (zabbix_agent_listeninterface) @@ -51,7 +51,7 @@ - config - name: "Set network interface" - set_fact: + ansible.builtin.set_fact: network_interface: ansible_{{ zabbix_agent_listeninterface }} when: - (zabbix_agent_listeninterface) @@ -60,7 +60,7 @@ - config - name: "Get IP of agent_listeninterface when no agent_listenip specified" - set_fact: + ansible.builtin.set_fact: zabbix_agent_listenip: "{{ hostvars[inventory_hostname][network_interface]['ipv4'].address | default('0.0.0.0') }}" when: - (zabbix_agent_listeninterface) @@ -70,7 +70,7 @@ - api - name: "Default agent_listenip to all when not specified" - set_fact: + ansible.builtin.set_fact: zabbix_agent_listenip: "0.0.0.0" when: - not (zabbix_agent_listenip) @@ -78,7 +78,7 @@ - config - name: "Fail invalid specified agent_listenip" - fail: + ansible.builtin.fail: msg: "The agent_listenip does not exist" when: - zabbix_agent_listenip != '0.0.0.0' @@ -88,12 +88,12 @@ - config - name: "Configure SELinux when enabled" - include_tasks: selinux.yml + ansible.builtin.include_tasks: selinux.yml when: - zabbix_selinux | bool - name: "Adding zabbix group" - group: + ansible.builtin.group: name: zabbix state: present gid: "{{ zabbix_agent_docker_user_gid | default(omit) }}" @@ -104,7 +104,7 @@ - config - name: "Adding zabbix user" - user: + ansible.builtin.user: name: zabbix group: zabbix state: present @@ -119,7 +119,7 @@ - config - name: "Configure zabbix-agent" - template: + ansible.builtin.template: src: "{{ 'zabbix_agentd.conf.j2' if not zabbix_agent2 else 'zabbix_agent2.conf.j2' }}" dest: "/etc/zabbix/{{ zabbix_agent_conf if not zabbix_agent2 else zabbix_agent2_conf }}" owner: root @@ -134,7 +134,7 @@ - config - name: "Create directory for PSK file if not exist." - file: + ansible.builtin.file: path: "{{ zabbix_agent_tlspskfile | dirname }}" mode: 0755 state: directory @@ -147,7 +147,7 @@ - config - name: "Create directory for PSK file if not exist (zabbix-agent2)" - file: + ansible.builtin.file: path: "{{ zabbix_agent2_tlspskfile | dirname }}" mode: 0755 state: directory @@ -160,7 +160,7 @@ - config - name: "Place TLS PSK File" - copy: + ansible.builtin.copy: dest: "{{ zabbix_agent_tlspskfile }}" content: "{{ zabbix_agent_tlspsk_secret }}" owner: zabbix @@ -178,7 +178,7 @@ - config - name: "Place TLS PSK File (zabbix-agent2)" - copy: + ansible.builtin.copy: dest: "{{ zabbix_agent2_tlspskfile }}" content: "{{ zabbix_agent2_tlspsk_secret }}" owner: zabbix @@ -196,7 +196,7 @@ - config - name: "Create include dir zabbix-agent" - file: + ansible.builtin.file: path: "{{ zabbix_agent_include if not zabbix_agent2 else zabbix_agent2_include }}" owner: root group: zabbix @@ -207,18 +207,18 @@ - config - name: "Install the Docker container" - include_tasks: Docker.yml + ansible.builtin.include_tasks: Docker.yml when: - zabbix_agent_docker | bool - name: "Remove zabbix-agent installation when zabbix-agent2 is used." - include_tasks: remove.yml + ansible.builtin.include_tasks: remove.yml when: - zabbix_agent2 | bool - zabbix_agent_package_remove - name: "Make sure the zabbix-agent service is running" - service: + ansible.builtin.service: name: "{{ zabbix_agent_service }}" state: started enabled: true @@ -229,7 +229,7 @@ - service - name: "Give zabbix-agent access to system.hw.chassis info" - file: + ansible.builtin.file: path: /sys/firmware/dmi/tables/DMI owner: root group: zabbix diff --git a/roles/zabbix_agent/tasks/RedHat.yml b/roles/zabbix_agent/tasks/RedHat.yml index 58ef5d3df..e23bc7eac 100644 --- a/roles/zabbix_agent/tasks/RedHat.yml +++ b/roles/zabbix_agent/tasks/RedHat.yml @@ -2,7 +2,7 @@ # Tasks specific for RedHat systems - name: "RedHat | Install basic repo file" - yum_repository: + ansible.builtin.yum_repository: name: "{{ item.name }}" description: "{{ item.description }}" baseurl: "{{ item.baseurl }}" @@ -21,14 +21,14 @@ - install - name: Check if warn parameter can be used for shell module - set_fact: + ansible.builtin.set_fact: produce_warn: False when: ansible_version.full is version("2.14", "<") tags: - always - name: "RedHat | Installing zabbix-agent" - package: + ansible.builtin.package: pkg: - "{{ zabbix_agent_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}" @@ -43,7 +43,7 @@ - install - name: "RedHat | Installing zabbix-{sender,get}" - package: + ansible.builtin.package: pkg: - "{{ zabbix_sender_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" - "{{ zabbix_get_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" @@ -61,7 +61,7 @@ - install - name: "RedHat | Enable the service" - service: + ansible.builtin.service: name: "{{ zabbix_agent_service }}" enabled: true use: service diff --git a/roles/zabbix_agent/tasks/Windows.yml b/roles/zabbix_agent/tasks/Windows.yml index ca9fda62f..3ab803c95 100644 --- a/roles/zabbix_agent/tasks/Windows.yml +++ b/roles/zabbix_agent/tasks/Windows.yml @@ -1,12 +1,12 @@ --- - name: "Windows | Set default architecture" - set_fact: + ansible.builtin.set_fact: windows_arch: 32 tags: - always - name: "Windows | Override architecture if 64-bit" - set_fact: + ansible.builtin.set_fact: windows_arch: 64 when: - ansible_architecture == "64-bit" @@ -14,13 +14,13 @@ - always - name: "Windows | Set path to zabbix.exe" - set_fact: + ansible.builtin.set_fact: zabbix_win_exe_path: '{{ zabbix_win_install_dir }}\bin\win{{ windows_arch }}\zabbix_agentd.exe' tags: - always - name: "Windows | Set variables specific to Zabbix" - set_fact: + ansible.builtin.set_fact: zabbix_win_svc_name: Zabbix Agent zabbix_win_exe_path: '{{ zabbix_win_install_dir }}\bin\zabbix_agentd.exe' zabbix_win_config_name: "zabbix_agentd.conf" @@ -51,7 +51,7 @@ - always - name: "Windows | Set facts current zabbix agent installation" - set_fact: + ansible.builtin.set_fact: zabbix_agent_1_binary_exist: true zabbix_agent_1_version: zabbix_win_exe_info.results[0].win_file_version.product_version when: @@ -63,7 +63,7 @@ - always - name: "Windows | Set facts current zabbix agent installation (agent 2)" - set_fact: + ansible.builtin.set_fact: zabbix_agent_2_binary_exist: true zabbix_agent_2_version: zabbix_win_exe_info.results[1].win_file_version.product_version when: @@ -84,7 +84,7 @@ - always - name: "Windows | Set facts about current zabbix agent service state" - set_fact: + ansible.builtin.set_fact: zabbix_agent_1_service_exist: true when: - zabbix_service_info.results[0].exists is defined @@ -94,7 +94,7 @@ - always - name: "Windows | Set facts about current zabbix agent service state (agent 2)" - set_fact: + ansible.builtin.set_fact: zabbix_agent_2_service_exist: true when: - zabbix_service_info.results[1].exists is defined @@ -104,7 +104,7 @@ - always - name: "Windows | Set fact about version change requirement" - set_fact: + ansible.builtin.set_fact: zabbix_agent_version_change: true when: > (zabbix_agent_1_binary_exist | default(false) and @@ -184,7 +184,7 @@ - install - name: "Windows | Set installation settings (agent 2)" - set_fact: + ansible.builtin.set_fact: zabbix_win_package: "{{ zabbix2_win_package }}" zabbix_win_download_link: "{{ zabbix2_win_download_link }}" zabbix_win_exe_path: "{{ zabbix2_win_exe_path }}" @@ -289,7 +289,7 @@ - install - name: "Create directory for PSK file if not exist." - win_file: + ansible.windows.win_file: path: "{{ zabbix_agent_tlspskfile | win_dirname }}" state: directory when: @@ -300,7 +300,7 @@ - config - name: "Create directory for PSK file if not exist (zabbix-agent2)" - win_file: + ansible.windows.win_file: path: "{{ zabbix_agent2_tlspskfile | win_dirname }}" state: directory when: @@ -311,7 +311,7 @@ - config - name: "Place TLS PSK File" - win_copy: + ansible.windows.win_copy: dest: "{{ zabbix_agent_tlspskfile }}" content: "{{ zabbix_agent_tlspsk_secret }}" when: @@ -325,7 +325,7 @@ - config - name: "Place TLS PSK File (zabbix-agent2)" - win_copy: + ansible.windows.win_copy: dest: "{{ zabbix_agent2_tlspskfile }}" content: "{{ zabbix_agent2_tlspsk_secret }}" when: diff --git a/roles/zabbix_agent/tasks/Windows_conf.yml b/roles/zabbix_agent/tasks/Windows_conf.yml index f3eed4cc2..72dee230f 100644 --- a/roles/zabbix_agent/tasks/Windows_conf.yml +++ b/roles/zabbix_agent/tasks/Windows_conf.yml @@ -1,6 +1,6 @@ --- - name: "Set default ip address for zabbix_agent_ip" - set_fact: + ansible.builtin.set_fact: zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_ip_addresses'] | ansible.utils.ipv4 | first }}" when: - zabbix_agent_ip is not defined diff --git a/roles/zabbix_agent/tasks/macOS.yml b/roles/zabbix_agent/tasks/macOS.yml index 62a5788b2..7bcdd6fe3 100644 --- a/roles/zabbix_agent/tasks/macOS.yml +++ b/roles/zabbix_agent/tasks/macOS.yml @@ -1,7 +1,7 @@ --- # Tasks specific for macOS - name: "macOS | Check installed package version" - shell: | + ansible.builtin.shell: | set -o pipefail pkgutil --pkg-info 'com.zabbix.pkg.ZabbixAgent' | grep 'version:' | cut -d ' ' -f 2 register: pkgutil_version @@ -10,13 +10,13 @@ failed_when: pkgutil_version.rc == 2 - name: "macOS | Download the Zabbix package" - get_url: + ansible.builtin.get_url: url: "{{ zabbix_mac_download_link }}" dest: "/tmp/{{ zabbix_mac_package }}" mode: 0644 when: pkgutil_version.stdout != zabbix_version_long - name: "macOS | Install the Zabbix package" - command: installer -pkg "/tmp/{{ zabbix_mac_package }}" -target / + ansible.builtin.command: installer -pkg "/tmp/{{ zabbix_mac_package }}" -target / become: true when: pkgutil_version.stdout != zabbix_version_long diff --git a/roles/zabbix_agent/tasks/main.yml b/roles/zabbix_agent/tasks/main.yml index 186e3b0a8..f5f87d18f 100644 --- a/roles/zabbix_agent/tasks/main.yml +++ b/roles/zabbix_agent/tasks/main.yml @@ -1,25 +1,25 @@ --- # tasks file for zabbix_agent - name: "Include OS-specific variables" - include_vars: "{{ ansible_os_family }}.yml" + ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" tags: - always - name: Determine Latest Supported Zabbix Version - set_fact: + ansible.builtin.set_fact: zabbix_agent_version: "{{ zabbix_valid_agent_versions[ansible_distribution_major_version][0] | default(6.4) }}" when: zabbix_agent_version is not defined or zabbix_agent_version is none tags: - always - name: Set More Variables - set_fact: + 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 - fail: + ansible.builtin.fail: msg: Zabbix version {{ zabbix_agent_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} when: not zabbix_valid_version tags: @@ -31,7 +31,7 @@ when: zabbix_api_server_port is undefined - name: "Set variables specific for Zabbix Agent 2" - set_fact: + ansible.builtin.set_fact: zabbix_agent_service: zabbix-agent2 zabbix_agent_package: zabbix-agent2 when: @@ -41,12 +41,12 @@ - always - name: "Install the correct repository" - include_tasks: "{{ ansible_os_family }}.yml" + ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" when: - not (zabbix_agent_docker | bool) - name: "Encrypt with TLS PSK auto management" - include_tasks: tlspsk_auto.yml + ansible.builtin.include_tasks: tlspsk_auto.yml when: - not zabbix_agent2 - zabbix_agent_tlspsk_auto | bool @@ -54,7 +54,7 @@ - (zabbix_agent_tlspsk_secret is undefined) or (zabbix_agent_tlspsk_secret | length == '0') - name: "Encrypt with TLS PSK auto management" - include_tasks: tlspsk_auto_agent2.yml + ansible.builtin.include_tasks: tlspsk_auto_agent2.yml when: - zabbix_agent2 | bool - zabbix_agent2_tlspsk_auto | bool @@ -62,12 +62,12 @@ - (zabbix_agent2_tlspsk_secret is undefined) or (zabbix_agent2_tlspsk_secret | length == '0') - name: "Configure Agent" - include_tasks: Windows_conf.yml + ansible.builtin.include_tasks: Windows_conf.yml when: - ansible_os_family == "Windows" - name: "Configure Agent" - include_tasks: Linux.yml + ansible.builtin.include_tasks: Linux.yml when: - (ansible_os_family != "Windows" and ansible_os_family != "Darwin") or (zabbix_agent_docker | bool) @@ -81,14 +81,14 @@ # Can't think of a way to make http_login_* vars be undefined -( http_login_user: "{{ zabbix_api_http_user | default(-42) }}" http_login_password: "{{ zabbix_api_http_password | default(-42) }}" - include_tasks: api.yml + ansible.builtin.include_tasks: api.yml when: - (zabbix_api_create_hostgroup | bool) or (zabbix_api_create_hosts | bool) tags: - api - name: "Including userparameters" - include_tasks: "userparameter.yml" + ansible.builtin.include_tasks: "userparameter.yml" when: zabbix_agent_userparameters|length > 0 tags: - config diff --git a/roles/zabbix_agent/tasks/remove.yml b/roles/zabbix_agent/tasks/remove.yml index 57968146c..181329a32 100644 --- a/roles/zabbix_agent/tasks/remove.yml +++ b/roles/zabbix_agent/tasks/remove.yml @@ -1,9 +1,9 @@ --- - name: Pull service facts - service_facts: + ansible.builtin.service_facts: -- name: "Remove | Make sure the \"old\" zabbix-agent service stopped" - service: +- name: 'Remove | Make sure the "old" zabbix-agent service stopped' + ansible.builtin.service: name: "zabbix-agent" state: stopped enabled: false @@ -13,13 +13,13 @@ ansible_facts.services["zabbix-agent"] is defined - name: "Remove | Package removal" - package: + ansible.builtin.package: name: "zabbix-agent" state: absent become: true - name: "Remove | Remove the agent-include-dir" - file: + ansible.builtin.file: path: "{{ zabbix_agent_include }}" state: absent become: true diff --git a/roles/zabbix_agent/tasks/selinux.yml b/roles/zabbix_agent/tasks/selinux.yml index 8c01e9c22..2b11d1a47 100644 --- a/roles/zabbix_agent/tasks/selinux.yml +++ b/roles/zabbix_agent/tasks/selinux.yml @@ -1,6 +1,6 @@ --- - name: "SELinux | Debian | Install policycoreutils-python" - apt: + ansible.builtin.apt: pkg: policycoreutils-python-utils state: present update_cache: true @@ -19,7 +19,7 @@ - install - name: "SELinux | RedHat | Install policycoreutils-python" - package: + ansible.builtin.package: name: policycoreutils-python state: installed environment: @@ -35,7 +35,7 @@ - install - name: "SELinux | RedHat | Install python3-policycoreutils on RHEL8" - package: + ansible.builtin.package: name: python3-policycoreutils state: installed environment: @@ -51,7 +51,7 @@ - install - name: "SELinux | RedHat | Install selinux-policy-targeted" - package: + ansible.builtin.package: name: selinux-policy-targeted state: installed register: zabbix_agent_selinuxpolicytargeted_installed @@ -64,7 +64,7 @@ # straight to getenforce binary , workaround for missing python_selinux library - name: "SELinux | Get getenforce binary" - stat: + ansible.builtin.stat: path: /usr/sbin/getenforce register: getenforce_bin become: true @@ -72,7 +72,7 @@ - always - name: "SELinux | Collect getenforce output" - command: /usr/sbin/getenforce + ansible.builtin.command: /usr/sbin/getenforce register: sestatus when: "getenforce_bin.stat.exists" changed_when: false @@ -82,7 +82,7 @@ - always - name: "SELinux | Set zabbix_selinux to true if getenforce returns Enforcing or Permissive" - set_fact: + ansible.builtin.set_fact: zabbix_selinux: "{{ true }}" when: - 'getenforce_bin.stat.exists and ("Enforcing" in sestatus.stdout or "Permissive" in sestatus.stdout)' diff --git a/roles/zabbix_agent/tasks/tlspsk_auto.yml b/roles/zabbix_agent/tasks/tlspsk_auto.yml index 35c7a371e..ad7d49aa3 100644 --- a/roles/zabbix_agent/tasks/tlspsk_auto.yml +++ b/roles/zabbix_agent/tasks/tlspsk_auto.yml @@ -1,12 +1,12 @@ --- -- include_tasks: tlspsk_auto_linux.yml +- ansible.builtin.include_tasks: tlspsk_auto_linux.yml when: (ansible_os_family != "Windows") or (zabbix_agent_docker | bool) -- include_tasks: tlspsk_auto_windows.yml +- ansible.builtin.include_tasks: tlspsk_auto_windows.yml when: ansible_os_family == "Windows" - name: AutoPSK | Default tlsaccept and tlsconnect to enforce PSK - set_fact: + ansible.builtin.set_fact: zabbix_agent_tlsaccept: psk zabbix_agent_tlsconnect: psk when: zabbix_api_create_hosts diff --git a/roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml b/roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml index 759ae496b..6e5f8dc4d 100644 --- a/roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml +++ b/roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml @@ -6,7 +6,7 @@ when: ansible_os_family == "Windows" - name: AutoPSK | Default tlsaccept and tlsconnect to enforce PSK - set_fact: + ansible.builtin.set_fact: zabbix_agent2_tlsaccept: psk zabbix_agent2_tlsconnect: psk when: zabbix_api_create_hosts diff --git a/roles/zabbix_agent/tasks/tlspsk_auto_agent2_common.yml b/roles/zabbix_agent/tasks/tlspsk_auto_agent2_common.yml index b3ebadf6e..3f6e0d2cd 100644 --- a/roles/zabbix_agent/tasks/tlspsk_auto_agent2_common.yml +++ b/roles/zabbix_agent/tasks/tlspsk_auto_agent2_common.yml @@ -1,7 +1,7 @@ --- # Process PSK Secret - name: AutoPSK | Save existing TLS PSK secret - set_fact: + ansible.builtin.set_fact: zabbix_agent2_tlspsk_read: "{{ zabbix_agent2_tlspsk_base64['content'] | b64decode | trim }}" when: zabbix_agent2_tlspskcheck.stat.exists no_log: "{{ ansible_verbosity < 3 }}" @@ -9,7 +9,7 @@ - config - name: AutoPSK | Use existing TLS PSK secret - set_fact: + ansible.builtin.set_fact: zabbix_agent2_tlspsk_secret: "{{ zabbix_agent2_tlspsk_read }}" when: - zabbix_agent2_tlspskcheck.stat.exists @@ -19,7 +19,7 @@ - config - name: AutoPSK | Generate new TLS PSK secret - set_fact: + ansible.builtin.set_fact: zabbix_agent2_tlspsk_secret: "{{ lookup('password', '/dev/null chars=hexdigits length=64') }}" when: - not zabbix_agent2_tlspskcheck.stat.exists @@ -30,7 +30,7 @@ # Process PSK Identity - name: AutoPSK | Use existing TLS PSK identity - set_fact: + ansible.builtin.set_fact: zabbix_agent2_tlspskidentity: "{{ zabbix_agent2_tlspskidentity_base64['content'] | b64decode | trim }}" when: - zabbix_agent2_tlspskidentity_check.stat.exists @@ -39,7 +39,7 @@ - config - name: AutoPSK | Generate new TLS PSK identity - set_fact: + ansible.builtin.set_fact: zabbix_agent2_tlspskidentity: >- {{ zabbix_agent_visible_hostname diff --git a/roles/zabbix_agent/tasks/tlspsk_auto_agent2_linux.yml b/roles/zabbix_agent/tasks/tlspsk_auto_agent2_linux.yml index 0c554636f..aaff36128 100644 --- a/roles/zabbix_agent/tasks/tlspsk_auto_agent2_linux.yml +++ b/roles/zabbix_agent/tasks/tlspsk_auto_agent2_linux.yml @@ -1,13 +1,13 @@ --- - name: AutoPSK | Set default path variables (Linux) - set_fact: + ansible.builtin.set_fact: zabbix_agent2_tlspskfile: "/etc/zabbix/tls_psk_auto.secret" zabbix_agent2_tlspskidentity_file: "/etc/zabbix/tls_psk_auto.identity" tags: - config - name: AutoPSK | Check for existing TLS PSK file (Linux) - stat: + ansible.builtin.stat: path: "{{ zabbix_agent2_tlspskfile }}" register: zabbix_agent2_tlspskcheck become: true @@ -15,7 +15,7 @@ - config - name: AutoPSK | Check for existing TLS PSK identity (Linux) - stat: + ansible.builtin.stat: path: "{{ zabbix_agent2_tlspskidentity_file }}" register: zabbix_agent2_tlspskidentity_check become: true @@ -23,7 +23,7 @@ - config - name: AutoPSK | read existing TLS PSK file (Linux) - slurp: + ansible.builtin.slurp: src: "{{ zabbix_agent2_tlspskfile }}" register: zabbix_agent2_tlspsk_base64 become: true @@ -34,7 +34,7 @@ - config - name: AutoPSK | Read existing TLS PSK identity file (Linux) - slurp: + ansible.builtin.slurp: src: "{{ zabbix_agent2_tlspskidentity_file }}" register: zabbix_agent2_tlspskidentity_base64 become: true @@ -46,7 +46,7 @@ - include_tasks: tlspsk_auto_agent2_common.yml - name: AutoPSK | Template TLS PSK identity in file (Linux) - copy: + ansible.builtin.copy: dest: "{{ zabbix_agent2_tlspskidentity_file }}" content: "{{ zabbix_agent2_tlspskidentity }}" owner: zabbix @@ -63,7 +63,7 @@ - config - name: AutoPSK | Template TLS PSK secret in file (Linux) - copy: + ansible.builtin.copy: dest: "{{ zabbix_agent2_tlspskfile }}" content: "{{ zabbix_agent2_tlspsk_secret }}" owner: zabbix diff --git a/roles/zabbix_agent/tasks/tlspsk_auto_agent2_windows.yml b/roles/zabbix_agent/tasks/tlspsk_auto_agent2_windows.yml index a32388c67..3e1529e6b 100644 --- a/roles/zabbix_agent/tasks/tlspsk_auto_agent2_windows.yml +++ b/roles/zabbix_agent/tasks/tlspsk_auto_agent2_windows.yml @@ -1,6 +1,6 @@ --- - name: AutoPSK | Set default path variables for Windows - set_fact: + ansible.builtin.set_fact: zabbix_agent2_tlspskfile: "{{ zabbix_win_install_dir }}\\tls_psk_auto.secret.txt" zabbix_agent2_tlspskidentity_file: "{{ zabbix_win_install_dir }}\\tls_psk_auto.identity.txt" tags: @@ -21,7 +21,7 @@ - config - name: AutoPSK | read existing TLS PSK file (Windows) - slurp: + ansible.builtin.slurp: src: "{{ zabbix_agent2_tlspskfile }}" register: zabbix_agent2_tlspsk_base64 when: @@ -31,7 +31,7 @@ - config - name: AutoPSK | Read existing TLS PSK identity file (Windows) - slurp: + ansible.builtin.slurp: src: "{{ zabbix_agent2_tlspskidentity_file }}" register: zabbix_agent2_tlspskidentity_base64 when: zabbix_agent2_tlspskidentity_check.stat.exists @@ -39,10 +39,10 @@ tags: - config -- include_tasks: tlspsk_auto_agent2_common.yml +- ansible.builtin.include_tasks: tlspsk_auto_agent2_common.yml - name: Windows | AutoPSK | Template TLS PSK identity in file (Windows) - win_copy: + ansible.windows.win_copy: dest: "{{ zabbix_agent2_tlspskidentity_file }}" content: "{{ zabbix_agent2_tlspskidentity }}" when: @@ -54,7 +54,7 @@ - config - name: AutoPSK | Template TLS PSK secret in file (Windows) - win_copy: + ansible.windows.win_copy: dest: "{{ zabbix_agent2_tlspskfile }}" content: "{{ zabbix_agent2_tlspsk_secret }}" when: diff --git a/roles/zabbix_agent/tasks/tlspsk_auto_common.yml b/roles/zabbix_agent/tasks/tlspsk_auto_common.yml index 6d12e477d..05ef24d0e 100644 --- a/roles/zabbix_agent/tasks/tlspsk_auto_common.yml +++ b/roles/zabbix_agent/tasks/tlspsk_auto_common.yml @@ -1,7 +1,7 @@ --- # Process PSK Secret - name: AutoPSK | Save existing TLS PSK secret - set_fact: + ansible.builtin.set_fact: zabbix_agent_tlspsk_read: "{{ zabbix_agent_tlspsk_base64['content'] | b64decode | trim }}" when: zabbix_agent_tlspskcheck.stat.exists no_log: "{{ ansible_verbosity < 3 }}" @@ -9,7 +9,7 @@ - config - name: AutoPSK | Use existing TLS PSK secret - set_fact: + ansible.builtin.set_fact: zabbix_agent_tlspsk_secret: "{{ zabbix_agent_tlspsk_read }}" when: - zabbix_agent_tlspskcheck.stat.exists @@ -19,7 +19,7 @@ - config - name: AutoPSK | Generate new TLS PSK secret - set_fact: + ansible.builtin.set_fact: zabbix_agent_tlspsk_secret: "{{ lookup('password', '/dev/null chars=hexdigits length=64') }}" when: - (not zabbix_agent_tlspskcheck.stat.exists) or (zabbix_agent_tlspsk_read|length < 32) @@ -29,7 +29,7 @@ # Process PSK Identity - name: AutoPSK | Use existing TLS PSK identity - set_fact: + ansible.builtin.set_fact: zabbix_agent_tlspskidentity: "{{ zabbix_agent_tlspskidentity_base64['content'] | b64decode | trim }}" when: - zabbix_agent_tlspskidentity_check.stat.exists @@ -38,7 +38,7 @@ - config - name: AutoPSK | Generate new TLS PSK identity - set_fact: + ansible.builtin.set_fact: zabbix_agent_tlspskidentity: >- {{ zabbix_agent_visible_hostname diff --git a/roles/zabbix_agent/tasks/tlspsk_auto_linux.yml b/roles/zabbix_agent/tasks/tlspsk_auto_linux.yml index 1fb749ece..8cc711fcb 100644 --- a/roles/zabbix_agent/tasks/tlspsk_auto_linux.yml +++ b/roles/zabbix_agent/tasks/tlspsk_auto_linux.yml @@ -1,13 +1,13 @@ --- - name: AutoPSK | Set default path variables (Linux) - set_fact: + ansible.builtin.set_fact: zabbix_agent_tlspskfile: "/etc/zabbix/tls_psk_auto.secret" zabbix_agent_tlspskidentity_file: "/etc/zabbix/tls_psk_auto.identity" tags: - config - name: AutoPSK | Check for existing TLS PSK file (Linux) - stat: + ansible.builtin.stat: path: "{{ zabbix_agent_tlspskfile }}" register: zabbix_agent_tlspskcheck become: true @@ -15,7 +15,7 @@ - config - name: AutoPSK | Check for existing TLS PSK identity (Linux) - stat: + ansible.builtin.stat: path: "{{ zabbix_agent_tlspskidentity_file }}" register: zabbix_agent_tlspskidentity_check become: true @@ -23,7 +23,7 @@ - config - name: AutoPSK | read existing TLS PSK file (Linux) - slurp: + ansible.builtin.slurp: src: "{{ zabbix_agent_tlspskfile }}" register: zabbix_agent_tlspsk_base64 become: true @@ -34,7 +34,7 @@ - config - name: AutoPSK | Read existing TLS PSK identity file (Linux) - slurp: + ansible.builtin.slurp: src: "{{ zabbix_agent_tlspskidentity_file }}" register: zabbix_agent_tlspskidentity_base64 become: true @@ -46,7 +46,7 @@ - include_tasks: tlspsk_auto_common.yml - name: AutoPSK | Template TLS PSK identity in file (Linux) - copy: + ansible.builtin.copy: dest: "{{ zabbix_agent_tlspskidentity_file }}" content: "{{ zabbix_agent_tlspskidentity }}" owner: zabbix @@ -63,7 +63,7 @@ - config - name: AutoPSK | Template TLS PSK secret in file (Linux) - copy: + ansible.builtin.copy: dest: "{{ zabbix_agent_tlspskfile }}" content: "{{ zabbix_agent_tlspsk_secret }}" owner: zabbix diff --git a/roles/zabbix_agent/tasks/tlspsk_auto_windows.yml b/roles/zabbix_agent/tasks/tlspsk_auto_windows.yml index 8aa5497ff..b9289ac49 100644 --- a/roles/zabbix_agent/tasks/tlspsk_auto_windows.yml +++ b/roles/zabbix_agent/tasks/tlspsk_auto_windows.yml @@ -1,6 +1,6 @@ --- - name: AutoPSK | Set default path variables for Windows - set_fact: + ansible.builtin.set_fact: zabbix_agent_tlspskfile: "{{ zabbix_win_install_dir }}\\tls_psk_auto.secret.txt" zabbix_agent_tlspskidentity_file: "{{ zabbix_win_install_dir }}\\tls_psk_auto.identity.txt" tags: @@ -21,7 +21,7 @@ - config - name: AutoPSK | read existing TLS PSK file (Windows) - slurp: + ansible.builtin.slurp: src: "{{ zabbix_agent_tlspskfile }}" register: zabbix_agent_tlspsk_base64 when: @@ -31,7 +31,7 @@ - config - name: AutoPSK | Read existing TLS PSK identity file (Windows) - slurp: + ansible.builtin.slurp: src: "{{ zabbix_agent_tlspskidentity_file }}" register: zabbix_agent_tlspskidentity_base64 when: zabbix_agent_tlspskidentity_check.stat.exists @@ -42,7 +42,7 @@ - include_tasks: tlspsk_auto_common.yml - name: AutoPSK | Template TLS PSK identity in file (Windows) - win_copy: + ansible.windows.win_copy: dest: "{{ zabbix_agent_tlspskidentity_file }}" content: "{{ zabbix_agent_tlspskidentity }}" when: @@ -54,7 +54,7 @@ - config - name: AutoPSK | Template TLS PSK secret in file (Windows) - win_copy: + ansible.windows.win_copy: dest: "{{ zabbix_agent_tlspskfile }}" content: "{{ zabbix_agent_tlspsk_secret }}" when: diff --git a/roles/zabbix_agent/tasks/userparameter.yml b/roles/zabbix_agent/tasks/userparameter.yml index fda62606e..a80be1736 100644 --- a/roles/zabbix_agent/tasks/userparameter.yml +++ b/roles/zabbix_agent/tasks/userparameter.yml @@ -22,7 +22,7 @@ - block: - name: "Installing user-defined userparameters" - template: + ansible.builtin.template: src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2" dest: "{{ zabbix_agent_include }}/userparameter_{{ item.name }}.conf" owner: zabbix @@ -35,7 +35,7 @@ with_items: "{{ zabbix_agent_userparameters }}" - name: "Installing user-defined scripts" - copy: + ansible.builtin.copy: src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}" dest: "/etc/zabbix/scripts/" owner: zabbix @@ -55,7 +55,7 @@ - block: - name: "Installing user-defined userparameters" - template: + ansible.builtin.template: src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2" dest: "{{ zabbix_agent2_include }}/userparameter_{{ item.name }}.conf" owner: zabbix @@ -68,7 +68,7 @@ with_items: "{{ zabbix_agent_userparameters }}" - name: "Installing user-defined scripts" - copy: + ansible.builtin.copy: src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}" dest: "/etc/zabbix/scripts/" owner: zabbix diff --git a/roles/zabbix_javagateway/handlers/main.yml b/roles/zabbix_javagateway/handlers/main.yml index c7034aa7d..9b6ed50c1 100644 --- a/roles/zabbix_javagateway/handlers/main.yml +++ b/roles/zabbix_javagateway/handlers/main.yml @@ -2,14 +2,14 @@ # handlers file for zabbix-javagateway - name: zabbix-java-gateway restarted - service: + ansible.builtin.service: name: zabbix-java-gateway state: restarted enabled: true become: true - name: "clean repo files from proxy creds" - shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + ansible.builtin.shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true become: true when: - ansible_os_family == 'RedHat' diff --git a/roles/zabbix_javagateway/tasks/Debian.yml b/roles/zabbix_javagateway/tasks/Debian.yml index c99bb69f1..fbaa5c3c7 100644 --- a/roles/zabbix_javagateway/tasks/Debian.yml +++ b/roles/zabbix_javagateway/tasks/Debian.yml @@ -1,12 +1,12 @@ --- - name: "Debian | Set some variables" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_javagateway_version | regex_replace('\\.', '') }}" tags: - always - name: "Debian | Set some variables" - set_fact: + ansible.builtin.set_fact: zabbix_javagateway_apt_repository: - "http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}/{{ ansible_distribution.lower() }}/" - "{{ ansible_distribution_release }}" @@ -17,7 +17,7 @@ - install - name: "Debian | Set some variables" - set_fact: + ansible.builtin.set_fact: zabbix_javagateway_apt_repository: - "http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}/{{ ansible_distribution.lower() }}-arm64/" - "{{ ansible_distribution_release }}" @@ -51,7 +51,7 @@ - install - name: "Debian | Installing repository Debian" - apt_repository: + ansible.builtin.apt_repository: repo: "{{ item }} [signed-by={{ zabbix_gpg_key }}] {{ zabbix_javagateway_apt_repository | join(' ') }}" state: present become: true @@ -62,7 +62,7 @@ - install - name: "Debian | Installing zabbix-java-gateway" - apt: + ansible.builtin.apt: pkg: zabbix-java-gateway state: "{{ zabbix_javagateway_package_state }}" update_cache: true @@ -78,7 +78,7 @@ - install - name: "Debian | Make sure Zabbix Java Gateway is not yet running" - systemd: + ansible.builtin.systemd: name: zabbix-java-gateway state: stopped enabled: true diff --git a/roles/zabbix_javagateway/tasks/RedHat.yml b/roles/zabbix_javagateway/tasks/RedHat.yml index 3f15b3e3e..96d9d3928 100644 --- a/roles/zabbix_javagateway/tasks/RedHat.yml +++ b/roles/zabbix_javagateway/tasks/RedHat.yml @@ -2,7 +2,7 @@ # Tasks specific for RedHat systems - name: "RedHat | Install basic repo file" - yum_repository: + ansible.builtin.yum_repository: name: "{{ item.name }}" description: "{{ item.description }}" baseurl: "{{ item.baseurl }}" @@ -21,7 +21,7 @@ - install - name: "RedHat | Installing zabbix-java-gateway" - package: + ansible.builtin.package: pkg: zabbix-java-gateway state: "{{ zabbix_javagateway_package_state }}" disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}" diff --git a/roles/zabbix_javagateway/tasks/main.yml b/roles/zabbix_javagateway/tasks/main.yml index 0eb13da1c..6b56d43d3 100644 --- a/roles/zabbix_javagateway/tasks/main.yml +++ b/roles/zabbix_javagateway/tasks/main.yml @@ -2,35 +2,35 @@ # tasks file for zabbix_javagateway - name: Include OS-specific variables - include_vars: "{{ ansible_os_family }}.yml" + ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" tags: - always - name: Determine Latest Supported Zabbix Version - set_fact: + ansible.builtin.set_fact: zabbix_javagateway_version: "{{ zabbix_valid_javagateway_versions[ansible_distribution_major_version][0] | default(6.4) }}" when: zabbix_javagateway_version is not defined tags: - always - name: Set More Variables - set_fact: + 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 - fail: + ansible.builtin.fail: msg: Zabbix version {{ zabbix_javagateway_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} when: not zabbix_valid_version tags: - always - name: "Install the correct repository" - include_tasks: "{{ ansible_os_family }}.yml" + ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" - name: "Configure zabbix-proxy" - template: + ansible.builtin.template: src: zabbix_java_gateway.conf.j2 dest: /etc/zabbix/zabbix_java_gateway.conf owner: zabbix @@ -43,7 +43,7 @@ - config - name: "Make sure Zabbix Java Gateway is running" - systemd: + ansible.builtin.systemd: name: zabbix-java-gateway state: started enabled: true diff --git a/roles/zabbix_proxy/handlers/main.yml b/roles/zabbix_proxy/handlers/main.yml index f10f76184..9d5b88ee3 100644 --- a/roles/zabbix_proxy/handlers/main.yml +++ b/roles/zabbix_proxy/handlers/main.yml @@ -2,7 +2,7 @@ # handlers file for zabbix-proxy - name: restart zabbix-proxy - service: + ansible.builtin.service: name: zabbix-proxy state: restarted enabled: true @@ -11,7 +11,7 @@ - zabbix_proxy_manage_service | bool - name: "clean repo files from proxy creds" - shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + ansible.builtin.shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true become: true when: - ansible_os_family == 'RedHat' diff --git a/roles/zabbix_proxy/tasks/Debian.yml b/roles/zabbix_proxy/tasks/Debian.yml index 8a8d56455..a6d9df881 100644 --- a/roles/zabbix_proxy/tasks/Debian.yml +++ b/roles/zabbix_proxy/tasks/Debian.yml @@ -1,6 +1,6 @@ --- - name: "Debian | Set short version name" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_proxy_version | regex_replace('\\.', '') }}" zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}" zabbix_underscore_version: "{{ zabbix_proxy_version | regex_replace('\\.', '_') }}" @@ -8,14 +8,14 @@ - always - name: "Debian | Set some facts for Zabbix" - set_fact: + ansible.builtin.set_fact: datafiles_path: /usr/share/doc/zabbix-sql-scripts/{{ zabbix_proxy_db_long }} tags: - install - config - name: "Debian | Installing gnupg" - apt: + ansible.builtin.apt: pkg: gnupg update_cache: true cache_valid_time: 3600 @@ -56,7 +56,7 @@ - install - name: "Debian | Installing repository {{ ansible_distribution }}" - apt_repository: + ansible.builtin.apt_repository: repo: "{{ item }} [signed-by={{ zabbix_gpg_key }}] http://repo.zabbix.com/zabbix/{{ zabbix_proxy_version }}/{{ ansible_distribution.lower() }}/ {{ ansible_distribution_release }} main" state: present become: true @@ -67,7 +67,7 @@ - install - name: "Debian | Create /etc/apt/preferences.d/" - file: + ansible.builtin.file: path: /etc/apt/preferences.d/ state: directory mode: "0755" @@ -78,7 +78,7 @@ - install - name: "Debian | Configuring the weight for APT" - copy: + ansible.builtin.copy: dest: "/etc/apt/preferences.d/zabbix-proxy-{{ zabbix_proxy_database }}" content: | Package: zabbix-proxy-{{ zabbix_proxy_database }} @@ -93,7 +93,7 @@ - install - name: "Debian | Installing zabbix-proxy-{{ zabbix_proxy_database }}" - apt: + ansible.builtin.apt: pkg: "zabbix-proxy-{{ zabbix_proxy_database }}" update_cache: true cache_valid_time: 3600 @@ -110,7 +110,7 @@ - install - name: "Debian | Installing zabbix-sql-scripts" - apt: + ansible.builtin.apt: pkg: zabbix-sql-scripts state: "{{ zabbix_proxy_package_state }}" update_cache: true @@ -128,7 +128,7 @@ - install - name: "Debian | Install Ansible module dependencies" - apt: + ansible.builtin.apt: name: "{{ zabbix_python_prefix }}-psycopg2" state: present environment: @@ -144,7 +144,7 @@ - dependencies - name: "Debian | Install Mysql Client package" - apt: + ansible.builtin.apt: name: "{{ mysql_client_pkgs[ansible_distribution_major_version] }}" state: present environment: @@ -162,7 +162,7 @@ - database - name: "Debian | Install PostgreSQL Client package" - apt: + ansible.builtin.apt: name: postgresql-client state: present environment: @@ -181,7 +181,7 @@ - database - name: "Debian | Install sqlite3" - apt: + ansible.builtin.apt: name: sqlite3 state: present environment: diff --git a/roles/zabbix_proxy/tasks/RedHat.yml b/roles/zabbix_proxy/tasks/RedHat.yml index cd56d3e88..da389e0c8 100644 --- a/roles/zabbix_proxy/tasks/RedHat.yml +++ b/roles/zabbix_proxy/tasks/RedHat.yml @@ -2,26 +2,26 @@ # Tasks specific for RedHat systems - name: "RedHat | Set short version name" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_proxy_version | regex_replace('\\.', '') }}" tags: - always - name: "RedHat | Define package without version" - set_fact: + ansible.builtin.set_fact: zabbix_proxy_package: "zabbix-proxy-{{ zabbix_proxy_database }}" cacheable: true tags: - always - name: "RedHat | Set facts for Zabbix" - set_fact: + ansible.builtin.set_fact: datafiles_path: "/usr/share/doc/zabbix-sql-scripts/{{ zabbix_proxy_db_long }}" tags: - always - name: "RedHat | Make sure old file is absent" - file: + ansible.builtin.file: path: /etc/yum.repos.d/zabbix-supported.repo state: absent become: true @@ -29,7 +29,7 @@ - install - name: "RedHat | Install basic repo file" - yum_repository: + ansible.builtin.yum_repository: name: "{{ item.name }}" description: "{{ item.description }}" baseurl: "{{ item.baseurl }}" @@ -50,7 +50,7 @@ - name: Install packages for Zabbix Repository block: - name: "RedHat | Installing zabbix-proxy-{{ zabbix_proxy_database }}" - yum: + ansible.builtin.yum: pkg: "{{ zabbix_proxy_package }}-{{ zabbix_proxy_version }}.{{ zabbix_proxy_version_minor }}" state: "{{ zabbix_proxy_package_state }}" disablerepo: "{{ zabbix_proxy_disable_repo | default(omit) }}" @@ -62,7 +62,7 @@ until: is_zabbix_proxy_package_installed is succeeded - name: "RedHat | Installing zabbix-sql-scripts" - yum: + ansible.builtin.yum: pkg: "zabbix-sql-scripts-{{ zabbix_proxy_version }}.{{ zabbix_proxy_version_minor }}" state: "{{ zabbix_proxy_package_state }}" disablerepo: "{{ zabbix_proxy_disable_repo | default(omit) }}" @@ -76,7 +76,7 @@ - install - name: "RedHat | Install Ansible PostgreSQL Client package" - yum: + ansible.builtin.yum: name: "{{ pgsql_depenencies[ansible_distribution_major_version] }}" state: present environment: @@ -105,7 +105,7 @@ when: ansible_distribution_major_version == '7' - name: "RedHat | Install Mysql Client package" - yum: + ansible.builtin.yum: name: "{{ mysql_client_pkgs[ansible_distribution_major_version] }}" state: installed environment: @@ -124,7 +124,7 @@ - dependencies - name: "RedHat | Install sqlite3" - yum: + ansible.builtin.yum: name: - sqlite state: present @@ -142,6 +142,6 @@ - dependencies - name: "Configure SELinux when enabled" - include_tasks: selinux.yml + ansible.builtin.include_tasks: selinux.yml when: - zabbix_proxy_selinux | bool diff --git a/roles/zabbix_proxy/tasks/main.yml b/roles/zabbix_proxy/tasks/main.yml index 27aae59e3..ee19e04db 100644 --- a/roles/zabbix_proxy/tasks/main.yml +++ b/roles/zabbix_proxy/tasks/main.yml @@ -1,19 +1,19 @@ --- # tasks file for zabbix_proxy - name: "Include OS-specific variables" - include_vars: "{{ ansible_os_family }}.yml" + ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" tags: - always - name: Determine Latest Supported Zabbix Version - set_fact: + ansible.builtin.set_fact: zabbix_proxy_version: "{{ zabbix_valid_proxy_versions[ansible_distribution_major_version][0] | default(6.4) }}" when: zabbix_proxy_version is not defined or zabbix_proxy_version is none tags: - always - name: Set More Variables - set_fact: + 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('\\.', '') }}" @@ -21,7 +21,7 @@ - always - name: Stopping Install of Invalid Version - fail: + ansible.builtin.fail: msg: Zabbix version {{ zabbix_proxy_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} when: not zabbix_valid_version tags: @@ -33,14 +33,14 @@ when: zabbix_api_server_port is undefined - name: Set Path to SQL File - set_fact: + ansible.builtin.set_fact: datafile_path: "{{ db_file_path[zabbix_short_version] }}" tags: - install - config - name: "Set default ip address for zabbix_proxy_ip" - set_fact: + ansible.builtin.set_fact: zabbix_proxy_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4'].address }}" when: - zabbix_proxy_ip is not defined @@ -51,10 +51,10 @@ - api - name: "Complete OS Specific Tasks" - include: "{{ ansible_os_family }}.yml" + ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" - name: "Get the file for database schema" - shell: ls -1 {{ db_file_path[zabbix_short_version] }} + ansible.builtin.shell: ls -1 {{ db_file_path[zabbix_short_version] }} changed_when: false become: true when: @@ -64,10 +64,10 @@ - database - name: "Installing the database" - include_tasks: "{{ zabbix_proxy_db_long }}.yml" + ansible.builtin.include_tasks: "{{ zabbix_proxy_db_long }}.yml" - name: "Create include dir zabbix-proxy" - file: + ansible.builtin.file: path: "{{ zabbix_proxy_include }}" owner: "{{ zabbix_os_user }}" group: "{{ zabbix_os_user }}" @@ -79,7 +79,7 @@ - config - name: "Create module dir zabbix-proxy" - file: + ansible.builtin.file: path: "{{ zabbix_proxy_loadmodulepath }}" owner: "{{ zabbix_os_user }}" group: "{{ zabbix_os_user }}" @@ -91,7 +91,7 @@ - config - name: "Create directory for PSK file if not exist." - file: + ansible.builtin.file: path: "{{ zabbix_proxy_tlspskfile | dirname }}" mode: 0755 state: directory @@ -102,7 +102,7 @@ - config - name: "Place TLS PSK File" - copy: + ansible.builtin.copy: dest: "{{ zabbix_proxy_tlspskfile }}" content: "{{ zabbix_proxy_tlspsk_secret }}" owner: "{{ zabbix_os_user }}" @@ -118,7 +118,7 @@ - config - name: "Configure zabbix-proxy" - template: + ansible.builtin.template: src: zabbix_proxy.conf.j2 dest: "{{ zabbix_proxy_config }}" owner: "{{ zabbix_os_user }}" @@ -156,7 +156,7 @@ - api - name: "zabbix-proxy started" - service: + ansible.builtin.service: name: zabbix-proxy state: started enabled: true diff --git a/roles/zabbix_proxy/tasks/mysql.yml b/roles/zabbix_proxy/tasks/mysql.yml index c16f31f5f..b6dcb1363 100644 --- a/roles/zabbix_proxy/tasks/mysql.yml +++ b/roles/zabbix_proxy/tasks/mysql.yml @@ -1,7 +1,7 @@ --- # task file for mysql - name: "MySQL | Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ zabbix_proxy_dbhost if (zabbix_proxy_dbhost != 'localhost') else inventory_hostname }}" when: - zabbix_proxy_dbhost_run_install @@ -9,7 +9,7 @@ - database - name: "MySQL | Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ inventory_hostname }}" when: - not zabbix_proxy_dbhost_run_install @@ -17,14 +17,14 @@ - database - name: "MySQL | Override delegated_dbhost with real dbhost when dbhost is behind loadbalancer" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ zabbix_proxy_real_dbhost }}" when: zabbix_proxy_real_dbhost | default(false) tags: - database - name: PyMySQL - pip: + ansible.builtin.pip: name: PyMySQL register: installation_dependencies until: installation_dependencies is succeeded @@ -68,7 +68,7 @@ - database - name: "MySQL | Check if we have done files" - stat: + ansible.builtin.stat: path: /etc/zabbix/schema.done register: done_file become: true @@ -160,7 +160,7 @@ - database - name: "MySQL | Create done file" - file: + ansible.builtin.file: path: /etc/zabbix/schema.done state: touch mode: "0644" diff --git a/roles/zabbix_proxy/tasks/postgresql.yml b/roles/zabbix_proxy/tasks/postgresql.yml index b08f80567..291052455 100644 --- a/roles/zabbix_proxy/tasks/postgresql.yml +++ b/roles/zabbix_proxy/tasks/postgresql.yml @@ -2,7 +2,7 @@ # task file for postgresql - name: "PostgreSQL | Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ zabbix_proxy_dbhost if (zabbix_proxy_dbhost != 'localhost') else inventory_hostname }}" when: - zabbix_proxy_dbhost_run_install @@ -10,7 +10,7 @@ - database - name: "PostgreSQL | Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ inventory_hostname }}" when: - not zabbix_proxy_dbhost_run_install @@ -73,14 +73,14 @@ - database - name: "PostgreSQL | Handle Compressed Schema File" - set_fact: + ansible.builtin.set_fact: zabbix_proxy_cat_cmd: zcat when: "'.gz' in ls_output_schema.stdout" tags: - database - name: "PostgreSQL | Importing schema file" - shell: | + ansible.builtin.shell: | set -euxo pipefail {{ zabbix_proxy_cat_cmd }} {{ ls_output_schema.stdout }} | psql -h '{{ zabbix_proxy_dbhost }}' -U '{{ zabbix_proxy_dbuser }}' -d '{{ zabbix_proxy_dbname }}' touch /etc/zabbix/schema.done diff --git a/roles/zabbix_proxy/tasks/selinux.yml b/roles/zabbix_proxy/tasks/selinux.yml index 606cafbbe..0dca77c52 100644 --- a/roles/zabbix_proxy/tasks/selinux.yml +++ b/roles/zabbix_proxy/tasks/selinux.yml @@ -1,6 +1,6 @@ --- - name: "SELinux | RedHat | Install related SELinux package to fix issues" - yum: + ansible.builtin.yum: name: "{{ selinux_pkgs[ansible_distribution_major_version] }}" state: present environment: @@ -13,7 +13,7 @@ - zabbix-proxy - name: "SELinux | RedHat | Add SEmodule to fix SELinux issue: zabbix_proxy_alerter.sock" - script: + ansible.builtin.script: cmd: files/install_semodule.bsx args: creates: /etc/selinux/targeted/active/modules/400/zabbix_proxy_add/cil diff --git a/roles/zabbix_proxy/tasks/sqlite3.yml b/roles/zabbix_proxy/tasks/sqlite3.yml index f7893e411..3d74b73e7 100644 --- a/roles/zabbix_proxy/tasks/sqlite3.yml +++ b/roles/zabbix_proxy/tasks/sqlite3.yml @@ -2,7 +2,7 @@ # task file for sqlite3 - name: "Sqlite3 | Default Database Path" - set_fact: + ansible.builtin.set_fact: zabbix_proxy_dbname: /var/lib/zabbix/zabbix_proxy.db when: - zabbix_proxy_dbname == "zabbix_proxy" @@ -10,7 +10,7 @@ - database - name: "Sqlite3 | Create database" - file: + ansible.builtin.file: name: "{{ zabbix_proxy_dbname | dirname }}" mode: 0744 owner: "{{ zabbix_os_user }}" @@ -26,7 +26,7 @@ - database - name: "Sqlite3 | Handle Compressed Schema File" - set_fact: + ansible.builtin.set_fact: zabbix_proxy_cat_cmd: zcat when: "'.gz' in ls_output_schema.stdout" tags: @@ -35,7 +35,7 @@ - name: "Sqlite3 | Importing schema file" become: true become_user: "{{ zabbix_os_user }}" - shell: | + ansible.builtin.shell: | set -euxo pipefail {{ zabbix_proxy_cat_cmd }} {{ ls_output_schema.stdout }} | sqlite3 {{ zabbix_proxy_dbname }} args: @@ -49,7 +49,7 @@ - database - name: "Sqlite3 | Fix zabbix db file permission (SELinux)" - file: + ansible.builtin.file: path: "{{ zabbix_proxy_dbname }}" state: file seuser: system_u diff --git a/roles/zabbix_server/handlers/main.yml b/roles/zabbix_server/handlers/main.yml index 8bf6ee1c4..b0e272e2d 100644 --- a/roles/zabbix_server/handlers/main.yml +++ b/roles/zabbix_server/handlers/main.yml @@ -2,7 +2,7 @@ # handlers file for wdijkerman.zabbix - name: zabbix-server restarted - service: + ansible.builtin.service: name: zabbix-server state: restarted enabled: true @@ -12,7 +12,7 @@ - zabbix_server_manage_service | bool - name: "clean repo files from proxy creds" - shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + ansible.builtin.shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true become: true when: - ansible_os_family == 'RedHat' diff --git a/roles/zabbix_server/tasks/Debian.yml b/roles/zabbix_server/tasks/Debian.yml index 8da8a46e1..cb56f4b05 100644 --- a/roles/zabbix_server/tasks/Debian.yml +++ b/roles/zabbix_server/tasks/Debian.yml @@ -1,6 +1,6 @@ --- - name: "Debian | Set some variables" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_server_version | regex_replace('\\.', '') }}" zabbix_server_apt_repository: - "http://repo.zabbix.com/zabbix/{{ zabbix_server_version }}/{{ ansible_distribution.lower() }}/" @@ -14,7 +14,7 @@ - always - name: "Debian | Set some variables" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_server_version | regex_replace('\\.', '') }}" zabbix_server_apt_repository: - "http://repo.zabbix.com/zabbix/{{ zabbix_server_version }}/{{ ansible_distribution.lower() }}-arm64/" @@ -28,13 +28,13 @@ - always - name: "Debian | Set some facts for Zabbix" - set_fact: + ansible.builtin.set_fact: datafiles_path: /usr/share/zabbix-sql-scripts/{{ 'postgresql' if zabbix_server_database == 'pgsql' else 'mysql' }} tags: - always - name: "Debian | Installing gnupg" - apt: + ansible.builtin.apt: pkg: gnupg update_cache: true cache_valid_time: 3600 @@ -75,7 +75,7 @@ - install - name: "Debian | Installing repository {{ ansible_distribution }}" - apt_repository: + ansible.builtin.apt_repository: repo: "{{ item }} [signed-by={{ zabbix_gpg_key }}] {{ zabbix_server_apt_repository | join(' ') }}" state: present become: true @@ -86,7 +86,7 @@ - install - name: "Debian | Create /etc/apt/preferences.d/" - file: + ansible.builtin.file: path: /etc/apt/preferences.d/ state: directory mode: "0755" @@ -97,7 +97,7 @@ - install - name: "Debian | Configuring the weight for APT" - copy: + ansible.builtin.copy: dest: "/etc/apt/preferences.d/zabbix_server-{{ zabbix_proxy_database }}" content: | Package: zabbix_server-{{ zabbix_proxy_database }} @@ -112,7 +112,7 @@ - install - name: "Debian | apt-get clean" - shell: apt-get clean; apt-get update + ansible.builtin.shell: apt-get clean; apt-get update args: warn: "{{ produce_warn | default(omit) }}" changed_when: false @@ -126,7 +126,7 @@ # 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" - command: grep -F 'path-exclude=/usr/share/doc/*' /etc/dpkg/dpkg.cfg.d/excludes + 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 @@ -136,7 +136,7 @@ - install - name: "Debian | Allow Zabbix dpkg installs to /usr/share/doc/zabbix*" - lineinfile: + ansible.builtin.lineinfile: path: /etc/dpkg/dpkg.cfg.d/excludes line: "path-include=/usr/share/doc/zabbix*" become: true @@ -146,7 +146,7 @@ - install - name: "Debian | Installing zabbix-server-{{ zabbix_server_database }}" - apt: + ansible.builtin.apt: pkg: zabbix-server-{{ zabbix_server_database }} state: "{{ zabbix_server_package_state }}" update_cache: true @@ -163,7 +163,7 @@ - install - name: "Debian | Installing zabbix-sql-scripts" - apt: + ansible.builtin.apt: pkg: zabbix-sql-scripts state: "{{ zabbix_server_package_state }}" update_cache: true @@ -184,7 +184,7 @@ - name: "Debian | Install Database Client Package" block: - name: "Debian | Install Mysql Client package" - apt: + ansible.builtin.apt: name: - default-mysql-client - "{{ zabbix_python_prefix }}-mysqldb" @@ -200,7 +200,7 @@ - ansible_distribution_release != "buster" - name: "Debian 10 | Install Mysql Client package" - apt: + ansible.builtin.apt: name: - mariadb-client - "{{ zabbix_python_prefix }}-mysqldb" @@ -216,7 +216,7 @@ - ansible_distribution_release == "buster" - name: "Debian | Install PostgreSQL Client package" - apt: + ansible.builtin.apt: name: - postgresql-client - "{{ zabbix_python_prefix }}-psycopg2" diff --git a/roles/zabbix_server/tasks/RedHat.yml b/roles/zabbix_server/tasks/RedHat.yml index abdc66049..fefd7e86c 100644 --- a/roles/zabbix_server/tasks/RedHat.yml +++ b/roles/zabbix_server/tasks/RedHat.yml @@ -2,25 +2,25 @@ # Tasks specific for RedHat systems - name: "RedHat | Set short version name" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_server_version | regex_replace('\\.', '') }}" tags: - always - name: "RedHat | Use Zabbix package name" - set_fact: + ansible.builtin.set_fact: zabbix_server_package: "zabbix-server-{{ zabbix_server_database }}" tags: - always - name: "RedHat | Set facts for Zabbix" - set_fact: + 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" - file: + ansible.builtin.file: path: /etc/yum.repos.d/zabbix-supported.repo state: absent become: true @@ -28,7 +28,7 @@ - install - name: "RedHat | Install basic repo file" - yum_repository: + ansible.builtin.yum_repository: name: "{{ item.name }}" description: "{{ item.description }}" baseurl: "{{ item.baseurl }}" @@ -47,7 +47,7 @@ - install - name: "RedHat | Installing zabbix-server-{{ zabbix_server_database }}" - package: + 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) }}" @@ -61,7 +61,7 @@ - install - name: "RedHat | Installing zabbix-sql-scripts" - package: + 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) }}" @@ -77,7 +77,7 @@ - install - name: "RedHat | Install Ansible module dependencies" - yum: + ansible.builtin.yum: name: "{{ pgsql_depenencies[ansible_distribution_major_version] }}" state: present environment: @@ -96,7 +96,7 @@ - name: RedHat | Install Database Client Package block: - name: "RedHat | Install Mysql Client packages" - yum: + ansible.builtin.yum: name: "{{ mysql_client_pkgs[ansible_distribution_major_version] }}" state: present environment: @@ -109,7 +109,7 @@ - zabbix_server_database == 'mysql' - name: "RedHat | Install PostgreSQL client package" - yum: + ansible.builtin.yum: name: postgresql state: present environment: @@ -127,6 +127,6 @@ - database - name: "RedHat | Configure SELinux when enabled" - include_tasks: selinux.yml + ansible.builtin.include_tasks: selinux.yml when: - zabbix_server_selinux | bool diff --git a/roles/zabbix_server/tasks/main.yml b/roles/zabbix_server/tasks/main.yml index c6a010543..ac520aa50 100644 --- a/roles/zabbix_server/tasks/main.yml +++ b/roles/zabbix_server/tasks/main.yml @@ -1,38 +1,38 @@ --- - name: Include OS-specific variables - include_vars: "{{ ansible_os_family }}.yml" + ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" tags: - always - name: Determine Latest Supported Zabbix Version - set_fact: + ansible.builtin.set_fact: zabbix_server_version: "{{ zabbix_valid_server_versions[ansible_distribution_major_version][0] | default(6.4) }}" when: zabbix_server_version is not defined tags: - always - name: Set More Variables - set_fact: + 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] }}" tags: - always - name: Stopping Install of Invalid Version - fail: + ansible.builtin.fail: msg: Zabbix version {{ zabbix_server_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} when: not zabbix_valid_version tags: - always - name: Install the correct repository - include_tasks: "{{ ansible_os_family }}.yml" + ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" - name: Installing the {{ zabbix_db_type_long }} database - include_tasks: "{{ zabbix_db_type_long }}.yml" + ansible.builtin.include_tasks: "{{ zabbix_db_type_long }}.yml" - name: "Configure zabbix-server" - template: + ansible.builtin.template: src: zabbix_server.conf.j2 dest: "{{ zabbix_server_config }}" owner: "{{ zabbix_os_user }}" @@ -45,7 +45,7 @@ - config - name: "Create include dir zabbix-server" - file: + ansible.builtin.file: path: "{{ zabbix_server_include }}" owner: "{{ zabbix_os_user }}" group: "{{ zabbix_os_user }}" @@ -57,12 +57,12 @@ - config - name: "Add zabbix-server scripts" - include_tasks: "scripts.yml" + ansible.builtin.include_tasks: "scripts.yml" when: ( zabbix_server_alertscripts is defined ) or ( zabbix_server_externalscripts is defined ) - name: "Zabbix-server started" - service: + ansible.builtin.service: name: zabbix-server state: "{{ zabbix_service_state }}" enabled: "{{ zabbix_service_enabled }}" diff --git a/roles/zabbix_server/tasks/mysql.yml b/roles/zabbix_server/tasks/mysql.yml index 1c20d86cb..aad009816 100644 --- a/roles/zabbix_server/tasks/mysql.yml +++ b/roles/zabbix_server/tasks/mysql.yml @@ -2,7 +2,7 @@ # task file for mysql - name: "MySQL | Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ zabbix_server_dbhost if (zabbix_server_dbhost != 'localhost') else inventory_hostname }}" when: - zabbix_server_dbhost_run_install @@ -10,7 +10,7 @@ - database - name: "MySQL | Set the correct delegated_dbhost (to support MySQL db deployment on a remote dbhost)" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ inventory_hostname }}" when: - not zabbix_server_dbhost_run_install @@ -18,7 +18,7 @@ - database - name: "MySQL | Override delegated_dbhost with real dbhost when dbhost is behind loadbalancer" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ zabbix_server_real_dbhost }}" when: zabbix_server_real_dbhost | default(false) tags: @@ -61,7 +61,7 @@ - database - name: "MySQL | Get the file for create.sql" - shell: ls -1 {{ datafiles_path }}/{{ 'create' if zabbix_server_version is version('6.0', '<') else 'server' }}.sq* + 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: @@ -71,7 +71,7 @@ - database - name: MySQL | Get current database version - shell: | + 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;' @@ -86,7 +86,7 @@ # 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 - set_fact: + ansible.builtin.set_fact: mysql_schema_empty: "{{ mysql_db_version is failed }}" - name: "MySQL | Get current value for innodb_default_row_format" @@ -150,7 +150,7 @@ - database - name: "MySQL | Copy sql create file" - copy: + ansible.builtin.copy: src: /tmp/{{ role_name }}/ dest: "{{ ls_output_create.stdout | dirname }}" mode: "0640" @@ -201,7 +201,7 @@ - database - name: "MySQL | Check if we have sql_done files" - file: + ansible.builtin.file: path: /etc/zabbix/create.done state: touch mode: "0644" diff --git a/roles/zabbix_server/tasks/postgresql.yml b/roles/zabbix_server/tasks/postgresql.yml index 2db11970d..947a73462 100644 --- a/roles/zabbix_server/tasks/postgresql.yml +++ b/roles/zabbix_server/tasks/postgresql.yml @@ -2,7 +2,7 @@ # task file for postgresql - name: "PostgreSQL | Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ zabbix_server_dbhost if (zabbix_server_dbhost != 'localhost') else inventory_hostname }}" when: - zabbix_server_dbhost_run_install @@ -10,7 +10,7 @@ - database - name: "PostgreSQL | Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)" - set_fact: + ansible.builtin.set_fact: delegated_dbhost: "{{ inventory_hostname }}" when: - not zabbix_server_dbhost_run_install @@ -24,6 +24,7 @@ name: "{{ zabbix_server_dbname }}" port: "{{ zabbix_server_dbport }}" state: present + - name: "PostgreSQL | Delegated | Create database user" community.postgresql.postgresql_user: db: "{{ zabbix_server_dbname }}" @@ -33,6 +34,7 @@ priv: ALL state: present encrypted: true + - name: "PostgreSQL | Delegated | Create timescaledb extension" community.postgresql.postgresql_ext: db: "{{ zabbix_server_dbname }}" @@ -58,6 +60,7 @@ name: "{{ zabbix_server_dbname }}" port: "{{ zabbix_server_dbport }}" state: present + - name: "PostgreSQL | Remote | Create database user" community.postgresql.postgresql_user: login_host: "{{ zabbix_server_pgsql_login_host | default(omit) }}" @@ -70,6 +73,7 @@ priv: ALL state: present encrypted: true + - name: "PostgreSQL | Remote | Create timescaledb extension" community.postgresql.postgresql_ext: login_host: "{{ zabbix_server_pgsql_login_host | default(omit) }}" @@ -86,7 +90,7 @@ - database - name: "PostgreSQL | Create schema" - shell: | + ansible.builtin.shell: | set -euxo pipefail FILE={{ 'create.sql' if zabbix_server_version is version('6.0', '<') else 'server.sql' }} cd {{ datafiles_path }} @@ -114,7 +118,7 @@ - database - name: "PostgreSQL | Create TimescaleDB hypertables" - shell: | + ansible.builtin.shell: | set -euxo pipefail cd {{ datafiles_path }} && if [ -f timescaledb.sql.gz ]; then zcat timescaledb.sql.gz > /etc/timescaledb.sql ; else cp -p timescaledb.sql /etc/timescaledb.sql ; fi diff --git a/roles/zabbix_server/tasks/scripts.yml b/roles/zabbix_server/tasks/scripts.yml index e7ed65194..b253f325a 100644 --- a/roles/zabbix_server/tasks/scripts.yml +++ b/roles/zabbix_server/tasks/scripts.yml @@ -1,6 +1,6 @@ --- - name: "Configure zabbix-server alertscripts" - template: + ansible.builtin.template: src: "{{ item.path }}" dest: "{{ zabbix_server_alertscriptspath }}/{{ item.name }}" owner: "{{ zabbix_os_user }}" @@ -13,7 +13,7 @@ - config - name: "Configure zabbix-server externalscripts" - template: + ansible.builtin.template: src: "{{ item.path }}" dest: "{{ zabbix_server_externalscriptspath }}/{{ item.name }}" owner: "{{ zabbix_os_user }}" diff --git a/roles/zabbix_server/tasks/selinux.yml b/roles/zabbix_server/tasks/selinux.yml index d532adba9..fe203aed1 100644 --- a/roles/zabbix_server/tasks/selinux.yml +++ b/roles/zabbix_server/tasks/selinux.yml @@ -1,7 +1,7 @@ --- # straight to getenforce binary , workaround for missing python_selinux library - name: "SELinux | Get getenforce binary" - stat: + ansible.builtin.stat: path: /usr/sbin/getenforce register: getenforce_bin become: true @@ -9,7 +9,7 @@ - always - name: "SELinux | Collect getenforce output" - command: getenforce + ansible.builtin.command: getenforce register: sestatus when: "getenforce_bin.stat.exists" changed_when: false @@ -19,14 +19,14 @@ - always - name: "Set zabbix_server_selinux to true if getenforce returns Enforcing or Permissive" - set_fact: + ansible.builtin.set_fact: zabbix_server_selinux: "{{ true }}" when: 'getenforce_bin.stat.exists and ("Enforcing" in sestatus.stdout or "Permissive" in sestatus.stdout)' tags: - config - name: "SELinux | RedHat | Install related SELinux package" - yum: + ansible.builtin.yum: name: - libsemanage-python - policycoreutils @@ -46,7 +46,7 @@ - install - name: "SELinux | RedHat | Install related SELinux package on RHEL8" - yum: + ansible.builtin.yum: name: - python3-libsemanage state: present @@ -86,7 +86,7 @@ - config - name: "SELinux | RedHat | Install related SELinux package to fix issues" - yum: + ansible.builtin.yum: name: - policycoreutils-python state: present @@ -103,7 +103,7 @@ - install - name: "SELinux | RedHat | Install related SELinux package to fix issues on RHEL8" - yum: + ansible.builtin.yum: name: - policycoreutils - checkpolicy @@ -122,7 +122,7 @@ - install - name: "SELinux | RedHat | Add SEmodule to fix SELinux issue: zabbix_server_alerter.sock" - script: + ansible.builtin.script: cmd: files/install_semodule.bsx args: creates: /etc/selinux/targeted/active/modules/400/zabbix_server_add/cil diff --git a/roles/zabbix_web/handlers/main.yml b/roles/zabbix_web/handlers/main.yml index fa6f8b11f..e97787b12 100644 --- a/roles/zabbix_web/handlers/main.yml +++ b/roles/zabbix_web/handlers/main.yml @@ -1,6 +1,6 @@ --- - name: restart apache - service: + ansible.builtin.service: name: "{{ _apache_service }}" state: restarted enabled: true @@ -10,7 +10,7 @@ - name: test nginx config listen: restart nginx - command: nginx -t + ansible.builtin.command: nginx -t register: zabbix_nginx_cfg_check notify: restart nginx tested become: true @@ -18,7 +18,7 @@ - zabbix_web_http_server == 'nginx' - name: restart nginx tested - service: + ansible.builtin.service: name: nginx state: restarted enabled: true @@ -28,7 +28,7 @@ - zabbix_nginx_cfg_check.rc == 0 - name: restart php-fpm-version - service: + ansible.builtin.service: name: php{{ zabbix_web_php_installed_version }}-fpm state: restarted enabled: true @@ -37,7 +37,7 @@ - zabbix_web_version is version('5.0', '>=') - name: "clean repo files from proxy creds" - shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true + ansible.builtin.shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true become: true when: - ansible_os_family == 'RedHat' diff --git a/roles/zabbix_web/tasks/Debian.yml b/roles/zabbix_web/tasks/Debian.yml index f0ae3d31c..00f5341f4 100644 --- a/roles/zabbix_web/tasks/Debian.yml +++ b/roles/zabbix_web/tasks/Debian.yml @@ -1,12 +1,12 @@ --- - name: "Debian | Set PHP Dependencies" - set_fact: + ansible.builtin.set_fact: zabbix_web_php_dependencies: "{{ _apache_php_dependencies if zabbix_web_http_server == 'apache' else _nginx_php_dependencies }}" tags: - config - name: "Debian | Set some variables" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_web_version | regex_replace('\\.', '') }}" zabbix_web_apt_repository: - "http://repo.zabbix.com/zabbix/{{ zabbix_web_version }}/{{ ansible_distribution.lower() }}/" @@ -20,7 +20,7 @@ - always - name: "Debian | Set some variables" - set_fact: + ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_web_version | regex_replace('\\.', '') }}" zabbix_web_apt_repository: - "http://repo.zabbix.com/zabbix/{{ zabbix_web_version }}/{{ ansible_distribution.lower() }}-arm64/" @@ -34,7 +34,7 @@ - always - name: "Debian | Install PHP Dependencies" - apt: + ansible.builtin.apt: pkg: "{{ zabbix_web_php_dependencies }}" state: "present" update_cache: true @@ -50,7 +50,7 @@ - dependencies - name: "Debian | Install PgSQL Dependencies" - apt: + ansible.builtin.apt: pkg: "php{{ zabbix_web_php_installed_version }}-pgsql" state: "present" update_cache: true @@ -91,7 +91,7 @@ - install - name: "Debian | Installing repository {{ ansible_distribution }}" - apt_repository: + ansible.builtin.apt_repository: repo: "{{ item }} [signed-by={{ zabbix_gpg_key }}] {{ zabbix_web_apt_repository | join(' ') }}" state: present become: true @@ -102,7 +102,7 @@ - install - name: "Debian | Create /etc/apt/preferences.d/" - file: + ansible.builtin.file: path: /etc/apt/preferences.d/ state: directory mode: "0755" @@ -113,7 +113,7 @@ - install - name: "Debian | Configuring the weight for APT" - copy: + ansible.builtin.copy: dest: "/etc/apt/preferences.d/zabbix_server-{{ zabbix_proxy_database }}" content: | Package: zabbix_server-{{ zabbix_proxy_database }} @@ -128,7 +128,7 @@ - install - name: "Debian | apt-get clean" - shell: apt-get clean; apt-get update + ansible.builtin.shell: apt-get clean; apt-get update args: warn: "{{ produce_warn | default(omit) }}" changed_when: false @@ -138,7 +138,7 @@ - install - name: "Debian | Install zabbix-web" - apt: + ansible.builtin.apt: pkg: "zabbix-frontend-php" state: "{{ zabbix_web_package_state }}" update_cache: true @@ -153,7 +153,7 @@ - install - name: "Debian | Link graphfont.ttf (workaround ZBX-10467)" - file: + ansible.builtin.file: src: "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" path: "/usr/share/zabbix/fonts/graphfont.ttf" state: link diff --git a/roles/zabbix_web/tasks/RedHat.yml b/roles/zabbix_web/tasks/RedHat.yml index 2afb63548..30871017e 100644 --- a/roles/zabbix_web/tasks/RedHat.yml +++ b/roles/zabbix_web/tasks/RedHat.yml @@ -1,11 +1,11 @@ - name: "RedHat | Setting Short PHP Version" - set_fact: + ansible.builtin.set_fact: zabbix_web_php_installed_version: "{{ zabbix_web_php_installed_version | regex_replace('\\.', '') }}" tags: - always - name: "RedHat | Install basic repo file" - yum_repository: + ansible.builtin.yum_repository: name: "{{ item.name }}" description: "{{ item.description | default(omit) }}" baseurl: "{{ item.baseurl }}" @@ -24,7 +24,7 @@ - install - name: "RedHat | Install zabbix-web-{{ zabbix_server_database }}" - yum: + ansible.builtin.yum: name: - "zabbix-web-{{ zabbix_server_database }}" state: "{{ zabbix_web_package_state }}" @@ -40,7 +40,7 @@ - install - name: "RedHat | Install zabbix-web-configuration" - yum: + ansible.builtin.yum: name: - "zabbix-{{ zabbix_web_http_server }}-conf" state: "{{ zabbix_web_package_state }}" diff --git a/roles/zabbix_web/tasks/apache.yml b/roles/zabbix_web/tasks/apache.yml index e76686c1f..7e55fe3e9 100644 --- a/roles/zabbix_web/tasks/apache.yml +++ b/roles/zabbix_web/tasks/apache.yml @@ -1,6 +1,6 @@ --- - name: Setting Web Server Facts - set_fact: + ansible.builtin.set_fact: zabbix_web_user: "{{ zabbix_web_user if zabbix_web_user is defined else _apache_user }}" zabbix_web_group: "{{ zabbix_web_group if zabbix_web_group is defined else _apache_group }}" zabbix_web_vhost_location: "{{ zabbix_web_vhost_location if zabbix_web_vhost_location is defined else _apache_vhost_location }}" @@ -10,7 +10,7 @@ - name: "Apache | Installing Zabbix Apache Conf" block: - name: "Debian | Install zabbix-apache-conf" - apt: + ansible.builtin.apt: pkg: "zabbix-apache-conf" state: "{{ zabbix_web_package_state }}" update_cache: true @@ -24,7 +24,7 @@ when: ansible_os_family == "Debian" - name: "RedHat | Install zabbix-apache-conf" - yum: + ansible.builtin.yum: name: - "zabbix-apache-conf-{{ zabbix_web_version }}.{{ zabbix_web_version_minor }}" state: "{{ zabbix_web_package_state }}" @@ -41,7 +41,7 @@ - install - name: "Apache | Get Apache version" - shell: | + ansible.builtin.shell: | PATH=/usr/sbin:$PATH set -o pipefail apachectl -v | grep 'version' | awk -F '/' '{ print $2 }'| awk '{ print $1 }' | cut -c 1-3 @@ -54,13 +54,13 @@ - config - name: "Apache | Set correct apache_version" - set_fact: + ansible.builtin.set_fact: apache_version: "{{ apachectl_version.stdout }}" tags: - config - name: "Apache | Install apache vhost" - template: + ansible.builtin.template: src: apache_vhost.conf.j2 dest: "{{ zabbix_web_vhost_location }}" owner: "{{ zabbix_web_user }}" @@ -74,7 +74,7 @@ - config - name: "Apache | Enable Site (Debian Only)" - file: + ansible.builtin.file: src: "{{ zabbix_web_vhost_location }}" dest: /etc/apache2/sites-enabled/zabbix.conf state: link diff --git a/roles/zabbix_web/tasks/main.yml b/roles/zabbix_web/tasks/main.yml index 7971605a5..ac1213f64 100644 --- a/roles/zabbix_web/tasks/main.yml +++ b/roles/zabbix_web/tasks/main.yml @@ -1,32 +1,32 @@ --- - name: "Include OS-specific variables" - include_vars: "{{ ansible_os_family }}.yml" + ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" tags: - always - name: Determine Latest Supported Zabbix Version - set_fact: + ansible.builtin.set_fact: zabbix_web_version: "{{ zabbix_valid_web_versions[ansible_distribution_major_version][0] | default(6.4) }}" when: zabbix_web_version is not defined tags: - always - name: Set More Variables - set_fact: + 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 - fail: + ansible.builtin.fail: msg: Zabbix version {{ zabbix_web_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }} when: not zabbix_valid_version tags: - always - name: Determine PHP Version - shell: php --version | head -1 | awk '{ print $2 }' | awk -F '.' '{print $1"."$2}' + ansible.builtin.shell: php --version | head -1 | awk '{ print $2 }' | awk -F '.' '{print $1"."$2}' register: _zabbix_web_php_installed_version changed_when: false tags: @@ -34,14 +34,14 @@ - install - name: Set PHP Version - set_fact: + ansible.builtin.set_fact: zabbix_web_php_installed_version: "{{ _zabbix_web_php_installed_version.stdout }}" tags: - config - install - name: Set PHP Variables - set_fact: + ansible.builtin.set_fact: zabbix_php_fpm_listen: "{{ zabbix_php_fpm_listen if zabbix_php_fpm_listen is defined else _zabbix_php_fpm_listen }}" zabbix_php_fpm_dir: "{{ zabbix_php_fpm_dir if zabbix_php_fpm_dir is defined else _php_fpm_dir }}" zabbix_php_fpm_session: "{{ zabbix_php_fpm_session if zabbix_php_fpm_session is defined else _php_fpm_session }}" @@ -50,13 +50,13 @@ - install - name: Include OS Specific Tasks - include_tasks: "{{ ansible_os_family }}.yml" + ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" - name: "Install the web server specific tasks" - include_tasks: "{{ zabbix_web_http_server }}.yml" + ansible.builtin.include_tasks: "{{ zabbix_web_http_server }}.yml" - name: "Create zabbix-web directory" - file: + ansible.builtin.file: path: /etc/zabbix/web owner: "{{ zabbix_web_user }}" group: "{{ zabbix_web_group }}" @@ -68,7 +68,7 @@ - config - name: "Configure zabbix-web" - template: + ansible.builtin.template: src: zabbix.conf.php.j2 dest: /etc/zabbix/web/zabbix.conf.php owner: "{{ zabbix_web_user }}" @@ -81,7 +81,7 @@ - config - name: "Debian | Install PHP" - template: + ansible.builtin.template: src: php-fpm.conf.j2 dest: "{{ zabbix_php_fpm_dir }}/zabbix.conf" owner: "{{ zabbix_web_user }}" diff --git a/roles/zabbix_web/tasks/nginx.yml b/roles/zabbix_web/tasks/nginx.yml index fb609d2c7..1f50263ca 100644 --- a/roles/zabbix_web/tasks/nginx.yml +++ b/roles/zabbix_web/tasks/nginx.yml @@ -1,6 +1,6 @@ --- - name: "Nginx | Set websrv specific variables" - set_fact: + ansible.builtin.set_fact: zabbix_web_user: "{{ zabbix_web_user if zabbix_web_user is defined else _nginx_user }}" zabbix_web_group: "{{ zabbix_web_group if zabbix_web_group is defined else _nginx_group }}" zabbix_web_vhost_location: "{{ zabbix_web_vhost_location if zabbix_web_vhost_location is defined else _nginx_vhost_location }}" @@ -13,7 +13,7 @@ - name: "Nginx | Installing Zabbix Nginx Conf" block: - name: "Debian | Install zabbix-nginx-conf" - apt: + ansible.builtin.apt: pkg: "zabbix-nginx-conf" state: "{{ zabbix_web_package_state }}" update_cache: true @@ -27,7 +27,7 @@ when: ansible_os_family == "Debian" - name: "RedHat | Install zabbix-nginx-conf" - yum: + ansible.builtin.yum: name: - "zabbix-nginx-conf" state: "{{ zabbix_web_package_state }}" @@ -44,7 +44,7 @@ - install - name: "Nginx | Install vhost in conf.d" - template: + ansible.builtin.template: src: nginx_vhost.conf.j2 dest: "{{ zabbix_web_vhost_location }}" owner: "{{ zabbix_web_user }}" diff --git a/roles/zabbix_web/tasks/selinux.yml b/roles/zabbix_web/tasks/selinux.yml index 49cc027ab..56e2ae05e 100644 --- a/roles/zabbix_web/tasks/selinux.yml +++ b/roles/zabbix_web/tasks/selinux.yml @@ -1,6 +1,6 @@ --- - name: "SELinux | RedHat | Install related SELinux package" - yum: + ansible.builtin.yum: name: - libsemanage-python state: present @@ -18,7 +18,7 @@ - install - name: "SELinux | RedHat | Install related SELinux package on RHEL9 and RHEL8" - yum: + ansible.builtin.yum: name: - python3-libsemanage state: present diff --git a/tests/integration/targets/setup_zabbix/tasks/main.yml b/tests/integration/targets/setup_zabbix/tasks/main.yml index ba4c30311..fd7f6a700 100644 --- a/tests/integration/targets/setup_zabbix/tasks/main.yml +++ b/tests/integration/targets/setup_zabbix/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: get zabbix version - uri: + ansible.builtin.uri: url: "{{ zabbix_api_server_url }}/api_jsonrpc.php" method: POST body: @@ -16,7 +16,7 @@ register: zabbix_version_result - name: set zabbix_version variable - set_fact: + ansible.builtin.set_fact: zabbix_version: >- {{ [0,1] | map('extract', zabbix_version_result.json.result.split('.')) @@ -27,7 +27,7 @@ ansible_connection: httpapi # ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 ansible_host: 127.0.0.1 - ansible_zabbix_url_path: '' + ansible_zabbix_url_path: "" ansible_httpapi_port: 8080 ansible_httpapi_use_ssl: false ansible_httpapi_validate_certs: false @@ -36,7 +36,7 @@ - debug: var=zabbix_version - name: check login to zabbix for Zabbix < 6.4 - uri: + ansible.builtin.uri: url: "{{ zabbix_api_server_url }}/api_jsonrpc.php" method: POST body: @@ -55,7 +55,7 @@ when: zabbix_version is version('6.4', '<') - name: check login to zabbix for Zabbix >= 6.4 - uri: + ansible.builtin.uri: url: "{{ zabbix_api_server_url }}/api_jsonrpc.php" method: POST body: diff --git a/tests/integration/targets/test_zabbix_action/tasks/main.yml b/tests/integration/targets/test_zabbix_action/tasks/main.yml index 95fb3e14d..446f7cd3b 100644 --- a/tests/integration/targets/test_zabbix_action/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_action/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - prepare example template for zabbix_action module - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleTemplateForActionModule template_groups: - Templates @@ -8,7 +8,7 @@ register: zbxaction_prep_template - name: test - prepare example mediatype for zabbix_action module - zabbix_mediatype: + community.zabbix.zabbix_mediatype: name: ExampleMediaTypeForActionModule smtp_email: zabbix@example.com type: email @@ -38,122 +38,122 @@ block: - name: test - create new action - zabbix_action: + community.zabbix.zabbix_action: register: zbxaction_new - - assert: + - ansible.builtin.assert: that: zbxaction_new.changed is sameas True - name: test - create new action (again) - zabbix_action: + community.zabbix.zabbix_action: register: zbxaction_new - - assert: + - ansible.builtin.assert: that: zbxaction_new.changed is sameas False - name: test - update action with esc_period as string - zabbix_action: + community.zabbix.zabbix_action: esc_period: 2m register: zbxaction_escperiod_str - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod_str.changed is sameas True - name: test - update action with esc_period as string (again) - zabbix_action: + community.zabbix.zabbix_action: esc_period: 2m register: zbxaction_escperiod_str - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod_str.changed is sameas False - name: test - update action with esc_period as macro - zabbix_action: + community.zabbix.zabbix_action: esc_period: "{$MYMACRO}" register: zbxaction_escperiod_macro - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod_macro.changed is sameas True - name: test - update action with esc_period as macro (again) - zabbix_action: + community.zabbix.zabbix_action: esc_period: "{$MYMACRO}" register: zbxaction_escperiod_macro - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod_macro.changed is sameas False - name: test - update action with esc_period - zabbix_action: + community.zabbix.zabbix_action: esc_period: 120 register: zbxaction_escperiod - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod.changed is sameas True - name: test - update action with esc_period (again) - zabbix_action: + community.zabbix.zabbix_action: esc_period: 120 register: zbxaction_escperiod - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod.changed is sameas False - name: test - update action with pause_in_maintenance - zabbix_action: + community.zabbix.zabbix_action: esc_period: 120 pause_in_maintenance: false register: zbxaction_maintpause - - assert: + - ansible.builtin.assert: that: zbxaction_maintpause.changed is sameas True - name: test - update action with pause_in_maintenance (again) - zabbix_action: + community.zabbix.zabbix_action: esc_period: 120 pause_in_maintenance: false register: zbxaction_maintpause - - assert: + - ansible.builtin.assert: that: zbxaction_maintpause.changed is sameas False - name: test - reset action to default - zabbix_action: + community.zabbix.zabbix_action: register: zbxaction_reset - - assert: + - ansible.builtin.assert: that: zbxaction_reset.changed is sameas True - name: test - disable action - zabbix_action: + community.zabbix.zabbix_action: status: disabled register: zbxaction_disable - - assert: + - ansible.builtin.assert: that: zbxaction_disable.changed is sameas True - name: test - disable action (again) - zabbix_action: + community.zabbix.zabbix_action: status: disabled register: zbxaction_disable - - assert: + - ansible.builtin.assert: that: zbxaction_disable.changed is sameas False - name: test - delete action - zabbix_action: + community.zabbix.zabbix_action: state: absent register: zbxaction_delete - - assert: + - ansible.builtin.assert: that: zbxaction_delete.changed is sameas True - name: test - delete action (again) - zabbix_action: + community.zabbix.zabbix_action: state: absent register: zbxaction_delete - - assert: + - ansible.builtin.assert: that: zbxaction_delete.changed is sameas False - name: test - trigger actions with conditions @@ -175,7 +175,7 @@ block: - name: test - create new action with multiple conditions - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "=" @@ -192,11 +192,11 @@ value: 6-7,00:00-24:00 register: zbxaction_conditions - - assert: + - ansible.builtin.assert: that: zbxaction_conditions.changed is sameas True - name: test - create new action with multiple conditions (again) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "=" @@ -213,11 +213,11 @@ value: 6-7,00:00-24:00 register: zbxaction_conditions - - assert: + - ansible.builtin.assert: that: zbxaction_conditions.changed is sameas False - name: test - create new action with multiple conditions (reorder) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "=" @@ -234,11 +234,11 @@ value: 6-7,00:00-24:00 register: zbxaction_conditions_reorder - - assert: + - ansible.builtin.assert: that: zbxaction_conditions_reorder.changed is sameas False - name: test - update action with multiple conditions by removing one condition - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "=" @@ -252,11 +252,11 @@ value: Average register: zbxaction_conditions_delone - - assert: + - ansible.builtin.assert: that: zbxaction_conditions_delone.changed is sameas True - name: test - update action with multiple conditions by changing operators - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "<>" @@ -270,11 +270,11 @@ value: Average register: zbxaction_conditions_operators - - assert: + - ansible.builtin.assert: that: zbxaction_conditions_operators.changed is sameas True - name: test - update action with multiple conditions with operator aliases - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: does not equal @@ -288,11 +288,11 @@ value: Average register: zbxaction_conditions_operator_aliases - - assert: + - ansible.builtin.assert: that: zbxaction_conditions_operator_aliases.changed is sameas True - name: test - update action with multiple conditions and evaltype - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "<>" @@ -307,11 +307,11 @@ eval_type: and register: zbxaction_conditions_eval - - assert: + - ansible.builtin.assert: that: zbxaction_conditions_eval.changed is sameas True - name: test - update action with multiple conditions and evaltype (again) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "<>" @@ -326,11 +326,11 @@ eval_type: and register: zbxaction_conditions_eval - - assert: + - ansible.builtin.assert: that: zbxaction_conditions_eval.changed is sameas False - name: test - update action with reduced conditions and formula - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "=" @@ -348,11 +348,11 @@ formula: A and (B or C) register: zbxaction_conditions_formula - - assert: + - ansible.builtin.assert: that: zbxaction_conditions_formula.changed is sameas True - name: test - update formula used in action with reduced conditions - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "=" @@ -370,11 +370,11 @@ formula: (A or B) or C register: zbxaction_conditions_formula - - assert: + - ansible.builtin.assert: that: zbxaction_conditions_formula.changed is sameas True - name: test - update formula used in action with reduced conditions (again) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_group operator: "=" @@ -392,15 +392,15 @@ formula: (A or B) or C register: zbxaction_conditions_formula - - assert: + - ansible.builtin.assert: that: zbxaction_conditions_formula.changed is sameas False - name: test - delete action - zabbix_action: + community.zabbix.zabbix_action: state: absent register: zbxaction_delete - - assert: + - ansible.builtin.assert: that: zbxaction_delete.changed is sameas True - name: test - trigger actions with message operations @@ -419,7 +419,7 @@ block: - name: test - create new action with send_message operations - zabbix_action: + community.zabbix.zabbix_action: operations: - type: send_message send_to_users: @@ -442,11 +442,11 @@ esc_period: 300 register: zbxaction_ops - - assert: + - ansible.builtin.assert: that: zbxaction_ops.changed is sameas True - name: test - create new action with send_message operations (again) - zabbix_action: + community.zabbix.zabbix_action: operations: - type: send_message send_to_users: @@ -469,19 +469,19 @@ esc_period: 300 register: zbxaction_ops - - assert: + - ansible.builtin.assert: that: zbxaction_ops.changed is sameas False - name: test - delete action - zabbix_action: + community.zabbix.zabbix_action: state: absent register: zbxaction_delete - - assert: + - ansible.builtin.assert: that: zbxaction_delete.changed is sameas True - name: test - create new action with escalation steps 1-1 - zabbix_action: + community.zabbix.zabbix_action: operations: - type: send_message send_to_users: @@ -491,11 +491,11 @@ esc_step_to: 1 register: zbxaction_esc11 - - assert: + - ansible.builtin.assert: that: zbxaction_esc11.changed is sameas True - name: test - create new action with escalation steps 1-1 (again) - zabbix_action: + community.zabbix.zabbix_action: operations: - type: send_message send_to_users: @@ -505,11 +505,11 @@ esc_step_to: 1 register: zbxaction_esc11_again - - assert: + - ansible.builtin.assert: that: zbxaction_esc11_again.changed is sameas False - name: test - update action with escalation steps 2-2 - zabbix_action: + community.zabbix.zabbix_action: operations: - type: send_message send_to_users: @@ -519,11 +519,11 @@ esc_step_to: 2 register: zbxaction_esc22 - - assert: + - ansible.builtin.assert: that: zbxaction_esc22.changed is sameas True - name: test - create new action with escalation steps 2-2 (again) - zabbix_action: + community.zabbix.zabbix_action: operations: - type: send_message send_to_users: @@ -533,15 +533,15 @@ esc_step_to: 2 register: zbxaction_esc22_again - - assert: + - ansible.builtin.assert: that: zbxaction_esc11_again.changed is sameas False - name: test - delete action - zabbix_action: + community.zabbix.zabbix_action: state: absent register: zbxaction_delete - - assert: + - ansible.builtin.assert: that: zbxaction_delete.changed is sameas True - name: test - discovery actions @@ -555,7 +555,7 @@ block: - name: test - create new discovery action - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_IP operator: "=" @@ -582,11 +582,11 @@ inventory: automatic register: zbxaction_discovery - - assert: + - ansible.builtin.assert: that: zbxaction_discovery.changed is sameas True - name: test - create new discovery action (again) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_IP operator: "=" @@ -613,11 +613,11 @@ inventory: automatic register: zbxaction_discovery - - assert: + - ansible.builtin.assert: that: zbxaction_discovery.changed is sameas False - name: test - update discovery action conditions and operations - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_IP operator: "=" @@ -652,11 +652,11 @@ esc_step_to: 2 register: zbxaction_discovery_update - - assert: + - ansible.builtin.assert: that: zbxaction_discovery_update.changed is sameas True - name: test - update discovery action conditions and operations (again) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_IP operator: "=" @@ -691,15 +691,15 @@ esc_step_to: 2 register: zbxaction_discovery_update - - assert: + - ansible.builtin.assert: that: zbxaction_discovery_update.changed is sameas False - name: test - delete action - zabbix_action: + community.zabbix.zabbix_action: state: absent register: zbxaction_delete - - assert: + - ansible.builtin.assert: that: zbxaction_delete.changed is sameas True - name: test - auto registration actions @@ -713,7 +713,7 @@ block: - name: test - create new auto registration action - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_name operator: like @@ -725,11 +725,11 @@ - type: add_host register: zbxaction_autoreg - - assert: + - ansible.builtin.assert: that: zbxaction_autoreg.changed is sameas True - name: test - create new auto registration action (again) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_name operator: like @@ -741,11 +741,11 @@ - type: add_host register: zbxaction_autoreg - - assert: + - ansible.builtin.assert: that: zbxaction_autoreg.changed is sameas False - name: test - update auto registration action - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_name operator: like @@ -760,11 +760,11 @@ - type: add_host register: zbxaction_autoreg_update - - assert: + - ansible.builtin.assert: that: zbxaction_autoreg_update.changed is sameas True - name: test - update auto registration action (again) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_name operator: like @@ -779,15 +779,15 @@ - type: add_host register: zbxaction_autoreg_update - - assert: + - ansible.builtin.assert: that: zbxaction_autoreg_update.changed is sameas False - name: test - delete action - zabbix_action: + community.zabbix.zabbix_action: state: absent register: zbxaction_delete - - assert: + - ansible.builtin.assert: that: zbxaction_delete.changed is sameas True - name: test - internal actions @@ -808,7 +808,7 @@ block: - name: test - create new internal action - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_template operator: "=" @@ -818,11 +818,11 @@ value: item in not supported state register: zbxaction_internal - - assert: + - ansible.builtin.assert: that: zbxaction_internal.changed is sameas True - name: test - create new internal action (again) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_template operator: "=" @@ -832,11 +832,11 @@ value: item in not supported state register: zbxaction_internal - - assert: + - ansible.builtin.assert: that: zbxaction_internal.changed is sameas False - name: test - update internal action conditions - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_template operator: "=" @@ -849,11 +849,11 @@ value: trigger in unknown state register: zbxaction_internal_update - - assert: + - ansible.builtin.assert: that: zbxaction_internal_update.changed is sameas True - name: test - update internal action conditions (again) - zabbix_action: + community.zabbix.zabbix_action: conditions: - type: host_template operator: "=" @@ -866,15 +866,15 @@ value: trigger in unknown state register: zbxaction_internal_update - - assert: + - ansible.builtin.assert: that: zbxaction_internal_update.changed is sameas False - name: test - delete action - zabbix_action: + community.zabbix.zabbix_action: state: absent register: zbxaction_delete - - assert: + - ansible.builtin.assert: that: zbxaction_delete.changed is sameas True - module_defaults: @@ -899,7 +899,7 @@ block: - name: test - create new action with recovery and acknowledge operations - zabbix_action: + community.zabbix.zabbix_action: recovery_operations: - type: send_message subject: ExampleSubject @@ -923,11 +923,11 @@ media_type: ExampleMediaTypeForActionModule register: zbxaction_recack_new - - assert: + - ansible.builtin.assert: that: zbxaction_recack_new.changed is sameas True - name: test - create new action with recovery and acknowledge operations (again) - zabbix_action: + community.zabbix.zabbix_action: recovery_operations: - type: send_message subject: ExampleSubject @@ -951,13 +951,13 @@ media_type: ExampleMediaTypeForActionModule register: zbxaction_recack_new - - assert: + - ansible.builtin.assert: that: zbxaction_recack_new.changed is sameas False - when: zabbix_version is version('6.4', '>=') block: - name: test - update action with pause_symptoms off - zabbix_action: + community.zabbix.zabbix_action: recovery_operations: - type: send_message subject: ExampleSubject @@ -982,11 +982,11 @@ pause_symptoms: False register: zbxaction_pause_symptoms - - assert: + - ansible.builtin.assert: that: zbxaction_pause_symptoms.changed is sameas True - name: test - update action with pause_symptoms off (again) - zabbix_action: + community.zabbix.zabbix_action: recovery_operations: - type: send_message subject: ExampleSubject @@ -1011,15 +1011,15 @@ pause_symptoms: False register: zbxaction_pause_symptoms - - assert: + - ansible.builtin.assert: that: zbxaction_pause_symptoms.changed is sameas False - name: test - delete action - zabbix_action: + community.zabbix.zabbix_action: state: absent register: zbxaction_delete - - assert: + - ansible.builtin.assert: that: zbxaction_delete.changed is sameas True - name: delete ExampleApplicationAction action @@ -1028,13 +1028,13 @@ state: absent - name: test - cleanup example template for zabbix_action module - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleTemplateForActionModule state: absent register: zbxaction_prep_template - name: test - cleanup example mediatype for zabbix_action module - zabbix_mediatype: + community.zabbix.zabbix_mediatype: name: ExampleMediaTypeForActionModule type: email state: absent diff --git a/tests/integration/targets/test_zabbix_api_info/tasks/main.yml b/tests/integration/targets/test_zabbix_api_info/tasks/main.yml index ffd844618..cb28929a4 100644 --- a/tests/integration/targets/test_zabbix_api_info/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_api_info/tasks/main.yml @@ -1,9 +1,9 @@ --- - name: Retrieve API information - zabbix_api_info: + community.zabbix.zabbix_api_info: register: zbxapiinfo_get -- assert: +- ansible.builtin.assert: that: - zbxapiinfo_get.failed is sameas False - zbxapiinfo_get.api.version is version(zabbix_version, '>=') diff --git a/tests/integration/targets/test_zabbix_authentication/tasks/main.yml b/tests/integration/targets/test_zabbix_authentication/tasks/main.yml index f6364f35a..37b1d2c9a 100644 --- a/tests/integration/targets/test_zabbix_authentication/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_authentication/tasks/main.yml @@ -1,10 +1,10 @@ --- - block: - - include_tasks: zabbix_authentication_tests.yml + - include_tasks: zabbix_authentication_tests.yml always: - - name: Cleanup - zabbix_user_directory: - name: TestUserDirectory - state: absent - ignore_errors: true + - name: Cleanup + community.zabbix.zabbix_user_directory: + name: TestUserDirectory + state: absent + ignore_errors: true diff --git a/tests/integration/targets/test_zabbix_authentication/tasks/zabbix_authentication_tests.yml b/tests/integration/targets/test_zabbix_authentication/tasks/zabbix_authentication_tests.yml index 5863d3d8f..90b8b7868 100644 --- a/tests/integration/targets/test_zabbix_authentication/tasks/zabbix_authentication_tests.yml +++ b/tests/integration/targets/test_zabbix_authentication/tasks/zabbix_authentication_tests.yml @@ -2,52 +2,52 @@ - when: zabbix_version is version('6.0', '=') name: support Zabbix version (=6.0) block: - - name: test - update ldap_configured without mandatory paramters - zabbix_authentication: + - name: test - update ldap_configured without mandatory paramters + community.zabbix.zabbix_authentication: ldap_configured: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set ldap_host, ldap_search_attribute and ldap_base_dn when you change a value of ldap_configured to true." - - name: test - update saml_auth_enabled without mandatory paramters - zabbix_authentication: + - name: test - update saml_auth_enabled without mandatory paramters + community.zabbix.zabbix_authentication: saml_auth_enabled: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set saml_idp_entityid, saml_sso_url, saml_username_attribute and saml_sp_entityid when you change a value of saml_auth_enabled to true." - name: test - update all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form - http_strip_domains: 'comp,any' + http_strip_domains: "comp,any" http_case_sensitive: true ldap_configured: true - ldap_host: 'ldap://localhost' + ldap_host: "ldap://localhost" ldap_port: 389 - ldap_base_dn: 'ou=Users,ou=system' - ldap_search_attribute: 'uid' - ldap_bind_dn: 'uid=ldap_search,ou=system' + ldap_base_dn: "ou=Users,ou=system" + ldap_search_attribute: "uid" + ldap_bind_dn: "uid=ldap_search,ou=system" ldap_case_sensitive: true - ldap_bind_password: 'password' + ldap_bind_password: "password" saml_auth_enabled: true - saml_idp_entityid: '' - saml_sso_url: 'https://localhost/SAML2/SSO' - saml_slo_url: 'https://localhost/SAML2/SLO' - saml_username_attribute: 'uid' - saml_sp_entityid: 'https://localhost' - saml_nameid_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity' + saml_idp_entityid: "" + saml_sso_url: "https://localhost/SAML2/SSO" + saml_slo_url: "https://localhost/SAML2/SLO" + saml_username_attribute: "uid" + saml_sp_entityid: "https://localhost" + saml_nameid_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:entity" saml_sign_messages: true saml_sign_assertions: true saml_sign_authn_requests: true @@ -65,11 +65,11 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True - name: test - update all authentication setting (again) - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form @@ -78,20 +78,20 @@ - any http_case_sensitive: true ldap_configured: true - ldap_host: 'ldap://localhost' + ldap_host: "ldap://localhost" ldap_port: 389 - ldap_base_dn: 'ou=Users,ou=system' - ldap_search_attribute: 'uid' - ldap_bind_dn: 'uid=ldap_search,ou=system' + ldap_base_dn: "ou=Users,ou=system" + ldap_search_attribute: "uid" + ldap_bind_dn: "uid=ldap_search,ou=system" ldap_case_sensitive: true - ldap_bind_password: 'password' + ldap_bind_password: "password" saml_auth_enabled: true - saml_idp_entityid: '' - saml_sso_url: 'https://localhost/SAML2/SSO' - saml_slo_url: 'https://localhost/SAML2/SLO' - saml_username_attribute: 'uid' - saml_sp_entityid: 'https://localhost' - saml_nameid_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity' + saml_idp_entityid: "" + saml_sso_url: "https://localhost/SAML2/SSO" + saml_slo_url: "https://localhost/SAML2/SLO" + saml_username_attribute: "uid" + saml_sp_entityid: "https://localhost" + saml_nameid_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:entity" saml_sign_messages: true saml_sign_assertions: true saml_sign_authn_requests: true @@ -109,31 +109,31 @@ register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas False - name: test - initialize all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: false http_login_form: zabbix_login_form http_strip_domains: [] http_case_sensitive: true ldap_configured: false - ldap_host: '' + ldap_host: "" ldap_port: 389 - ldap_base_dn: '' - ldap_search_attribute: '' - ldap_bind_dn: '' + ldap_base_dn: "" + ldap_search_attribute: "" + ldap_bind_dn: "" ldap_case_sensitive: true - ldap_bind_password: '' + ldap_bind_password: "" saml_auth_enabled: false - saml_idp_entityid: '' - saml_sso_url: '' - saml_slo_url: '' - saml_username_attribute: '' - saml_sp_entityid: '' - saml_nameid_format: '' + saml_idp_entityid: "" + saml_sso_url: "" + saml_slo_url: "" + saml_username_attribute: "" + saml_sp_entityid: "" + saml_nameid_format: "" saml_sign_messages: false saml_sign_assertions: false saml_sign_authn_requests: false @@ -148,61 +148,61 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True - when: zabbix_version is version('6.2', '=') name: support Zabbix version (=6.2) block: - name: test - create user directory - zabbix_user_directory: + community.zabbix.zabbix_user_directory: name: TestUserDirectory - host: 'test.com' + host: "test.com" port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - - - name: test - update ldap_configured without mandatory paramters - zabbix_authentication: + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + + - name: test - update ldap_configured without mandatory paramters + community.zabbix.zabbix_authentication: ldap_configured: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set ldap_userdirectory when you change a value of ldap_configured to true." - - name: test - update saml_auth_enabled without mandatory paramters - zabbix_authentication: + - name: test - update saml_auth_enabled without mandatory paramters + community.zabbix.zabbix_authentication: saml_auth_enabled: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set saml_idp_entityid, saml_sso_url, saml_username_attribute and saml_sp_entityid when you change a value of saml_auth_enabled to true." - name: test - update all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form - http_strip_domains: 'comp,any' + http_strip_domains: "comp,any" http_case_sensitive: true ldap_configured: true ldap_case_sensitive: true ldap_userdirectory: TestUserDirectory saml_auth_enabled: true - saml_idp_entityid: '' - saml_sso_url: 'https://localhost/SAML2/SSO' - saml_slo_url: 'https://localhost/SAML2/SLO' - saml_username_attribute: 'uid' - saml_sp_entityid: 'https://localhost' - saml_nameid_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity' + saml_idp_entityid: "" + saml_sso_url: "https://localhost/SAML2/SSO" + saml_slo_url: "https://localhost/SAML2/SLO" + saml_username_attribute: "uid" + saml_sp_entityid: "https://localhost" + saml_nameid_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:entity" saml_sign_messages: true saml_sign_assertions: true saml_sign_authn_requests: true @@ -220,11 +220,11 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True - name: test - update all authentication setting (again) - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form @@ -236,12 +236,12 @@ ldap_case_sensitive: true ldap_userdirectory: TestUserDirectory saml_auth_enabled: true - saml_idp_entityid: '' - saml_sso_url: 'https://localhost/SAML2/SSO' - saml_slo_url: 'https://localhost/SAML2/SLO' - saml_username_attribute: 'uid' - saml_sp_entityid: 'https://localhost' - saml_nameid_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity' + saml_idp_entityid: "" + saml_sso_url: "https://localhost/SAML2/SSO" + saml_slo_url: "https://localhost/SAML2/SLO" + saml_username_attribute: "uid" + saml_sp_entityid: "https://localhost" + saml_nameid_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:entity" saml_sign_messages: true saml_sign_assertions: true saml_sign_authn_requests: true @@ -259,11 +259,11 @@ register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas False - name: test - initialize all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: false http_login_form: zabbix_login_form @@ -272,12 +272,12 @@ ldap_configured: false ldap_case_sensitive: true saml_auth_enabled: false - saml_idp_entityid: '' - saml_sso_url: '' - saml_slo_url: '' - saml_username_attribute: '' - saml_sp_entityid: '' - saml_nameid_format: '' + saml_idp_entityid: "" + saml_sso_url: "" + saml_slo_url: "" + saml_username_attribute: "" + saml_sp_entityid: "" + saml_nameid_format: "" saml_sign_messages: false saml_sign_assertions: false saml_sign_authn_requests: false @@ -292,43 +292,43 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True - name: test - delete user directory - zabbix_user_directory: + community.zabbix.zabbix_user_directory: name: TestUserDirectory state: absent - when: zabbix_version is version('6.4', '>=') name: support Zabbix version (>=6.4) block: - - name: test - update ldap_configured without mandatory paramters - zabbix_authentication: + - name: test - update ldap_configured without mandatory paramters + community.zabbix.zabbix_authentication: ldap_auth_enabled: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set ldap_userdirectory when you change a value of ldap_auth_enabled to true." - name: test - create LDAP user directory - zabbix_user_directory: + community.zabbix.zabbix_user_directory: name: TestUserDirectory idp_type: ldap - host: 'test.ca' + host: "test.ca" port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" provision_status: True group_name: cn group_basedn: ou=Group,dc=example,dc=org group_member: member user_ref_attr: uid - group_filter: '(member=uid=%{ref},ou=Users,dc=example,dc=com)' + group_filter: "(member=uid=%{ref},ou=Users,dc=example,dc=com)" user_username: first_name user_lastname: last_name provision_media: @@ -342,11 +342,11 @@ - Guests - name: test - update all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form - http_strip_domains: 'comp,any' + http_strip_domains: "comp,any" http_case_sensitive: true ldap_auth_enabled: true ldap_case_sensitive: true @@ -366,15 +366,15 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True - name: test - update all authentication setting (again) - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form - http_strip_domains: 'comp,any' + http_strip_domains: "comp,any" http_case_sensitive: true ldap_auth_enabled: true ldap_case_sensitive: true @@ -394,11 +394,11 @@ register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas False - name: test - initialize all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: false http_login_form: zabbix_login_form @@ -416,5 +416,5 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True diff --git a/tests/integration/targets/test_zabbix_autoregister/tasks/main.yml b/tests/integration/targets/test_zabbix_autoregister/tasks/main.yml index c203ac8a2..797ad2c2c 100644 --- a/tests/integration/targets/test_zabbix_autoregister/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_autoregister/tasks/main.yml @@ -4,7 +4,7 @@ register: zbxautoregister_update_result ignore_errors: true -- assert: +- ansible.builtin.assert: that: zbxautoregister_update_result.failed is sameas True - name: test update autoregistration with all parameters @@ -12,11 +12,11 @@ tls_accept: - unsecure - tls_with_psk - tls_psk_identity: 'PSK 001' + tls_psk_identity: "PSK 001" tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478" register: zbxautoregister_update_result -- assert: +- ansible.builtin.assert: that: zbxautoregister_update_result.changed is sameas True - name: test update autoregistration with all parameters (again) @@ -24,11 +24,11 @@ tls_accept: - unsecure - tls_with_psk - tls_psk_identity: 'PSK 001' + tls_psk_identity: "PSK 001" tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478" register: zbxautoregister_update_result -- assert: +- ansible.builtin.assert: that: zbxautoregister_update_result.changed is sameas True - name: test update autoregistration with only tls_accept @@ -36,7 +36,7 @@ tls_accept: "tls_with_psk" register: zbxautoregister_update_result -- assert: +- ansible.builtin.assert: that: zbxautoregister_update_result.changed is sameas True - name: test update autoregistration with only tls_accept (again) @@ -45,7 +45,7 @@ - tls_with_psk register: zbxautoregister_update_result -- assert: +- ansible.builtin.assert: that: zbxautoregister_update_result.changed is sameas False - name: test update autoregistration with only tls_accept (unsecure) @@ -54,7 +54,7 @@ - unsecure register: zbxautoregister_update_result -- assert: +- ansible.builtin.assert: that: zbxautoregister_update_result.changed is sameas True - name: test fail to update autoregistration with only tls_accept (tls_with_psk) @@ -63,17 +63,17 @@ register: zbxautoregister_update_result ignore_errors: true -- assert: +- ansible.builtin.assert: that: zbxautoregister_update_result.failed is sameas True - name: test fail to update autoregistration with only tls_accept and tls_psk_identity (tls_with_psk) community.zabbix.zabbix_autoregister: tls_accept: "tls_with_psk" - tls_psk_identity: 'PSK 001' + tls_psk_identity: "PSK 001" register: zbxautoregister_update_result ignore_errors: true -- assert: +- ansible.builtin.assert: that: zbxautoregister_update_result.failed is sameas True - name: test fail to update autoregistration with only tls_accept and tls_psk (tls_with_psk) @@ -83,5 +83,5 @@ register: zbxautoregister_update_result ignore_errors: true -- assert: +- ansible.builtin.assert: that: zbxautoregister_update_result.failed is sameas True diff --git a/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml b/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml index 19e38936e..cbf13b391 100644 --- a/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml @@ -9,267 +9,267 @@ - type: ICMP block: - - name: test - create new Zabbix discovery rule (checkmode) - zabbix_discovery_rule: - check_mode: true - register: drule_new_checkmode - - - name: assert that drule will be created (checkmode) - assert: - that: drule_new_checkmode is changed - - - name: test - create new Zabbix discovery rule - zabbix_discovery_rule: - register: drule_new - - - name: assert that drule was created - assert: - that: drule_new is changed - - - name: test - create same Zabbix discovery rule - zabbix_discovery_rule: - register: drule_exists - - - name: assert that nothing has been changed - assert: - that: not drule_exists is changed - - - name: test - update Zabbix discovery rule iprange (checkmode) - zabbix_discovery_rule: - iprange: - - 192.168.1.1-255 - - 10.0.0.1-255 - check_mode: true - register: drule_iprange_update_checkmode - - - name: assert that iprange will be changed - assert: - that: drule_iprange_update_checkmode is changed - - - name: test - update Zabbix discovery rule iprange - zabbix_discovery_rule: - iprange: - - 192.168.1.1-255 - - 10.0.0.1-255 - register: drule_iprange_update - - - name: assert that iprange has been changed - assert: - that: drule_iprange_update is changed - - - name: test - reset Zabbix discovery rule to default - zabbix_discovery_rule: - register: drule_reset - - - name: assert that iprange has been changed - assert: - that: drule_reset is changed - - - name: test - update Zabbix discovery rule status - zabbix_discovery_rule: - status: disabled - register: drule_status_update - - - name: assert that iprange has been changed - assert: - that: drule_status_update is changed - - - name: test - reset Zabbix discovery rule to default - zabbix_discovery_rule: - register: drule_reset - - - name: assert that iprange has been changed - assert: - that: drule_reset is changed - - - name: test - update Zabbix discovery rule dchecks - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: Zabbix - key: "system.hostname" - ports: "10050" - uniq: true - host_source: discovery - register: drule_dchecks_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_update is changed - - - name: test - update Zabbix discovery rule dchecks ssh - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: SSH - ports: "22" - register: drule_dchecks_ssh_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_ssh_update is changed - - - name: test - update Zabbix discovery rule dchecks ldap - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: SSH - ports: "22" - - type: LDAP - ports: "389" - register: drule_dchecks_ldap_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_ldap_update is changed - - - name: test - update Zabbix discovery rule dchecks smtp - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: SSH - ports: "22" - - type: LDAP - ports: "389" - - type: SMTP - ports: 25,465,587 - register: drule_dchecks_smtp_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_smtp_update is changed - - - name: test - update Zabbix discovery rule dchecks http - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: SSH - ports: "22" - - type: LDAP - ports: "389" - - type: SMTP - ports: 25,465,587 - - type: HTTP - ports: 80,8080 - register: drule_dchecks_http_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_http_update is changed - - - name: test - remove Zabbix discovery rule dchecks - zabbix_discovery_rule: - dchecks: - - type: ICMP - register: drule_dchecks_remove_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_remove_update is changed - - - name: test - update Zabbix discovery rule snmp dcheck - zabbix_discovery_rule: - dchecks: - - type: SNMPv2 - snmp_community: CUSTOMER@snmp-readonly - ports: "161" - key: iso.3.6.1.2.1.1.1.0 - uniq: false - host_source: discovery - name_source: discovery - register: drule_snmp_update - - - name: assert that snmp dcheck has been changed - assert: - that: drule_snmp_update is changed - - - name: test - update Zabbix discovery rule snmp3 dcheck - zabbix_discovery_rule: - dchecks: - - type: SNMPv3 - snmp_community: CUSTOMER@snmp3-readonly - ports: "161" - key: iso.3.6.1.2.1.1.1.0 - snmpv3_contextname: "ContextName" - snmpv3_securityname: "SecurityName" - snmpv3_securitylevel: authPriv - snmpv3_authprotocol: SHA - snmpv3_authpassphrase: "SeCrEt" - snmpv3_privprotocol: AES - snmpv3_privpassphrase: "TopSecret" - uniq: false - host_source: DNS - name_source: None - register: drule_snmp3_update - - - name: assert that snmp3 dcheck has been changed - assert: - that: drule_snmp3_update is changed - - - name: test - reset Zabbix discovery rule to default - zabbix_discovery_rule: - register: drule_reset - - - name: assert that iprange has been changed - assert: - that: drule_reset is changed - - - name: test - create new active Zabbix proxy server - zabbix_proxy: - proxy_name: ACME_proxy - status: active - state: present - register: zbxproxy_active - - - name: assert that proxy was created - assert: - that: zbxproxy_active is changed - - - name: test - update Zabbix discovery rule proxy - zabbix_discovery_rule: - proxy: ACME_proxy - register: drule_proxy_update - - - name: assert that proxy has been changed - assert: - that: drule_proxy_update is changed - - - name: test - update Zabbix discovery rule proxy (again) - zabbix_discovery_rule: - proxy: ACME_proxy - register: drule_proxy_update_again - - - name: assert that nothing has been changed - assert: - that: not drule_proxy_update_again is changed + - name: test - create new Zabbix discovery rule (checkmode) + community.zabbix.zabbix_discovery_rule: + check_mode: true + register: drule_new_checkmode + + - name: assert that drule will be created (checkmode) + ansible.builtin.assert: + that: drule_new_checkmode is changed + + - name: test - create new Zabbix discovery rule + community.zabbix.zabbix_discovery_rule: + register: drule_new + + - name: assert that drule was created + ansible.builtin.assert: + that: drule_new is changed + + - name: test - create same Zabbix discovery rule + community.zabbix.zabbix_discovery_rule: + register: drule_exists + + - name: assert that nothing has been changed + ansible.builtin.assert: + that: not drule_exists is changed + + - name: test - update Zabbix discovery rule iprange (checkmode) + community.zabbix.zabbix_discovery_rule: + iprange: + - 192.168.1.1-255 + - 10.0.0.1-255 + check_mode: true + register: drule_iprange_update_checkmode + + - name: assert that iprange will be changed + ansible.builtin.assert: + that: drule_iprange_update_checkmode is changed + + - name: test - update Zabbix discovery rule iprange + community.zabbix.zabbix_discovery_rule: + iprange: + - 192.168.1.1-255 + - 10.0.0.1-255 + register: drule_iprange_update + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_iprange_update is changed + + - name: test - reset Zabbix discovery rule to default + community.zabbix.zabbix_discovery_rule: + register: drule_reset + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_reset is changed + + - name: test - update Zabbix discovery rule status + community.zabbix.zabbix_discovery_rule: + status: disabled + register: drule_status_update + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_status_update is changed + + - name: test - reset Zabbix discovery rule to default + community.zabbix.zabbix_discovery_rule: + register: drule_reset + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_reset is changed + + - name: test - update Zabbix discovery rule dchecks + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: Zabbix + key: "system.hostname" + ports: "10050" + uniq: true + host_source: discovery + register: drule_dchecks_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_update is changed + + - name: test - update Zabbix discovery rule dchecks ssh + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + register: drule_dchecks_ssh_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_ssh_update is changed + + - name: test - update Zabbix discovery rule dchecks ldap + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + - type: LDAP + ports: "389" + register: drule_dchecks_ldap_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_ldap_update is changed + + - name: test - update Zabbix discovery rule dchecks smtp + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + - type: LDAP + ports: "389" + - type: SMTP + ports: 25,465,587 + register: drule_dchecks_smtp_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_smtp_update is changed + + - name: test - update Zabbix discovery rule dchecks http + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + - type: LDAP + ports: "389" + - type: SMTP + ports: 25,465,587 + - type: HTTP + ports: 80,8080 + register: drule_dchecks_http_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_http_update is changed + + - name: test - remove Zabbix discovery rule dchecks + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + register: drule_dchecks_remove_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_remove_update is changed + + - name: test - update Zabbix discovery rule snmp dcheck + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: SNMPv2 + snmp_community: CUSTOMER@snmp-readonly + ports: "161" + key: iso.3.6.1.2.1.1.1.0 + uniq: false + host_source: discovery + name_source: discovery + register: drule_snmp_update + + - name: assert that snmp dcheck has been changed + ansible.builtin.assert: + that: drule_snmp_update is changed + + - name: test - update Zabbix discovery rule snmp3 dcheck + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: SNMPv3 + snmp_community: CUSTOMER@snmp3-readonly + ports: "161" + key: iso.3.6.1.2.1.1.1.0 + snmpv3_contextname: "ContextName" + snmpv3_securityname: "SecurityName" + snmpv3_securitylevel: authPriv + snmpv3_authprotocol: SHA + snmpv3_authpassphrase: "SeCrEt" + snmpv3_privprotocol: AES + snmpv3_privpassphrase: "TopSecret" + uniq: false + host_source: DNS + name_source: None + register: drule_snmp3_update + + - name: assert that snmp3 dcheck has been changed + ansible.builtin.assert: + that: drule_snmp3_update is changed + + - name: test - reset Zabbix discovery rule to default + community.zabbix.zabbix_discovery_rule: + register: drule_reset + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_reset is changed + + - name: test - create new active Zabbix proxy server + community.zabbix.zabbix_proxy: + proxy_name: ACME_proxy + status: active + state: present + register: zbxproxy_active + + - name: assert that proxy was created + ansible.builtin.assert: + that: zbxproxy_active is changed + + - name: test - update Zabbix discovery rule proxy + community.zabbix.zabbix_discovery_rule: + proxy: ACME_proxy + register: drule_proxy_update + + - name: assert that proxy has been changed + ansible.builtin.assert: + that: drule_proxy_update is changed + + - name: test - update Zabbix discovery rule proxy (again) + community.zabbix.zabbix_discovery_rule: + proxy: ACME_proxy + register: drule_proxy_update_again + + - name: assert that nothing has been changed + ansible.builtin.assert: + that: not drule_proxy_update_again is changed - name: test - delete Zabbix discovery rule - zabbix_discovery_rule: + community.zabbix.zabbix_discovery_rule: name: ACME state: absent register: drule_delete - name: assert that proxy has been deleted - assert: + ansible.builtin.assert: that: drule_delete is changed - name: test - delete Zabbix discovery rule (again) - zabbix_discovery_rule: + community.zabbix.zabbix_discovery_rule: name: ACME state: absent register: drule_delete_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not drule_delete_again is changed # Cleanup - name: delete active Zabbix proxy server - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: ACME_proxy state: absent register: zbxproxy_delete - name: assert that proxy has been deleted - assert: + ansible.builtin.assert: that: zbxproxy_delete is changed diff --git a/tests/integration/targets/test_zabbix_globalmacro/tasks/main.yml b/tests/integration/targets/test_zabbix_globalmacro/tasks/main.yml index e07072c9b..bc15fec2c 100644 --- a/tests/integration/targets/test_zabbix_globalmacro/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_globalmacro/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - attempt to create new global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 macro_value: 123 macro_type: text @@ -8,11 +8,11 @@ register: zbxgmacro_new - name: assert that macro was created - assert: + ansible.builtin.assert: that: zbxgmacro_new is changed - name: test - attempt to create same global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 macro_value: 123 macro_type: text @@ -20,11 +20,11 @@ register: zbxgmacro_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_existing is changed - name: test - attempt to create same global macro in zabbix native format - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: "{$zbxgmacro_test01}" macro_value: 123 macro_type: text @@ -32,22 +32,22 @@ register: zbxgmacro_existing_native - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_existing_native is changed - name: test - attempt to create new global macro in zabbix native format - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: "{$ZBXGMACRO_TEST02}" macro_value: abcd macro_type: text register: zbxgmacro_new_native - name: assert that nothing macro was created - assert: + ansible.builtin.assert: that: zbxgmacro_new_native is changed - name: test - attempt to update global macro with string value while force=no - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 macro_value: abc macro_type: text @@ -55,44 +55,44 @@ register: zbxgmacro_update_noforce - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_update_noforce is changed - name: test - attempt to update global macro with string value - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 macro_value: abc macro_type: text register: zbxgmacro_update - name: assert that global macro was updated - assert: + ansible.builtin.assert: that: zbxgmacro_update is changed - name: test - attempt to create global macro with context - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: low_space_limit:/home macro_value: 10 macro_type: text register: zbxgmacro_context_new - name: assert that macro was created - assert: + ansible.builtin.assert: that: zbxgmacro_context_new is changed - name: test - attempt to create same global macro with context and verify that it was converted to uppercase - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: LOW_SPACE_LIMIT:/home macro_value: 10 macro_type: text register: zbxgmacro_context_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_context_existing is changed - name: test - attempt to delete all global macros - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: "{{ item }}" state: absent loop: @@ -102,66 +102,66 @@ register: zbxgmacro_delete_existing - name: assert that all macros have been deleted - assert: + ansible.builtin.assert: that: item.changed is sameas True loop: "{{ zbxgmacro_delete_existing.results }}" - name: test - attempt to delete non-existing global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 state: absent register: zbxgmacro_delete_missing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_delete_missing is changed - name: test - attempt to create secret global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test_secret macro_value: 123 macro_type: secret macro_description: Global Macro description register: zbxgmacro_secret -- assert: +- ansible.builtin.assert: that: zbxgmacro_secret.changed is sameas True - name: test - attempt to create same global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test_secret macro_value: 123 macro_type: secret macro_description: Global Macro description register: zbxgmacro_secret -- assert: +- ansible.builtin.assert: that: zbxgmacro_secret.changed is sameas True - name: test - attempt to create vault global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test_vault macro_value: path/to/vault:zabbix macro_type: vault macro_description: Global Macro description register: zbxgmacro_vault -- assert: +- ansible.builtin.assert: that: zbxgmacro_vault.changed is sameas True - name: test - attempt to create same global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test_vault macro_value: path/to/vault:zabbix macro_type: vault macro_description: Global Macro description register: zbxgmacro_vault -- assert: +- ansible.builtin.assert: that: zbxgmacro_vault.changed is sameas False - name: delete all global macros - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: "{{ item }}" state: absent loop: diff --git a/tests/integration/targets/test_zabbix_group/tasks/main.yml b/tests/integration/targets/test_zabbix_group/tasks/main.yml index 0f099d7c1..b45711a25 100644 --- a/tests/integration/targets/test_zabbix_group/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_group/tasks/main.yml @@ -1,17 +1,17 @@ --- - name: test - create new Zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: present register: zbxgrp_new - name: assert that group was created - assert: + ansible.builtin.assert: that: zbxgrp_new is changed - name: test - create simple zabbix host to assign to group - zabbix_host: + community.zabbix.zabbix_host: host_name: zbxgrp_example_host01 host_groups: - zbxgrp_example_group01 @@ -23,33 +23,33 @@ register: zbxgrp_host_assignement - name: assert that host was assigned successfully - assert: + ansible.builtin.assert: that: zbxgrp_host_assignement is changed - name: test - create same Zabbix group once again - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: present register: zbxgrp_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgrp_existing is changed - name: test - attempt to create new Zabbix group matching name of default Zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - Linux servers state: present register: zbxgrp_default_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgrp_default_existing is changed - name: test - attempt to delete host group while its only group host has assigned - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: absent @@ -57,32 +57,32 @@ ignore_errors: true - name: assert that group deletion failed - assert: + ansible.builtin.assert: that: zbxgrp_existing_delete_failed is failed - name: delete helper zabbix host - zabbix_host: + community.zabbix.zabbix_host: host_name: zbxgrp_example_host01 state: absent - name: test - attempt to delete previously created zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: absent register: zbxgrp_existing_delete - name: assert that group was deleted - assert: + ansible.builtin.assert: that: zbxgrp_existing_delete is changed - name: test - attempt to delete non-existing zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: absent register: zbxgrp_missing_delete - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgrp_missing_delete is changed diff --git a/tests/integration/targets/test_zabbix_group_info/tasks/main.yml b/tests/integration/targets/test_zabbix_group_info/tasks/main.yml index 624679603..51c03af3b 100644 --- a/tests/integration/targets/test_zabbix_group_info/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_group_info/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - create new Zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 - zbxgrp_example_group02 @@ -8,7 +8,7 @@ register: zbxgrp_new - name: assert that group was created - assert: + ansible.builtin.assert: that: zbxgrp_new is changed - name: test - get one hostgroup info @@ -18,7 +18,7 @@ register: get_hostgorup_info_result - name: assert that one group was get - assert: + ansible.builtin.assert: that: - get_hostgorup_info_result.host_groups | length == 1 - get_hostgorup_info_result.host_groups.0.name == 'zbxgrp_example_group01' @@ -31,14 +31,14 @@ register: get_hostgorup_info_result - name: assert that two group was get - assert: + ansible.builtin.assert: that: - get_hostgorup_info_result.host_groups | length == 2 - get_hostgorup_info_result.host_groups.0.name == 'zbxgrp_example_group01' - get_hostgorup_info_result.host_groups.1.name == 'zbxgrp_example_group02' - name: test - delete Zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 - zbxgrp_example_group02 @@ -46,5 +46,5 @@ register: delete_zbxgrp - name: assert that group was deleted - assert: + ansible.builtin.assert: that: delete_zbxgrp is changed diff --git a/tests/integration/targets/test_zabbix_host/tasks/main.yml b/tests/integration/targets/test_zabbix_host/tasks/main.yml index 20755061f..97b9f4612 100644 --- a/tests/integration/targets/test_zabbix_host/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_host/tasks/main.yml @@ -12,8 +12,8 @@ # tear down stuff set up earlier - include_tasks: zabbix_host_teardown.yml always: - - name: "cleanup if tests failed" - zabbix_host: - host_name: ExampleHost - state: absent - ignore_errors: true + - name: "cleanup if tests failed" + community.zabbix.zabbix_host: + host_name: ExampleHost + state: absent + ignore_errors: true diff --git a/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml b/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml index 170868571..c84050dcf 100644 --- a/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml +++ b/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml @@ -2,7 +2,7 @@ # These two tests are close to documentation example - name: Create a new host or update an existing host's info - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost1 visible_name: ExampleName description: My ExampleHost Description @@ -10,8 +10,8 @@ - Linux servers - Zabbix servers link_templates: - - 'IMAP Service' - - 'NTP Service' + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -41,7 +41,7 @@ dns: "" port: "12345" macros: - - macro: '{$EXAMPLEMACRO}' + - macro: "{$EXAMPLEMACRO}" value: ExampleMacroValue - macro: EXAMPLEMACRO2 value: ExampleMacroValue2 @@ -53,7 +53,7 @@ register: zabbix_host1 - name: Update an existing host's tls settings - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost2 visible_name: ExampleName2 interfaces: @@ -71,7 +71,7 @@ register: zabbix_host2 - name: expect both to succeed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - "zabbix_host2 is changed" diff --git a/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml b/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml index fb5b18e06..924119467 100644 --- a/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml +++ b/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml @@ -2,7 +2,7 @@ # set up a zabbix proxy to test zabbix_host with - name: Create a new proxy - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: ExampleProxy description: ExampleProxy status: active @@ -15,7 +15,7 @@ register: zabbix_proxy - name: Create Templates - zabbix_template: + community.zabbix.zabbix_template: template_name: "{{ item }}" template_groups: - Templates diff --git a/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml b/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml index 7eedcf12d..1617f449f 100644 --- a/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml +++ b/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml @@ -2,12 +2,12 @@ # remove zabbix_proxy (hopefully) created earlier - name: remove proxy - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: ExampleProxy state: absent - name: remove Templates - zabbix_template: + community.zabbix.zabbix_template: template_name: "{{ item }}" state: absent with_items: diff --git a/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml b/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml index 6ab475983..a4829a051 100644 --- a/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml +++ b/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml @@ -1,6 +1,6 @@ --- - name: "test: create host with many options set" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: ExampleName description: My ExampleHost Description @@ -8,8 +8,8 @@ - Linux servers - Zabbix servers link_templates: - - 'IMAP Service' - - 'NTP Service' + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -44,7 +44,7 @@ macros: - macro: MACRO1 value: test1 - - macro: '{$MACRO2}' + - macro: "{$MACRO2}" value: test2 tags: - tag: Tag1 @@ -53,12 +53,12 @@ register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: try to create the same host with the same settings" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: ExampleName description: My ExampleHost Description @@ -66,8 +66,8 @@ - Linux servers - Zabbix servers link_templates: - - 'IMAP Service' - - 'NTP Service' + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -102,7 +102,7 @@ macros: - macro: MACRO1 value: test1 - - macro: '{$MACRO2}' + - macro: "{$MACRO2}" value: test2 tags: - tag: Tag1 @@ -111,12 +111,12 @@ register: zabbix_host1 - name: updating with same values should be idempotent - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: try to create the same host with the same settings and force false" - zabbix_host: + community.zabbix.zabbix_host: force: false host_name: ExampleHost visible_name: ExampleName @@ -125,8 +125,8 @@ - Linux servers - Zabbix servers link_templates: - - 'IMAP Service' - - 'NTP Service' + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -161,12 +161,12 @@ register: zabbix_host1 - name: updating with same values and force false should be idempotent - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: try to create the same host changing one parameter in the inventory with force false" - zabbix_host: + community.zabbix.zabbix_host: force: false host_name: ExampleHost visible_name: ExampleName @@ -175,8 +175,8 @@ - Linux servers - Zabbix servers link_templates: - - 'IMAP Service' - - 'NTP Service' + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -211,56 +211,56 @@ register: zabbix_host1 - name: changing the value of an already defined inventory should work and mark task as changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change visible_name" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: "ExampleName Changed" register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change visible_name (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: "ExampleName Changed" register: zabbix_host1 - name: updating with same values should be idempotent - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change description" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost description: "My ExampleHost Description Changed" register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change description (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost description: "My ExampleHost Description Changed" register: zabbix_host1 - name: updating with same values should be idempotent - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host groups (adding one group)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost host_groups: - Linux servers @@ -269,12 +269,12 @@ register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host groups (remove one group)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost host_groups: - Linux servers @@ -282,12 +282,12 @@ register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host groups (add one group using force=no)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost host_groups: - Virtual machines @@ -295,12 +295,12 @@ register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host groups (check whether we are at three groups)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost host_groups: - Linux servers @@ -309,12 +309,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host groups (attempt to remove all host groups)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost # list with empty value, expected: host_groups: @@ -323,133 +323,133 @@ ignore_errors: true - name: expect to fail - assert: + ansible.builtin.assert: that: - "zabbix_host1 is failed" - name: "test: change host linked templates (same as before)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: - - 'IMAP Service' - - 'NTP Service' + - "IMAP Service" + - "NTP Service" register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host linked templates (add one template)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: - - 'IMAP Service' - - 'NTP Service' - - 'HTTP Service' + - "IMAP Service" + - "NTP Service" + - "HTTP Service" register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host linked templates (add one template, using force=no)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: - - 'LDAP Service' + - "LDAP Service" force: false register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host linked templates (make sure we are at 4 templates)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: - - 'IMAP Service' - - 'NTP Service' - - 'HTTP Service' - - 'LDAP Service' + - "IMAP Service" + - "NTP Service" + - "HTTP Service" + - "LDAP Service" register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host linked templates (remove all templates)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: [] register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host linked templates (check we have no templates left)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: [] register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host status" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost status: disabled register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host status (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost status: disabled register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host inventory mode" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_mode: automatic register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host inventory mode" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_mode: automatic register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host inventory data (one field)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_zabbix: tag: test-tag-two @@ -462,12 +462,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host inventory data (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_zabbix: tag: test-tag-two @@ -480,45 +480,45 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: remove host proxy" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost - proxy: '' + proxy: "" register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add host proxy" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost proxy: ExampleProxy register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add host proxy (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost proxy: ExampleProxy register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change tls certificate settings" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tls_connect: 4 tls_accept: 4 @@ -527,12 +527,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change tls certificate settings (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tls_connect: 4 tls_accept: 4 @@ -541,12 +541,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change tls psk (write-only) settings" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tls_connect: 2 tls_accept: 2 @@ -555,11 +555,11 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: zabbix_host1 is changed - name: "test: change tls psk (write-only) settings (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tls_connect: 2 tls_accept: 2 @@ -568,11 +568,11 @@ register: zabbix_host1 - name: expect to succeed and that things have changed (tls_psk makes module non-idempotent) - assert: + ansible.builtin.assert: that: zabbix_host1 is changed - name: "test: change interface settings (remove one)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -584,12 +584,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change interface settings (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -601,12 +601,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change interface settings (add one interface using force=no)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 4 @@ -619,12 +619,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change interface settings (verify that we are at two interfaces)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -642,12 +642,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: configure interface to useip=1 but provide no ip" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -663,12 +663,12 @@ ignore_errors: true - name: expect to fail - assert: + ansible.builtin.assert: that: - "zabbix_host1 is failed" - name: "test: configure interface to useip=0 but provide no dns" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -685,12 +685,12 @@ ignore_errors: true - name: expect to fail - assert: + ansible.builtin.assert: that: - "zabbix_host1 is failed" - name: "test: configure SNMPv2 interface without details (fail)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -707,12 +707,12 @@ ignore_errors: true - name: expect to fail - assert: + ansible.builtin.assert: that: - "zabbix_host1 is failed" - name: "test: configure details for SNMPv2 interface" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -731,12 +731,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: configure details for SNMPv2 interface (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -755,12 +755,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: configure SNMPv2 interface with the same options and force=False " - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost force: False interfaces: @@ -780,12 +780,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: update details for SNMPv2 interface with bulk sub option" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -805,12 +805,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: configure details for SNMPv3 interface" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -831,12 +831,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: configure details for SNMPv3 interface (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -857,12 +857,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: update details for SNMPv3 interface" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -887,12 +887,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "reset interfaces to two of the same type" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: "1" @@ -905,12 +905,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "reset interfaces to two of the same type (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: "1" @@ -923,12 +923,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: add IPMI settings" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost ipmi_authtype: 2 ipmi_privilege: 4 @@ -937,12 +937,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add IPMI settings again" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost ipmi_authtype: 2 ipmi_privilege: 4 @@ -951,22 +951,22 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: verify that an empty change is idempotent" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: IPMI set default values" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost ipmi_authtype: -1 ipmi_privilege: 2 @@ -975,12 +975,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: IPMI set default values (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost ipmi_authtype: -1 ipmi_privilege: 2 @@ -989,82 +989,82 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: change host inventory mode to disabled" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_mode: disabled register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host inventory mode to manual" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_mode: manual register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - - "zabbix_host1 is changed" + - "zabbix_host1 is changed" - name: "test: add new set of user macros to the host" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACRO1}' + - macro: "{$NEWMACRO1}" value: test123 - macro: NEWMACRO2 value: abc register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add new set of user macros to the host (again - lowercase)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$newmacro1}' + - macro: "{$newmacro1}" value: test123 - macro: newmacro2 value: abc register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: update one of the user macros present on the host" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACRO1}' + - macro: "{$NEWMACRO1}" value: test1234 - macro: NEWMACRO2 value: abc register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: update one of the user macros with description" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACRO1}' + - macro: "{$NEWMACRO1}" value: test1234 description: Example Description - macro: NEWMACRO2 @@ -1072,15 +1072,15 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: update one of the user macros with description (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACRO1}' + - macro: "{$NEWMACRO1}" value: test1234 description: Example Description - macro: NEWMACRO2 @@ -1088,122 +1088,122 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: update one of the user macros by removing description" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACRO1}' + - macro: "{$NEWMACRO1}" value: test1234 - macro: NEWMACRO2 value: abc register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add user macro while keeping previous ones with force=no" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost force: false macros: - - macro: '{$NEWMACRO3}' + - macro: "{$NEWMACRO3}" value: testing register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add user macro while keeping previous ones with force=no (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost force: false macros: - - macro: '{$NEWMACRO3}' + - macro: "{$NEWMACRO3}" value: testing register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: add the same user macros (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACRO1}' + - macro: "{$NEWMACRO1}" value: test1234 - macro: NEWMACRO2 value: abc - - macro: '{$NEWMACRO3}' + - macro: "{$NEWMACRO3}" value: testing register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: add new user macro with type secret" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACROSECRET}' + - macro: "{$NEWMACROSECRET}" value: secretvalue type: secret register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add new user macro with type secret (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACROSECRET}' + - macro: "{$NEWMACROSECRET}" value: secretvalue type: secret register: zabbix_host1 - name: expect to succeed and that things have changed as it has secret value - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: wipe out all of the user macros" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: [] register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: wipe out all of the user macros (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: [] register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: add new set of tags to the host" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tags: - tag: NEWTAG1 @@ -1212,12 +1212,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add new set of tags to the host (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tags: - tag: NEWTAG1 @@ -1226,12 +1226,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: update one of the tags present on the host" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tags: - tag: NEWTAG1 @@ -1240,12 +1240,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add tag while keeping previous ones with force=no" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost force: false tags: @@ -1254,12 +1254,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add the same tags (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tags: - tag: NEWTAG1 @@ -1270,56 +1270,56 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: wipe out all of the tags" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tags: [] register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: wipe out all of the tags (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tags: [] register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: attempt to delete host created earlier" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost state: absent register: zabbix_host1 - name: deleting a host is a change, right? - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: attempt deleting a non-existant host" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost state: absent register: zabbix_host1 - name: deleting a non-existant host is not a change, right? - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: create host without host interfaces" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: ExampleName description: My ExampleHost Description @@ -1330,11 +1330,11 @@ register: zbx_host_create_interfaceless - name: verify host was created without interfaces - assert: + ansible.builtin.assert: that: zbx_host_create_interfaceless is changed - name: "test: create host without host interfaces (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: ExampleName description: My ExampleHost Description @@ -1345,10 +1345,10 @@ register: zbx_host_create_interfaceless - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: zbx_host_create_interfaceless is not changed - name: "cleanup" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost state: absent diff --git a/tests/integration/targets/test_zabbix_host_info/tasks/main.yml b/tests/integration/targets/test_zabbix_host_info/tasks/main.yml index 603d497fc..022d86c1a 100644 --- a/tests/integration/targets/test_zabbix_host_info/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_host_info/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: "test - Prepare host for zabbix_host_info module" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHostForHostInfoModule visible_name: ExampleHostForHostInfoModuleName description: Test Host @@ -24,7 +24,7 @@ state: present register: prepare_host_result -- assert: +- ansible.builtin.assert: that: - prepare_host_result.changed is sameas true @@ -35,7 +35,7 @@ environment: ZABBIX_VALIDATE_CERTS: false -- assert: +- ansible.builtin.assert: that: - env_vars_usage.hosts[0].name == "ExampleHostForHostInfoModuleName" @@ -46,11 +46,11 @@ block: - name: "test - Gather all facts of zabbix host" - zabbix_host_info: + community.zabbix.zabbix_host_info: register: gather_all_facts_result - when: zabbix_version is version('5.4', '>=') and zabbix_version is version('6.2', '<') - assert: + ansible.builtin.assert: that: - gather_all_facts_result.hosts | length == 1 - gather_all_facts_result.hosts.0.host == "ExampleHostForHostInfoModule" @@ -71,7 +71,7 @@ - gather_all_facts_result.hosts.0.hostinterfaces.0.useip == "1" - when: zabbix_version is version('6.2', '>=') - assert: + ansible.builtin.assert: that: - gather_all_facts_result.hosts | length == 1 - gather_all_facts_result.hosts.0.host == "ExampleHostForHostInfoModule" @@ -92,44 +92,44 @@ - gather_all_facts_result.hosts.0.hostinterfaces.0.useip == "1" - name: "test - Gather facts of zabbix host with host_inventory" - zabbix_host_info: + community.zabbix.zabbix_host_info: host_inventory: - tag - os register: gather_facts_with_host_inventory_result - - assert: + - ansible.builtin.assert: that: - gather_facts_with_host_inventory_result.hosts.0.inventory | length == 2 - gather_facts_with_host_inventory_result.hosts.0.inventory.tag == "tag1" - gather_facts_with_host_inventory_result.hosts.0.inventory.os == "Linux" - name: "test - Partial match of zabbix host name" - zabbix_host_info: + community.zabbix.zabbix_host_info: host_name: HostForHostInfo exact_match: false register: partial_match_result - - assert: + - ansible.builtin.assert: that: - partial_match_result.hosts | length == 1 - name: "test - Exact match of zabbix host name" - zabbix_host_info: + community.zabbix.zabbix_host_info: exact_match: true register: exact_match_result - - assert: + - ansible.builtin.assert: that: - exact_match_result.hosts | length == 1 - name: "test - Exact match of zabbix host name(expectations - host not found)" - zabbix_host_info: + community.zabbix.zabbix_host_info: host_name: HostForHostInfo exact_match: true register: exact_match_host_not_found_result ignore_errors: true - - assert: + - ansible.builtin.assert: that: - exact_match_host_not_found_result.failed is sameas true diff --git a/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml b/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml index 5544c3a6e..adc4d0402 100644 --- a/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: create helper zabbix host - zabbix_host: + community.zabbix.zabbix_host: host_name: zbx_hmacro_host01 host_groups: - Linux servers @@ -10,7 +10,7 @@ dns: zbx_hmacro_host01 - name: test - attempt to create new host macro - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 macro_value: 123 @@ -18,11 +18,11 @@ register: zbxhmacro_new - name: assert that macro was created - assert: + ansible.builtin.assert: that: zbxhmacro_new is changed - name: test - attempt to create same host macro - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 macro_value: 123 @@ -30,11 +30,11 @@ register: zbxhmacro_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_existing is changed - name: test - attempt to create same host macro in zabbix native format - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: "{$ZBXHMACRO_TEST01}" macro_value: 123 @@ -42,11 +42,11 @@ register: zbxhmacro_existing_native - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_existing_native is changed - name: test - attempt to create new host macro in zabbix native format - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: "{$ZBXHMACRO_TEST02}" macro_value: abcd @@ -54,11 +54,11 @@ register: zbxhmacro_new_native - name: assert that nothing macro was created - assert: + ansible.builtin.assert: that: zbxhmacro_new_native is changed - name: test - attempt to update host macro with string value while force=no - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 macro_value: abc @@ -67,11 +67,11 @@ register: zbxhmacro_update_noforce - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_update_noforce is changed - name: test - attempt to update host macro with string value - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 macro_value: abc @@ -80,11 +80,11 @@ ignore_errors: true - name: assert that host macro was updated - assert: + ansible.builtin.assert: that: zbxhmacro_update is changed - name: test - attempt to create host macro with context - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: low_space_limit:/home macro_value: 10 @@ -92,11 +92,11 @@ register: zbxhmacro_context_new - name: assert that macro was created - assert: + ansible.builtin.assert: that: zbxhmacro_context_new is changed - name: test - attempt to create same host macro with context and verify that it was converted to uppercase - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: LOW_SPACE_LIMIT:/home macro_value: 10 @@ -104,11 +104,11 @@ register: zbxhmacro_context_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_context_existing is changed - name: test - attempt to delete all host macros - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: "{{ item }}" state: absent @@ -119,23 +119,23 @@ register: zbxhmacro_delete_existing - name: assert that all macros have been deleted - assert: + ansible.builtin.assert: that: item.changed is sameas True loop: "{{ zbxhmacro_delete_existing.results }}" - name: test - attempt to delete non-existing host macro - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 state: absent register: zbxhmacro_delete_missing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_delete_missing is changed - name: test - attempt to create host macro with type secret - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test03 macro_value: abcd @@ -145,11 +145,11 @@ ignore_errors: true - name: assert that host macro was updated - assert: + ansible.builtin.assert: that: zbxhmacro_update is changed - name: test - attempt to update host macro with type secret with same value - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test03 macro_value: abcd @@ -159,11 +159,11 @@ ignore_errors: true - name: assert that host macro was updated - assert: + ansible.builtin.assert: that: zbxhmacro_update is changed - name: test - attempt to delete host macros type secret - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: "{{ item }}" state: absent @@ -172,6 +172,6 @@ register: zbxhmacro_delete_existing - name: assert that all macros have been deleted - assert: + ansible.builtin.assert: that: item.changed is sameas True loop: "{{ zbxhmacro_delete_existing.results }}" diff --git a/tests/integration/targets/test_zabbix_housekeeping/tasks/main.yml b/tests/integration/targets/test_zabbix_housekeeping/tasks/main.yml index b90416d30..242b11927 100644 --- a/tests/integration/targets/test_zabbix_housekeeping/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_housekeeping/tasks/main.yml @@ -23,7 +23,7 @@ compress_older: 7d register: zbxhk_update_result -- assert: +- ansible.builtin.assert: that: zbxhk_update_result.changed is sameas True - name: test update housekeeping parameters (again). @@ -50,7 +50,7 @@ compress_older: 7d register: zbxhk_update_result -- assert: +- ansible.builtin.assert: that: zbxhk_update_result.changed is sameas False - name: initialize housekeeping setting. diff --git a/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml b/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml index 0daca8d13..1b9c6f6bd 100644 --- a/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml @@ -1,7 +1,7 @@ --- # New host create test from here - name: "test - Create a new host" - zabbix_host: + community.zabbix.zabbix_host: host_name: example host_groups: - Linux servers @@ -14,24 +14,24 @@ port: 10050 register: create_host_result -- assert: +- ansible.builtin.assert: that: - create_host_result.changed is sameas true - name: "test - Create maintenance with a host_name param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example state: present register: create_maintenance_host_name_result -- assert: +- ansible.builtin.assert: that: - create_maintenance_host_name_result.changed is sameas true # This check doesn't modify maintenace object and thus will be changed=false unless there are hosts without visible name defined - name: "test - Create maintenance with a host_name param and disabled visible_name" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example visible_name: false @@ -40,12 +40,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - create_maintenance_host_name_result.changed is sameas false - name: "test - Create maintenance with a host_name param(again - expectations: false change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example state: present @@ -53,12 +53,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - create_maintenance_host_name_again_result.changed is sameas false - name: "test - Update maintenance with a desc param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -67,12 +67,12 @@ - debug: msg="{{ update_maintenance_desc_result }}" -- assert: +- ansible.builtin.assert: that: - update_maintenance_desc_result.changed is sameas true - name: "test - Update maintenance with a desc param(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -81,12 +81,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_desc_again_result.changed is sameas false - name: "test - Update maintenance with a collect_data" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -94,12 +94,12 @@ state: present register: update_maintenance_collect_data_result -- assert: +- ansible.builtin.assert: that: - update_maintenance_collect_data_result.changed is sameas true - name: "test - Update maintenance with a collect_data(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -109,12 +109,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_collect_data_again_result.changed is sameas false - name: "test - Update maintenance with a minutes param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -123,12 +123,12 @@ state: present register: update_maintenance_minutes_result -- assert: +- ansible.builtin.assert: that: - update_maintenance_minutes_result.changed is sameas true - name: "test - Update maintenance with a minutes param(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -139,12 +139,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_minutes_again_result.changed is sameas false - name: "test - Update maintenance with a host_groups param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example host_groups: @@ -156,12 +156,12 @@ state: present register: update_maintenance_host_groups_result -- assert: +- ansible.builtin.assert: that: - update_maintenance_host_groups_result.changed is sameas true - name: "test - Update maintenance with a host_groups param(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example host_groups: @@ -175,12 +175,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_host_groups_again_result.changed is sameas false - name: "test - Update maintenance with change host_name to host_names param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_names: - example @@ -194,12 +194,12 @@ state: present register: update_maintenance_host_names_result -- assert: +- ansible.builtin.assert: that: - update_maintenance_host_names_result.changed is sameas true - name: "test - Update maintenance with change host_name to host_names param(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_names: - example @@ -215,12 +215,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_host_names_again_result.changed is sameas false - name: "test - Update maintenance with tags" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_names: - example @@ -229,7 +229,7 @@ - Linux servers - Hypervisors desc: "test description" - collect_data: yes # required for tags + collect_data: yes # required for tags minutes: 90 state: present tags: @@ -241,12 +241,12 @@ operator: 0 register: update_maintenance_host_tags -- assert: +- ansible.builtin.assert: that: - update_maintenance_host_tags.changed is sameas true - name: "test - Update maintenance with tags (again)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_names: - example @@ -269,12 +269,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -#- assert: +#- ansible.builtin.assert: # that: # - update_maintenance_host_tags.changed is sameas false - name: "test - Delete maintenance" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example state: absent @@ -282,23 +282,23 @@ tags: - cleanup -- assert: +- ansible.builtin.assert: that: - delete_maintenance_result.changed is sameas true - name: "test - Delete maintenance(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example state: absent register: delete_maintenance_again_result -- assert: +- ansible.builtin.assert: that: - delete_maintenance_again_result.changed is sameas false - name: "test - Delete testing host" - zabbix_host: + community.zabbix.zabbix_host: host_name: example state: absent tags: diff --git a/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml b/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml index c464e1532..a49166d37 100644 --- a/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml @@ -8,301 +8,301 @@ smtp_email: zabbix@example.com block: - - name: test - create new email mediatype without authentication - zabbix_mediatype: - register: zbxmediatype_new - - - assert: - that: zbxmediatype_new.changed is sameas True - - - name: test - create new email mediatype without authentication (again) - zabbix_mediatype: - register: zbxmediatype_new - - - assert: - that: zbxmediatype_new.changed is sameas False - - - name: test - update email mediatype smtp information - zabbix_mediatype: - smtp_helo: example.com - smtp_server: mail.example.com - smtp_server_port: 465 - register: zbxmediatype_smtp - - - assert: - that: zbxmediatype_smtp.changed is sameas True - - - name: test - update email mediatype smtp information (again) - zabbix_mediatype: - smtp_helo: example.com - smtp_server: mail.example.com - smtp_server_port: 465 - register: zbxmediatype_smtp - - - assert: - that: zbxmediatype_smtp.changed is sameas False - - - name: test - reset email mediatype smtp information to default - zabbix_mediatype: - register: zbxmediatype_reset - - - assert: - that: zbxmediatype_reset.changed is sameas True - - - name: test - update email mediatype with authentication without credentials (fail) - zabbix_mediatype: - smtp_authentication: true - smtp_security: STARTTLS - register: zbxmediatype_auth_fail - ignore_errors: true - - - assert: - that: zbxmediatype_auth_fail.failed is sameas True - - - name: test - update email mediatype with authentication - zabbix_mediatype: - smtp_authentication: true - smtp_security: STARTTLS - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_auth - - - assert: - that: zbxmediatype_auth.changed is sameas True - - - name: test - update email mediatype with authentication (again) - zabbix_mediatype: - smtp_authentication: true - smtp_security: STARTTLS - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_auth - - - assert: - that: zbxmediatype_auth.changed is sameas False - - - name: test - update email mediatype with SSL/TLS and host/peer verification - zabbix_mediatype: - smtp_authentication: true - smtp_security: SSL/TLS - smtp_verify_host: true - smtp_verify_peer: true - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_verif - - - assert: - that: zbxmediatype_verif.changed is sameas True - - - name: test - update email mediatype with SSL/TLS and host/peer verification (again) - zabbix_mediatype: - smtp_authentication: true - smtp_security: SSL/TLS - smtp_verify_host: true - smtp_verify_peer: true - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_verif - - - assert: - that: zbxmediatype_verif.changed is sameas False - - - name: test - reset email mediatype smtp information to default - zabbix_mediatype: - register: zbxmediatype_reset - - - assert: - that: zbxmediatype_reset.changed is sameas True - - - name: test - update email mediatype concurrent settings - zabbix_mediatype: - max_sessions: 99 - max_attempts: 10 - attempt_interval: 30s - register: zbxmediatype_concur - - - assert: - that: zbxmediatype_concur.changed is sameas True - - - name: test - update email mediatype concurrent settings (again) - zabbix_mediatype: - max_sessions: 99 - max_attempts: 10 - attempt_interval: 30s - register: zbxmediatype_concur - - - assert: - that: zbxmediatype_concur.changed is sameas False - - - name: test - update email mediatype concurrent settings above range (fail) - zabbix_mediatype: - max_sessions: 102 - max_attempts: 101 - attempt_interval: 61m - register: zbxmediatype_concur_fail - ignore_errors: true - - - assert: - that: zbxmediatype_concur_fail.failed is sameas True - - - name: test - reset email mediatype smtp information to default - zabbix_mediatype: - register: zbxmediatype_reset - - - assert: - that: zbxmediatype_reset.changed is sameas True - - - name: test - update email mediatype with message templates - zabbix_mediatype: - message_templates: - - eventsource: triggers - recovery: operations - subject: "Problem: {EVENT.NAME}" - body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" - - eventsource: discovery - recovery: operations - subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" - body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" - - eventsource: autoregistration - recovery: operations - subject: "Autoregistration: {HOST.HOST}" - body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" - - eventsource: internal - recovery: operations - subject: "Internal: {EVENT.NAME}" - body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" - register: zbxmediatype_msg_templates - - - assert: - that: zbxmediatype_msg_templates.changed is sameas True - - - name: test - update email mediatype with message templates (again) - zabbix_mediatype: - message_templates: - - eventsource: triggers - recovery: operations - subject: "Problem: {EVENT.NAME}" - body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" - - eventsource: discovery - recovery: operations - subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" - body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" - - eventsource: autoregistration - recovery: operations - subject: "Autoregistration: {HOST.HOST}" - body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" - - eventsource: internal - recovery: operations - subject: "Internal: {EVENT.NAME}" - body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" - register: zbxmediatype_msg_templates - - - assert: - that: zbxmediatype_msg_templates.changed is sameas False - - - name: test - update subject of message template in email mediatype - zabbix_mediatype: - message_templates: - - eventsource: triggers - recovery: operations - subject: "Problem: {EVENT.NAME} - test change" - body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" - - eventsource: discovery - recovery: operations - subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" - body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" - - eventsource: autoregistration - recovery: operations - subject: "Autoregistration: {HOST.HOST}" - body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" - - eventsource: internal - recovery: operations - subject: "Internal: {EVENT.NAME}" - body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" - register: zbxmediatype_msg_templates - - - assert: - that: zbxmediatype_msg_templates.changed is sameas True - - - name: test - update message of message template in email mediatype - zabbix_mediatype: - message_templates: - - eventsource: triggers - recovery: operations - subject: "Problem: {EVENT.NAME} - test change" - body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" - - eventsource: discovery - recovery: operations - subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" - body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS} - test" - - eventsource: autoregistration - recovery: operations - subject: "Autoregistration: {HOST.HOST}" - body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" - - eventsource: internal - recovery: operations - subject: "Internal: {EVENT.NAME}" - body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" - register: zbxmediatype_msg_templates - - - assert: - that: zbxmediatype_msg_templates.changed is sameas True - - - name: test - update subject and message of message template in email mediatype (again) - zabbix_mediatype: - message_templates: - - eventsource: triggers - recovery: operations - subject: "Problem: {EVENT.NAME} - test change" - body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" - - eventsource: discovery - recovery: operations - subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" - body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS} - test" - - eventsource: autoregistration - recovery: operations - subject: "Autoregistration: {HOST.HOST}" - body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" - - eventsource: internal - recovery: operations - subject: "Internal: {EVENT.NAME}" - body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" - register: zbxmediatype_msg_templates - - - assert: - that: zbxmediatype_msg_templates.changed is sameas False - - - name: test - disable email mediatype - zabbix_mediatype: - status: disabled - register: zbxmediatype_disable - - - assert: - that: zbxmediatype_disable.changed is sameas True - - - name: test - disable email mediatype (again) - zabbix_mediatype: - status: disabled - register: zbxmediatype_disable - - - assert: - that: zbxmediatype_disable.changed is sameas False - - - name: test - delete email mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete - - - assert: - that: zbxmediatype_delete.changed is sameas True - - - name: test - delete email mediatype (again) - zabbix_mediatype: - state: absent - register: zbxmediatype_delete - - - assert: - that: zbxmediatype_delete.changed is sameas False + - name: test - create new email mediatype without authentication + community.zabbix.zabbix_mediatype: + register: zbxmediatype_new + + - ansible.builtin.assert: + that: zbxmediatype_new.changed is sameas True + + - name: test - create new email mediatype without authentication (again) + community.zabbix.zabbix_mediatype: + register: zbxmediatype_new + + - ansible.builtin.assert: + that: zbxmediatype_new.changed is sameas False + + - name: test - update email mediatype smtp information + community.zabbix.zabbix_mediatype: + smtp_helo: example.com + smtp_server: mail.example.com + smtp_server_port: 465 + register: zbxmediatype_smtp + + - ansible.builtin.assert: + that: zbxmediatype_smtp.changed is sameas True + + - name: test - update email mediatype smtp information (again) + community.zabbix.zabbix_mediatype: + smtp_helo: example.com + smtp_server: mail.example.com + smtp_server_port: 465 + register: zbxmediatype_smtp + + - ansible.builtin.assert: + that: zbxmediatype_smtp.changed is sameas False + + - name: test - reset email mediatype smtp information to default + community.zabbix.zabbix_mediatype: + register: zbxmediatype_reset + + - ansible.builtin.assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update email mediatype with authentication without credentials (fail) + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: STARTTLS + register: zbxmediatype_auth_fail + ignore_errors: true + + - ansible.builtin.assert: + that: zbxmediatype_auth_fail.failed is sameas True + + - name: test - update email mediatype with authentication + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: STARTTLS + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_auth + + - ansible.builtin.assert: + that: zbxmediatype_auth.changed is sameas True + + - name: test - update email mediatype with authentication (again) + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: STARTTLS + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_auth + + - ansible.builtin.assert: + that: zbxmediatype_auth.changed is sameas False + + - name: test - update email mediatype with SSL/TLS and host/peer verification + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: SSL/TLS + smtp_verify_host: true + smtp_verify_peer: true + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_verif + + - ansible.builtin.assert: + that: zbxmediatype_verif.changed is sameas True + + - name: test - update email mediatype with SSL/TLS and host/peer verification (again) + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: SSL/TLS + smtp_verify_host: true + smtp_verify_peer: true + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_verif + + - ansible.builtin.assert: + that: zbxmediatype_verif.changed is sameas False + + - name: test - reset email mediatype smtp information 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 + max_attempts: 10 + attempt_interval: 30s + register: zbxmediatype_concur + + - ansible.builtin.assert: + that: zbxmediatype_concur.changed is sameas True + + - name: test - update email mediatype concurrent settings (again) + community.zabbix.zabbix_mediatype: + max_sessions: 99 + max_attempts: 10 + attempt_interval: 30s + register: zbxmediatype_concur + + - ansible.builtin.assert: + that: zbxmediatype_concur.changed is sameas False + + - name: test - update email mediatype concurrent settings above range (fail) + community.zabbix.zabbix_mediatype: + max_sessions: 102 + max_attempts: 101 + attempt_interval: 61m + register: zbxmediatype_concur_fail + ignore_errors: true + + - ansible.builtin.assert: + that: zbxmediatype_concur_fail.failed is sameas True + + - name: test - reset email mediatype smtp information to default + community.zabbix.zabbix_mediatype: + register: zbxmediatype_reset + + - ansible.builtin.assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update email mediatype with message templates + community.zabbix.zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME}" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - ansible.builtin.assert: + that: zbxmediatype_msg_templates.changed is sameas True + + - name: test - update email mediatype with message templates (again) + community.zabbix.zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME}" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - ansible.builtin.assert: + that: zbxmediatype_msg_templates.changed is sameas False + + - name: test - update subject of message template in email mediatype + community.zabbix.zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME} - test change" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - ansible.builtin.assert: + that: zbxmediatype_msg_templates.changed is sameas True + + - name: test - update message of message template in email mediatype + community.zabbix.zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME} - test change" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS} - test" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - ansible.builtin.assert: + that: zbxmediatype_msg_templates.changed is sameas True + + - name: test - update subject and message of message template in email mediatype (again) + community.zabbix.zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME} - test change" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS} - test" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - ansible.builtin.assert: + that: zbxmediatype_msg_templates.changed is sameas False + + - name: test - disable email mediatype + community.zabbix.zabbix_mediatype: + status: disabled + register: zbxmediatype_disable + + - ansible.builtin.assert: + that: zbxmediatype_disable.changed is sameas True + + - name: test - disable email mediatype (again) + community.zabbix.zabbix_mediatype: + status: disabled + register: zbxmediatype_disable + + - ansible.builtin.assert: + that: zbxmediatype_disable.changed is sameas False + + - name: test - delete email mediatype + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas True + + - name: test - delete email mediatype (again) + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas False - name: test - script mediatypes module_defaults: @@ -312,59 +312,59 @@ type: script block: - - name: test - create new script mediatype - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - register: zbxmediatype_script_new - - - assert: - that: zbxmediatype_script_new.changed is sameas True - - - name: test - create new script mediatype (again) - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - register: zbxmediatype_script_new - - - assert: - that: zbxmediatype_script_new.changed is sameas False - - - name: test - update script mediatype with script parameters - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - script_params: - - '-p test' - - '-q' - register: zbxmediatype_script_params - - - assert: - that: zbxmediatype_script_params.changed is sameas True - - - name: test - update script mediatype with script parameters (again) - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - script_params: - - '-p test' - - '-q' - register: zbxmediatype_script_params - - - assert: - that: zbxmediatype_script_params.changed is sameas False - - - name: test - remove script mediatype parameters - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - register: zbxmediatype_script_params_rev - - - assert: - that: zbxmediatype_script_params_rev.changed is sameas True - - - name: test - delete script mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete - - - assert: - that: zbxmediatype_delete.changed is sameas True + - name: test - create new script mediatype + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + register: zbxmediatype_script_new + + - ansible.builtin.assert: + that: zbxmediatype_script_new.changed is sameas True + + - name: test - create new script mediatype (again) + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + register: zbxmediatype_script_new + + - ansible.builtin.assert: + that: zbxmediatype_script_new.changed is sameas False + + - name: test - update script mediatype with script parameters + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + script_params: + - "-p test" + - "-q" + register: zbxmediatype_script_params + + - ansible.builtin.assert: + that: zbxmediatype_script_params.changed is sameas True + + - name: test - update script mediatype with script parameters (again) + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + script_params: + - "-p test" + - "-q" + register: zbxmediatype_script_params + + - ansible.builtin.assert: + that: zbxmediatype_script_params.changed is sameas False + + - name: test - remove script mediatype parameters + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + register: zbxmediatype_script_params_rev + + - ansible.builtin.assert: + that: zbxmediatype_script_params_rev.changed is sameas True + + - name: test - delete script mediatype + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas True - name: test - sms mediatypes module_defaults: @@ -374,61 +374,61 @@ type: sms block: - - name: test - create new sms mediatype - zabbix_mediatype: - gsm_modem: /dev/ttyS0 - register: zbxmediatype_sms_new - - - assert: - that: zbxmediatype_sms_new.changed is sameas True - - - name: test - create new sms mediatype (again) - zabbix_mediatype: - gsm_modem: /dev/ttyS0 - register: zbxmediatype_sms_new - - - assert: - that: zbxmediatype_sms_new.changed is sameas False - - - name: test - update sms mediatype with concurrent settings - zabbix_mediatype: - gsm_modem: /dev/ttyS0 - max_sessions: 1 - max_attempts: 3 - attempt_interval: 30 - register: zbxmediatype_sms_concur - - - assert: - that: zbxmediatype_sms_concur.changed is sameas True - - - name: test - update sms mediatype with concurrent settings (again) - zabbix_mediatype: - gsm_modem: /dev/ttyS0 - max_sessions: 1 - max_attempts: 3 - attempt_interval: 30 - register: zbxmediatype_sms_concur - - - assert: - that: zbxmediatype_sms_concur.changed is sameas False - - - name: test - update sms mediatype with invalid max sessions (fail) - zabbix_mediatype: - gsm_modem: /dev/ttyS0 - max_sessions: 2 - register: zbxmediatype_sms_fail - ignore_errors: true - - - assert: + - name: test - create new sms mediatype + community.zabbix.zabbix_mediatype: + gsm_modem: /dev/ttyS0 + register: zbxmediatype_sms_new + + - ansible.builtin.assert: + that: zbxmediatype_sms_new.changed is sameas True + + - name: test - create new sms mediatype (again) + community.zabbix.zabbix_mediatype: + gsm_modem: /dev/ttyS0 + register: zbxmediatype_sms_new + + - ansible.builtin.assert: + that: zbxmediatype_sms_new.changed is sameas False + + - name: test - update sms mediatype with concurrent settings + community.zabbix.zabbix_mediatype: + gsm_modem: /dev/ttyS0 + max_sessions: 1 + max_attempts: 3 + attempt_interval: 30 + register: zbxmediatype_sms_concur + + - ansible.builtin.assert: + that: zbxmediatype_sms_concur.changed is sameas True + + - name: test - update sms mediatype with concurrent settings (again) + community.zabbix.zabbix_mediatype: + gsm_modem: /dev/ttyS0 + max_sessions: 1 + max_attempts: 3 + attempt_interval: 30 + register: zbxmediatype_sms_concur + + - ansible.builtin.assert: + that: zbxmediatype_sms_concur.changed is sameas False + + - name: test - update sms mediatype with invalid max sessions (fail) + community.zabbix.zabbix_mediatype: + gsm_modem: /dev/ttyS0 + max_sessions: 2 + register: zbxmediatype_sms_fail + ignore_errors: true + + - ansible.builtin.assert: that: zbxmediatype_sms_fail.failed is sameas True - - name: test - delete sms mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete + - name: test - delete sms mediatype + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete - - assert: - that: zbxmediatype_delete.changed is sameas True + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas True - name: test - email mediatypes module_defaults: @@ -439,150 +439,150 @@ webhook_script: "return 'Hello, world!';" block: - - name: test - create new webhook mediatype - zabbix_mediatype: - register: zbxmediatype_webhook_new - - - assert: - that: zbxmediatype_webhook_new.changed is sameas True - - - name: test - create new webhook mediatype (again) - zabbix_mediatype: - register: zbxmediatype_webhook_new - - - assert: - that: zbxmediatype_webhook_new.changed is sameas False - - - name: test - update webhook mediatype with process_tags - zabbix_mediatype: - process_tags: true - register: zbxmediatype_webhook_tags - - - assert: - that: zbxmediatype_webhook_tags.changed is sameas True - - - name: test - update webhook mediatype with process_tags (again) - zabbix_mediatype: - process_tags: true - register: zbxmediatype_webhook_tags - - - assert: - that: zbxmediatype_webhook_tags.changed is sameas False - - - name: test - update webhook mediatype with description - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - register: zbxmediatype_webhook_desc - - - assert: - that: zbxmediatype_webhook_desc.changed is sameas True - - - name: test - update webhook mediatype with description (again) - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - register: zbxmediatype_webhook_desc - - - assert: - that: zbxmediatype_webhook_desc.changed is sameas False - - - name: test - update webhook mediatype with event_menu without name and url (fail) - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - event_menu: true - register: zbxmediatype_webhook_eventmenu - ignore_errors: true - - - assert: - that: zbxmediatype_webhook_eventmenu.failed is sameas True - - - name: test - update webhook mediatype with event_menu - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - event_menu: true - event_menu_name: Example entry name - event_menu_url: '{EVENT.TAGS.__message_link}' - register: zbxmediatype_webhook_eventmenu - - - assert: - that: zbxmediatype_webhook_eventmenu.changed is sameas True - - - name: test - update webhook mediatype with event_menu (again) - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - event_menu: true - event_menu_name: Example entry name - event_menu_url: '{EVENT.TAGS.__message_link}' - register: zbxmediatype_webhook_eventmenu - - - assert: - that: zbxmediatype_webhook_eventmenu.changed is sameas False - - - name: test - reset webhook mediatype to default - zabbix_mediatype: - register: zbxmediatype_reset - - - assert: - that: zbxmediatype_reset.changed is sameas True - - - name: test - update webhook mediatype with webhook_params - zabbix_mediatype: - webhook_params: - - name: param1 - value: value1 - register: zbxmediatype_webhook_params - - - assert: - that: zbxmediatype_webhook_params.changed is sameas True - - - name: test - update webhook mediatype with webhook_params (again) - zabbix_mediatype: - webhook_params: - - name: param1 - value: value1 - register: zbxmediatype_webhook_params - - - assert: - that: zbxmediatype_webhook_params.changed is sameas False - - - name: test - update webhook mediatype with webhook_params (reorder) - zabbix_mediatype: - webhook_params: - - name: z.param2 - value: xyz - - name: param1 - value: value1 - - name: b.param3 - - name: a.param4 - value: abc - register: zbxmediatype_webhook_params - - - assert: - that: zbxmediatype_webhook_params.changed is sameas True - - - name: test - update webhook mediatype with webhook_params (reorder again) - zabbix_mediatype: - webhook_params: - - name: param1 - value: value1 - - name: a.param4 - value: abc - - name: b.param3 - - name: z.param2 - value: xyz - register: zbxmediatype_webhook_params - - - assert: - that: zbxmediatype_webhook_params.changed is sameas False - - - name: test - delete webhook mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete - - - assert: - that: zbxmediatype_delete.changed is sameas True + - name: test - create new webhook mediatype + community.zabbix.zabbix_mediatype: + register: zbxmediatype_webhook_new + + - ansible.builtin.assert: + that: zbxmediatype_webhook_new.changed is sameas True + + - name: test - create new webhook mediatype (again) + community.zabbix.zabbix_mediatype: + register: zbxmediatype_webhook_new + + - ansible.builtin.assert: + that: zbxmediatype_webhook_new.changed is sameas False + + - name: test - update webhook mediatype with process_tags + community.zabbix.zabbix_mediatype: + process_tags: true + register: zbxmediatype_webhook_tags + + - ansible.builtin.assert: + that: zbxmediatype_webhook_tags.changed is sameas True + + - name: test - update webhook mediatype with process_tags (again) + community.zabbix.zabbix_mediatype: + process_tags: true + register: zbxmediatype_webhook_tags + + - ansible.builtin.assert: + that: zbxmediatype_webhook_tags.changed is sameas False + + - name: test - update webhook mediatype with description + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + register: zbxmediatype_webhook_desc + + - ansible.builtin.assert: + that: zbxmediatype_webhook_desc.changed is sameas True + + - name: test - update webhook mediatype with description (again) + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + register: zbxmediatype_webhook_desc + + - ansible.builtin.assert: + that: zbxmediatype_webhook_desc.changed is sameas False + + - name: test - update webhook mediatype with event_menu without name and url (fail) + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + event_menu: true + register: zbxmediatype_webhook_eventmenu + ignore_errors: true + + - ansible.builtin.assert: + that: zbxmediatype_webhook_eventmenu.failed is sameas True + + - name: test - update webhook mediatype with event_menu + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + event_menu: true + event_menu_name: Example entry name + event_menu_url: "{EVENT.TAGS.__message_link}" + register: zbxmediatype_webhook_eventmenu + + - ansible.builtin.assert: + that: zbxmediatype_webhook_eventmenu.changed is sameas True + + - name: test - update webhook mediatype with event_menu (again) + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + event_menu: true + event_menu_name: Example entry name + event_menu_url: "{EVENT.TAGS.__message_link}" + register: zbxmediatype_webhook_eventmenu + + - ansible.builtin.assert: + that: zbxmediatype_webhook_eventmenu.changed is sameas False + + - name: test - reset webhook mediatype to default + community.zabbix.zabbix_mediatype: + register: zbxmediatype_reset + + - ansible.builtin.assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update webhook mediatype with webhook_params + community.zabbix.zabbix_mediatype: + webhook_params: + - name: param1 + value: value1 + register: zbxmediatype_webhook_params + + - ansible.builtin.assert: + that: zbxmediatype_webhook_params.changed is sameas True + + - name: test - update webhook mediatype with webhook_params (again) + community.zabbix.zabbix_mediatype: + webhook_params: + - name: param1 + value: value1 + register: zbxmediatype_webhook_params + + - ansible.builtin.assert: + that: zbxmediatype_webhook_params.changed is sameas False + + - name: test - update webhook mediatype with webhook_params (reorder) + community.zabbix.zabbix_mediatype: + webhook_params: + - name: z.param2 + value: xyz + - name: param1 + value: value1 + - name: b.param3 + - name: a.param4 + value: abc + register: zbxmediatype_webhook_params + + - ansible.builtin.assert: + that: zbxmediatype_webhook_params.changed is sameas True + + - name: test - update webhook mediatype with webhook_params (reorder again) + community.zabbix.zabbix_mediatype: + webhook_params: + - name: param1 + value: value1 + - name: a.param4 + value: abc + - name: b.param3 + - name: z.param2 + value: xyz + register: zbxmediatype_webhook_params + + - ansible.builtin.assert: + that: zbxmediatype_webhook_params.changed is sameas False + + - name: test - delete webhook mediatype + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas True diff --git a/tests/integration/targets/test_zabbix_module_defaults_group/tasks/main.yml b/tests/integration/targets/test_zabbix_module_defaults_group/tasks/main.yml index 5b861810a..04b19f2d4 100644 --- a/tests/integration/targets/test_zabbix_module_defaults_group/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_module_defaults_group/tasks/main.yml @@ -7,11 +7,11 @@ state: present block: - name: Create host group - zabbix_group: + community.zabbix.zabbix_group: register: _grp - name: Create host - zabbix_host: + community.zabbix.zabbix_host: host_name: Example Host interfaces: - type: agent @@ -20,7 +20,7 @@ register: _host - name: Assert that resources were correctly created - assert: + ansible.builtin.assert: that: - _grp is changed - _host is changed @@ -33,16 +33,16 @@ state: absent block: - name: Delete host - zabbix_host: + community.zabbix.zabbix_host: host_name: Example Host register: _host - name: Delete host group - zabbix_group: + community.zabbix.zabbix_group: register: _grp - name: Assert that resources were correctly deleted - assert: + ansible.builtin.assert: that: - _grp is changed - _host is changed diff --git a/tests/integration/targets/test_zabbix_proxy/tasks/main.yml b/tests/integration/targets/test_zabbix_proxy/tasks/main.yml index a91228498..86ece24f3 100644 --- a/tests/integration/targets/test_zabbix_proxy/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_proxy/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - create new passive Zabbix proxy server - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -13,11 +13,11 @@ register: zbxproxy_new - name: assert that proxy was created - assert: + ansible.builtin.assert: that: zbxproxy_new is changed - name: test - create same passive Zabbix proxy server - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -30,11 +30,11 @@ register: zbxproxy_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_existing is changed - name: test - update Zabbix proxy server description - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -47,11 +47,11 @@ register: zbxproxy_desc_update - name: assert that description has been updated - assert: + ansible.builtin.assert: that: zbxproxy_desc_update is changed - name: test - update Zabbix proxy server interface - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -64,11 +64,11 @@ register: zbxproxy_interface_update - name: assert that interface has been updated - assert: + ansible.builtin.assert: that: zbxproxy_interface_update is changed - name: test - update Zabbix proxy server description & interface (again) - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -81,11 +81,11 @@ register: zbxproxy_desc_interface_update - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_desc_interface_update is changed - name: test - update Zabbix proxy server interface to use only ip - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -97,11 +97,11 @@ register: zbxproxy_interface_onlyip - name: assert that interface has been updated - assert: + ansible.builtin.assert: that: zbxproxy_interface_onlyip is changed - name: test - update Zabbix proxy server interface to use only ip again - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -113,11 +113,11 @@ register: zbxproxy_interface_onlyip_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_interface_onlyip_again is changed - name: test - update Zabbix proxy server interface to use only dns - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -129,11 +129,11 @@ register: zbxproxy_interface_onlydns - name: assert that interface has been updated - assert: + ansible.builtin.assert: that: zbxproxy_interface_onlydns is changed - name: test - update Zabbix proxy server interface to use only dns again - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -145,11 +145,11 @@ register: zbxproxy_interface_onlydns_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_interface_onlydns_again is changed - name: test - update Zabbix proxy server interface to fail - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -162,11 +162,11 @@ ignore_errors: true - name: assert that module has failed - assert: + ansible.builtin.assert: that: zbxproxy_interface_fail is failed - name: test - update Zabbix proxy server to be active - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -174,11 +174,11 @@ register: zbxproxy_active_update - name: assert that proxy was updated - assert: + ansible.builtin.assert: that: zbxproxy_active_update is changed - name: test - update Zabbix proxy server to be active (again) - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -186,11 +186,11 @@ register: zbxproxy_active_update_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_active_update_again is changed - name: test - update Zabbix proxy server to be active and use proxy_address - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -199,11 +199,11 @@ register: zbxproxy_active_proxyaddress - name: assert that proxy was updated - assert: + ansible.builtin.assert: that: zbxproxy_active_proxyaddress is changed - name: test - update Zabbix proxy server to be active use proxy_address (again) - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -212,11 +212,11 @@ register: zbxproxy_active_proxyaddress_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_active_proxyaddress_again is changed - name: test - update Zabbix proxy server to use encryption - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -228,11 +228,11 @@ register: zbxproxy_encryption - name: assert that encryption has been enabled - assert: + ansible.builtin.assert: that: zbxproxy_encryption is changed - name: test - update Zabbix proxy server to use encryption (again) - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -244,11 +244,11 @@ register: zbxproxy_encryption_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: zbxproxy_encryption_again is changed - name: test - update Zabbix proxy server encryption settings - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -260,11 +260,11 @@ register: zbxproxy_encryption_update - name: assert that encryption has been updated - assert: + ansible.builtin.assert: that: zbxproxy_encryption_update is changed - name: test - update Zabbix proxy server back to being passive - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -277,25 +277,25 @@ register: zbxproxy_passive_update - name: assert that proxy was updated - assert: + ansible.builtin.assert: that: zbxproxy_passive_update is changed - name: test - delete Zabbix proxy server - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 state: absent register: zbxproxy_delete - name: assert that proxy has been deleted - assert: + ansible.builtin.assert: that: zbxproxy_delete is changed - name: test - delete Zabbix proxy server (again) - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 state: absent register: zbxproxy_delete_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_delete_again is changed diff --git a/tests/integration/targets/test_zabbix_proxy_info/tasks/main.yml b/tests/integration/targets/test_zabbix_proxy_info/tasks/main.yml index a5feb2731..ddd101850 100644 --- a/tests/integration/targets/test_zabbix_proxy_info/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_proxy_info/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - Create new Zabbix proxy - zabbix_proxy: + community.zabbix.zabbix_proxy: state: present proxy_name: ExampleProxy description: ExampleProxy @@ -12,12 +12,12 @@ dns: ExampleProxy.local register: create_proxy_result -- assert: +- ansible.builtin.assert: that: - create_proxy_result.changed is sameas true - name: test - Create new Zabbix host monitored by the proxy - zabbix_host: + community.zabbix.zabbix_host: state: present host_name: ExampleHost host_groups: @@ -33,33 +33,33 @@ port: "10050" register: create_host_result -- assert: +- ansible.builtin.assert: that: - create_host_result.changed is sameas true - name: test - Get zabbix proxy information - zabbix_proxy_info: + community.zabbix.zabbix_proxy_info: proxy_name: ExampleProxy proxy_hosts: true register: get_proxy_info_result -- assert: +- ansible.builtin.assert: that: - - get_proxy_info_result["zabbix_proxy"].host == "ExampleProxy" - - get_proxy_info_result["zabbix_proxy"].hosts | length > 0 - - get_proxy_info_result["zabbix_proxy"].hosts[0].host == "ExampleHost" - - get_proxy_info_result["zabbix_proxy"].interface | length > 0 - - get_proxy_info_result["zabbix_proxy"].interface.ip == "10.1.1.2" - - get_proxy_info_result["zabbix_proxy"].interface.useip == "1" - - get_proxy_info_result["zabbix_proxy"].interface.port == "10051" - - get_proxy_info_result["zabbix_proxy"].interface.dns == "ExampleProxy.local" + - get_proxy_info_result["zabbix_proxy"].host == "ExampleProxy" + - get_proxy_info_result["zabbix_proxy"].hosts | length > 0 + - get_proxy_info_result["zabbix_proxy"].hosts[0].host == "ExampleHost" + - get_proxy_info_result["zabbix_proxy"].interface | length > 0 + - get_proxy_info_result["zabbix_proxy"].interface.ip == "10.1.1.2" + - get_proxy_info_result["zabbix_proxy"].interface.useip == "1" + - get_proxy_info_result["zabbix_proxy"].interface.port == "10051" + - get_proxy_info_result["zabbix_proxy"].interface.dns == "ExampleProxy.local" - name: test - cleanup test Zabbix host - zabbix_host: + community.zabbix.zabbix_host: state: absent host_name: ExampleHost - name: test - cleanup test Zabbix proxy - zabbix_proxy: + community.zabbix.zabbix_proxy: state: absent proxy_name: ExampleProxy diff --git a/tests/integration/targets/test_zabbix_regexp/tasks/main.yml b/tests/integration/targets/test_zabbix_regexp/tasks/main.yml index 2c6595fc5..8e2afc02d 100644 --- a/tests/integration/targets/test_zabbix_regexp/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_regexp/tasks/main.yml @@ -7,7 +7,7 @@ name: Unsupport Zabbix version (<6.0) block: - name: test - fail to update regexp setting - zabbix_regexp: + community.zabbix.zabbix_regexp: name: File systems for discovery test_string: ext3 expressions: @@ -16,14 +16,14 @@ ignore_errors: true register: zbxauth_update - - assert: + - ansible.builtin.assert: that: zbxauth_update.failed is sameas True - when: zabbix_version is version('6.0', '>=') name: support Zabbix version (>=6.0) block: - name: test - try to update regexp (present) - zabbix_regexp: + community.zabbix.zabbix_regexp: name: File systems for discovery test_string: ext3 expressions: @@ -32,25 +32,24 @@ register: zbxregexp_update - name: assert that regexp was NOT updated - assert: + ansible.builtin.assert: that: - zbxregexp_update.changed is sameas False - name: test - try to delete regexp - zabbix_regexp: + community.zabbix.zabbix_regexp: name: File systems for discovery state: absent register: zbxregexp_update - name: assert that regexp was deleted - assert: + ansible.builtin.assert: that: - zbxregexp_update.changed is sameas True - zbxregexp_update.msg == "Successfully deleted regular expression setting." - - name: test - try to create regexp - zabbix_regexp: + community.zabbix.zabbix_regexp: name: File systems for discovery test_string: ext3 expressions: @@ -59,13 +58,13 @@ register: zbxregexp_update - name: assert that regexp was created - assert: + ansible.builtin.assert: that: - zbxregexp_update.changed is sameas True - zbxregexp_update.msg == "Successfully created regular expression setting." - name: test - try to update regexp - zabbix_regexp: + community.zabbix.zabbix_regexp: name: File systems for discovery test_string: ext3 expressions: @@ -74,7 +73,7 @@ - expression: "update/delete" expression_type: any_character_string_included case_sensitive: true - exp_delimiter: '/' + exp_delimiter: "/" - expression: "failed" expression_type: character_string_not_included - expression: "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$" @@ -84,20 +83,20 @@ register: zbxregexp_update - name: assert that regexp was updated - assert: + ansible.builtin.assert: that: - zbxregexp_update.changed is sameas True - zbxregexp_update.msg == "Successfully updated regular expression setting." - name: test - try to update regexp (will not update) - zabbix_regexp: + community.zabbix.zabbix_regexp: name: File systems for discovery test_string: ext3 expressions: - expression: "update/delete" expression_type: any_character_string_included case_sensitive: true - exp_delimiter: '/' + exp_delimiter: "/" - expression: "create" expression_type: character_string_included - expression: "failed" @@ -109,6 +108,6 @@ register: zbxregexp_update - name: assert that regexp was updated - assert: + ansible.builtin.assert: that: - zbxregexp_update.changed is sameas False diff --git a/tests/integration/targets/test_zabbix_script/tasks/main.yml b/tests/integration/targets/test_zabbix_script/tasks/main.yml index 3bc160097..4c5ea8a4c 100644 --- a/tests/integration/targets/test_zabbix_script/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_script/tasks/main.yml @@ -5,339 +5,339 @@ name: Test action operation script scope: action_operation script_type: webhook - command: 'return 0' + command: "return 0" description: "Test action operation script" state: present block: - - name: test - Create new action operation script to execute webhook check mode - zabbix_script: - check_mode: true - register: create_action_check_mode_result - - - assert: - that: - - create_action_check_mode_result.changed is sameas true - - - name: test - Create new action operation script to execute webhook - zabbix_script: - register: create_action_result - - - assert: - that: - - create_action_result.changed is sameas true - - - name: test - Create new action operation script to execute webhook again - zabbix_script: - register: create_action_again_result - - - assert: - that: - - create_action_again_result.changed is sameas false - - - name: test - Update action operation script to execute webhook with host group - zabbix_script: - host_group: 'Discovered hosts' - register: update_action_host_group_result - - - assert: - that: - - update_action_host_group_result.changed is sameas true - - - name: test - Update action operation script to execute webhook with host group again - zabbix_script: - host_group: 'Discovered hosts' - register: update_action_host_group_again_result - - - assert: - that: - - update_action_host_group_again_result.changed is sameas false - - - name: test - Update action operation script to execute webhook with parameters - zabbix_script: - host_group: 'Discovered hosts' - parameters: - - name: param_name1 - register: update_action_param_result - - - assert: - that: - - update_action_param_result.changed is sameas true - - - name: test - Update action operation script to execute webhook with parameters again - zabbix_script: - host_group: 'Discovered hosts' - parameters: - - name: param_name1 - register: update_action_param_again_result - - - assert: - that: - - update_action_param_again_result.changed is sameas false - - - name: test - Update action operation script to execute webhook with parameters and value - zabbix_script: - host_group: 'Discovered hosts' - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: update_action_param_value_result - - - assert: - that: - - update_action_param_value_result.changed is sameas true - - - name: test - Update action operation script to execute webhook with parameters and value again - zabbix_script: - host_group: 'Discovered hosts' - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: update_action_param_value_again_result - - - assert: - that: - - update_action_param_value_again_result.changed is sameas false - - - name: test - Update action operation script remove host group - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: update_action_no_host_group_result - - - assert: - that: - - update_action_no_host_group_result.changed is sameas true - - - name: test - Update action operation script remove host group again - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: update_action_no_host_group_again_result - - - assert: - that: - - update_action_no_host_group_again_result.changed is sameas false - - - name: test - Update action operation script to type Script - zabbix_script: - script_type: script - execute_on: zabbix_agent - command: echo 1 - register: update_action_script_result - - - assert: - that: - - update_action_script_result.changed is sameas true - - - name: test - Update action operation script to type Script again - zabbix_script: - script_type: script - execute_on: zabbix_agent - command: echo 1 - register: update_action_script_again_result - - - assert: - that: - - update_action_script_again_result.changed is sameas false - - - name: test - Update action operation script to execute on server - zabbix_script: - script_type: script - execute_on: zabbix_server - command: echo 1 - register: update_action_script_server_result - - - assert: - that: - - update_action_script_server_result.changed is sameas true - - - name: test - Update action operation script to execute on server again - zabbix_script: - script_type: script - execute_on: zabbix_server - command: echo 1 - register: update_action_script_server_again_result - - - assert: - that: - - update_action_script_server_again_result.changed is sameas false - - - name: test - Update action operation script to execute on server or proxy - zabbix_script: - script_type: script - execute_on: zabbix_server_proxy - command: echo 1 - register: update_action_script_server_proxy_result - - - assert: - that: - - update_action_script_server_proxy_result.changed is sameas true - - - name: test - Update action operation script to execute on server or proxy again - zabbix_script: - script_type: script - execute_on: zabbix_server_proxy - command: echo 1 - register: update_action_script_server_proxy_again_result - - - assert: - that: - - update_action_script_server_proxy_again_result.changed is sameas false - - - name: test - Update action operation script to type SSH - zabbix_script: - script_type: ssh - authtype: password - username: bla - password: blabla - command: echo 2 - register: update_action_script_ssh_result - - - assert: - that: - - update_action_script_ssh_result.changed is sameas true - - - name: test - Update action operation script to type SSH again - zabbix_script: - script_type: ssh - authtype: password - username: bla - password: blabla - command: echo 2 - register: update_action_script_ssh_again_result - - - assert: - that: - - update_action_script_ssh_again_result.changed is sameas false - - - name: test - Update action operation script type SSH key auth - zabbix_script: - script_type: ssh - authtype: public_key - username: bla - publickey: blabla - privatekey: blablabla - command: echo 3 - register: update_action_script_ssh_authkey_result - - - assert: - that: - - update_action_script_ssh_authkey_result.changed is sameas true - - - name: test - Update action operation script type SSH key auth again - zabbix_script: - script_type: ssh - authtype: public_key - username: bla - publickey: blabla - privatekey: blablabla - command: echo 3 - register: update_action_script_ssh_authkey_again_result - - - assert: - that: - - update_action_script_ssh_authkey_again_result.changed is sameas false - - - name: test - Update action operation script type SSH add port - zabbix_script: - script_type: ssh - authtype: public_key - username: bla - publickey: blabla - privatekey: blablabla - command: echo 3 - port: 222 - register: update_action_script_ssh_port_result - - - assert: - that: - - update_action_script_ssh_port_result.changed is sameas true - - - name: test - Update action operation script type SSH add port again - zabbix_script: - script_type: ssh - authtype: public_key - username: bla - publickey: blabla - privatekey: blablabla - command: echo 3 - port: 222 - register: update_action_script_ssh_port_again_result - - - assert: - that: - - update_action_script_ssh_port_again_result.changed is sameas false - - - name: test - Update action operation script to type Telnet - zabbix_script: - script_type: telnet - username: bla1 - password: blabla1 - command: echo 4 - port: 223 - register: update_action_script_telnet_result - - - assert: - that: - - update_action_script_telnet_result.changed is sameas true - - - name: test - Update action operation script to type Telnet again - zabbix_script: - script_type: telnet - username: bla1 - password: blabla1 - command: echo 4 - port: 223 - register: update_action_script_telnet_again_result - - - assert: - that: - - update_action_script_telnet_again_result.changed is sameas false - - - name: test - Update action operation script to type IPMI - zabbix_script: - script_type: ipmi - command: echo 5 - register: update_action_script_ipmi_result - - - assert: - that: - - update_action_script_ipmi_result.changed is sameas true - - - name: test - Update action operation script to type IPMI again - zabbix_script: - script_type: ipmi - command: echo 5 - register: update_action_script_ipmi_again_result - - - assert: - that: - - update_action_script_ipmi_again_result.changed is sameas false - - - name: test - Delete action operation script - zabbix_script: - state: absent - register: delete_action_result - - - assert: - that: - - delete_action_result.changed is sameas true - - - name: test - Delete action operation script again - zabbix_script: - state: absent - register: delete_action_again_result - - - assert: - that: - - delete_action_again_result.changed is sameas false + - name: test - Create new action operation script to execute webhook check mode + zabbix_script: + check_mode: true + register: create_action_check_mode_result + + - assert: + that: + - create_action_check_mode_result.changed is sameas true + + - name: test - Create new action operation script to execute webhook + zabbix_script: + register: create_action_result + + - assert: + that: + - create_action_result.changed is sameas true + + - name: test - Create new action operation script to execute webhook again + zabbix_script: + register: create_action_again_result + + - assert: + that: + - create_action_again_result.changed is sameas false + + - name: test - Update action operation script to execute webhook with host group + zabbix_script: + host_group: "Discovered hosts" + register: update_action_host_group_result + + - assert: + that: + - update_action_host_group_result.changed is sameas true + + - name: test - Update action operation script to execute webhook with host group again + zabbix_script: + host_group: "Discovered hosts" + register: update_action_host_group_again_result + + - assert: + that: + - update_action_host_group_again_result.changed is sameas false + + - name: test - Update action operation script to execute webhook with parameters + zabbix_script: + host_group: "Discovered hosts" + parameters: + - name: param_name1 + register: update_action_param_result + + - assert: + that: + - update_action_param_result.changed is sameas true + + - name: test - Update action operation script to execute webhook with parameters again + zabbix_script: + host_group: "Discovered hosts" + parameters: + - name: param_name1 + register: update_action_param_again_result + + - assert: + that: + - update_action_param_again_result.changed is sameas false + + - name: test - Update action operation script to execute webhook with parameters and value + zabbix_script: + host_group: "Discovered hosts" + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: update_action_param_value_result + + - assert: + that: + - update_action_param_value_result.changed is sameas true + + - name: test - Update action operation script to execute webhook with parameters and value again + zabbix_script: + host_group: "Discovered hosts" + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: update_action_param_value_again_result + + - assert: + that: + - update_action_param_value_again_result.changed is sameas false + + - name: test - Update action operation script remove host group + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: update_action_no_host_group_result + + - assert: + that: + - update_action_no_host_group_result.changed is sameas true + + - name: test - Update action operation script remove host group again + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: update_action_no_host_group_again_result + + - assert: + that: + - update_action_no_host_group_again_result.changed is sameas false + + - name: test - Update action operation script to type Script + zabbix_script: + script_type: script + execute_on: zabbix_agent + command: echo 1 + register: update_action_script_result + + - assert: + that: + - update_action_script_result.changed is sameas true + + - name: test - Update action operation script to type Script again + zabbix_script: + script_type: script + execute_on: zabbix_agent + command: echo 1 + register: update_action_script_again_result + + - assert: + that: + - update_action_script_again_result.changed is sameas false + + - name: test - Update action operation script to execute on server + zabbix_script: + script_type: script + execute_on: zabbix_server + command: echo 1 + register: update_action_script_server_result + + - assert: + that: + - update_action_script_server_result.changed is sameas true + + - name: test - Update action operation script to execute on server again + zabbix_script: + script_type: script + execute_on: zabbix_server + command: echo 1 + register: update_action_script_server_again_result + + - assert: + that: + - update_action_script_server_again_result.changed is sameas false + + - name: test - Update action operation script to execute on server or proxy + zabbix_script: + script_type: script + execute_on: zabbix_server_proxy + command: echo 1 + register: update_action_script_server_proxy_result + + - assert: + that: + - update_action_script_server_proxy_result.changed is sameas true + + - name: test - Update action operation script to execute on server or proxy again + zabbix_script: + script_type: script + execute_on: zabbix_server_proxy + command: echo 1 + register: update_action_script_server_proxy_again_result + + - assert: + that: + - update_action_script_server_proxy_again_result.changed is sameas false + + - name: test - Update action operation script to type SSH + zabbix_script: + script_type: ssh + authtype: password + username: bla + password: blabla + command: echo 2 + register: update_action_script_ssh_result + + - assert: + that: + - update_action_script_ssh_result.changed is sameas true + + - name: test - Update action operation script to type SSH again + zabbix_script: + script_type: ssh + authtype: password + username: bla + password: blabla + command: echo 2 + register: update_action_script_ssh_again_result + + - assert: + that: + - update_action_script_ssh_again_result.changed is sameas false + + - name: test - Update action operation script type SSH key auth + zabbix_script: + script_type: ssh + authtype: public_key + username: bla + publickey: blabla + privatekey: blablabla + command: echo 3 + register: update_action_script_ssh_authkey_result + + - assert: + that: + - update_action_script_ssh_authkey_result.changed is sameas true + + - name: test - Update action operation script type SSH key auth again + zabbix_script: + script_type: ssh + authtype: public_key + username: bla + publickey: blabla + privatekey: blablabla + command: echo 3 + register: update_action_script_ssh_authkey_again_result + + - assert: + that: + - update_action_script_ssh_authkey_again_result.changed is sameas false + + - name: test - Update action operation script type SSH add port + zabbix_script: + script_type: ssh + authtype: public_key + username: bla + publickey: blabla + privatekey: blablabla + command: echo 3 + port: 222 + register: update_action_script_ssh_port_result + + - assert: + that: + - update_action_script_ssh_port_result.changed is sameas true + + - name: test - Update action operation script type SSH add port again + zabbix_script: + script_type: ssh + authtype: public_key + username: bla + publickey: blabla + privatekey: blablabla + command: echo 3 + port: 222 + register: update_action_script_ssh_port_again_result + + - assert: + that: + - update_action_script_ssh_port_again_result.changed is sameas false + + - name: test - Update action operation script to type Telnet + zabbix_script: + script_type: telnet + username: bla1 + password: blabla1 + command: echo 4 + port: 223 + register: update_action_script_telnet_result + + - assert: + that: + - update_action_script_telnet_result.changed is sameas true + + - name: test - Update action operation script to type Telnet again + zabbix_script: + script_type: telnet + username: bla1 + password: blabla1 + command: echo 4 + port: 223 + register: update_action_script_telnet_again_result + + - assert: + that: + - update_action_script_telnet_again_result.changed is sameas false + + - name: test - Update action operation script to type IPMI + zabbix_script: + script_type: ipmi + command: echo 5 + register: update_action_script_ipmi_result + + - assert: + that: + - update_action_script_ipmi_result.changed is sameas true + + - name: test - Update action operation script to type IPMI again + zabbix_script: + script_type: ipmi + command: echo 5 + register: update_action_script_ipmi_again_result + + - assert: + that: + - update_action_script_ipmi_again_result.changed is sameas false + + - name: test - Delete action operation script + zabbix_script: + state: absent + register: delete_action_result + + - assert: + that: + - delete_action_result.changed is sameas true + + - name: test - Delete action operation script again + zabbix_script: + state: absent + register: delete_action_again_result + + - assert: + that: + - delete_action_again_result.changed is sameas false - name: test - Test manual host action script module_defaults: @@ -345,125 +345,125 @@ name: Test manual host action script scope: manual_host_action script_type: webhook - command: 'return 0' + command: "return 0" description: "Test manual host action script" state: present block: - - name: test - Create new manual host action script to execute webhook check mode - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - check_mode: true - register: create_action_check_mode_result - - - assert: - that: - - create_action_check_mode_result.changed is sameas true - - - name: test - Create new manual host action script to execute webhook - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: create_action_result - - - assert: - that: - - create_action_result.changed is sameas true - - - name: test - Create new manual host action script to execute webhook again - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: create_action_again_result - - - assert: - that: - - create_action_again_result.changed is sameas false - - - name: test - Update manual host action script with menu path - zabbix_script: - menu_path: menu/submenu - register: update_action_result - - - assert: - that: - - update_action_result.changed is sameas true - - - name: test - Update manual host action script with menu path again - zabbix_script: - menu_path: menu/submenu - register: update_action_again_result - - - assert: - that: - - update_action_again_result.changed is sameas false - - - name: test - Update manual host action script with user group - zabbix_script: - menu_path: menu/submenu - user_group: Guests - register: update_action_usrgrp_result - - - assert: - that: - - update_action_usrgrp_result.changed is sameas true - - - name: test - Update manual host action script with user group again - zabbix_script: - menu_path: menu/submenu - user_group: Guests - register: update_action_usrgrp_again_result - - - assert: - that: - - update_action_usrgrp_again_result.changed is sameas false - - - name: test - Update manual host action script with Write permissions - zabbix_script: - host_access: write - register: update_action_host_perms_result - - - assert: - that: - - update_action_host_perms_result.changed is sameas true - - - name: test - Update manual host action script with Write permissions again - zabbix_script: - host_access: write - register: update_action_host_perms_again_result - - - assert: - that: - - update_action_host_perms_again_result.changed is sameas false - - - name: test - Update manual host action script with confirmation - zabbix_script: - confirmation: 'Are you sure?' - register: update_action_host_confirm_result - - - assert: - that: - - update_action_host_confirm_result.changed is sameas true - - - name: test - Update manual host action script with confirmation again - zabbix_script: - confirmation: 'Are you sure?' - register: update_action_host_confirm_again_result - - - assert: - that: - - update_action_host_confirm_again_result.changed is sameas false - - - name: test - Delete manual host action script - zabbix_script: - state: absent + - name: test - Create new manual host action script to execute webhook check mode + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + check_mode: true + register: create_action_check_mode_result + + - assert: + that: + - create_action_check_mode_result.changed is sameas true + + - name: test - Create new manual host action script to execute webhook + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: create_action_result + + - assert: + that: + - create_action_result.changed is sameas true + + - name: test - Create new manual host action script to execute webhook again + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: create_action_again_result + + - assert: + that: + - create_action_again_result.changed is sameas false + + - name: test - Update manual host action script with menu path + zabbix_script: + menu_path: menu/submenu + register: update_action_result + + - assert: + that: + - update_action_result.changed is sameas true + + - name: test - Update manual host action script with menu path again + zabbix_script: + menu_path: menu/submenu + register: update_action_again_result + + - assert: + that: + - update_action_again_result.changed is sameas false + + - name: test - Update manual host action script with user group + zabbix_script: + menu_path: menu/submenu + user_group: Guests + register: update_action_usrgrp_result + + - assert: + that: + - update_action_usrgrp_result.changed is sameas true + + - name: test - Update manual host action script with user group again + zabbix_script: + menu_path: menu/submenu + user_group: Guests + register: update_action_usrgrp_again_result + + - assert: + that: + - update_action_usrgrp_again_result.changed is sameas false + + - name: test - Update manual host action script with Write permissions + zabbix_script: + host_access: write + register: update_action_host_perms_result + + - assert: + that: + - update_action_host_perms_result.changed is sameas true + + - name: test - Update manual host action script with Write permissions again + zabbix_script: + host_access: write + register: update_action_host_perms_again_result + + - assert: + that: + - update_action_host_perms_again_result.changed is sameas false + + - name: test - Update manual host action script with confirmation + zabbix_script: + confirmation: "Are you sure?" + register: update_action_host_confirm_result + + - assert: + that: + - update_action_host_confirm_result.changed is sameas true + + - name: test - Update manual host action script with confirmation again + zabbix_script: + confirmation: "Are you sure?" + register: update_action_host_confirm_again_result + + - assert: + that: + - update_action_host_confirm_again_result.changed is sameas false + + - name: test - Delete manual host action script + zabbix_script: + state: absent - name: test - Test manual event action script module_defaults: @@ -471,49 +471,49 @@ name: Test manual event action script scope: manual_event_action script_type: webhook - command: 'return 0' + command: "return 0" description: "Test manual event action script" state: present block: - - name: test - Create new manual event action script to execute webhook check mode - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - check_mode: true - register: create_action_check_mode_result - - - assert: - that: - - create_action_check_mode_result.changed is sameas true - - - name: test - Create new manual event action script to execute webhook - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: create_action_result - - - assert: - that: - - create_action_result.changed is sameas true - - - name: test - Create new manual event action script to execute webhook again - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - diff: true - register: create_action_again_result - - - assert: - that: - - create_action_again_result.changed is sameas false - - - name: test - Delete manual host action script - zabbix_script: - state: absent + - name: test - Create new manual event action script to execute webhook check mode + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + check_mode: true + register: create_action_check_mode_result + + - assert: + that: + - create_action_check_mode_result.changed is sameas true + + - name: test - Create new manual event action script to execute webhook + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: create_action_result + + - assert: + that: + - create_action_result.changed is sameas true + + - name: test - Create new manual event action script to execute webhook again + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + diff: true + register: create_action_again_result + + - assert: + that: + - create_action_again_result.changed is sameas false + + - name: test - Delete manual host action script + zabbix_script: + state: absent diff --git a/tests/integration/targets/test_zabbix_service/tasks/main.yml b/tests/integration/targets/test_zabbix_service/tasks/main.yml index a6f04a933..03501a43b 100644 --- a/tests/integration/targets/test_zabbix_service/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_service/tasks/main.yml @@ -10,59 +10,59 @@ block: - name: "test - Create a new service with check_mode" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule check_mode: true register: create_service_check_mode_result - - assert: + - ansible.builtin.assert: that: - create_service_check_mode_result.changed is sameas true - name: "test - Create a new service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule register: create_service_result - - assert: + - ansible.builtin.assert: that: - create_service_result.changed is sameas true - name: "test - Create a new service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule register: create_service_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_service_idempotency_check_result.changed is sameas false - name: "test - Update service add service tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName1 value: TagValue1 register: update_service_stags_result - - assert: + - ansible.builtin.assert: that: - update_service_stags_result.changed is sameas true - name: "test - Update service with service tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName1 value: TagValue1 register: update_service_stags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_stags_idempotency_check_result.changed is sameas false - name: "test - Update service add more service tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName1 @@ -71,12 +71,12 @@ value: TagValue2 register: update_service_more_stags_result - - assert: + - ansible.builtin.assert: that: - update_service_more_stags_result.changed is sameas true - name: "test - Update service add more service tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName1 @@ -85,41 +85,41 @@ value: TagValue2 register: update_service_more_stags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_more_stags_idempotency_check_result.changed is sameas false - name: "test - Update service remove service tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName2 value: TagValue2 register: update_service_less_stags_result - - assert: + - ansible.builtin.assert: that: - update_service_less_stags_result.changed is sameas true - name: "test - Update service remove service tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName2 value: TagValue2 register: update_service_less_stags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_less_stags_idempotency_check_result.changed is sameas false - name: "test - Delete service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule state: absent - name: "test - Create service with one problem tag" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -127,12 +127,12 @@ value: TagValue1 register: create_service_with_ptag_result - - assert: + - ansible.builtin.assert: that: - create_service_with_ptag_result.changed is sameas true - name: "test - Create service with one problem tag (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -141,7 +141,7 @@ register: create_service_with_ptag_idempotency_check_result - name: "test - Update service with problem tag without operator" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -151,12 +151,12 @@ value: TagValue2 register: update_service_with_ptag_woop_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_woop_result.changed is sameas true - name: "test - Update service with problem tag without operator (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -166,12 +166,12 @@ value: TagValue2 register: update_service_with_ptag_woop_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_woop_idempotency_check_result.changed is sameas false - name: "test - Update service with problem tag with like operator" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -184,12 +184,12 @@ value: TagValue3 register: update_service_with_ptag_wlikeop_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_wlikeop_result.changed is sameas true - name: "test - Update service with problem tag with like operator (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -202,12 +202,12 @@ value: TagValue3 register: update_service_with_ptag_wlikeop_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_wlikeop_idempotency_check_result.changed is sameas false - name: "test - Update service with problem tag without operator and without value" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -221,12 +221,12 @@ - tag: TagName4 register: update_service_with_ptag_woov_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_woov_result.changed is sameas true - name: "test - Update service with problem tag without operator and without value (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -240,12 +240,12 @@ - tag: TagName4 register: update_service_with_ptag_woov_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_woov_idempotency_check_result.changed is sameas false - name: "test - Update service remove problem tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -256,12 +256,12 @@ value: TagValue3 register: update_service_remove_tags_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_tags_result.changed is sameas true - name: "test - Update service remove problem tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -272,237 +272,237 @@ value: TagValue3 register: update_service_remove_tags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_tags_idempotency_check_result.changed is sameas false - name: "test - Update service remove all problem tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule register: update_service_remove_all_tags_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_all_tags_result.changed is sameas true - name: "test - Update service remove all problem tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule register: update_service_remove_all_tags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_all_tags_idempotency_check_result.changed is sameas false - name: "test - Create a new child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule sortorder: 10 parents: - ExampleServiceForServiceModule register: create_child_service_result - - assert: + - ansible.builtin.assert: that: - create_child_service_result.changed is sameas true - name: "test - Create a new child service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule sortorder: 10 parents: - ExampleServiceForServiceModule register: create_child_service_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_child_service_idempotency_check_result.changed is sameas false - name: "test - Update child service to remove parent" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: [] register: update_child_service_delete_parent_result - - assert: + - ansible.builtin.assert: that: - update_child_service_delete_parent_result.changed is sameas true - name: "test - Create a new parent service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule - name: "test - Delete child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule state: absent - name: "test - Create a new child service with two parents" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: - ExampleServiceForServiceModule - ExampleParentServiceForServiceModule register: create_child_service_two_parents_result - - assert: + - ansible.builtin.assert: that: - create_child_service_two_parents_result.changed is sameas true - name: "test - Create a new child service with two parents (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: - ExampleServiceForServiceModule - ExampleParentServiceForServiceModule register: create_child_service_two_parents_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_child_service_two_parents_idempotency_check_result.changed is sameas false - name: "test - Remove one parent from new child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: - ExampleParentServiceForServiceModule register: update_child_service_remove_parent_result - - assert: + - ansible.builtin.assert: that: - update_child_service_remove_parent_result.changed is sameas true - name: "test - Remove one parent from new child service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: - ExampleParentServiceForServiceModule register: update_child_service_remove_parent_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_child_service_remove_parent_idempotency_check_result.changed is sameas false - name: "test - Delete parent service 2" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule state: absent - name: "test - Create parent service with child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule register: create_parent_service_with_child_result - - assert: + - ansible.builtin.assert: that: - create_parent_service_with_child_result.changed is sameas true - name: "test - Create parent service with child service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule register: create_parent_service_with_child_result_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_parent_service_with_child_result_idempotency_check_result.changed is sameas false - name: "test - Create second chile service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule2 - name: "test - Update parent service with the second child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule - ExampleChildServiceForServiceModule2 register: update_parent_service_with_second_child_result - - assert: + - ansible.builtin.assert: that: - update_parent_service_with_second_child_result.changed is sameas true - name: "test - Update parent service with the second child service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule - ExampleChildServiceForServiceModule2 register: update_parent_service_with_second_child_result_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_parent_service_with_second_child_result_idempotency_check_result.changed is sameas false - name: "test - Delete parent service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule state: absent - name: "test - Create parent service with two child services" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule - ExampleChildServiceForServiceModule2 register: create_parent_service_with_two_children_result - - assert: + - ansible.builtin.assert: that: - create_parent_service_with_two_children_result.changed is sameas true - name: "test - Create parent service with child services (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule - ExampleChildServiceForServiceModule2 register: create_parent_service_with_two_children_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_parent_service_with_two_children_idempotency_check_result.changed is sameas false - name: "test - Delete parent service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule state: absent - name: "test - Delete child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule state: absent - name: "test - Delete child servicei 2" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule2 state: absent - name: "test - Delete new service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule state: absent register: delete_service_result - - assert: + - ansible.builtin.assert: that: - delete_service_result.changed is sameas true - name: "test - Delete new service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule state: absent register: delete_service_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - delete_service_idempotency_check_result.changed is sameas false - name: "test - Create a new service with status rule" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_n_child_services_have_status_or_above @@ -511,12 +511,12 @@ new_status: not_classified register: create_service_sr_result - - assert: + - ansible.builtin.assert: that: - create_service_sr_result.changed is sameas true - name: "test - Create a new service with status rule (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_n_child_services_have_status_or_above @@ -525,12 +525,12 @@ new_status: not_classified register: create_service_sr_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_service_sr_idempotency_check_result.changed is sameas false - name: "test - Update service with the second status rule" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_n_child_services_have_status_or_above @@ -543,12 +543,12 @@ new_status: warning register: update_service_add_sr_result - - assert: + - ansible.builtin.assert: that: - update_service_add_sr_result.changed is sameas true - name: "test - Update service with the second status rule (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_n_child_services_have_status_or_above @@ -561,12 +561,12 @@ new_status: warning register: update_service_add_sr_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_add_sr_idempotency_check_result.changed is sameas false - name: "test - Update service remove status rule" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_npct_child_services_have_status_or_above @@ -575,12 +575,12 @@ new_status: warning register: update_service_remove_sr_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_sr_result.changed is sameas true - name: "test - Update service remove status rule (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_npct_child_services_have_status_or_above @@ -589,12 +589,12 @@ new_status: warning register: update_service_remove_sr_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_sr_idempotency_check_result.changed is sameas false - name: "test - Delete new service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule state: absent register: delete_service_result diff --git a/tests/integration/targets/test_zabbix_settings/tasks/main.yml b/tests/integration/targets/test_zabbix_settings/tasks/main.yml index a51ab8142..7be88158e 100644 --- a/tests/integration/targets/test_zabbix_settings/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_settings/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - Update zabbix settings (same as default) - zabbix_settings: + community.zabbix.zabbix_settings: alert_usrgrp: "Zabbix administrators" auditlog_enabled: true blink_period: "2m" @@ -69,36 +69,35 @@ register: zbx_settings - name: assert that settings was NOT updated - assert: + ansible.builtin.assert: that: - zbx_settings.changed is sameas False - - when: zabbix_version is version('6.2', '>=') name: support Zabbix version (>=6.2) block: - name: test - Zabbix settings (same as default) - zabbix_settings: + community.zabbix.zabbix_settings: vault_provider: HashiCorp_Vault register: zbx_settings - name: assert that settings was NOT updated - assert: + ansible.builtin.assert: that: - zbx_settings.changed is sameas False - name: test - Update zabbix settings - zabbix_settings: + community.zabbix.zabbix_settings: vault_provider: CyberArk_Vault register: zbx_settings - name: assert that settings was updated - assert: + ansible.builtin.assert: that: - zbx_settings.changed is sameas True - name: test - Update zabbix settings - zabbix_settings: + community.zabbix.zabbix_settings: alert_usrgrp: "0" auditlog_enabled: false blink_period: "10m" @@ -166,12 +165,12 @@ register: zbx_settings - name: assert that settings was updated - assert: + ansible.builtin.assert: that: - zbx_settings.changed is sameas True - name: test - Update zabbix settings (same setting) - zabbix_settings: + community.zabbix.zabbix_settings: alert_usrgrp: "0" auditlog_enabled: false blink_period: "10m" @@ -239,32 +238,32 @@ register: zbx_settings - name: assert that settings was NOT updated - assert: + ansible.builtin.assert: that: - zbx_settings.changed is sameas False - name: test - Update zabbix alert_usrgrp setting - zabbix_settings: + community.zabbix.zabbix_settings: alert_usrgrp: "No access to the frontend" register: zbx_settings - name: assert that setting was updated - assert: + ansible.builtin.assert: that: - zbx_settings.changed is sameas True - name: test - Update zabbix alert_usrgrp setting (same parameter) - zabbix_settings: + community.zabbix.zabbix_settings: alert_usrgrp: "No access to the frontend" register: zbx_settings - name: assert that settings was NOT updated - assert: + ansible.builtin.assert: that: - zbx_settings.changed is sameas False - name: test - Update zabbix settings (same as default) - zabbix_settings: + community.zabbix.zabbix_settings: alert_usrgrp: "Zabbix administrators" auditlog_enabled: true blink_period: "2m" diff --git a/tests/integration/targets/test_zabbix_template/tasks/main.yml b/tests/integration/targets/test_zabbix_template/tasks/main.yml index 81a3eaf3d..69aabe6b0 100644 --- a/tests/integration/targets/test_zabbix_template/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_template/tasks/main.yml @@ -1,124 +1,124 @@ --- - name: Create FTP Service Template - zabbix_template: + community.zabbix.zabbix_template: template_name: FTP Service template_groups: - - 'Templates' + - "Templates" state: present - name: Create a new Zabbix template (check mode). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" state: present register: create_zabbix_template_result check_mode: true -- assert: +- ansible.builtin.assert: that: - create_zabbix_template_result.changed is sameas true - name: Create a new Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" state: present register: create_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_template_result.changed is sameas true - name: Create a new Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" state: present register: create_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_template_result.changed is sameas false - name: Create a new Zabbix template with linked templates. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHostWithLinked template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - 'Zabbix proxy health' - - 'FTP Service' + - "Zabbix proxy health" + - "FTP Service" state: present register: create_zabbix_template_linked_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_template_linked_result.changed is sameas true - name: Gather Zabbix template infomation. - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleHost format: json register: gather_template_result - name: "test - Set key to template_export_key variable(This deals with the key being masked)" - set_fact: + ansible.builtin.set_fact: template_export_key: "{{ item }}" loop: "{{ gather_template_result.template_json.keys() | list }}" when: - item | regex_search('_export') -- assert: +- ansible.builtin.assert: that: - gather_template_result.template_json[template_export_key][template_groups_key].0.name == 'Templates' - gather_template_result.template_json[template_export_key][template_groups_key].1.name == 'Templates/Applications' - name: Add link_templates to Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - 'Zabbix proxy health' - - 'FTP Service' + - "Zabbix proxy health" + - "FTP Service" state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - update_zabbix_template_result.changed is sameas true - name: Add link_templates to Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - 'Zabbix proxy health' - - 'FTP Service' + - "Zabbix proxy health" + - "FTP Service" state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - update_zabbix_template_result.changed is sameas false - name: Gather Zabbix template infomation. - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleHost format: json register: gather_template_result -- assert: +- ansible.builtin.assert: that: - gather_template_result.template_json[template_export_key][template_groups_key].0.name == 'Templates' - gather_template_result.template_json[template_export_key][template_groups_key].1.name == 'Templates/Applications' @@ -126,61 +126,61 @@ - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix proxy health' - name: Add macros to Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - 'Zabbix proxy health' - - 'FTP Service' + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - update_zabbix_template_result.changed is sameas true - name: Add macros to Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - 'Zabbix proxy health' - - 'FTP Service' + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - update_zabbix_template_result.changed is sameas false - name: Add tags to Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - 'Zabbix proxy health' - - 'FTP Service' + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" tags: - tag: tag1 value: 1000 @@ -189,23 +189,23 @@ state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: update_zabbix_template_result is changed - name: Add tags to Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - 'Zabbix proxy health' - - 'FTP Service' + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" tags: - tag: tag1 value: 1000 @@ -214,37 +214,37 @@ state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: update_zabbix_template_result is not changed - name: Remove tags from Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - 'Zabbix proxy health' - - 'FTP Service' + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" tags: [] state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: update_zabbix_template_result is changed - name: Delete Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost state: absent register: delete_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - delete_zabbix_template_result.changed is sameas true @@ -253,35 +253,35 @@ # - name: Import Zabbix template from JSON file (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_json: "{{ lookup('file', 'template3_54_higher.json') }}" state: present register: import_template_json - name: Assert Zabbix template from JSON file (idempotency check). - assert: + ansible.builtin.assert: that: - import_template_json.changed is sameas true - name: Import Zabbix template from JSON file with matching values (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_json: "{{ lookup('file', 'template3_54_higher.json') }}" state: present register: import_template_json - name: Assert Zabbix template from JSON file with matching values (idempotency check). - assert: + ansible.builtin.assert: that: - import_template_json.changed is sameas false - name: Gather Zabbix template infomation. - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleHost format: json register: gather_template_result - block: - - assert: + - ansible.builtin.assert: that: - gather_template_result.template_json[template_export_key][template_groups_key].0.name == 'Templates' - gather_template_result.template_json[template_export_key][template_groups_key].1.name == 'Templates/Applications' @@ -293,22 +293,22 @@ - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' - name: Import Zabbix template from JSON file with updated values. - zabbix_template: + community.zabbix.zabbix_template: template_json: "{{ lookup('file', 'template3-changed_54_higher.json') }}" state: present register: import_template_json -- assert: +- ansible.builtin.assert: that: - import_template_json.changed is sameas true - name: Gather Zabbix template infomation. - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleHost format: json register: gather_template_result -- assert: +- ansible.builtin.assert: that: - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' @@ -323,24 +323,24 @@ - block: - name: Import Zabbix template from XML file with updated values. - zabbix_template: + community.zabbix.zabbix_template: template_xml: "{{ lookup('file', 'template3_54_higher.xml') }}" state: present register: import_template_xml - - assert: + - ansible.builtin.assert: that: - import_template_xml.changed is sameas true - name: Gather Zabbix template infomation. - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleHost format: json register: gather_template_result # zabbix returns values sorted alphabetically so HTTP Service template comes before Zabbix Proxy template - block: - - assert: + - ansible.builtin.assert: that: - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix proxy health' @@ -350,22 +350,22 @@ # - name: Delete Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost state: absent register: delete_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - delete_zabbix_template_result.changed is sameas true - name: Delete Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost state: absent register: delete_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - delete_zabbix_template_result.changed is sameas false @@ -376,33 +376,33 @@ # The test if decode Unicode correctly and to be imported the template. # https://github.com/ansible-collections/community.zabbix/issues/314 - name: Import Zabbix template from JSON file with unicode. - zabbix_template: + community.zabbix.zabbix_template: template_json: "{{ lookup('file', 'template1_50_higher_decode_unicode.json') }}" state: present register: import_template_json - name: Gather Zabbix template infomation. - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplate314 format: json register: gather_template_result -- assert: +- ansible.builtin.assert: that: - import_template_json.changed is sameas true - gather_template_result.template_json.zabbix_export.templates.0.description == "\u30c6\u30b9\u30c8\u30b3\u30e1\u30f3\u30c8" - name: Delete Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleTemplate314 state: absent register: delete_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - delete_zabbix_template_result.changed is sameas true - name: Clean up ExampleHostWithLinked template - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHostWithLinked state: absent diff --git a/tests/integration/targets/test_zabbix_template_info/tasks/main.yml b/tests/integration/targets/test_zabbix_template_info/tasks/main.yml index 74ca2e537..ae790f1f9 100644 --- a/tests/integration/targets/test_zabbix_template_info/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_template_info/tasks/main.yml @@ -1,48 +1,48 @@ --- - name: "test - Prepare integration tests for zabbix_template_info module" - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleTemplateForTempleteInfoModule template_groups: - Templates state: present register: prepare_result -- assert: +- ansible.builtin.assert: that: - prepare_result.changed is sameas true - name: "test - Fetch template info as a JSON format from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: json register: fetch_template_json_format_result - name: "test - Set key to template_export_key variable(This deals with the key being masked)" - set_fact: + ansible.builtin.set_fact: template_export_key: "{{ item }}" loop: "{{ fetch_template_json_format_result.template_json.keys() | list }}" when: - item | regex_search('_export') -- assert: +- ansible.builtin.assert: that: - fetch_template_json_format_result.template_json[template_export_key].date is defined when: zabbix_version is version('6.2', '<=') -- assert: +- ansible.builtin.assert: that: - fetch_template_json_format_result.template_json[template_export_key][template_groups_key].0.name == "Templates" - fetch_template_json_format_result.template_json[template_export_key].templates.0.name == "ExampleTemplateForTempleteInfoModule" - fetch_template_json_format_result.template_json[template_export_key].templates.0.template == "ExampleTemplateForTempleteInfoModule" - name: "test - Fetch template info as a JSON format with omit_date parameter from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: json omit_date: true register: fetch_template_json_format_omit_date_result -- assert: +- ansible.builtin.assert: that: - fetch_template_json_format_omit_date_result.template_json[template_export_key].date is not defined - fetch_template_json_format_omit_date_result.template_json[template_export_key][template_groups_key].0.name == "Templates" @@ -50,62 +50,62 @@ - fetch_template_json_format_omit_date_result.template_json[template_export_key].templates.0.template == "ExampleTemplateForTempleteInfoModule" - name: "test - Fetch template info as a XML format from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: xml register: fetch_template_xml_format_result -- assert: +- ansible.builtin.assert: that: - fetch_template_xml_format_result.template_xml | regex_search('.*') is defined - fetch_template_xml_format_result.template_xml | regex_search('Templates') is defined - fetch_template_xml_format_result.template_xml | regex_search('') is defined - name: "test - Fetch template info as a XML format with omit_date parameter from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: xml omit_date: true register: fetch_template_xml_format_omit_date_result -- assert: +- ansible.builtin.assert: that: - fetch_template_xml_format_omit_date_result.template_xml | regex_search('.*') is none - fetch_template_xml_format_omit_date_result.template_xml | regex_search('Templates') is defined - fetch_template_xml_format_omit_date_result.template_xml | regex_search('') is defined - name: "test - Fetch template info as a YAML format from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: yaml register: fetch_template_yaml_format_result -- assert: +- ansible.builtin.assert: that: - fetch_template_yaml_format_result.template_yaml | regex_search('date: .+') is defined - fetch_template_yaml_format_result.template_yaml | regex_search('name: Templates') is defined - fetch_template_yaml_format_result.template_yaml | regex_search('template: ExampleTemplateForTempleteInfoModule') is defined - name: "test - Fetch template info as a YAML format with omit_date parameter from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: yaml omit_date: true register: fetch_template_yaml_format_omit_date_result -- assert: +- ansible.builtin.assert: that: - fetch_template_yaml_format_result.template_yaml | regex_search('date: .+') is not defined - fetch_template_yaml_format_result.template_yaml | regex_search('name: Templates') is defined - fetch_template_yaml_format_result.template_yaml | regex_search('template: ExampleTemplateForTempleteInfoModule') is defined - name: "test - Fetch template info with none format from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: none register: fetch_template_none_format_result -- assert: +- ansible.builtin.assert: that: - fetch_template_none_format_result.template_id is defined - fetch_template_none_format_result.template_json is not defined diff --git a/tests/integration/targets/test_zabbix_token/tasks/main.yml b/tests/integration/targets/test_zabbix_token/tasks/main.yml index d7e01120f..59b87b0f4 100644 --- a/tests/integration/targets/test_zabbix_token/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_token/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Create token - zabbix_token: + community.zabbix.zabbix_token: name: test token description: Admin test token username: Admin @@ -10,12 +10,12 @@ register: zbx_token - name: assert that token was created - assert: + ansible.builtin.assert: that: - zbx_token is changed - name: Update token - zabbix_token: + community.zabbix.zabbix_token: name: test token description: Admin test token (Updated) username: Admin @@ -24,12 +24,12 @@ register: zbx_token - name: assert that token was updated - assert: + ansible.builtin.assert: that: - zbx_token is changed - name: Update token (not changes) - zabbix_token: + community.zabbix.zabbix_token: name: test token description: Admin test token (Updated) username: Admin @@ -38,61 +38,61 @@ register: zbx_token - name: assert that token was NOT updated - assert: + ansible.builtin.assert: that: - not zbx_token is changed - name: Delete token - zabbix_token: + community.zabbix.zabbix_token: name: test token username: Admin state: absent register: zbx_token - name: assert that token was deleted - assert: + ansible.builtin.assert: that: - zbx_token is changed - name: Delete token (already deleted) - zabbix_token: + community.zabbix.zabbix_token: name: test token username: Admin state: absent register: zbx_token - name: assert that token was not deleted - assert: + ansible.builtin.assert: that: - not zbx_token is changed - name: Create token with generating token - zabbix_token: + community.zabbix.zabbix_token: name: test token username: Admin generate_token: true register: zbx_token - name: assert that token was created - assert: + ansible.builtin.assert: that: - zbx_token is changed - name: Re-generate token - zabbix_token: + community.zabbix.zabbix_token: name: test token username: Admin generate_token: true register: zbx_new_token - name: assert that token was updated - assert: + ansible.builtin.assert: that: - zbx_token is changed - zbx_token.token != zbx_new_token.token - name: Delete token - zabbix_token: + community.zabbix.zabbix_token: name: test token username: Admin state: absent diff --git a/tests/integration/targets/test_zabbix_user/tasks/main.yml b/tests/integration/targets/test_zabbix_user/tasks/main.yml index 9d03bd1f6..29163436f 100644 --- a/tests/integration/targets/test_zabbix_user/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_user/tasks/main.yml @@ -1,7 +1,7 @@ --- # New user create test from here - name: test - Create a new Zabbix user with check_mode and diff - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -12,12 +12,12 @@ diff: true register: create_zabbix_user_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_result.changed is sameas true - name: test - Create a new Zabbix user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -26,12 +26,12 @@ passwd: G$jd_79!jw register: create_zabbix_user_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_result.changed is sameas true - name: test - Create a new Zabbix user(again) - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -40,13 +40,13 @@ passwd: G$jd_79!jw register: create_zabbix_user_result -- assert: +- ansible.builtin.assert: that: - not create_zabbix_user_result.changed is sameas true # Parameter add test from here to existing user - name: test - Add user group to existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -56,12 +56,12 @@ passwd: G$jd_79!jw register: add_usergroup_to_existing_user_result -- assert: +- ansible.builtin.assert: that: - add_usergroup_to_existing_user_result.changed is sameas true - name: test - Add user medias(Email) to existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -83,12 +83,12 @@ active: true register: add_user_medias_to_existing_user_result -- assert: +- ansible.builtin.assert: that: - add_user_medias_to_existing_user_result.changed is sameas true - name: test - Add multiple user medias(Email and SMS) to existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -121,13 +121,13 @@ active: true register: add_user_medias_to_existing_user_result -- assert: +- ansible.builtin.assert: that: - add_user_medias_to_existing_user_result.changed is sameas true # Existing parameter updates test from here - name: test - Update password parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -161,12 +161,12 @@ active: true register: update_password_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_password_parameter_existing_user_result.changed is sameas true - name: test - Update autologin parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -200,12 +200,12 @@ active: true register: update_autologin_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_autologin_parameter_existing_user_result.changed is sameas true - name: test - Update autologout parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -239,12 +239,12 @@ active: true register: update_autologout_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_autologout_parameter_existing_user_result.changed is sameas true - name: test - Update refresh parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -279,12 +279,12 @@ active: true register: update_refresh_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_refresh_parameter_existing_user_result.changed is sameas true - name: test - Update rows_per_page parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -320,12 +320,12 @@ active: true register: update_rows_per_page_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_rows_per_page_parameter_existing_user_result.changed is sameas true - name: test - Update after_login_url parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -362,12 +362,12 @@ active: true register: update_after_login_url_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_after_login_url_parameter_existing_user_result.changed is sameas true - name: test - Update theme parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -408,13 +408,13 @@ - dark-theme register: update_theme_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - item.changed is sameas true loop: "{{ update_theme_parameter_existing_user_result.results }}" - name: test - Update role_name parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -456,13 +456,13 @@ - Admin role register: update_type_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - item.changed is sameas true loop: "{{ update_type_parameter_existing_user_result.results }}" - name: test - Update lang parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -502,12 +502,12 @@ active: true register: update_lang_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_lang_parameter_existing_user_result.changed is sameas true - name: test - Update timezone parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example surname: test @@ -548,12 +548,12 @@ active: true register: update_timezone_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_timezone_parameter_existing_user_result.changed is sameas true - name: test - Update name and surname parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example2 surname: test2 @@ -594,12 +594,12 @@ active: true register: update_name_and_surname_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_name_and_surname_parameter_existing_user_result.changed is sameas true - name: test - Update lang parameter for existing user with check_mode and diff - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example2 surname: test2 @@ -642,12 +642,12 @@ diff: true register: update_lang_parameter_existing_user_with_check_mode_diff_result -- assert: +- ansible.builtin.assert: that: - update_lang_parameter_existing_user_with_check_mode_diff_result.changed is sameas true - name: test - Update lang parameter for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example2 surname: test2 @@ -688,12 +688,12 @@ active: true register: update_lang_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - update_lang_parameter_existing_user_result.changed is sameas true - name: test - Update lang parameter for existing user(again) - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example2 surname: test2 @@ -734,13 +734,13 @@ active: true register: update_lang_parameter_existing_user_result -- assert: +- ansible.builtin.assert: that: - not update_lang_parameter_existing_user_result.changed is sameas true # Parameter delete test from here from existing user - name: test - Delete user medias(SMS) for existing user with check_mode and diff - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example2 surname: test2 @@ -772,12 +772,12 @@ diff: true register: delete_user_medias_existing_user_result -- assert: +- ansible.builtin.assert: that: - delete_user_medias_existing_user_result.changed is sameas true - name: test - Delete user medias(SMS) for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example2 surname: test2 @@ -807,12 +807,12 @@ active: true register: delete_user_medias_existing_user_result -- assert: +- ansible.builtin.assert: that: - delete_user_medias_existing_user_result.changed is sameas true - name: test - Delete user group for existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example2 surname: test2 @@ -841,12 +841,12 @@ active: true register: delete_user_group_existing_user_result -- assert: +- ansible.builtin.assert: that: - - delete_user_group_existing_user_result.changed is sameas true + - delete_user_group_existing_user_result.changed is sameas true - name: test - optional user_medias - zabbix_user: + community.zabbix.zabbix_user: username: example1 name: example2 surname: test2 @@ -863,54 +863,54 @@ lang: fr_FR register: update_user_optional_user_medias_existing_user_result -- assert: +- ansible.builtin.assert: that: - - update_user_optional_user_medias_existing_user_result.changed is sameas False + - update_user_optional_user_medias_existing_user_result.changed is sameas False - name: test - Delete existing user with check_mode and diff - zabbix_user: + community.zabbix.zabbix_user: username: example1 state: absent check_mode: true diff: true register: delete_existing_user_result -- assert: +- ansible.builtin.assert: that: - delete_existing_user_result.changed is sameas true - name: test - Delete existing user - zabbix_user: + community.zabbix.zabbix_user: username: example1 state: absent register: delete_existing_user_result -- assert: +- ansible.builtin.assert: that: - delete_existing_user_result.changed is sameas true - name: test - Delete existing user(again) - zabbix_user: + community.zabbix.zabbix_user: username: example1 state: absent register: delete_existing_user_result -- assert: +- ansible.builtin.assert: that: - not delete_existing_user_result.changed is sameas true - name: test prepare - Create LDAP user group - zabbix_usergroup: + community.zabbix.zabbix_usergroup: name: testLDAPgrp gui_access: LDAP register: zbxuser_create_ldap_group -- assert: +- ansible.builtin.assert: that: - zbxuser_create_ldap_group.changed is sameas True - name: test - Create new password-less user without LDAP group (fail) - zabbix_user: + community.zabbix.zabbix_user: username: example2username name: example2 surname: testldap @@ -919,12 +919,12 @@ register: create_zabbix_user_ldap_fail ignore_errors: true -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_ldap_fail.failed is sameas True - name: test - Create new password-less user as member in LDAP group - zabbix_user: + community.zabbix.zabbix_user: username: example2username name: example2 surname: testldap @@ -932,12 +932,12 @@ - testLDAPgrp register: create_zabbix_user_ldap_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_ldap_result.changed is sameas True - name: test - Create new password-less user as member in LDAP group (again) - zabbix_user: + community.zabbix.zabbix_user: username: example2username name: example2 surname: testldap @@ -945,24 +945,24 @@ - testLDAPgrp register: create_zabbix_user_ldap_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_ldap_result.changed is sameas False - name: test - Delete existing user - zabbix_user: + community.zabbix.zabbix_user: username: example2username state: absent register: delete_existing_user_result -- assert: +- ansible.builtin.assert: that: - delete_existing_user_result.changed is sameas true # The tests are to check the patch for PR hasn't a problem. # https://github.com/ansible-collections/community.zabbix/pull/382 - name: test - Create a zabbix user with minimum parameters - zabbix_user: + community.zabbix.zabbix_user: username: example2 usrgrps: - Guests @@ -970,12 +970,12 @@ role_name: "User role" register: create_zabbix_user_with_minimum_params_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_with_minimum_params_result.changed is sameas true - name: test - Create a zabbix user with minimum parameters(again) - zabbix_user: + community.zabbix.zabbix_user: username: example2 usrgrps: - Guests @@ -983,12 +983,12 @@ role_name: "User role" register: create_zabbix_user_with_minimum_params_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_with_minimum_params_result.changed is sameas false - name: test - Update the parameters without role_name - zabbix_user: + community.zabbix.zabbix_user: username: example2 name: example2 surname: test @@ -997,12 +997,12 @@ passwd: G$jd_79!jw register: update_params_without_role_name_result -- assert: +- ansible.builtin.assert: that: - update_params_without_role_name_result.changed is sameas true - name: test - Update the parameters without role_name(again) - zabbix_user: + community.zabbix.zabbix_user: username: example2 name: example2 surname: test @@ -1011,12 +1011,12 @@ passwd: G$jd_79!jw register: update_params_without_role_name_result -- assert: +- ansible.builtin.assert: that: - update_params_without_role_name_result.changed is sameas false - name: test - Add user medias(Email) as list to existing user - zabbix_user: + community.zabbix.zabbix_user: username: example2 name: example2 surname: test @@ -1039,12 +1039,12 @@ active: true register: add_user_email_media_as_list_to_existing_user_result -- assert: +- ansible.builtin.assert: that: - add_user_email_media_as_list_to_existing_user_result.changed is sameas true - name: test - Add user medias(Email) as list to existing user(again) - zabbix_user: + community.zabbix.zabbix_user: username: example2 name: example2 surname: test @@ -1067,16 +1067,16 @@ active: true register: add_user_email_media_as_list_to_existing_user_result -- assert: +- ansible.builtin.assert: that: - add_user_email_media_as_list_to_existing_user_result.changed is sameas false - name: test - Delete existing user - zabbix_user: + community.zabbix.zabbix_user: username: example2 state: absent - name: test prepare - Delete LDAP user group - zabbix_usergroup: + community.zabbix.zabbix_usergroup: name: testLDAPgrp state: absent diff --git a/tests/integration/targets/test_zabbix_user_directory/tasks/main.yml b/tests/integration/targets/test_zabbix_user_directory/tasks/main.yml index 6c697a2e5..e4cc87d28 100644 --- a/tests/integration/targets/test_zabbix_user_directory/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_user_directory/tasks/main.yml @@ -3,8 +3,8 @@ - include_tasks: zabbix_user_directory_tests.yml always: - - name: Cleanup - zabbix_user_directory: - name: TestUserDirectory - state: absent - ignore_errors: true + - name: Cleanup + community.zabbix.zabbix_user_directory: + name: TestUserDirectory + state: absent + ignore_errors: true diff --git a/tests/integration/targets/test_zabbix_user_directory/tasks/zabbix_user_directory_tests.yml b/tests/integration/targets/test_zabbix_user_directory/tasks/zabbix_user_directory_tests.yml index db057a5d0..6488b80e5 100644 --- a/tests/integration/targets/test_zabbix_user_directory/tasks/zabbix_user_directory_tests.yml +++ b/tests/integration/targets/test_zabbix_user_directory/tasks/zabbix_user_directory_tests.yml @@ -10,97 +10,97 @@ name: TestUserDirectory block: - - name: test - create new user directory in check mode - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - check_mode: true - register: directory_check_result - - - assert: - that: directory_check_result.changed is sameas True - - - name: test - attempt to create new user directory with not all mandatory parameters - zabbix_user_directory: - host: 'test.com' - port: 389 - ignore_errors: true - register: directory_expect_fail_result - - - assert: - that: directory_expect_fail_result.failed is sameas True - - - name: test - create new user directory withoud bind_password - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_result - - - assert: - that: directory_result.changed is sameas True - - - name: test - create new user directory without bind_password again - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_again_result - - - assert: - that: directory_again_result.changed is sameas False - - - name: test - delete user directory - zabbix_user_directory: - state: absent - register: directory_delete_result - - - assert: - that: directory_delete_result.changed is sameas True - - - name: test - create new user directory with bind_password - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - bind_password: 'password' - register: directory_result - - - assert: - that: directory_result.changed is sameas True - - - name: test - create new user directory with bind_password again - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - bind_password: 'password' - register: directory_again_result - - - assert: - that: directory_again_result.changed is sameas True - - - name: test - update only host parameter in user directory - zabbix_user_directory: - host: 'test.ca' - register: directory_update_result - - - assert: - that: directory_update_result.changed is sameas True - - - name: test - update only host parameter in user directory again - zabbix_user_directory: - host: 'test.ca' - register: directory_update_again_result - - - assert: - that: directory_update_again_result.changed is sameas False + - name: test - create new user directory in check mode + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + check_mode: true + register: directory_check_result + + - ansible.builtin.assert: + that: directory_check_result.changed is sameas True + + - name: test - attempt to create new user directory with not all mandatory parameters + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + ignore_errors: true + register: directory_expect_fail_result + + - ansible.builtin.assert: + that: directory_expect_fail_result.failed is sameas True + + - name: test - create new user directory withoud bind_password + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_result + + - ansible.builtin.assert: + that: directory_result.changed is sameas True + + - name: test - create new user directory without bind_password again + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_again_result + + - ansible.builtin.assert: + that: directory_again_result.changed is sameas False + + - name: test - delete user directory + community.zabbix.zabbix_user_directory: + state: absent + register: directory_delete_result + + - ansible.builtin.assert: + that: directory_delete_result.changed is sameas True + + - name: test - create new user directory with bind_password + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + bind_password: "password" + register: directory_result + + - ansible.builtin.assert: + that: directory_result.changed is sameas True + + - name: test - create new user directory with bind_password again + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + bind_password: "password" + register: directory_again_result + + - ansible.builtin.assert: + that: directory_again_result.changed is sameas True + + - name: test - update only host parameter in user directory + community.zabbix.zabbix_user_directory: + host: "test.ca" + register: directory_update_result + + - ansible.builtin.assert: + that: directory_update_result.changed is sameas True + + - name: test - update only host parameter in user directory again + community.zabbix.zabbix_user_directory: + host: "test.ca" + register: directory_update_again_result + + - ansible.builtin.assert: + that: directory_update_again_result.changed is sameas False when: zabbix_version is version('6.4', '<') @@ -111,327 +111,327 @@ name: TestUserDirectory block: - - name: test - create new LDAP user directory in check mode - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - check_mode: true - register: directory_check_result - - - assert: - that: directory_check_result.changed is sameas True - - - name: test - attempt to create new LDAP user directory with not all mandatory parameters - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - ignore_errors: true - register: directory_expect_fail_result - - - assert: - that: directory_expect_fail_result.failed is sameas True - - - name: test - create new LDAP user directory withoud bind_password - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_result - - - assert: - that: directory_result.changed is sameas True - - - name: test - create new LDAP user directory without bind_password again - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_again_result - - - assert: - that: directory_again_result.changed is sameas False - - - name: test - delete LDAP user directory - zabbix_user_directory: - state: absent - register: directory_delete_result - - - assert: - that: directory_delete_result.changed is sameas True - - - name: test - create new LDAP user directory with bind_password - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - bind_password: 'password' - register: directory_result - - - assert: - that: directory_result.changed is sameas True - - - name: test - create new LDAP user directory with bind_password again - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - bind_password: 'password' - register: directory_again_result - - - assert: - that: directory_again_result.changed is sameas True - - - name: test - update host parameter in LDAP user directory - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_update_result - - - assert: - that: directory_update_result.changed is sameas True - - - name: test - update host parameter in LDAP user directory again - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_update_again_result - - - assert: - that: directory_update_again_result.changed is sameas False - - - name: test - add media type mapping with non-existing media type - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - provision_status: True - provision_media: - - name: Media1 - mediatype: EmailX - attribute: email - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - ignore_errors: True - register: directory_update_media_fail_result - - - assert: - that: directory_update_media_fail_result.failed is sameas True - - - name: test - add mappings - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - provision_status: True - group_name: cn - group_basedn: ou=Group,dc=example,dc=org - group_member: member - user_ref_attr: uid - group_filter: '(member=uid=%{ref},ou=Users,dc=example,dc=com)' - user_username: first_name - user_lastname: last_name - provision_media: - - name: Media1 - mediatype: Email - attribute: email1 - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - register: directory_update_media_result - - - assert: - that: directory_update_media_result.changed is sameas True - - - name: test - add mappings again - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - provision_status: True - group_name: cn - group_basedn: ou=Group,dc=example,dc=org - group_member: member - user_ref_attr: uid - group_filter: '(member=uid=%{ref},ou=Users,dc=example,dc=com)' - user_username: first_name - user_lastname: last_name - provision_media: - - name: Media1 - mediatype: Email - attribute: email1 - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - register: directory_update_media_again_result - - - assert: - that: directory_update_media_again_result.changed is sameas False - - - name: test - delete LDAP user directory - zabbix_user_directory: - state: absent - - - name: test - create new SAML user directory in check mode - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - check_mode: true - register: directory_check_result - - - assert: - that: directory_check_result.changed is sameas True - - - name: test - attempt to create new SAML user directory with not all mandatory parameters - zabbix_user_directory: - idp_type: saml - ignore_errors: true - register: directory_expect_fail_result - - - assert: - that: directory_expect_fail_result.failed is sameas True - - - name: test - create new SAML user directory - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - register: directory_create_result - - - assert: - that: directory_create_result.changed is sameas True - - - name: test - update SAML user directory with all optional parameters - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - slo_url: http://yyyy.okta.com - nameid_format: 'urn:oasis' - scim_status: true - encrypt_nameid: true - encrypt_assertions: true - sign_messages: true - sign_assertions: true - sign_authn_requests: true - sign_logout_requests: true - sign_logout_responses: true - register: directory_create_all_result - - - assert: - that: directory_create_all_result.changed is sameas True - - - name: test - update SAML user directory with all optional parameters again - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - slo_url: http://yyyy.okta.com - nameid_format: 'urn:oasis' - scim_status: true - encrypt_nameid: true - encrypt_assertions: true - sign_messages: true - sign_assertions: true - sign_authn_requests: true - sign_logout_requests: true - sign_logout_responses: true - register: directory_create_all_again_result - - - assert: - that: directory_create_all_again_result.changed is sameas False - - - name: test - delete SAML user directory - zabbix_user_directory: - state: absent - - - name: test - create new SAML user directory with mappings - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - provision_status: True - group_name: cn - user_username: first_name - user_lastname: last_name - provision_media: - - name: Media1 - mediatype: Email - attribute: email1 - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - register: directory_create_mappings_result - - - assert: - that: directory_create_mappings_result.changed is sameas True - - - name: test - create new SAML user directory with mappings again - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - provision_status: True - group_name: cn - user_username: first_name - user_lastname: last_name - provision_media: - - name: Media1 - mediatype: Email - attribute: email1 - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - register: directory_create_mappings_again_result - - - assert: - that: directory_create_mappings_again_result.changed is sameas False + - name: test - create new LDAP user directory in check mode + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + check_mode: true + register: directory_check_result + + - ansible.builtin.assert: + that: directory_check_result.changed is sameas True + + - name: test - attempt to create new LDAP user directory with not all mandatory parameters + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + ignore_errors: true + register: directory_expect_fail_result + + - ansible.builtin.assert: + that: directory_expect_fail_result.failed is sameas True + + - name: test - create new LDAP user directory withoud bind_password + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_result + + - ansible.builtin.assert: + that: directory_result.changed is sameas True + + - name: test - create new LDAP user directory without bind_password again + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_again_result + + - ansible.builtin.assert: + that: directory_again_result.changed is sameas False + + - name: test - delete LDAP user directory + community.zabbix.zabbix_user_directory: + state: absent + register: directory_delete_result + + - ansible.builtin.assert: + that: directory_delete_result.changed is sameas True + + - name: test - create new LDAP user directory with bind_password + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + bind_password: "password" + register: directory_result + + - ansible.builtin.assert: + that: directory_result.changed is sameas True + + - name: test - create new LDAP user directory with bind_password again + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + bind_password: "password" + register: directory_again_result + + - ansible.builtin.assert: + that: directory_again_result.changed is sameas True + + - name: test - update host parameter in LDAP user directory + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_update_result + + - ansible.builtin.assert: + that: directory_update_result.changed is sameas True + + - name: test - update host parameter in LDAP user directory again + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_update_again_result + + - ansible.builtin.assert: + that: directory_update_again_result.changed is sameas False + + - name: test - add media type mapping with non-existing media type + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + provision_status: True + provision_media: + - name: Media1 + mediatype: EmailX + attribute: email + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + ignore_errors: True + register: directory_update_media_fail_result + + - ansible.builtin.assert: + that: directory_update_media_fail_result.failed is sameas True + + - name: test - add mappings + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + provision_status: True + group_name: cn + group_basedn: ou=Group,dc=example,dc=org + group_member: member + user_ref_attr: uid + group_filter: "(member=uid=%{ref},ou=Users,dc=example,dc=com)" + user_username: first_name + user_lastname: last_name + provision_media: + - name: Media1 + mediatype: Email + attribute: email1 + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + register: directory_update_media_result + + - ansible.builtin.assert: + that: directory_update_media_result.changed is sameas True + + - name: test - add mappings again + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + provision_status: True + group_name: cn + group_basedn: ou=Group,dc=example,dc=org + group_member: member + user_ref_attr: uid + group_filter: "(member=uid=%{ref},ou=Users,dc=example,dc=com)" + user_username: first_name + user_lastname: last_name + provision_media: + - name: Media1 + mediatype: Email + attribute: email1 + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + register: directory_update_media_again_result + + - ansible.builtin.assert: + that: directory_update_media_again_result.changed is sameas False + + - name: test - delete LDAP user directory + community.zabbix.zabbix_user_directory: + state: absent + + - name: test - create new SAML user directory in check mode + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + check_mode: true + register: directory_check_result + + - ansible.builtin.assert: + that: directory_check_result.changed is sameas True + + - name: test - attempt to create new SAML user directory with not all mandatory parameters + community.zabbix.zabbix_user_directory: + idp_type: saml + ignore_errors: true + register: directory_expect_fail_result + + - ansible.builtin.assert: + that: directory_expect_fail_result.failed is sameas True + + - name: test - create new SAML user directory + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + register: directory_create_result + + - ansible.builtin.assert: + that: directory_create_result.changed is sameas True + + - name: test - update SAML user directory with all optional parameters + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + slo_url: http://yyyy.okta.com + nameid_format: "urn:oasis" + scim_status: true + encrypt_nameid: true + encrypt_assertions: true + sign_messages: true + sign_assertions: true + sign_authn_requests: true + sign_logout_requests: true + sign_logout_responses: true + register: directory_create_all_result + + - ansible.builtin.assert: + that: directory_create_all_result.changed is sameas True + + - name: test - update SAML user directory with all optional parameters again + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + slo_url: http://yyyy.okta.com + nameid_format: "urn:oasis" + scim_status: true + encrypt_nameid: true + encrypt_assertions: true + sign_messages: true + sign_assertions: true + sign_authn_requests: true + sign_logout_requests: true + sign_logout_responses: true + register: directory_create_all_again_result + + - ansible.builtin.assert: + that: directory_create_all_again_result.changed is sameas False + + - name: test - delete SAML user directory + community.zabbix.zabbix_user_directory: + state: absent + + - name: test - create new SAML user directory with mappings + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + provision_status: True + group_name: cn + user_username: first_name + user_lastname: last_name + provision_media: + - name: Media1 + mediatype: Email + attribute: email1 + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + register: directory_create_mappings_result + + - ansible.builtin.assert: + that: directory_create_mappings_result.changed is sameas True + + - name: test - create new SAML user directory with mappings again + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + provision_status: True + group_name: cn + user_username: first_name + user_lastname: last_name + provision_media: + - name: Media1 + mediatype: Email + attribute: email1 + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + register: directory_create_mappings_again_result + + - ansible.builtin.assert: + that: directory_create_mappings_again_result.changed is sameas False when: zabbix_version is version('6.4', '>=') diff --git a/tests/integration/targets/test_zabbix_user_info/tasks/main.yml b/tests/integration/targets/test_zabbix_user_info/tasks/main.yml index 9b959b209..1f1862586 100644 --- a/tests/integration/targets/test_zabbix_user_info/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_user_info/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - Create a new Zabbix user - zabbix_user: + community.zabbix.zabbix_user: username: example name: user name surname: user surname @@ -11,10 +11,10 @@ lang: en_US theme: blue-theme autologin: false - autologout: '0' - refresh: '30' - rows_per_page: '200' - after_login_url: '' + autologout: "0" + refresh: "30" + rows_per_page: "200" + after_login_url: "" user_medias: - mediatype: Email sendto: example@example.com @@ -32,12 +32,12 @@ state: present register: create_zabbix_user_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_result.changed is sameas true - name: test - Set definition_of_results variable - set_fact: + ansible.builtin.set_fact: definition_of_results: - get_user_info_result[user_info_key].username == "example" - get_user_info_result[user_info_key].autologin is defined @@ -72,23 +72,22 @@ - get_user_info_result[user_info_key].usrgrps.1.usrgrpid is defined - name: "test - Get a zabbix user information" - zabbix_user_info: + community.zabbix.zabbix_user_info: username: example register: get_user_info_result - name: "test - Set key to user_info_key variable(This deals with the key being masked)" - set_fact: + ansible.builtin.set_fact: user_info_key: "{{ item }}" loop: "{{ get_user_info_result.keys() | list }}" when: - item | regex_search('_user') -- assert: +- ansible.builtin.assert: that: definition_of_results - - name: test - Create a new Zabbix user - zabbix_user: + community.zabbix.zabbix_user: username: example2 usrgrps: - Guests @@ -97,22 +96,22 @@ state: present register: create_zabbix_user_result2 -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_result2.changed is sameas true - name: "test - Get a zabbix user information" - zabbix_user_info: + community.zabbix.zabbix_user_info: username: example2 register: get_user_info_result2 - name: "test - Set key to user_info_key variable(This deals with the key being masked)" - set_fact: + ansible.builtin.set_fact: user_info_key: "{{ item }}" loop: "{{ get_user_info_result2.keys() | list }}" when: - item | regex_search('_user') -- assert: +- ansible.builtin.assert: that: - get_user_info_result2[user_info_key].username == "example2" diff --git a/tests/integration/targets/test_zabbix_user_role/tasks/main.yml b/tests/integration/targets/test_zabbix_user_role/tasks/main.yml index 9648f2f90..53e57a043 100644 --- a/tests/integration/targets/test_zabbix_user_role/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_user_role/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - Create a new Zabbix role - zabbix_user_role: + community.zabbix.zabbix_user_role: state: present name: Operators type: User @@ -13,13 +13,13 @@ status: 1 register: create_zabbix_user_role_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_role_result.changed is sameas true # Check user role idempotency - name: test - Update a Zabbix role with same rules - zabbix_user_role: + community.zabbix.zabbix_user_role: state: present name: Operators type: User @@ -32,13 +32,13 @@ status: 1 register: create_zabbix_user_role_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_role_result.changed is sameas false # Check user role change - name: test - Update a Zabbix role with new rules - zabbix_user_role: + community.zabbix.zabbix_user_role: state: present name: Operators type: User @@ -51,23 +51,23 @@ status: 0 register: create_zabbix_user_role_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_role_result.changed is sameas true # Check user role remove - name: test - Remove Zabbix role - zabbix_user_role: + community.zabbix.zabbix_user_role: state: absent name: Operators register: create_zabbix_user_role_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_role_result.changed is sameas true - name: test - Create a new Zabbix role type Admin - zabbix_user_role: + community.zabbix.zabbix_user_role: state: present name: Admins type: Admin @@ -75,17 +75,17 @@ ui.default_access: 0 register: create_zabbix_user_role_admin_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_role_admin_result.changed is sameas true - name: test - Remove Zabbix role type Admin - zabbix_user_role: + community.zabbix.zabbix_user_role: state: absent name: Admins - name: test - Create a new Zabbix role type Super Admin - zabbix_user_role: + community.zabbix.zabbix_user_role: state: present name: Super Admins type: Super Admin @@ -93,11 +93,11 @@ ui.default_access: 0 register: create_zabbix_user_role_super_admin_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_role_super_admin_result.changed is sameas true - name: test - Remove Zabbix role type Super Admin - zabbix_user_role: + community.zabbix.zabbix_user_role: state: absent name: Super Admins diff --git a/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml b/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml index 4b9d75530..d1922315b 100644 --- a/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml @@ -5,270 +5,269 @@ name: ACME block: - - name: test - create new Zabbix user group - zabbix_usergroup: - state: present - register: usergroup_new - - - name: assert that user group was created - assert: - that: usergroup_new is changed - - - name: test - create new Zabbix user group (again) - zabbix_usergroup: - state: present - register: usergroup_again - - - name: assert that user group was created - assert: - that: not usergroup_again is changed - - - name: test - update Zabbix user group with disabled gui_access - zabbix_usergroup: - gui_access: disable - register: usergroup_updated - - - name: assert that user group was updated - assert: - that: usergroup_updated is changed - - - name: test - update Zabbix user group with disabled gui_access (again) - zabbix_usergroup: - gui_access: disable - register: usergroup_updated_again - - - name: assert that user group was updated - assert: - that: not usergroup_updated_again is changed - - - name: test - reset Zabbix user group to default - zabbix_usergroup: - register: usergroup_reset - - - name: assert that user group was created - assert: - that: usergroup_reset is changed - - - when: zabbix_version is version('6.2', '<') - block: - - name: test - update Zabbix user group with one right - zabbix_usergroup: - rights: - - host_group: Discovered hosts - permission: read-only - register: usergroup_updated_right + - name: test - create new Zabbix user group + community.zabbix.zabbix_usergroup: + state: present + register: usergroup_new - - name: assert that user group was updated - assert: - that: usergroup_updated_right is changed + - name: assert that user group was created + ansible.builtin.assert: + that: usergroup_new is changed - - name: test - update Zabbix user group with multiple rights - zabbix_usergroup: - rights: - - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - register: usergroup_updated_rights + - name: test - create new Zabbix user group (again) + community.zabbix.zabbix_usergroup: + state: present + register: usergroup_again - - name: assert that user group was updated - assert: - that: usergroup_updated_rights is changed + - name: assert that user group was created + ansible.builtin.assert: + that: not usergroup_again is changed - - name: test - update Zabbix user group with multiple rights (again) - zabbix_usergroup: - rights: - - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - register: usergroup_updated_rights_again - - - name: assert that user group was not updated - assert: - that: not usergroup_updated_rights_again is changed - - - when: zabbix_version is version('6.2', '>=') - block: - - name: test - update Zabbix user group with one hostgroup right - zabbix_usergroup: - hostgroup_rights: - - host_group: Discovered hosts - permission: read-only - register: usergroup_updated_hostgroup_right + - name: test - update Zabbix user group with disabled gui_access + community.zabbix.zabbix_usergroup: + gui_access: disable + register: usergroup_updated - name: assert that user group was updated - assert: - that: usergroup_updated_hostgroup_right is changed + ansible.builtin.assert: + that: usergroup_updated is changed - - name: test - update Zabbix user group with multiple hostgroup rights - zabbix_usergroup: - hostgroup_rights: - - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - register: usergroup_updated_hostgroup_rights + - name: test - update Zabbix user group with disabled gui_access (again) + community.zabbix.zabbix_usergroup: + gui_access: disable + register: usergroup_updated_again - name: assert that user group was updated - assert: - that: usergroup_updated_hostgroup_rights is changed - - - name: test - update Zabbix user group with multiple hostgroup rights (again) - zabbix_usergroup: - hostgroup_rights: + ansible.builtin.assert: + that: not usergroup_updated_again is changed + + - name: test - reset Zabbix user group to default + community.zabbix.zabbix_usergroup: + register: usergroup_reset + + - name: assert that user group was created + ansible.builtin.assert: + that: usergroup_reset is changed + + - when: zabbix_version is version('6.2', '<') + block: + - name: test - update Zabbix user group with one right + community.zabbix.zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + register: usergroup_updated_right + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_right is changed + + - name: test - update Zabbix user group with multiple rights + community.zabbix.zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_rights + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_rights is changed + + - name: test - update Zabbix user group with multiple rights (again) + community.zabbix.zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_rights_again + + - name: assert that user group was not updated + ansible.builtin.assert: + that: not usergroup_updated_rights_again is changed + + - when: zabbix_version is version('6.2', '>=') + block: + - name: test - update Zabbix user group with one hostgroup right + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + register: usergroup_updated_hostgroup_right + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_hostgroup_right is changed + + - name: test - update Zabbix user group with multiple hostgroup rights + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_hostgroup_rights + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_hostgroup_rights is changed + + - name: test - update Zabbix user group with multiple hostgroup rights (again) + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_hostgroup_rights_again + + - name: assert that user group was not updated + ansible.builtin.assert: + that: not usergroup_updated_hostgroup_rights_again is changed + + - name: test - update Zabbix user group with one template group right + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + templategroup_rights: + - template_group: Templates + permission: read-only + register: usergroup_updated_templategroup_right + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_templategroup_right is changed + + - name: test - update Zabbix user group with multiple template group rights + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + templategroup_rights: + - template_group: Templates + permission: read-only + - template_group: Templates/Applications + permission: read-write + register: usergroup_updated_templategroup_rights + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_templategroup_right is changed + + - name: test - update Zabbix user group with multiple template group rights (again) + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + templategroup_rights: + - template_group: Templates + permission: read-only + - template_group: Templates/Applications + permission: read-write + register: usergroup_updated_templategroup_rights_again + + - name: assert that user group was not updated + ansible.builtin.assert: + that: not usergroup_updated_templategroup_rights_again is changed + + - name: test - reset Zabbix user group to default + community.zabbix.zabbix_usergroup: + register: usergroup_reset + + - name: assert that user group was created + ansible.builtin.assert: + that: usergroup_reset is changed + + - name: test - update Zabbix user group with one tag_filter + community.zabbix.zabbix_usergroup: + tag_filters: - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - register: usergroup_updated_hostgroup_rights_again - - - name: assert that user group was not updated - assert: - that: not usergroup_updated_hostgroup_rights_again is changed - - - name: test - update Zabbix user group with one template group right - zabbix_usergroup: - hostgroup_rights: - - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - templategroup_rights: - - template_group: Templates - permission: read-only - register: usergroup_updated_templategroup_right + tag: Service + value: JIRA + register: usergroup_updated_tag_filter - name: assert that user group was updated - assert: - that: usergroup_updated_templategroup_right is changed + ansible.builtin.assert: + that: usergroup_updated_tag_filter is changed - - name: test - update Zabbix user group with multiple template group rights - zabbix_usergroup: - hostgroup_rights: + - name: test - update Zabbix user group with multiple tag_filters + community.zabbix.zabbix_usergroup: + tag_filters: - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - templategroup_rights: - - template_group: Templates - permission: read-only - - template_group: Templates/Applications - permission: read-write - register: usergroup_updated_templategroup_rights - - - name: assert that user group was updated - assert: - that: usergroup_updated_templategroup_right is changed - - - name: test - update Zabbix user group with multiple template group rights (again) - zabbix_usergroup: - hostgroup_rights: + tag: Service + value: JIRA - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - templategroup_rights: - - template_group: Templates - permission: read-only - - template_group: Templates/Applications - permission: read-write - register: usergroup_updated_templategroup_rights_again - - - name: assert that user group was not updated - assert: - that: not usergroup_updated_templategroup_rights_again is changed - - - name: test - reset Zabbix user group to default - zabbix_usergroup: - register: usergroup_reset - - - name: assert that user group was created - assert: - that: usergroup_reset is changed - - - name: test - update Zabbix user group with one tag_filter - zabbix_usergroup: - tag_filters: - - host_group: Discovered hosts - tag: Service - value: JIRA - register: usergroup_updated_tag_filter - - - name: assert that user group was updated - assert: - that: usergroup_updated_tag_filter is changed - - - name: test - update Zabbix user group with multiple tag_filters - zabbix_usergroup: - tag_filters: - - host_group: Discovered hosts - tag: Service - value: JIRA - - host_group: Discovered hosts - tag: Service - value: Zabbix - register: usergroup_updated_tag_filters - - - name: assert that user group was updated - assert: - that: usergroup_updated_tag_filters is changed - - - name: test - reset Zabbix user group to default - zabbix_usergroup: - - - when: zabbix_version is version('6.2', '>=') - block: - - name: test - create new user directory - zabbix_user_directory: - name: LDAP infra 1 - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - when: zabbix_version is version('6.4', '<') - - - name: test - create new user directory - zabbix_user_directory: - name: LDAP infra 1 - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - when: zabbix_version is version('6.4', '>=') - - - name: test - update Zabbix user group with user directory - zabbix_usergroup: - userdirectory: LDAP infra 1 - register: usergroup_create_userdir + tag: Service + value: Zabbix + register: usergroup_updated_tag_filters - name: assert that user group was updated - assert: - that: usergroup_create_userdir is changed - - - name: test - update Zabbix user group with user directory (again) - zabbix_usergroup: - userdirectory: LDAP infra 1 - register: usergroup_create_userdir_again - - - name: assert that user group was not updated - assert: - that: not usergroup_create_userdir_again is changed - - - name: test - delete Zabbix user group - zabbix_usergroup: - state: absent - register: usergroup_delete - - - name: assert that Zabbix user group has been deleted - assert: - that: usergroup_delete is changed - - - - name: test - delete user directory - zabbix_user_directory: - name: LDAP infra 1 - host: 'test.com' - state: absent - when: zabbix_version is version('6.2', '>=') + ansible.builtin.assert: + that: usergroup_updated_tag_filters is changed + + - name: test - reset Zabbix user group to default + community.zabbix.zabbix_usergroup: + + - when: zabbix_version is version('6.2', '>=') + block: + - name: test - create new user directory + community.zabbix.zabbix_user_directory: + name: LDAP infra 1 + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + when: zabbix_version is version('6.4', '<') + + - name: test - create new user directory + community.zabbix.zabbix_user_directory: + name: LDAP infra 1 + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + when: zabbix_version is version('6.4', '>=') + + - name: test - update Zabbix user group with user directory + community.zabbix.zabbix_usergroup: + userdirectory: LDAP infra 1 + register: usergroup_create_userdir + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_create_userdir is changed + + - name: test - update Zabbix user group with user directory (again) + community.zabbix.zabbix_usergroup: + userdirectory: LDAP infra 1 + register: usergroup_create_userdir_again + + - name: assert that user group was not updated + ansible.builtin.assert: + that: not usergroup_create_userdir_again is changed + + - name: test - delete Zabbix user group + community.zabbix.zabbix_usergroup: + state: absent + register: usergroup_delete + + - name: assert that Zabbix user group has been deleted + ansible.builtin.assert: + that: usergroup_delete is changed + + - name: test - delete user directory + community.zabbix.zabbix_user_directory: + name: LDAP infra 1 + host: "test.com" + state: absent + when: zabbix_version is version('6.2', '>=')