Add external LB management handler hook interface
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 Change-Id: I19818234d9c8a5ad90b6387c360d598fda03a65e
This commit is contained in:
@@ -47,6 +47,19 @@ 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 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``, allowing external roles
|
||||||
|
to manage the load balancer endpoints responsible for sending traffic to the
|
||||||
|
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.
|
||||||
|
|
||||||
Tags
|
Tags
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
@@ -56,4 +69,3 @@ The ``cinder-install`` tag can be used to install and upgrade.
|
|||||||
|
|
||||||
The ``cinder-config`` tag can be used to maintain configuration of the
|
The ``cinder-config`` tag can be used to maintain configuration of the
|
||||||
service.
|
service.
|
||||||
|
|
||||||
|
|||||||
@@ -67,3 +67,7 @@
|
|||||||
enabled: yes
|
enabled: yes
|
||||||
state: restarted
|
state: restarted
|
||||||
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
|
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
|
||||||
|
|
||||||
|
- meta: noop
|
||||||
|
listen: Manage LB
|
||||||
|
when: false
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
group: "root"
|
group: "root"
|
||||||
with_items: "{{ filtered_cinder_services }}"
|
with_items: "{{ filtered_cinder_services }}"
|
||||||
notify:
|
notify:
|
||||||
|
- Manage LB
|
||||||
- Restart cinder services
|
- Restart cinder services
|
||||||
|
|
||||||
- name: Place the systemd init script
|
- name: Place the systemd init script
|
||||||
@@ -63,4 +64,5 @@
|
|||||||
config_type: "ini"
|
config_type: "ini"
|
||||||
with_items: "{{ filtered_cinder_services }}"
|
with_items: "{{ filtered_cinder_services }}"
|
||||||
notify:
|
notify:
|
||||||
|
- Manage LB
|
||||||
- Restart cinder services
|
- Restart cinder services
|
||||||
|
|||||||
@@ -80,7 +80,9 @@
|
|||||||
dest: "{{ cinder_bin | dirname }}"
|
dest: "{{ cinder_bin | dirname }}"
|
||||||
copy: "no"
|
copy: "no"
|
||||||
when: cinder_get_venv | changed
|
when: cinder_get_venv | changed
|
||||||
notify: Restart cinder services
|
notify:
|
||||||
|
- Manage LB
|
||||||
|
- Restart cinder services
|
||||||
|
|
||||||
- name: Install pip packages
|
- name: Install pip packages
|
||||||
pip:
|
pip:
|
||||||
@@ -97,7 +99,9 @@
|
|||||||
retries: 5
|
retries: 5
|
||||||
delay: 2
|
delay: 2
|
||||||
when: cinder_get_venv | failed or cinder_get_venv | skipped
|
when: cinder_get_venv | failed or cinder_get_venv | skipped
|
||||||
notify: Restart cinder services
|
notify:
|
||||||
|
- Manage LB
|
||||||
|
- Restart cinder services
|
||||||
|
|
||||||
- name: Remove python from path first (CentOS, openSUSE)
|
- name: Remove python from path first (CentOS, openSUSE)
|
||||||
file:
|
file:
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
config_overrides: "{{ cinder_policy_overrides }}"
|
config_overrides: "{{ cinder_policy_overrides }}"
|
||||||
config_type: "json"
|
config_type: "json"
|
||||||
notify:
|
notify:
|
||||||
|
- Manage LB
|
||||||
- Restart cinder services
|
- Restart cinder services
|
||||||
|
|
||||||
- name: Copy cinder configs
|
- name: Copy cinder configs
|
||||||
@@ -51,6 +52,7 @@
|
|||||||
with_fileglob:
|
with_fileglob:
|
||||||
- rootwrap.d/*
|
- rootwrap.d/*
|
||||||
notify:
|
notify:
|
||||||
|
- Manage LB
|
||||||
- Restart cinder services
|
- Restart cinder services
|
||||||
|
|
||||||
- name: Ensure cinder tgt include
|
- name: Ensure cinder tgt include
|
||||||
|
|||||||
@@ -29,4 +29,5 @@
|
|||||||
with_items: "{{ filtered_cinder_services }}"
|
with_items: "{{ filtered_cinder_services }}"
|
||||||
when: item.wsgi_app | default(False)
|
when: item.wsgi_app | default(False)
|
||||||
notify:
|
notify:
|
||||||
|
- Manage LB
|
||||||
- Restart cinder services
|
- Restart cinder services
|
||||||
|
|||||||
Reference in New Issue
Block a user