Add the MQ vhost/user creation and configuration

Change-Id: If92a53d9447c09e9a1388ca99b25380bb301b1bf
This commit is contained in:
Taseer 2018-09-20 14:59:12 +02:00
parent fde07089dd
commit 3d2f1bf465
6 changed files with 132 additions and 13 deletions

View File

@ -123,18 +123,22 @@ blazar_service_in_ldap: false
blazar_messaging_enabled: true
# RPC
blazar_oslomsg_rpc_transport: rabbit
blazar_oslomsg_rpc_servers: 127.0.0.1
blazar_oslomsg_rpc_port: 5672
blazar_oslomsg_rpc_use_ssl: False
blazar_oslomsg_rpc_host_group: "{{ oslomsg_rpc_host_group | default('rabbitmq_all') }}"
blazar_oslomsg_rpc_setup_host: "{{ (blazar_oslomsg_rpc_host_group in groups) | ternary(groups[blazar_oslomsg_rpc_host_group][0], 'localhost') }}"
blazar_oslomsg_rpc_transport: "{{ oslomsg_rpc_transport | default('rabbit') }}"
blazar_oslomsg_rpc_servers: "{{ oslomsg_rpc_servers | default('127.0.0.1') }}"
blazar_oslomsg_rpc_port: "{{ oslomsg_rpc_port | default('5672') }}"
blazar_oslomsg_rpc_use_ssl: "{{ oslomsg_rpc_use_ssl | default(False) }}"
blazar_oslomsg_rpc_userid: blazar
keystone_oslomsg_rpc_vhost: /blazar
blazar_oslomsg_rpc_vhost: /blazar
# Notify
blazar_oslomsg_notify_transport: rabbit
blazar_oslomsg_notify_servers: 127.0.0.1
blazar_oslomsg_notify_port: 5672
blazar_oslomsg_notify_use_ssl: False
blazar_oslomsg_notify_host_group: "{{ oslomsg_notify_host_group | default('rabbitmq_all') }}"
blazar_oslomsg_notify_setup_host: "{{ (blazar_oslomsg_notify_host_group in groups) | ternary(groups[blazar_oslomsg_notify_host_group][0], 'localhost') }}"
blazar_oslomsg_notify_transport: "{{ oslomsg_notify_transport | default('rabbit') }}"
blazar_oslomsg_notify_servers: "{{ oslomsg_notify_servers | default('127.0.0.1') }}"
blazar_oslomsg_notify_port: "{{ oslomsg_notify_port | default('5672') }}"
blazar_oslomsg_notify_use_ssl: "{{ oslomsg_notify_use_ssl | default(False) }}"
blazar_oslomsg_notify_userid: blazar
blazar_oslomsg_notify_vhost: /blazar

View File

@ -66,14 +66,31 @@
- blazar-config
- systemd-service
- include_tasks: mq_setup.yml
when:
- "inventory_hostname == ((groups['blazar_all'] | intersect(ansible_play_hosts)) | list)[0]"
with_items:
- oslomsg_setup_host: "{{ blazar_oslomsg_rpc_setup_host }}"
oslomsg_userid: "{{ blazar_oslomsg_rpc_userid }}"
oslomsg_password: "{{ blazar_oslomsg_rpc_password }}"
oslomsg_vhost: "{{ blazar_oslomsg_rpc_vhost }}"
oslomsg_transport: "{{ blazar_oslomsg_rpc_transport }}"
- oslomsg_setup_host: "{{ blazar_oslomsg_notify_setup_host }}"
oslomsg_userid: "{{ blazar_oslomsg_notify_userid }}"
oslomsg_password: "{{ blazar_oslomsg_notify_password }}"
oslomsg_vhost: "{{ blazar_oslomsg_notify_vhost }}"
oslomsg_transport: "{{ blazar_oslomsg_notify_transport }}"
tags:
- blazar-config
- include_tasks: blazar_db_setup.yml
when:
- "inventory_hostname == ((groups['blazar_all']| intersect(ansible_play_hosts)) | list)[0]"
- "inventory_hostname == ((groups['blazar_all'] | intersect(ansible_play_hosts)) | list)[0]"
tags:
- blazar-config
- include_tasks: blazar_service_setup.yml
when:
- "inventory_hostname == ((groups['blazar_all']| intersect(ansible_play_hosts)) | list)[0]"
- "inventory_hostname == ((groups['blazar_all'] | intersect(ansible_play_hosts)) | list)[0]"
tags:
- blazar-config

82
tasks/mq_setup.yml Normal file
View File

@ -0,0 +1,82 @@
---
# Copyright 2018, 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.
# WARNING:
# This file is maintained in the openstack-ansible-tests repository.
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/sync/mq_setup.yml
# If you need to modify this file, update the one in the openstack-ansible-tests
# repository. Once it merges there, the changes will automatically be proposed to
# all the repositories which use it.
- name: Setup RPC MQ Service (RabbitMQ)
delegate_to: "{{ _oslomsg_rpc_setup_host }}"
when:
- "(_oslomsg_configure_rpc | default(_oslomsg_rpc_transport is defined))"
- "(_oslomsg_rpc_transport is defined) and (_oslomsg_rpc_transport == 'rabbit')"
tags:
- common-rabbitmq
block:
- name: Add RPC RabbitMQ vhost
rabbitmq_vhost:
name: "{{ _oslomsg_rpc_vhost }}"
state: "present"
- name: Add RPC RabbitMQ user
rabbitmq_user:
user: "{{ _oslomsg_rpc_userid }}"
password: "{{ _oslomsg_rpc_password }}"
vhost: "{{ _oslomsg_rpc_vhost }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
state: "present"
force: true
no_log: true
- name: Setup Notify MQ Service (RabbitMQ)
delegate_to: "{{ _oslomsg_notify_setup_host }}"
when:
- "(_oslomsg_configure_notify | default(_oslomsg_notify_transport is defined))"
- "(_oslomsg_notify_transport is defined) and (_oslomsg_notify_transport == 'rabbit')"
tags:
- common-rabbitmq
block:
- name: Add Notify RabbitMQ vhost
rabbitmq_vhost:
name: "{{ _oslomsg_notify_vhost }}"
state: "present"
- name: Add Notify RabbitMQ user
rabbitmq_user:
user: "{{ _oslomsg_notify_userid }}"
password: "{{ _oslomsg_notify_password }}"
vhost: "{{ _oslomsg_notify_vhost }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
state: "present"
force: true
no_log: true
- name: Setup RPC MQ Service (Qdrouterd)
delegate_to: "{{ _oslomsg_rpc_setup_host }}"
when:
- "(_oslomsg_configure_rpc | default(_oslomsg_rpc_transport is defined))"
- "(_oslomsg_rpc_transport is defined) and (_oslomsg_rpc_transport == 'amqp')"
tags:
- common-qdrouterd
block:
- name: Add RPC Qdrouterd user
shell: "echo {{ _oslomsg_rpc_password }} | saslpasswd2 -c -p -f /var/lib/qdrouterd/qdrouterd.sasldb -u AMQP {{ _oslomsg_rpc_userid }}"
no_log: true

View File

@ -4,6 +4,16 @@ use_journal = True
host=0.0.0.0
port={{ blazar_service_port }}
# oslo.messaging default transport
transport_url = {{ blazar_oslomsg_rpc_transport }}://{% for host in blazar_oslomsg_rpc_servers.split(',') %}{{ blazar_oslomsg_rpc_userid }}:{{ blazar_oslomsg_rpc_password }}@{{ host }}:{{ blazar_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ blazar_oslomsg_rpc_vhost }}{% if (blazar_oslomsg_rpc_use_ssl | lower) | bool %}?ssl=1{% else %}?ssl=0{% endif %}{% endif %}{% endfor %}
[oslo_messaging_rabbit]
ssl = {{ blazar_oslomsg_notify_use_ssl | bool }}
[oslo_messaging_notifications]
transport_url = {{ blazar_oslomsg_notify_transport }}://{% for host in blazar_oslomsg_notify_servers.split(',') %}{{ blazar_oslomsg_notify_userid }}:{{ blazar_oslomsg_notify_password }}@{{ host }}:{{ blazar_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ blazar_oslomsg_notify_vhost }}{% if (blazar_oslomsg_notify_use_ssl | lower) | bool %}?ssl=1{% else %}?ssl=0{% endif %}{% endif %}{% endfor %}
[manager]
plugins=physical.host.plugin,virtual.instance.plugin

View File

@ -9,6 +9,12 @@ infra1
openstack1
blazar1
[oslomsg_rpc_all]
infra1
[oslomsg_notify_all]
infra1
[rabbitmq_all]
infra1

View File

@ -15,12 +15,12 @@
# Use the tests repo values
blazar_galera_address: "{{ test_galera_host }}"
blazar_rabbitmq_vhost: /blazar
blazar_rabbitmq_userid: blazar
# Required settings with no defaults
blazar_service_password: "secrete"
blazar_container_mysql_password: "secrete"
blazar_oslomsg_rpc_password: "secrete"
blazar_oslomsg_notify_password: "secrete"
# Force dev mode for the role test
blazar_developer_mode: true