From 5772b128a5202bb71ca8bf0b33ccfe3de2753292 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 23 Apr 2024 19:13:13 +0200 Subject: [PATCH] Add variable to globally control notifications enablement and disable RPC 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. This change also disables RPC communication for Glance since there's no signs of RPC usage in Glance code. RabbitMQ seems to be used solely for notifications Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-plugins/+/914144 Change-Id: I854374788ed92efe0164c29414978a1d14b83410 --- defaults/main.yml | 2 ++ tasks/main.yml | 2 ++ templates/glance-api.conf.j2 | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 6a4d9c35..4316c41d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -107,6 +107,7 @@ glance_enable_v2_api: True ## Oslo Messaging Info # RPC +glance_oslomsg_rpc_configure: False glance_oslomsg_rpc_host_group: "{{ oslomsg_rpc_host_group | default('rabbitmq_all') }}" glance_oslomsg_rpc_setup_host: "{{ (glance_oslomsg_rpc_host_group in groups) | ternary(groups[glance_oslomsg_rpc_host_group][0], 'localhost') }}" glance_oslomsg_rpc_transport: "{{ oslomsg_rpc_transport | default('rabbit') }}" @@ -126,6 +127,7 @@ glance_oslomsg_rpc_ssl_version: "{{ oslomsg_rpc_ssl_version | default('TLSv1_2') glance_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" # Notify +glance_oslomsg_notify_configure: "{{ oslomsg_notify_configure | default(glance_ceilometer_enabled) }}" glance_oslomsg_notify_host_group: "{{ oslomsg_notify_host_group | default('rabbitmq_all') }}" glance_oslomsg_notify_setup_host: "{{ (glance_oslomsg_notify_host_group in groups) | ternary(groups[glance_oslomsg_notify_host_group][0], 'localhost') }}" glance_oslomsg_notify_transport: "{{ oslomsg_notify_transport | default('rabbit') }}" diff --git a/tasks/main.yml b/tasks/main.yml index feecd99c..f63e85d6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -81,12 +81,14 @@ _oslomsg_rpc_vhost: "{{ glance_oslomsg_rpc_vhost }}" _oslomsg_rpc_transport: "{{ glance_oslomsg_rpc_transport }}" _oslomsg_rpc_policies: "{{ glance_oslomsg_rpc_policies }}" + _oslomsg_rpc_configure: "{{ glance_oslomsg_rpc_configure }}" _oslomsg_notify_setup_host: "{{ glance_oslomsg_notify_setup_host }}" _oslomsg_notify_userid: "{{ glance_oslomsg_notify_userid }}" _oslomsg_notify_password: "{{ glance_oslomsg_notify_password }}" _oslomsg_notify_vhost: "{{ glance_oslomsg_notify_vhost }}" _oslomsg_notify_transport: "{{ glance_oslomsg_notify_transport }}" _oslomsg_notify_policies: "{{ glance_oslomsg_notify_policies }}" + _oslomsg_notify_configure: "{{ glance_oslomsg_notify_configure }}" tags: - always diff --git a/templates/glance-api.conf.j2 b/templates/glance-api.conf.j2 index 52f8b267..e97178f4 100644 --- a/templates/glance-api.conf.j2 +++ b/templates/glance-api.conf.j2 @@ -16,7 +16,9 @@ worker_self_reference_url = {{ (glance_backend_ssl | ternary('https', 'http')) ~ enable_v2_api = {{ glance_enable_v2_api | bool }} +{% if glance_oslomsg_rpc_configure %} transport_url = {{ glance_oslomsg_rpc_transport }}://{% for host in glance_oslomsg_rpc_servers.split(',') %}{{ glance_oslomsg_rpc_userid }}:{{ glance_oslomsg_rpc_password }}@{{ host }}:{{ glance_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ _glance_oslomsg_rpc_vhost_conf }}{% if glance_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ glance_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ glance_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +{% endif %} scrub_time = 43200 @@ -83,7 +85,7 @@ rabbit_quorum_max_memory_bytes = {{ glance_oslomsg_rabbit_quorum_max_memory_byte [oslo_messaging_notifications] topics = notifications -driver = {{ (glance_ceilometer_enabled | bool) | ternary('messagingv2', 'noop') }} +driver = {{ (glance_oslomsg_notify_configure | bool) | ternary('messagingv2', 'noop') }} transport_url = {{ glance_oslomsg_notify_transport }}://{% for host in glance_oslomsg_notify_servers.split(',') %}{{ glance_oslomsg_notify_userid }}:{{ glance_oslomsg_notify_password }}@{{ host }}:{{ glance_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _glance_oslomsg_notify_vhost_conf }}{% if glance_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ glance_oslomsg_notify_ssl_version }}&ssl_ca_file={{ glance_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} [paste_deploy]