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: I5aecc26606f41bc6b27fbe9a5f600914a88ff2c7
This commit is contained in:
Logan V 2017-09-16 14:23:03 -05:00
parent b1fdb2daf7
commit 902e638d95
7 changed files with 35 additions and 5 deletions

View File

@ -31,6 +31,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
~~~~

View File

@ -74,3 +74,7 @@
- "'nova_compute' in group_names"
- "nova_discover_hosts_in_cells_interval | int < 1"
listen: "Restart nova services"
- meta: noop
listen: Manage LB
when: false

View File

@ -39,6 +39,8 @@
with_items:
- { content: "{{ nova_console_user_ssl_combined.stdout ~ '\n' }}", dest: "{{ nova_console_ssl_cert }}", mode: "0644" }
- { src: "{{ nova_console_user_ssl_key }}", dest: "{{ nova_console_ssl_key }}", mode: "0640" }
notify: Restart nova services
notify:
- Manage LB
- Restart nova services
tags:
- nova-config

View File

@ -49,6 +49,7 @@
group: "root"
with_items: "{{ filtered_nova_services }}"
notify:
- Manage LB
- Restart nova services
- name: Place the systemd init script
@ -62,4 +63,5 @@
config_type: "ini"
with_items: "{{ filtered_nova_services }}"
notify:
- Manage LB
- Restart nova services

View File

@ -118,7 +118,9 @@
copy: "no"
when:
- nova_get_venv | changed
notify: Restart nova services
notify:
- Manage LB
- Restart nova services
tags:
- nova-pip-packages
@ -138,7 +140,9 @@
delay: 2
when:
- nova_get_venv | failed or nova_get_venv | skipped
notify: Restart nova services
notify:
- Manage LB
- Restart nova services
tags:
- nova-pip-packages

View File

@ -51,7 +51,9 @@
dest: "/etc/nova/policy.json-{{ nova_venv_tag }}"
config_overrides: "{{ nova_policy_overrides }}"
config_type: "json"
notify: Restart nova services
notify:
- Manage LB
- Restart nova services
tags:
- nova-config
- nova-post-install
@ -64,7 +66,9 @@
group: "root"
with_fileglob:
- rootwrap.d/*
notify: Restart nova services
notify:
- Manage LB
- Restart nova services
tags:
- nova-config
- nova-post-install

View File

@ -30,6 +30,7 @@
with_items: "{{ filtered_nova_services }}"
when: item.wsgi_app | default(False)
notify:
- Manage LB
- Restart nova services
# Cleanup and restart nginx configuration