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:
Logan V 2017-09-16 13:53:56 -05:00
parent 59c2343d88
commit 5108e06793
6 changed files with 28 additions and 3 deletions

View File

@ -47,6 +47,19 @@ Example playbook
.. literalinclude:: ../../examples/playbook.yml
: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
~~~~
@ -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
service.

View File

@ -67,3 +67,7 @@
enabled: yes
state: restarted
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
- meta: noop
listen: Manage LB
when: false

View File

@ -50,6 +50,7 @@
group: "root"
with_items: "{{ filtered_cinder_services }}"
notify:
- Manage LB
- Restart cinder services
- name: Place the systemd init script
@ -63,4 +64,5 @@
config_type: "ini"
with_items: "{{ filtered_cinder_services }}"
notify:
- Manage LB
- Restart cinder services

View File

@ -80,7 +80,9 @@
dest: "{{ cinder_bin | dirname }}"
copy: "no"
when: cinder_get_venv | changed
notify: Restart cinder services
notify:
- Manage LB
- Restart cinder services
- name: Install pip packages
pip:
@ -97,7 +99,9 @@
retries: 5
delay: 2
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)
file:

View File

@ -40,6 +40,7 @@
config_overrides: "{{ cinder_policy_overrides }}"
config_type: "json"
notify:
- Manage LB
- Restart cinder services
- name: Copy cinder configs
@ -51,6 +52,7 @@
with_fileglob:
- rootwrap.d/*
notify:
- Manage LB
- Restart cinder services
- name: Ensure cinder tgt include

View File

@ -29,4 +29,5 @@
with_items: "{{ filtered_cinder_services }}"
when: item.wsgi_app | default(False)
notify:
- Manage LB
- Restart cinder services