From 2c27b7771e47291e01e0fdf858d3e4462c925c24 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 16 Jul 2015 14:55:47 -0500 Subject: [PATCH] Compartmentalizing RabbitMQ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Presently all services use the single root virtual host within RabbitMQ and while this is “OK” for small to mid sized deployments however it would be better to divide services into logical resource groups within RabbitMQ which will bring with it additional security. This change set provides OSAD better compartmentalization of consumer services that use RabbitMQ. UpgradeImpact DocImpact Change-Id: I6f9d07522faf133f3c1c84a5b9046a55d5789e52 Implements: blueprint compartmentalize-rabbitmq --- defaults/main.yml | 4 ++++ tasks/keystone_messaging_setup.yml | 37 ++++++++++++++++++++++++++++++ tasks/keystone_pre_install.yml | 4 ++++ templates/keystone.conf.j2 | 7 ++++-- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tasks/keystone_messaging_setup.yml diff --git a/defaults/main.yml b/defaults/main.yml index 79481b1c..e8ede18c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -78,6 +78,10 @@ keystone_database_min_pool_size: 5 keystone_database_max_pool_size: 120 keystone_database_pool_timeout: 30 +## RabbitMQ info +keystone_rabbitmq_userid: keystone +keystone_rabbitmq_vhost: /keystone + ## Role info keystone_role_name: admin keystone_default_role_name: _member_ diff --git a/tasks/keystone_messaging_setup.yml b/tasks/keystone_messaging_setup.yml new file mode 100644 index 00000000..ddd11c23 --- /dev/null +++ b/tasks/keystone_messaging_setup.yml @@ -0,0 +1,37 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Ensure Rabbitmq vhost + rabbitmq_vhost: + name: "{{ keystone_rabbitmq_vhost }}" + state: "present" + delegate_to: "{{ groups['rabbitmq_all'][0] }}" + tags: + - keystone-rabbitmq + - keystone-rabbitmq-vhost + +- name: Ensure rabbitmq user + rabbitmq_user: + user: "{{ keystone_rabbitmq_userid }}" + password: "{{ keystone_rabbitmq_password }}" + vhost: "{{ keystone_rabbitmq_vhost }}" + configure_priv: ".*" + read_priv: ".*" + write_priv: ".*" + state: "present" + delegate_to: "{{ groups['rabbitmq_all'][0] }}" + tags: + - keystone-rabbitmq + - keystone-rabbitmq-user diff --git a/tasks/keystone_pre_install.yml b/tasks/keystone_pre_install.yml index 1816ebf9..b75ababc 100644 --- a/tasks/keystone_pre_install.yml +++ b/tasks/keystone_pre_install.yml @@ -106,3 +106,7 @@ tags: - keystone-dirs - keystone-logs + +- include: keystone_messaging_setup.yml + when: > + inventory_hostname == groups['keystone_all'][0] diff --git a/templates/keystone.conf.j2 b/templates/keystone.conf.j2 index d2276353..802904e6 100644 --- a/templates/keystone.conf.j2 +++ b/templates/keystone.conf.j2 @@ -134,9 +134,11 @@ admin_port = {{ keystone_admin_port }} public_port = {{ keystone_service_port }} [oslo_messaging_rabbit] +rabbit_port = {{ rabbitmq_port }} +rabbit_userid = {{ keystone_rabbitmq_userid }} +rabbit_password = {{ keystone_rabbitmq_password }} +rabbit_virtual_host = {{ keystone_rabbitmq_vhost }} rabbit_hosts = {{ rabbitmq_servers }} -rabbit_userid = {{ rabbitmq_userid }} -rabbit_password = {{ rabbitmq_password }} {% if keystone_sp is defined %} [federation] @@ -147,3 +149,4 @@ trusted_dashboard = {{ item }} {% endfor %} {% endif %} {% endif %} +