From c92bee83c23c4bb51609258c8249dd64845528f9 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 3 May 2024 20:48:45 +0200 Subject: [PATCH] Add variable to globally control notifications enablement In order to be able to globally enable notification reporting for all services, without an need to have ceilometer deployed or bunch of overrides for each service, we add `oslomsg_notify_enabled` variable that aims to control behaviour of enabled notifications. Presence of ceilometer is still respected by default and being referenced. Potential usecase are various billing panels that do rely on notifications but do not require presence of Ceilometer. Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-plugins/+/914144 Change-Id: I3588572fda1e385ff7c39d5aa68c5aafcb6b89c6 --- defaults/main.yml | 1 + tasks/main.yml | 1 + templates/zun.conf.j2 | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 2dff4fe..6deb94f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -177,6 +177,7 @@ zun_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" zun_oslomsg_rpc_policies: [] # Notify +zun_oslomsg_notify_configure: "{{ oslomsg_notify_configure | default(zun_ceilometer_enabled or zun_designate_enabled) }}" zun_oslomsg_notify_host_group: "{{ oslomsg_notify_host_group | default('rabbitmq_all') }}" zun_oslomsg_notify_setup_host: "{{ (zun_oslomsg_notify_host_group in groups) | ternary(groups[zun_oslomsg_notify_host_group][0], 'localhost') }}" zun_oslomsg_notify_transport: "{{ oslomsg_notify_transport | default('rabbit') }}" diff --git a/tasks/main.yml b/tasks/main.yml index 22c7be4..12ac413 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -106,6 +106,7 @@ _oslomsg_notify_transport: "{{ zun_oslomsg_notify_transport }}" _oslomsg_configure_notify: "{{ (zun_ceilometer_enabled | bool) or (zun_designate_enabled | bool) }}" _oslomsg_notify_policies: "{{ zun_oslomsg_notify_policies }}" + _oslomsg_notify_configure: "{{ zun_oslomsg_notify_configure }}" tags: - always diff --git a/templates/zun.conf.j2 b/templates/zun.conf.j2 index eb6f40e..5acefd2 100644 --- a/templates/zun.conf.j2 +++ b/templates/zun.conf.j2 @@ -88,9 +88,9 @@ lock_path = {{ zun_lock_dir }}/{{ zun_system_slice_name }} [oslo_messaging_notifications] -driver = {{ (zun_ceilometer_enabled | bool) | ternary('messagingv2', 'noop') }} +driver = {{ (zun_oslomsg_notify_configure | bool) | ternary('messagingv2', 'noop') }} transport_url = {{ zun_oslomsg_notify_transport }}://{% for host in zun_oslomsg_notify_servers.split(',') %}{{ zun_oslomsg_notify_userid }}:{{ zun_oslomsg_notify_password }}@{{ host }}:{{ zun_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _zun_oslomsg_notify_vhost_conf }}{% if zun_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ zun_oslomsg_notify_ssl_version }}&ssl_ca_file={{ zun_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} -{% if zun_ceilometer_enabled or zun_designate_enabled %} +{% if zun_oslomsg_notify_configure %} {% set notification_topics = [] %} {% if zun_ceilometer_enabled %} {% set _ = notification_topics.append('notifications') %}