diff --git a/defaults/main.yml b/defaults/main.yml index fb115353..4e8493cb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -187,9 +187,6 @@ galera_ssl_address: "{{ ansible_host }}" # setting in the systemd unit file for MariaDB on CentOS 7 hosts. galera_disable_privatedevices: no -# Allow the playbook to orchestrate service restart handlers -galera_external_restart_handlers: no - ## Set default mirror for openSUSE repositories # NOTE(hwoarang): Ensure that the full path to the 'opensuse' directory is used. #galera_server_opensuse_mirror_obs_url: "http://widehat.opensuse.org" diff --git a/doc/source/index.rst b/doc/source/index.rst index 8d4324a2..1ff1b750 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -29,3 +29,16 @@ Example playbook .. literalinclude:: ../../examples/playbook.yml :language: yaml + +External Restart Hooks +~~~~~~~~~~~~~~~~~~~~~~ + +When the role performs a restart of the mariadb service, it will notify an +Ansible handler named ``Manage LB``, which is a noop within this role. In the +playbook, other roles may be loaded before and after this role which will +implement Ansible handler listeners for ``Manage LB``, that way external roles +can manage the load balancer endpoints responsible for sending traffic to the +MariaDB servers being restarted by marking them in maintenance or active mode, +draining sessions, etc. For an example implementation, please reference the +`ansible-haproxy-endpoints role `_ +used by the openstack-ansible project. diff --git a/handlers/main.yml b/handlers/main.yml index d8e67df7..5e47e9ce 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -29,7 +29,6 @@ when: - not galera_running_and_bootstrapped | bool - ansible_pkg_mgr != "zypper" - - not galera_external_restart_handlers | bool register: galera_restart until: galera_restart | success retries: 3 @@ -71,7 +70,6 @@ - not galera_running_and_bootstrapped | bool - not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node - ansible_pkg_mgr == "zypper" - - not galera_external_restart_handlers | bool - name: "Ensure node is not in bootstrap mode" lineinfile: @@ -83,7 +81,6 @@ - not galera_running_and_bootstrapped | bool - (not galera_existing_cluster | bool) or (not inventory_hostname == galera_server_bootstrap_node) - ansible_pkg_mgr == "zypper" - - not galera_external_restart_handlers | bool - name: Restart mysql on SUSE service: @@ -92,7 +89,6 @@ when: - not galera_running_and_bootstrapped | bool - ansible_pkg_mgr == "zypper" - - not galera_external_restart_handlers | bool register: galera_restart until: galera_restart | success retries: 3 @@ -103,3 +99,7 @@ notify: - "Remove stale .sst" listen: "Restart all mysql" + +- meta: noop + listen: Manage LB + when: false diff --git a/tasks/galera_install_yum.yml b/tasks/galera_install_yum.yml index 8644c389..4601336a 100644 --- a/tasks/galera_install_yum.yml +++ b/tasks/galera_install_yum.yml @@ -125,6 +125,7 @@ - ansible_pkg_mgr in ['yum', 'dnf'] - systemd_mysql_service.stat.exists notify: + - Manage LB - Reload the systemd daemon - Restart mysql tags: diff --git a/tasks/galera_post_install.yml b/tasks/galera_post_install.yml index 1b141e9f..f24e9ec6 100644 --- a/tasks/galera_post_install.yml +++ b/tasks/galera_post_install.yml @@ -78,7 +78,9 @@ dest: /etc/mysql/debian.cnf config_overrides: "{{ galera_debian_cnf_overrides }}" config_type: "ini" - notify: Restart all mysql + notify: + - Manage LB + - Restart all mysql tags: - galera-config - galera-client-user-config @@ -103,6 +105,7 @@ mode: "0644" when: ansible_pkg_mgr != 'zypper' notify: + - Manage LB - Restart all mysql - Reload the systemd daemon tags: @@ -130,6 +133,7 @@ when: - ansible_service_mgr == 'systemd' notify: + - Manage LB - Reload the systemd daemon - Restart all mysql tags: