From e624f216a840734c62a472c7df2b6c1b43acb8ef Mon Sep 17 00:00:00 2001
From: Bertrand Lallau <bertrand.lallau@gmail.com>
Date: Fri, 10 Mar 2017 22:32:49 +0100
Subject: [PATCH] Neutron oslo_messaging_notifications config error

With the following configuration in globals.yml:
enable_ceilometer="no"
enable_designate="no"
enable_searchlight="yes"

neutron.conf is generated like following:

[oslo_messaging_notifications]
driver = messagingv2
topics =

=> topics value is missing.
This patch fix it.

Closes-Bug: #1671940
Change-Id: I28ab60c61882caaba823bab84f30f77e270f29b4
---
 ansible/roles/neutron/defaults/main.yml         | 11 +++++++++++
 ansible/roles/neutron/templates/neutron.conf.j2 |  5 ++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/ansible/roles/neutron/defaults/main.yml b/ansible/roles/neutron/defaults/main.yml
index 6c247bf727..9771722847 100644
--- a/ansible/roles/neutron/defaults/main.yml
+++ b/ansible/roles/neutron/defaults/main.yml
@@ -320,3 +320,14 @@ service_plugins:
     enabled: "{{ neutron_plugin_agent == 'sfc' }}"
 
 neutron_service_plugins: "{{ service_plugins|selectattr('enabled', 'equalto', true)|list }}"
+
+####################
+# Notification
+####################
+neutron_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool or enable_searchlight | bool }}"
+  - name: notifications_designate
+    enabled: "{{ enable_designate | bool }}"
+
+neutron_enabled_notification_topics: "{{ neutron_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
diff --git a/ansible/roles/neutron/templates/neutron.conf.j2 b/ansible/roles/neutron/templates/neutron.conf.j2
index eed201f6d2..3e1963a137 100644
--- a/ansible/roles/neutron/templates/neutron.conf.j2
+++ b/ansible/roles/neutron/templates/neutron.conf.j2
@@ -97,10 +97,9 @@ memcached_servers = {% for host in groups['memcached'] %}{% if orchestration_eng
 {% endif %}
 
 [oslo_messaging_notifications]
-{% if enable_ceilometer | bool or enable_searchlight | bool or enable_designate | bool %}
+{% if neutron_enabled_notification_topics %}
 driver = messagingv2
-{% set topics=["notifications" if enable_ceilometer | bool else "", "notifications_designate" if enable_designate | bool else ""] %}
-topics = {{ topics|reject("equalto", "")|list|join(",") }}
+topics = {{ neutron_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
-- 
GitLab