Reimplement external LB management handler hook
Based on conversation on an ansible issue[1], I implemented a LB orchestration role[2] similar to the POC here[3]. This will allow external loadbalancer management roles to hook into a universal notify listener "Manage LB" to perform before/ after endpoint management actions when the service is being restarted. [1]: https://github.com/ansible/ansible/issues/27813 [2]: https://github.com/Logan2211/ansible-haproxy-endpoints [3]: https://github.com/Logan2211/tmp-ansible-27813 This reverts commit f876cf2926d5a80bd4e8b3acd6da2e9553b98e8f. Change-Id: Ib17c9ae6f5e75ce2288d52f6368cd40e9586ffdb
This commit is contained in:
parent
df18e4ecbe
commit
149076cd2c
@ -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"
|
||||
|
@ -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 <https://github.com/Logan2211/ansible-haproxy-endpoints>`_
|
||||
used by the openstack-ansible project.
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user