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.
|
# setting in the systemd unit file for MariaDB on CentOS 7 hosts.
|
||||||
galera_disable_privatedevices: no
|
galera_disable_privatedevices: no
|
||||||
|
|
||||||
# Allow the playbook to orchestrate service restart handlers
|
|
||||||
galera_external_restart_handlers: no
|
|
||||||
|
|
||||||
## Set default mirror for openSUSE repositories
|
## Set default mirror for openSUSE repositories
|
||||||
# NOTE(hwoarang): Ensure that the full path to the 'opensuse' directory is used.
|
# NOTE(hwoarang): Ensure that the full path to the 'opensuse' directory is used.
|
||||||
#galera_server_opensuse_mirror_obs_url: "http://widehat.opensuse.org"
|
#galera_server_opensuse_mirror_obs_url: "http://widehat.opensuse.org"
|
||||||
|
@ -29,3 +29,16 @@ Example playbook
|
|||||||
|
|
||||||
.. literalinclude:: ../../examples/playbook.yml
|
.. literalinclude:: ../../examples/playbook.yml
|
||||||
:language: yaml
|
: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:
|
when:
|
||||||
- not galera_running_and_bootstrapped | bool
|
- not galera_running_and_bootstrapped | bool
|
||||||
- ansible_pkg_mgr != "zypper"
|
- ansible_pkg_mgr != "zypper"
|
||||||
- not galera_external_restart_handlers | bool
|
|
||||||
register: galera_restart
|
register: galera_restart
|
||||||
until: galera_restart | success
|
until: galera_restart | success
|
||||||
retries: 3
|
retries: 3
|
||||||
@ -71,7 +70,6 @@
|
|||||||
- not galera_running_and_bootstrapped | bool
|
- not galera_running_and_bootstrapped | bool
|
||||||
- not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node
|
- not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node
|
||||||
- ansible_pkg_mgr == "zypper"
|
- ansible_pkg_mgr == "zypper"
|
||||||
- not galera_external_restart_handlers | bool
|
|
||||||
|
|
||||||
- name: "Ensure node is not in bootstrap mode"
|
- name: "Ensure node is not in bootstrap mode"
|
||||||
lineinfile:
|
lineinfile:
|
||||||
@ -83,7 +81,6 @@
|
|||||||
- not galera_running_and_bootstrapped | bool
|
- not galera_running_and_bootstrapped | bool
|
||||||
- (not galera_existing_cluster | bool) or (not inventory_hostname == galera_server_bootstrap_node)
|
- (not galera_existing_cluster | bool) or (not inventory_hostname == galera_server_bootstrap_node)
|
||||||
- ansible_pkg_mgr == "zypper"
|
- ansible_pkg_mgr == "zypper"
|
||||||
- not galera_external_restart_handlers | bool
|
|
||||||
|
|
||||||
- name: Restart mysql on SUSE
|
- name: Restart mysql on SUSE
|
||||||
service:
|
service:
|
||||||
@ -92,7 +89,6 @@
|
|||||||
when:
|
when:
|
||||||
- not galera_running_and_bootstrapped | bool
|
- not galera_running_and_bootstrapped | bool
|
||||||
- ansible_pkg_mgr == "zypper"
|
- ansible_pkg_mgr == "zypper"
|
||||||
- not galera_external_restart_handlers | bool
|
|
||||||
register: galera_restart
|
register: galera_restart
|
||||||
until: galera_restart | success
|
until: galera_restart | success
|
||||||
retries: 3
|
retries: 3
|
||||||
@ -103,3 +99,7 @@
|
|||||||
notify:
|
notify:
|
||||||
- "Remove stale .sst"
|
- "Remove stale .sst"
|
||||||
listen: "Restart all mysql"
|
listen: "Restart all mysql"
|
||||||
|
|
||||||
|
- meta: noop
|
||||||
|
listen: Manage LB
|
||||||
|
when: false
|
||||||
|
@ -125,6 +125,7 @@
|
|||||||
- ansible_pkg_mgr in ['yum', 'dnf']
|
- ansible_pkg_mgr in ['yum', 'dnf']
|
||||||
- systemd_mysql_service.stat.exists
|
- systemd_mysql_service.stat.exists
|
||||||
notify:
|
notify:
|
||||||
|
- Manage LB
|
||||||
- Reload the systemd daemon
|
- Reload the systemd daemon
|
||||||
- Restart mysql
|
- Restart mysql
|
||||||
tags:
|
tags:
|
||||||
|
@ -78,7 +78,9 @@
|
|||||||
dest: /etc/mysql/debian.cnf
|
dest: /etc/mysql/debian.cnf
|
||||||
config_overrides: "{{ galera_debian_cnf_overrides }}"
|
config_overrides: "{{ galera_debian_cnf_overrides }}"
|
||||||
config_type: "ini"
|
config_type: "ini"
|
||||||
notify: Restart all mysql
|
notify:
|
||||||
|
- Manage LB
|
||||||
|
- Restart all mysql
|
||||||
tags:
|
tags:
|
||||||
- galera-config
|
- galera-config
|
||||||
- galera-client-user-config
|
- galera-client-user-config
|
||||||
@ -103,6 +105,7 @@
|
|||||||
mode: "0644"
|
mode: "0644"
|
||||||
when: ansible_pkg_mgr != 'zypper'
|
when: ansible_pkg_mgr != 'zypper'
|
||||||
notify:
|
notify:
|
||||||
|
- Manage LB
|
||||||
- Restart all mysql
|
- Restart all mysql
|
||||||
- Reload the systemd daemon
|
- Reload the systemd daemon
|
||||||
tags:
|
tags:
|
||||||
@ -130,6 +133,7 @@
|
|||||||
when:
|
when:
|
||||||
- ansible_service_mgr == 'systemd'
|
- ansible_service_mgr == 'systemd'
|
||||||
notify:
|
notify:
|
||||||
|
- Manage LB
|
||||||
- Reload the systemd daemon
|
- Reload the systemd daemon
|
||||||
- Restart all mysql
|
- Restart all mysql
|
||||||
tags:
|
tags:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user