summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/zabbix/molecule/zabbix_proxy
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
commit38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch)
tree356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/community/zabbix/molecule/zabbix_proxy
parentAdding upstream version 7.7.0+dfsg. (diff)
downloadansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz
ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/zabbix/molecule/zabbix_proxy')
-rw-r--r--ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml33
-rw-r--r--ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml41
-rw-r--r--ansible_collections/community/zabbix/molecule/zabbix_proxy/tests/test_default.py26
3 files changed, 37 insertions, 63 deletions
diff --git a/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml b/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml
index 21ab813c4..4eb173acf 100644
--- a/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml
+++ b/ansible_collections/community/zabbix/molecule/zabbix_proxy/molecule.yml
@@ -1,43 +1,51 @@
---
-
driver:
name: docker
platforms:
- - name: zabbix-proxy-${MY_MOLECULE_CONTAINER:-mysql-centos}
- image: ${MY_MOLECULE_IMAGE:-"geerlingguy/docker-centos8-ansible"}
- command: ${MY_MOLECULE_DOCKER_COMMAND:-""}
+ - name: zabbix-proxy-${MY_MOLECULE_CONTAINER:-centos}
+ image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest
privileged: true
pre_build_image: true
+ command: ${MOLECULE_DOCKER_COMMAND:-""}
networks:
- name: zabbix
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
groups:
- - ${MY_MOLECULE_GROUP:-mysql}
+ - ${MY_MOLECULE_DATABASE:-mysql}
+ - ${MY_MOLECULE_VERSION:-v64}
provisioner:
name: ansible
- lint:
- name: ansible-lint
env:
ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix
ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles
inventory:
group_vars:
+ python3:
+ ansible_python_interpreter: /usr/bin/python3
+ python:
+ ansible_python_interpreter: /usr/bin/python
+ v64:
+ zabbix_proxy_version: 6.4
+ v62:
+ zabbix_proxy_version: 6.2
+ v60:
+ zabbix_proxy_version: 6.0
mysql:
+ zabbix_proxy_dbname: zabbix
+ zabbix_proxy_dbuser: zabbix-dbuser
zabbix_proxy_database: mysql
- zabbix_proxy_database_long: mysql
zabbix_proxy_dbport: 3306
zabbix_proxy_dbhost: mysql-host
zabbix_proxy_dbhost_run_install: false
- zabbix_proxy_privileged_host: '%'
+ zabbix_proxy_privileged_host: "%"
zabbix_proxy_mysql_login_host: mysql-host
zabbix_proxy_mysql_login_user: root
zabbix_proxy_mysql_login_password: changeme
zabbix_proxy_mysql_login_port: 3306
- postgresql:
+ pgsql:
zabbix_proxy_database: pgsql
- zabbix_proxy_database_long: postgresql
zabbix_proxy_dbport: 5432
zabbix_proxy_dbhost: postgresql-host
zabbix_proxy_dbhost_run_install: false
@@ -49,8 +57,5 @@ provisioner:
zabbix_proxy_database: sqlite3
zabbix_proxy_database_long: sqlite3
zabbix_proxy_dbname: /path/to/sqlite3.db
-
verifier:
name: testinfra
- lint:
- name: flake8
diff --git a/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml b/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml
index 0fc4ef320..c5e3b9e45 100644
--- a/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml
+++ b/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml
@@ -3,7 +3,6 @@
hosts: localhost
connection: local
pre_tasks:
-
- name: "Create MySQL Container"
docker_container:
name: mysql-host
@@ -32,14 +31,13 @@
no_log: true
with_items: "{{ molecule_yml.platforms }}"
when:
- - '"postgresql" in item.groups'
+ - '"pgsql" in item.groups'
- name: Prepare
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"
@@ -51,7 +49,7 @@
changed_when: false
- name: "Installing packages on CentOS"
- yum:
+ ansible.builtin.yum:
name:
- net-tools
- which
@@ -62,24 +60,13 @@
when:
- ansible_os_family == 'RedHat'
- - name: "Installing packages on CentOS"
- yum:
- name:
- - mysql
- state: present
- register: installation_dependencies
- until: installation_dependencies is succeeded
- when:
- - ansible_os_family == 'RedHat'
- - inventory_hostname in groups['mysql']
-
- name: 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
@@ -88,7 +75,7 @@
- ansible_os_family != 'RedHat'
- name: "Installing packages on NON-CentOS"
- apt:
+ ansible.builtin.apt:
name:
- net-tools
- apt-utils
@@ -104,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
@@ -118,17 +105,9 @@
- 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/*'
+ regexp: "path-exclude=/usr/share/doc/*"
when:
- ansible_os_family != 'RedHat'
-
- - name: PyMySQL
- pip:
- name: PyMySQL
- register: installation_dependencies
- until: installation_dependencies is succeeded
- when:
- - inventory_hostname in groups['mysql']
diff --git a/ansible_collections/community/zabbix/molecule/zabbix_proxy/tests/test_default.py b/ansible_collections/community/zabbix/molecule/zabbix_proxy/tests/test_default.py
index 4ccbfeb4e..f96874740 100644
--- a/ansible_collections/community/zabbix/molecule/zabbix_proxy/tests/test_default.py
+++ b/ansible_collections/community/zabbix/molecule/zabbix_proxy/tests/test_default.py
@@ -17,28 +17,18 @@ def test_zabbixproxy_running_and_enabled(host):
assert zabbix.is_running
-@pytest.mark.parametrize(
- "proxy", [("zabbix-proxy-pgsql"), ("zabbix-proxy-mysql"), ("zabbix-proxy-sqlite3")]
-)
-def test_zabbix_package(host, proxy):
+def test_zabbix_package(host):
ansible_data = host.ansible.get_variables()
- zabbixhost = ansible_data["inventory_hostname"]
+ version = ansible_data['zabbix_proxy_version']
+ database = ansible_data['zabbix_proxy_database']
- zabbixhost = zabbixhost.replace("-centos", "")
- zabbixhost = zabbixhost.replace("-debian", "")
- zabbixhost = zabbixhost.replace("-ubuntu", "")
-
- if zabbixhost == proxy:
- zabbix_proxy = host.package(proxy)
- if host.system_info.distribution in ["debian", "ubuntu"]:
- assert zabbix_proxy.version.startswith("1:6.4")
- elif host.system_info.distribution == "centos":
- assert zabbix_proxy.version.startswith("6.4")
- assert zabbix_proxy.is_installed
+ zabbix_proxy = host.package(f'zabbix-proxy-%s' % database)
+ assert str(version) in zabbix_proxy.version
def test_zabbix_proxy_dot_conf(host):
zabbix_proxy_conf = host.file("/etc/zabbix/zabbix_proxy.conf")
+ assert zabbix_proxy_conf.exists
assert zabbix_proxy_conf.user == "zabbix"
assert zabbix_proxy_conf.group == "zabbix"
assert zabbix_proxy_conf.mode == 0o644
@@ -52,13 +42,13 @@ def test_zabbix_include_dir(host):
assert zabbix_include_dir.is_directory
assert zabbix_include_dir.user == "zabbix"
assert zabbix_include_dir.group == "zabbix"
- # assert zabbix_include_dir.mode == 0o644
def test_zabbix_proxy_logfile(host):
zabbix_logfile = host.file("/var/log/zabbix/zabbix_proxy.log")
-
+ assert zabbix_logfile.exists
assert not zabbix_logfile.contains("Access denied for user")
assert not zabbix_logfile.contains("database is down: reconnecting")
+ assert not zabbix_logfile.contains("Both are missing in the system.") # Missing fping
assert zabbix_logfile.contains("current database version")
assert zabbix_logfile.contains(r"proxy #0 started \[main process\]")