From 22a6223b1b0d56011a4ddf3662104280d370f4ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Weing=C3=A4rtner?= <rafael@apache.org>
Date: Fri, 26 Jul 2019 09:25:25 -0300
Subject: [PATCH] Standardize the configuration of "oslo_messaging" section
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

After all of the discussions we had on
"https://review.opendev.org/#/c/670626/2", I studied all projects that
have an "oslo_messaging" section. Afterwards, I applied the same method
that is already used in "oslo_messaging" section in Nova, Cinder, and
others. This guarantees that we have a consistent method to
enable/disable notifications across projects based on components (e.g.
Ceilometer) being enabled or disabled. Here follows the list of
components, and the respective changes I did.

* Aodh:
The section is declared, but it is not used. Therefore, it will
be removed in an upcomming PR.

* Congress:
The section is declared, but it is not used. Therefore, it will
be removed in an upcomming PR.

* Cinder:
It was already properly configured.

* Octavia:
The section is declared, but it is not used. Therefore, it will
be removed in an upcomming PR.

* Heat:
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Ceilometer:
Ceilometer publishes some messages in the rabbitMQ. However, the
default driver is "messagingv2", and not ''(empty) as defined in Oslo;
these configurations are defined in ceilometer/publisher/messaging.py.
Therefore, we do not need to do anything for the
"oslo_messaging_notifications" section in Ceilometer

* Tacker:
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Neutron:
It was already properly configured.

* Nova
It was already properly configured. However, we found another issue
with its configuration. Kolla-ansible does not configure nova
notifications as it should. If 'searchlight' is not installed (enabled)
the 'notification_format' should be 'unversioned'. The default is
'both'; so nova will send a notification to the queue
versioned_notifications; but that queue has no consumer when
'searchlight' is disabled. In our case, the queue got 511k messages.
The huge amount of "stuck" messages made the Rabbitmq cluster
unstable.

https://bugzilla.redhat.com/show_bug.cgi?id=1478274
https://bugs.launchpad.net/ceilometer/+bug/1665449

* Nova_hyperv:
I added the same configurations as in Nova project.

* Vitrage
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Searchlight
I created a mechanism similar to what we have in AODH, Cinder, Nova,
and others.

* Ironic
I created a mechanism similar to what we have in AODH, Cinder, Nova,
and others.

* Glance
It was already properly configured.

* Trove
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Blazar
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Sahara
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Watcher
I created a mechanism similar to what we have in AODH, Cinder, Nova,
and others.

* Barbican
I created a mechanism similar to what we have in Cinder, Nova,
and others. I also added a configuration to 'keystone_notifications'
section. Barbican needs its own queue to capture events from Keystone.
Otherwise, it has an impact on Ceilometer and other systems that are
connected to the "notifications" default queue.

* Keystone
Keystone is the system that triggered this work with the discussions
that followed on https://review.opendev.org/#/c/670626/2. After a long
discussion, we agreed to apply the same approach that we have in Nova,
Cinder and other systems in Keystone. That is what we did. Moreover, we
introduce a new topic "barbican_notifications" when barbican is
enabled. We also removed the "variable" enable_cadf_notifications, as
it is obsolete, and the default in Keystone is CADF.

* Mistral:
It was hardcoded "noop" as the driver. However, that does not seem a
good practice. Instead, I applied the same standard of using the driver
and pushing to "notifications" queue if Ceilometer is enabled.

* Cyborg:
I created a mechanism similar to what we have in AODH, Cinder, Nova,
and others.

* Murano
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Senlin
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Manila
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Zun
The section is declared, but it is not used. Therefore, it will
be removed in an upcomming PR.

* Designate
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

* Magnum
It was already using a similar scheme; I just modified it a little bit
to be the same as we have in all other components

Closes-Bug: #1838985

Change-Id: I88bdb004814f37c81c9a9c4e5e491fac69f6f202
Signed-off-by: Rafael Weingärtner <rafael@apache.org>
---
 ansible/group_vars/all.yml                       |  1 +
 .../roles/barbican/templates/barbican.conf.j2    |  3 +++
 ansible/roles/blazar/defaults/main.yml           | 10 ++++++++++
 ansible/roles/blazar/templates/blazar.conf.j2    |  5 +++--
 ansible/roles/cyborg/defaults/main.yml           | 10 ++++++++++
 ansible/roles/cyborg/templates/cyborg.conf.j2    |  6 ++++++
 ansible/roles/designate/defaults/main.yml        | 12 ++++++++++++
 .../roles/designate/templates/designate.conf.j2  | 10 +++++++---
 ansible/roles/heat/defaults/main.yml             |  9 +++++++++
 ansible/roles/heat/templates/heat.conf.j2        |  4 ++--
 ansible/roles/ironic/defaults/main.yml           | 12 +++++++++++-
 ansible/roles/ironic/templates/ironic.conf.j2    |  6 ++++++
 ansible/roles/karbor/defaults/main.yml           | 10 ++++++++++
 ansible/roles/karbor/templates/karbor.conf.j2    |  6 ++++++
 ansible/roles/keystone/defaults/main.yml         | 15 +++++++++++++++
 .../roles/keystone/templates/keystone.conf.j2    |  9 +++++----
 ansible/roles/magnum/defaults/main.yml           | 10 ++++++++++
 ansible/roles/magnum/templates/magnum.conf.j2    |  4 ++--
 ansible/roles/manila/defaults/main.yml           | 10 ++++++++++
 ansible/roles/manila/templates/manila.conf.j2    |  7 +++++++
 ansible/roles/mistral/defaults/main.yml          | 10 ++++++++++
 ansible/roles/mistral/templates/mistral.conf.j2  |  5 +++++
 ansible/roles/murano/defaults/main.yml           |  9 +++++++++
 ansible/roles/murano/templates/murano.conf.j2    |  5 +++++
 ansible/roles/nova-hyperv/defaults/main.yml      | 13 +++++++++++++
 .../templates/neutron_hyperv_agent.conf.j2       |  6 ++++++
 .../nova-hyperv/templates/nova_hyperv.conf.j2    | 13 +++++++++++++
 ansible/roles/nova/templates/nova.conf.j2        |  6 ++++++
 ansible/roles/sahara/defaults/main.yml           |  9 +++++++++
 ansible/roles/sahara/templates/sahara.conf.j2    |  4 ++--
 ansible/roles/searchlight/defaults/main.yml      | 10 ++++++++++
 .../searchlight/templates/searchlight.conf.j2    |  7 +++++++
 ansible/roles/senlin/defaults/main.yml           | 10 ++++++++++
 ansible/roles/senlin/templates/senlin.conf.j2    |  4 ++--
 ansible/roles/tacker/defaults/main.yml           |  9 +++++++++
 ansible/roles/tacker/templates/tacker.conf.j2    |  4 ++--
 ansible/roles/trove/defaults/main.yml            |  9 +++++++++
 .../trove/templates/trove-conductor.conf.j2      |  6 ++++++
 .../trove/templates/trove-taskmanager.conf.j2    |  5 +++--
 ansible/roles/trove/templates/trove.conf.j2      |  4 ++--
 ansible/roles/vitrage/defaults/main.yml          | 11 +++++++++++
 ansible/roles/vitrage/templates/vitrage.conf.j2  |  6 +++++-
 ansible/roles/watcher/defaults/main.yml          | 10 ++++++++++
 ansible/roles/watcher/templates/watcher.conf.j2  |  6 ++++++
 ...oslo-messaging-sections-4769da25bc58aa02.yaml | 16 ++++++++++++++++
 45 files changed, 331 insertions(+), 25 deletions(-)
 create mode 100644 releasenotes/notes/standard-oslo-messaging-sections-4769da25bc58aa02.yaml

diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml
index 9b5922f3e6..fea006420e 100644
--- a/ansible/group_vars/all.yml
+++ b/ansible/group_vars/all.yml
@@ -518,6 +518,7 @@ enable_haproxy_memcached: "yes"
 enable_aodh: "no"
 enable_barbican: "no"
 enable_blazar: "no"
+# NOTE: This variable has been deprecated and will be removed in the U cycle.
 enable_cadf_notifications: "no"
 enable_ceilometer: "no"
 enable_ceilometer_ipmi: "no"
diff --git a/ansible/roles/barbican/templates/barbican.conf.j2 b/ansible/roles/barbican/templates/barbican.conf.j2
index 8d13adf810..06eaff3fa7 100644
--- a/ansible/roles/barbican/templates/barbican.conf.j2
+++ b/ansible/roles/barbican/templates/barbican.conf.j2
@@ -46,6 +46,9 @@ kek = '{{ barbican_crypto_key }}'
 
 [keystone_notifications]
 enable = True
+{% if enable_keystone | bool %}
+topic = barbican_notifications
+{% endif %}
 
 [keystone_authtoken]
 www_authenticate_uri = {{ keystone_internal_url }}
diff --git a/ansible/roles/blazar/defaults/main.yml b/ansible/roles/blazar/defaults/main.yml
index b919bb9d8e..cd0fc46872 100644
--- a/ansible/roles/blazar/defaults/main.yml
+++ b/ansible/roles/blazar/defaults/main.yml
@@ -95,3 +95,13 @@ blazar_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 blazar_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 blazar_dev_mode: "{{ kolla_dev_mode }}"
 blazar_source_version: "{{ kolla_source_version }}"
+
+
+####################
+# Notifications
+####################
+blazar_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+blazar_enabled_notification_topics: "{{ blazar_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/blazar/templates/blazar.conf.j2 b/ansible/roles/blazar/templates/blazar.conf.j2
index 8c83a8bc0f..fb778e9f6b 100644
--- a/ansible/roles/blazar/templates/blazar.conf.j2
+++ b/ansible/roles/blazar/templates/blazar.conf.j2
@@ -50,13 +50,14 @@ blazar_password = {{ blazar_keystone_password }}
 blazar_project_name = service
 
 [oslo_messaging_notifications]
-{% if enable_ceilometer | bool %}
+{% if blazar_enabled_notification_topics %}
 driver = messagingv2
-topics = notifications
+topics = {{ blazar_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
 
+
 {% if blazar_policy_file is defined %}
 [oslo_policy]
 policy_file = {{ blazar_policy_file }}
diff --git a/ansible/roles/cyborg/defaults/main.yml b/ansible/roles/cyborg/defaults/main.yml
index 4bb3a469ea..0da20352ed 100644
--- a/ansible/roles/cyborg/defaults/main.yml
+++ b/ansible/roles/cyborg/defaults/main.yml
@@ -86,3 +86,13 @@ cyborg_logging_debug: "{{ openstack_logging_debug }}"
 cyborg_keystone_user: "cyborg"
 
 openstack_cyborg_auth: "{{ openstack_auth }}"
+
+
+####################
+# Notifications
+####################
+cyborg_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+cyborg_enabled_notification_topics: "{{ cyborg_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/cyborg/templates/cyborg.conf.j2 b/ansible/roles/cyborg/templates/cyborg.conf.j2
index 92c0f8fa88..6fd8dae9ec 100644
--- a/ansible/roles/cyborg/templates/cyborg.conf.j2
+++ b/ansible/roles/cyborg/templates/cyborg.conf.j2
@@ -33,3 +33,9 @@ policy_file = {{ cyborg_policy_file }}
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if cyborg_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ cyborg_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
diff --git a/ansible/roles/designate/defaults/main.yml b/ansible/roles/designate/defaults/main.yml
index c4742a885a..ee12db66e6 100644
--- a/ansible/roles/designate/defaults/main.yml
+++ b/ansible/roles/designate/defaults/main.yml
@@ -206,3 +206,15 @@ designate_infoblox_auth_username: ""
 designate_infoblox_auth_password: ""
 designate_infoblox_multi_tenant: "false"
 designate_infoblox_ns_group: ""
+
+
+####################
+# Notifications
+####################
+designate_notifications_topic_name: "notifications_designate"
+
+designate_notification_topics:
+  - name: "{{ designate_notifications_topic_name }}"
+    enabled: True
+
+designate_enabled_notification_topics: "{{ designate_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/designate/templates/designate.conf.j2 b/ansible/roles/designate/templates/designate.conf.j2
index 97e90cfdb3..749ccdf0c1 100644
--- a/ansible/roles/designate/templates/designate.conf.j2
+++ b/ansible/roles/designate/templates/designate.conf.j2
@@ -80,7 +80,7 @@ idle_timeout = 3600
 [handler:nova_fixed]
 #NOTE: zone_id must be manually filled an ID from openstack zone list
 zone_id =
-notification_topics = notifications_designate
+notification_topics = {{ designate_notifications_topic_name }}
 control_exchange = nova
 formatv4 = '%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(zone)s'
 formatv4 = '%(hostname)s.%(project)s.%(zone)s'
@@ -91,14 +91,18 @@ formatv6 = '%(hostname)s.%(project)s.%(zone)s'
 [handler:neutron_floatingip]
 #NOTE: zone_id must be manually filled an ID from openstack zone list
 zone_id =
-notification_topics = notifications_designate
+notification_topics = {{ designate_notifications_topic_name }}
 control_exchange = neutron
 formatv4 = '%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(zone)s'
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-topics = notifications_designate
+{% if designate_enabled_notification_topics %}
 driver = messagingv2
+topics = {{ designate_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
 
 [oslo_concurrency]
 lock_path = /var/lib/designate/tmp
diff --git a/ansible/roles/heat/defaults/main.yml b/ansible/roles/heat/defaults/main.yml
index 2e4455d67c..06761f170c 100644
--- a/ansible/roles/heat/defaults/main.yml
+++ b/ansible/roles/heat/defaults/main.yml
@@ -127,3 +127,12 @@ heat_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 heat_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 heat_dev_mode: "{{ kolla_dev_mode }}"
 heat_source_version: "{{ kolla_source_version }}"
+
+####################
+# Notifications
+####################
+heat_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+heat_enabled_notification_topics: "{{ heat_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/heat/templates/heat.conf.j2 b/ansible/roles/heat/templates/heat.conf.j2
index 9431c4de08..e9da76dce6 100644
--- a/ansible/roles/heat/templates/heat.conf.j2
+++ b/ansible/roles/heat/templates/heat.conf.j2
@@ -77,9 +77,9 @@ auth_uri = {{ keystone_public_url }}
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool %}
+{% if heat_enabled_notification_topics %}
 driver = messagingv2
-topics = notifications
+topics = {{ heat_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
diff --git a/ansible/roles/ironic/defaults/main.yml b/ansible/roles/ironic/defaults/main.yml
index f1f0a29bca..1dbdd4077e 100644
--- a/ansible/roles/ironic/defaults/main.yml
+++ b/ansible/roles/ironic/defaults/main.yml
@@ -191,7 +191,6 @@ openstack_ironic_inspector_auth: "{{ openstack_auth }}"
 #########
 # Ironic
 #########
-
 ironic_dnsmasq_interface: "{{ api_interface }}"
 ironic_dnsmasq_dhcp_range:
 ironic_dnsmasq_default_gateway:
@@ -203,6 +202,7 @@ ironic_enable_rolling_upgrade: "yes"
 ironic_inspector_kernel_cmdline_extras: []
 ironic_inspector_pxe_filter: "{% if enable_neutron | bool %}dnsmasq{% else %}none{% endif %}"
 
+
 ####################
 ## Kolla
 #####################
@@ -211,3 +211,13 @@ ironic_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 ironic_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 ironic_dev_mode: "{{ kolla_dev_mode }}"
 ironic_source_version: "{{ kolla_source_version }}"
+
+
+####################
+# Notifications
+####################
+ironic_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+ironic_enabled_notification_topics: "{{ ironic_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/ironic/templates/ironic.conf.j2 b/ansible/roles/ironic/templates/ironic.conf.j2
index 674412d6de..bee01a1020 100644
--- a/ansible/roles/ironic/templates/ironic.conf.j2
+++ b/ansible/roles/ironic/templates/ironic.conf.j2
@@ -21,6 +21,12 @@ pin_release_version = {{ pin_release_version }}
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if ironic_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ ironic_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
 
 {% if ironic_policy_file is defined %}
 [oslo_policy]
diff --git a/ansible/roles/karbor/defaults/main.yml b/ansible/roles/karbor/defaults/main.yml
index 4979e29102..9ca3d767ec 100644
--- a/ansible/roles/karbor/defaults/main.yml
+++ b/ansible/roles/karbor/defaults/main.yml
@@ -88,3 +88,13 @@ karbor_logging_debug: "{{ openstack_logging_debug }}"
 karbor_keystone_user: "karbor"
 
 openstack_karbor_auth: "{{ openstack_auth }}"
+
+
+####################
+# Notification
+####################
+karbor_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+karbor_enabled_notification_topics: "{{ karbor_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/karbor/templates/karbor.conf.j2 b/ansible/roles/karbor/templates/karbor.conf.j2
index a945c21cc8..94d2d65a83 100644
--- a/ansible/roles/karbor/templates/karbor.conf.j2
+++ b/ansible/roles/karbor/templates/karbor.conf.j2
@@ -46,6 +46,12 @@ memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansi
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if karbor_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ karbor_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
 
 [oslo_middleware]
 enable_proxy_headers_parsing = True
diff --git a/ansible/roles/keystone/defaults/main.yml b/ansible/roles/keystone/defaults/main.yml
index 0e2d21fc57..db738bab0b 100644
--- a/ansible/roles/keystone/defaults/main.yml
+++ b/ansible/roles/keystone/defaults/main.yml
@@ -113,3 +113,18 @@ keystone_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 keystone_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 keystone_dev_mode: "{{ kolla_dev_mode }}"
 keystone_source_version: "{{ kolla_source_version }}"
+
+
+####################
+# Notifications
+####################
+keystone_default_notifications_topic_enabled: "{{ (enable_ceilometer | bool ) or (enable_cadf_notifications | bool)}}"
+keystone_default_notifications_topic_name: "notifications"
+
+keystone_notification_topics:
+  - name: "{{ keystone_default_notifications_topic_name }}"
+    enabled: "{{ keystone_default_notifications_topic_enabled | bool }}"
+  - name: barbican_notifications
+    enabled: "{{ enable_barbican | bool }}"
+
+keystone_enabled_notification_topics: "{{ keystone_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/keystone/templates/keystone.conf.j2 b/ansible/roles/keystone/templates/keystone.conf.j2
index 5e33e3c76f..8340dd5d5d 100644
--- a/ansible/roles/keystone/templates/keystone.conf.j2
+++ b/ansible/roles/keystone/templates/keystone.conf.j2
@@ -1,8 +1,5 @@
 [DEFAULT]
 debug = {{ keystone_logging_debug }}
-{% if enable_cadf_notifications | bool %}
-notification_format = cadf
-{% endif %}
 
 transport_url = {{ rpc_transport_url }}
 
@@ -53,10 +50,14 @@ memcache_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansib
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_cadf_notifications | bool %}
+{% if keystone_enabled_notification_topics %}
 driver = messagingv2
+topics = {{ keystone_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
 {% endif %}
 
+
 {% if enable_osprofiler | bool %}
 [profiler]
 enabled = true
diff --git a/ansible/roles/magnum/defaults/main.yml b/ansible/roles/magnum/defaults/main.yml
index 559035ae91..a5a6d8f09c 100644
--- a/ansible/roles/magnum/defaults/main.yml
+++ b/ansible/roles/magnum/defaults/main.yml
@@ -105,3 +105,13 @@ magnum_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 magnum_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 magnum_dev_mode: "{{ kolla_dev_mode }}"
 magnum_source_version: "{{ kolla_source_version }}"
+
+
+####################
+# Notifications
+####################
+magnum_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+magnum_enabled_notification_topics: "{{ magnum_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/magnum/templates/magnum.conf.j2 b/ansible/roles/magnum/templates/magnum.conf.j2
index a9ec797d32..67517f68ee 100644
--- a/ansible/roles/magnum/templates/magnum.conf.j2
+++ b/ansible/roles/magnum/templates/magnum.conf.j2
@@ -91,9 +91,9 @@ cert_manager_type = x509keypair
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool %}
+{% if magnum_enabled_notification_topics %}
 driver = messaging
-topics = notifications
+topics = {{ magnum_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
diff --git a/ansible/roles/manila/defaults/main.yml b/ansible/roles/manila/defaults/main.yml
index 264ac68812..03efea5040 100644
--- a/ansible/roles/manila/defaults/main.yml
+++ b/ansible/roles/manila/defaults/main.yml
@@ -183,3 +183,13 @@ manila_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 manila_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 manila_dev_mode: "{{ kolla_dev_mode }}"
 manila_source_version: "{{ kolla_source_version }}"
+
+
+####################
+# Notifications
+####################
+manila_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+manila_enabled_notification_topics: "{{ manila_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/manila/templates/manila.conf.j2 b/ansible/roles/manila/templates/manila.conf.j2
index 3a631df18d..2b01dc1399 100644
--- a/ansible/roles/manila/templates/manila.conf.j2
+++ b/ansible/roles/manila/templates/manila.conf.j2
@@ -44,6 +44,13 @@ memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansi
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if manila_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ manila_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
+
 
 [oslo_middleware]
 enable_proxy_headers_parsing = True
diff --git a/ansible/roles/mistral/defaults/main.yml b/ansible/roles/mistral/defaults/main.yml
index 8982e53e7a..3bb98fbe87 100644
--- a/ansible/roles/mistral/defaults/main.yml
+++ b/ansible/roles/mistral/defaults/main.yml
@@ -125,3 +125,13 @@ mistral_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 mistral_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 mistral_dev_mode: "{{ kolla_dev_mode }}"
 mistral_source_version: "{{ kolla_source_version }}"
+
+
+####################
+# Notifications
+####################
+mistral_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+mistral_enabled_notification_topics: "{{ mistral_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/mistral/templates/mistral.conf.j2 b/ansible/roles/mistral/templates/mistral.conf.j2
index 1fb9314110..60e7cb3094 100644
--- a/ansible/roles/mistral/templates/mistral.conf.j2
+++ b/ansible/roles/mistral/templates/mistral.conf.j2
@@ -60,7 +60,12 @@ default_region = {{ openstack_region_name }}
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if mistral_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ mistral_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
 driver = noop
+{% endif %}
 
 {% if mistral_policy_file is defined %}
 [oslo_policy]
diff --git a/ansible/roles/murano/defaults/main.yml b/ansible/roles/murano/defaults/main.yml
index 0fcba7d1a9..f19a5c74e3 100644
--- a/ansible/roles/murano/defaults/main.yml
+++ b/ansible/roles/murano/defaults/main.yml
@@ -89,3 +89,12 @@ murano_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 murano_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 murano_dev_mode: "{{ kolla_dev_mode }}"
 murano_source_version: "{{ kolla_source_version }}"
+
+####################
+# Notifications
+####################
+murano_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+murano_enabled_notification_topics: "{{ murano_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/murano/templates/murano.conf.j2 b/ansible/roles/murano/templates/murano.conf.j2
index 3fa686b70f..356f4daefc 100644
--- a/ansible/roles/murano/templates/murano.conf.j2
+++ b/ansible/roles/murano/templates/murano.conf.j2
@@ -48,7 +48,12 @@ api_workers = {{ openstack_service_workers }}
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if murano_enabled_notification_topics %}
 driver = messagingv2
+topics = {{ murano_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
 
 [oslo_middleware]
 enable_proxy_headers_parsing = True
diff --git a/ansible/roles/nova-hyperv/defaults/main.yml b/ansible/roles/nova-hyperv/defaults/main.yml
index dadbf3538c..e927c5d555 100644
--- a/ansible/roles/nova-hyperv/defaults/main.yml
+++ b/ansible/roles/nova-hyperv/defaults/main.yml
@@ -6,3 +6,16 @@ log_dir: "%SYSTEMDRIVE%\\OpenStack\\Log"
 freerdp_msi_url: "https://cloudbase.it/downloads/FreeRDPWebConnect.msi"
 hyperv_compute_msi: "HyperVNovaCompute.msi"
 freerdp_webconnect_msi: "FreeRDPWebConnect.msi"
+
+####################
+# Notification
+####################
+nova_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool or enable_searchlight | bool or enable_neutron_infoblox_ipam_agent | bool }}"
+  - name: notifications_designate
+    enabled: "{{ enable_designate | bool }}"
+  - name: vitrage_notifications
+    enabled: "{{ enable_vitrage | bool }}"
+
+nova_enabled_notification_topics: "{{ nova_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/nova-hyperv/templates/neutron_hyperv_agent.conf.j2 b/ansible/roles/nova-hyperv/templates/neutron_hyperv_agent.conf.j2
index eae7e013c2..a15e0edd4b 100644
--- a/ansible/roles/nova-hyperv/templates/neutron_hyperv_agent.conf.j2
+++ b/ansible/roles/nova-hyperv/templates/neutron_hyperv_agent.conf.j2
@@ -18,3 +18,9 @@ enable_security_group = true
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if nova_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ nova_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
diff --git a/ansible/roles/nova-hyperv/templates/nova_hyperv.conf.j2 b/ansible/roles/nova-hyperv/templates/nova_hyperv.conf.j2
index 9d0bb44938..52cc6774c6 100644
--- a/ansible/roles/nova-hyperv/templates/nova_hyperv.conf.j2
+++ b/ansible/roles/nova-hyperv/templates/nova_hyperv.conf.j2
@@ -60,3 +60,16 @@ auth_type = v3password
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if nova_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ nova_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
+
+[notifications]
+{% if not enable_searchlight | bool %}
+notification_format = unversioned
+{% else %}
+notification_format = both
+{% endif %}
diff --git a/ansible/roles/nova/templates/nova.conf.j2 b/ansible/roles/nova/templates/nova.conf.j2
index 4a6ac8534e..60834fff4a 100644
--- a/ansible/roles/nova/templates/nova.conf.j2
+++ b/ansible/roles/nova/templates/nova.conf.j2
@@ -264,6 +264,12 @@ os_interface = internal
 {% if enable_ceilometer | bool or enable_searchlight | bool or enable_designate | bool or enable_neutron_infoblox_ipam_agent | bool %}
 notify_on_state_change = vm_and_task_state
 {% endif %}
+{% if not enable_searchlight | bool %}
+notification_format = unversioned
+{% else %}
+notification_format = both
+{% endif %}
+
 
 {% if enable_osprofiler | bool %}
 [profiler]
diff --git a/ansible/roles/sahara/defaults/main.yml b/ansible/roles/sahara/defaults/main.yml
index 0c86d2867a..6080e7c53d 100644
--- a/ansible/roles/sahara/defaults/main.yml
+++ b/ansible/roles/sahara/defaults/main.yml
@@ -94,3 +94,12 @@ sahara_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 sahara_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 sahara_dev_mode: "{{ kolla_dev_mode }}"
 sahara_source_version: "{{ kolla_source_version }}"
+
+####################
+# Notifications
+####################
+sahara_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+sahara_enabled_notification_topics: "{{ sahara_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/sahara/templates/sahara.conf.j2 b/ansible/roles/sahara/templates/sahara.conf.j2
index f2189198c7..b49b5c0c3e 100644
--- a/ansible/roles/sahara/templates/sahara.conf.j2
+++ b/ansible/roles/sahara/templates/sahara.conf.j2
@@ -28,9 +28,9 @@ memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansi
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool %}
+{% if sahara_enabled_notification_topics %}
 driver = messagingv2
-topics = notifications
+topics = {{ sahara_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
diff --git a/ansible/roles/searchlight/defaults/main.yml b/ansible/roles/searchlight/defaults/main.yml
index 2006b8f50d..7ba76971ea 100644
--- a/ansible/roles/searchlight/defaults/main.yml
+++ b/ansible/roles/searchlight/defaults/main.yml
@@ -69,3 +69,13 @@ searchlight_logging_debug: "{{ openstack_logging_debug }}"
 searchlight_keystone_user: "searchlight"
 
 openstack_searchlight_auth: "{{ openstack_auth }}"
+
+
+####################
+# Notifications
+####################
+searchlight_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+searchlight_enabled_notification_topics: "{{ searchlight_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/searchlight/templates/searchlight.conf.j2 b/ansible/roles/searchlight/templates/searchlight.conf.j2
index ec407e2355..fe3025952c 100644
--- a/ansible/roles/searchlight/templates/searchlight.conf.j2
+++ b/ansible/roles/searchlight/templates/searchlight.conf.j2
@@ -36,6 +36,13 @@ memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansi
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if searchlight_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ searchlight_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
+
 
 {% if searchlight_policy_file is defined %}
 [oslo_policy]
diff --git a/ansible/roles/senlin/defaults/main.yml b/ansible/roles/senlin/defaults/main.yml
index 35a8022d67..f93b3d673f 100644
--- a/ansible/roles/senlin/defaults/main.yml
+++ b/ansible/roles/senlin/defaults/main.yml
@@ -91,3 +91,13 @@ senlin_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 senlin_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 senlin_dev_mode: "{{ kolla_dev_mode }}"
 senlin_source_version: "{{ kolla_source_version }}"
+
+
+####################
+# Notifications
+####################
+senlin_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+senlin_enabled_notification_topics: "{{ senlin_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/senlin/templates/senlin.conf.j2 b/ansible/roles/senlin/templates/senlin.conf.j2
index 48604fd73c..fe33dcaa77 100644
--- a/ansible/roles/senlin/templates/senlin.conf.j2
+++ b/ansible/roles/senlin/templates/senlin.conf.j2
@@ -45,9 +45,9 @@ memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansi
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool %}
+{% if senlin_enabled_notification_topics %}
 driver = messagingv2
-topics = notifications
+topics = {{ senlin_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
diff --git a/ansible/roles/tacker/defaults/main.yml b/ansible/roles/tacker/defaults/main.yml
index 3b481634c6..d1e2d79d90 100644
--- a/ansible/roles/tacker/defaults/main.yml
+++ b/ansible/roles/tacker/defaults/main.yml
@@ -87,3 +87,12 @@ tacker_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 tacker_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 tacker_dev_mode: "{{ kolla_dev_mode }}"
 tacker_source_version: "{{ kolla_source_version }}"
+
+####################
+# Notifications
+####################
+tacker_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+tacker_enabled_notification_topics: "{{ tacker_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/tacker/templates/tacker.conf.j2 b/ansible/roles/tacker/templates/tacker.conf.j2
index 9d5fe80b61..733745d14c 100644
--- a/ansible/roles/tacker/templates/tacker.conf.j2
+++ b/ansible/roles/tacker/templates/tacker.conf.j2
@@ -56,9 +56,9 @@ port = {{ tacker_server_port }}
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool %}
+{% if tacker_enabled_notification_topics %}
 driver = messagingv2
-topics = notifications
+topics = {{ tacker_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
diff --git a/ansible/roles/trove/defaults/main.yml b/ansible/roles/trove/defaults/main.yml
index 25f312df16..5211cd7393 100644
--- a/ansible/roles/trove/defaults/main.yml
+++ b/ansible/roles/trove/defaults/main.yml
@@ -111,3 +111,12 @@ trove_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 trove_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 trove_dev_mode: "{{ kolla_dev_mode }}"
 trove_source_version: "{{ kolla_source_version }}"
+
+####################
+# Notifications
+####################
+trove_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+trove_enabled_notification_topics: "{{ trove_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/trove/templates/trove-conductor.conf.j2 b/ansible/roles/trove/templates/trove-conductor.conf.j2
index 55eee599f3..a995eac5bc 100644
--- a/ansible/roles/trove/templates/trove-conductor.conf.j2
+++ b/ansible/roles/trove/templates/trove-conductor.conf.j2
@@ -12,6 +12,12 @@ os_region_name = {{ openstack_region_name }}
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if trove_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ trove_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
 
 [database]
 connection = mysql+pymysql://{{ trove_database_user }}:{{ trove_database_password }}@{{ trove_database_address }}/{{ trove_database_name }}
diff --git a/ansible/roles/trove/templates/trove-taskmanager.conf.j2 b/ansible/roles/trove/templates/trove-taskmanager.conf.j2
index 9d74a79982..685b07966a 100644
--- a/ansible/roles/trove/templates/trove-taskmanager.conf.j2
+++ b/ansible/roles/trove/templates/trove-taskmanager.conf.j2
@@ -36,13 +36,14 @@ max_retries = -1
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool %}
+{% if trove_enabled_notification_topics %}
 driver = messagingv2
-topics = notifications
+topics = {{ trove_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
 
+
 {% if enable_osprofiler | bool %}
 [profiler]
 enabled = true
diff --git a/ansible/roles/trove/templates/trove.conf.j2 b/ansible/roles/trove/templates/trove.conf.j2
index 39dcbc9d05..0c18d5e3e5 100644
--- a/ansible/roles/trove/templates/trove.conf.j2
+++ b/ansible/roles/trove/templates/trove.conf.j2
@@ -42,9 +42,9 @@ auth_type = password
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool %}
+{% if trove_enabled_notification_topics %}
 driver = messagingv2
-topics = notifications
+topics = {{ trove_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
diff --git a/ansible/roles/vitrage/defaults/main.yml b/ansible/roles/vitrage/defaults/main.yml
index fd1804c748..3dd012f197 100644
--- a/ansible/roles/vitrage/defaults/main.yml
+++ b/ansible/roles/vitrage/defaults/main.yml
@@ -160,3 +160,14 @@ vitrage_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 vitrage_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 vitrage_dev_mode: "{{ kolla_dev_mode }}"
 vitrage_source_version: "{{ kolla_source_version }}"
+
+####################
+# Notifications
+####################
+vitrage_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+  - name: vitrage_notifications
+    enabled: True
+
+vitrage_enabled_notification_topics: "{{ vitrage_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/vitrage/templates/vitrage.conf.j2 b/ansible/roles/vitrage/templates/vitrage.conf.j2
index be04ede0f1..d876f33950 100644
--- a/ansible/roles/vitrage/templates/vitrage.conf.j2
+++ b/ansible/roles/vitrage/templates/vitrage.conf.j2
@@ -61,8 +61,12 @@ memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansi
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-topics = notifications,vitrage_notifications
+{% if vitrage_enabled_notification_topics %}
 driver = messagingv2
+topics = {{ vitrage_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
 
 [oslo_concurrency]
 lock_path = /var/lib/vitrage/tmp
diff --git a/ansible/roles/watcher/defaults/main.yml b/ansible/roles/watcher/defaults/main.yml
index 002167bf32..5a764739b0 100644
--- a/ansible/roles/watcher/defaults/main.yml
+++ b/ansible/roles/watcher/defaults/main.yml
@@ -108,3 +108,13 @@ watcher_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
 watcher_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
 watcher_dev_mode: "{{ kolla_dev_mode }}"
 watcher_source_version: "{{ kolla_source_version }}"
+
+
+####################
+# Notifications
+####################
+watcher_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+
+watcher_enabled_notification_topics: "{{ watcher_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/watcher/templates/watcher.conf.j2 b/ansible/roles/watcher/templates/watcher.conf.j2
index 9ed4fb645e..ec837cb0ab 100644
--- a/ansible/roles/watcher/templates/watcher.conf.j2
+++ b/ansible/roles/watcher/templates/watcher.conf.j2
@@ -46,6 +46,12 @@ lock_path = /var/lib/watcher/tmp
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
+{% if watcher_enabled_notification_topics %}
+driver = messagingv2
+topics = {{ watcher_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
+{% endif %}
 
 {% if watcher_policy_file is defined %}
 [oslo_policy]
diff --git a/releasenotes/notes/standard-oslo-messaging-sections-4769da25bc58aa02.yaml b/releasenotes/notes/standard-oslo-messaging-sections-4769da25bc58aa02.yaml
new file mode 100644
index 0000000000..45dc048a52
--- /dev/null
+++ b/releasenotes/notes/standard-oslo-messaging-sections-4769da25bc58aa02.yaml
@@ -0,0 +1,16 @@
+---
+features:
+  - |
+    Standard method to execute the configuration of "oslo_messaging" sections
+upgrade:
+  - |
+    The ``enable_cadf_notifications`` variable is deprecated. CADF is the default
+    notification format in keystone. To enable keystone notifications, users should
+    now set ``keystone_default_notifications_topic_enabled`` to ``yes`` or enable
+    Ceilometer via ``enable_ceilometer``.
+deprecations:
+  - |
+    The ``enable_cadf_notifications`` variable is deprecated. CADF is the default
+    notification format in keystone. To enable keystone notifications, users should
+    now set ``keystone_default_notifications_topic_enabled`` to ``yes`` or enable
+    Ceilometer via ``enable_ceilometer``.