Skip to content

Commit

Permalink
Use SSL for database connection when zabbix_server_dbtlsconnect is set
Browse files Browse the repository at this point in the history
Signed-off-by: Chandler Swift <chandler+pearson@chandlerswift.com>
  • Loading branch information
ChandlerSwift committed Oct 14, 2024
1 parent c95389a commit 7863918
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions roles/zabbix_server/tasks/initialize-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}"
login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}"
login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}"
check_hostname: "{{ zabbix_server_dbtlsconnect is defined and zabbix_server_dbtlsconnect != '' }}"
name: "{{ zabbix_server_dbname }}"
encoding: "{{ zabbix_server_dbencoding }}"
collation: "{{ zabbix_server_dbcollation }}"
Expand All @@ -58,6 +59,7 @@
login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}"
login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}"
login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}"
check_hostname: "{{ zabbix_server_dbtlsconnect is defined and zabbix_server_dbtlsconnect != '' }}"
name: "{{ zabbix_server_dbuser }}"
password: "{{ zabbix_server_dbpassword }}"
host: "{{ zabbix_server_privileged_host }}"
Expand All @@ -82,6 +84,7 @@
login_host: "{{ zabbix_server_dbhost }}"
login_port: "{{ zabbix_server_dbport }}"
login_db: "{{ zabbix_server_dbname }}"
check_hostname: "{{ zabbix_server_dbtlsconnect is defined and zabbix_server_dbtlsconnect != '' }}"
query: "SELECT mandatory FROM dbversion"
rescue:
- name: "MySQL | Get and set schema import overrides"
Expand All @@ -95,6 +98,7 @@
login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}"
login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}"
login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}"
check_hostname: "{{ zabbix_server_dbtlsconnect is defined and zabbix_server_dbtlsconnect != '' }}"
loop:
- innodb_default_row_format
- log_bin_trust_function_creators
Expand All @@ -111,6 +115,7 @@
login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}"
login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}"
login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}"
check_hostname: "{{ zabbix_server_dbtlsconnect is defined and zabbix_server_dbtlsconnect != '' }}"
when: item.msg != _mysql_schema_import_overrides[item.name]
loop: "{{ _mysql_variable_defaults.results }}"
loop_control:
Expand All @@ -130,13 +135,15 @@
login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}"
login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}"
login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}"
check_hostname: "{{ zabbix_server_dbtlsconnect is defined and zabbix_server_dbtlsconnect != '' }}"

- name: "MySQL | Import schema"
community.mysql.mysql_db:
login_user: "{{ zabbix_server_dbuser }}"
login_password: "{{ zabbix_server_dbpassword }}"
login_host: "{{ zabbix_server_dbhost }}"
login_port: "{{ zabbix_server_dbport }}"
check_hostname: "{{ zabbix_server_dbtlsconnect is defined and zabbix_server_dbtlsconnect != '' }}"
name: "{{ zabbix_server_dbname }}"
encoding: "{{ zabbix_server_dbencoding }}"
collation: "{{ zabbix_server_dbcollation }}"
Expand All @@ -154,6 +161,7 @@
login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}"
login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}"
login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}"
check_hostname: "{{ zabbix_server_dbtlsconnect is defined and zabbix_server_dbtlsconnect != '' }}"
loop: "{{ _mysql_variable_defaults.results | default([]) }}"
loop_control:
label: "{{ item.name }}: {{ item.msg }}"

0 comments on commit 7863918

Please # to comment.