Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quality of life improvements for zabbix server role #1230

Merged
merged 4 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ jobs:
- v64
- v62
- v60
include:
- interpreter: python3
exclude:
- container: debian12
version: v62
Expand Down Expand Up @@ -86,6 +84,5 @@ jobs:
MY_MOLECULE_IMAGE=${{ matrix.container }}
MY_MOLECULE_VERSION=${{ matrix.version }}
MY_MOLECULE_DATABASE=${{ matrix.database }}
MY_MOLECULE_INTERPRETER=${{ matrix.interpreter }}
MY_MOLECULE_DOCKER_COMMAND=${{ matrix.command }}
molecule test -s ${{ matrix.collection_role }}
9 changes: 1 addition & 8 deletions molecule/zabbix_server/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ platforms:
groups:
- ${MY_MOLECULE_DATABASE:-mysql}
- ${MY_MOLECULE_VERSION:-v64}
- ${MY_MOLECULE_INTERPRETER:-python3}

provisioner:
name: ansible
Expand All @@ -23,23 +22,18 @@ provisioner:
ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles
inventory:
group_vars:
python3:
all:
ansible_python_interpreter: /usr/bin/python3
python:
ansible_python_interpreter: /usr/bin/python
v64:
zabbix_server_version: 6.4
v62:
zabbix_server_version: 6.2
v60:
zabbix_server_version: 6.0
v50:
zabbix_server_version: 5.0
mysql:
zabbix_server_dbname: zabbix
zabbix_server_dbuser: zabbix-dbuser
zabbix_server_database: mysql
zabbix_server_dbport: 3306
zabbix_server_dbhost: "{{ inventory_hostname }}-db"
zabbix_server_dbhost_run_install: false
zabbix_server_privileged_host: "%"
Expand All @@ -49,7 +43,6 @@ provisioner:
zabbix_server_mysql_login_port: 3306
pgsql:
zabbix_server_database: pgsql
zabbix_server_dbport: 5432
zabbix_server_dbhost: "{{ inventory_hostname }}-db"
zabbix_server_dbhost_run_install: false
zabbix_server_pgsql_login_host: "{{ inventory_hostname }}-db"
Expand Down
11 changes: 7 additions & 4 deletions roles/zabbix_server/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ zabbix_server_manage_service: true
# Database
zabbix_server_database_sqlload: true
zabbix_server_database_timescaledb: false
zabbix_server_real_dbhost:
#zabbix_server_real_dbhost:
zabbix_server_dbhost: localhost
zabbix_server_dbname: zabbix-server
zabbix_server_privileged_host: localhost
zabbix_server_dbencoding: utf8
zabbix_server_dbcollation: utf8_bin
zabbix_server_dbschema:
#zabbix_server_dbschema:
zabbix_server_dbuser: zabbix-server
zabbix_server_dbpassword: zabbix-server
zabbix_server_dbpassword_hash_method: md5
zabbix_server_dbsocket:
zabbix_server_dbport: 5432
#zabbix_server_dbsocket:
_zabbix_server_database_default_port:
mysql: 3306
pgsql: 5432
zabbix_server_dbport: "{{ _zabbix_server_database_default_port[zabbix_server_database] }}"
zabbix_server_dbhost_run_install: true
zabbix_server_database: pgsql
zabbix_server_database_creation: true
Expand Down
1 change: 1 addition & 0 deletions roles/zabbix_server/tasks/initialize-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

- name: "MySQL Database prep"
when: zabbix_server_database_creation
become: "{{ zabbix_server_dbhost_run_install }}"
pyrodie18 marked this conversation as resolved.
Show resolved Hide resolved
delegate_to: "{{ zabbix_server_real_dbhost | default(zabbix_server_dbhost_run_install | ternary(delegated_dbhost, inventory_hostname)) }}"
vars:
delegated_dbhost: "{{ (zabbix_server_dbhost == 'localhost') | ternary(inventory_hostname, zabbix_server_dbhost) }}"
Expand Down
16 changes: 12 additions & 4 deletions roles/zabbix_server/tasks/initialize-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
port: "{{ zabbix_server_dbport }}"
login_unix_socket: "{{ zabbix_server_pgsql_login_unix_socket | default(omit) }}"
name: "{{ zabbix_server_dbname }}"
state: present

- name: "PostgreSQL | Create database user"
community.postgresql.postgresql_user:
Expand All @@ -43,10 +42,19 @@
login_unix_socket: "{{ zabbix_server_pgsql_login_unix_socket | default(omit) }}"
name: "{{ zabbix_server_dbuser }}"
password: "{{ ('md5' + (zabbix_server_dbpassword + zabbix_server_dbuser)|hash('md5')) if zabbix_server_dbpassword_hash_method == 'md5' else zabbix_server_dbpassword }}"

- name: "PostgreSQL | Set database/user permissions"
community.postgresql.postgresql_privs:
login_user: "{{ zabbix_server_pgsql_login_user | default(omit) }}"
login_password: "{{ zabbix_server_pgsql_login_password | default(omit) }}"
login_host: "{{ zabbix_server_pgsql_login_host | default(omit) }}"
port: "{{ zabbix_server_dbport }}"
login_unix_socket: "{{ zabbix_server_pgsql_login_unix_socket | default(omit) }}"
db: "{{ zabbix_server_dbname }}"
priv: ALL
state: present
encrypted: true
privs: ALL
type: schema
objs: public
role: "{{ zabbix_server_dbuser }}"

- name: "PostgreSQL | Create timescaledb extension"
when: zabbix_server_database_timescaledb
Expand Down
Loading