From b78e58b1d7427ada28efc58eca97344401f596d0 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Fri, 25 Jan 2019 21:39:49 -0600 Subject: [PATCH] Allow mysqlcheck to be enabled/disabled and tuned The mysqlcheck allows deployers the ability to perform a cluster health check from anywhere using simple http requests on a specific port. This change makes it possible for deployers to enable or disable this check capability. This also allows deployers to change the port used for the mysqlcheck running within xinetd. New options: + galera_monitoring_check_enabled - bool + galera_monitoring_check_port - int The new options retains the hard-coded values as defaults, it will be enabled and run on port 9200. Change-Id: Ic966fbe5dfb39a35ecd10ece2901bb317c905c84 Signed-off-by: Kevin Carter --- defaults/main.yml | 6 +++ handlers/main.yml | 4 +- .../mysqlcheck-options-60fae226d8d4f3ca.yaml | 8 +++ tasks/galera_post_install.yml | 49 +++++++++++-------- templates/mysqlchk.j2 | 2 +- 5 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 releasenotes/notes/mysqlcheck-options-60fae226d8d4f3ca.yaml diff --git a/defaults/main.yml b/defaults/main.yml index d77b75dd..6917ec7f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -81,6 +81,12 @@ galera_monitoring_user_password: "" # #galera_monitoring_allowed_source: "0.0.0.0/0" +# Enable or disable the galera monitoring check capability +galera_monitoring_check_enabled: true + +# Set the monitoring port used with the galera monitoring check. +galera_monitoring_check_port: 9200 + galera_root_user: root # WARNING: This option is deprecated and will be removed in v12.0 diff --git a/handlers/main.yml b/handlers/main.yml index a35446be..b69003d5 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -93,5 +93,5 @@ - name: Restart xinetd service: name: xinetd - state: restarted - enabled: true + state: "{{ (galera_monitoring_check_enabled | bool) | ternary('restarted', 'stopped') }}" + enabled: "{{ galera_monitoring_check_enabled | bool }}" diff --git a/releasenotes/notes/mysqlcheck-options-60fae226d8d4f3ca.yaml b/releasenotes/notes/mysqlcheck-options-60fae226d8d4f3ca.yaml new file mode 100644 index 00000000..3e3dbec6 --- /dev/null +++ b/releasenotes/notes/mysqlcheck-options-60fae226d8d4f3ca.yaml @@ -0,0 +1,8 @@ +--- +features: + - It is now possible for deployers to enable or disable the `mysqlcheck` + capability. The Boolean option `galera_monitoring_check_enabled` has + been added which has a default value of **true**. + - It is now possible to change the port used by `mysqlcheck`. The integer + option `galera_monitoring_check_port` has been added with the default + value of **9200**. diff --git a/tasks/galera_post_install.yml b/tasks/galera_post_install.yml index 807f713b..4a34701f 100644 --- a/tasks/galera_post_install.yml +++ b/tasks/galera_post_install.yml @@ -175,33 +175,42 @@ dest: "/usr/local/bin/galera_new_cluster" mode: "0750" -- name: Create clustercheck script - template: - src: "clustercheck.j2" - dest: "/usr/local/bin/clustercheck" - mode: "0755" - # TODO: (nicolasbock) This task can be removed in T but is necessary # for S and earlier because deployments prior to this change will not # have the xinetd service enabled because the handler task runs only # for new deployments. +# NOTE(cloudnull): If `galera_monitoring_check_enabled` is set false +# the xinetd service will be disabled and stopped. +# using the handler. - name: Enable xinetd service service: name: xinetd - enabled: yes - -- name: Create mysqlchk config - template: - src: "mysqlchk.j2" - dest: "/etc/xinetd.d/mysqlchk" - mode: "0644" + enabled: "{{ galera_monitoring_check_enabled | bool }}" notify: - Restart xinetd -- name: Add galera service check to services - lineinfile: - dest: /etc/services - state: present - regexp: '^mysqlchk' - line: 'mysqlchk 9200/tcp # MySQL check' - backup: yes +- name: Cluster check block + block: + - name: Create clustercheck script + template: + src: "clustercheck.j2" + dest: "/usr/local/bin/clustercheck" + mode: "0755" + + - name: Create mysqlchk config + template: + src: "mysqlchk.j2" + dest: "/etc/xinetd.d/mysqlchk" + mode: "0644" + notify: + - Restart xinetd + + - name: Add galera service check to services + lineinfile: + dest: /etc/services + state: present + regexp: '^mysqlchk' + line: 'mysqlchk 9200/tcp # MySQL check' + backup: yes + when: + - galera_monitoring_check_enabled | bool diff --git a/templates/mysqlchk.j2 b/templates/mysqlchk.j2 index 3aa36001..ca6348d0 100644 --- a/templates/mysqlchk.j2 +++ b/templates/mysqlchk.j2 @@ -6,7 +6,7 @@ service mysqlchk disable = no flags = REUSE socket_type = stream - port = 9200 + port = {{ galera_monitoring_check_port }} wait = no user = nobody server = /usr/local/bin/clustercheck