Move RabbitMQ handling into a separate role and support disabling it

Ironic can use JSON RPC and ironic-inspector is compatible with fake:// transport.
Keystone does not seem to need oslo.messaging at all. This change moves
RabbitMQ bits to a separate role, but keeps it enabled until the next patch.

Change-Id: I096a347e3bf6270167d35b7c1cf46834ae2d4ece
This commit is contained in:
Dmitry Tantsur 2019-03-21 11:02:25 +01:00
parent ec68d4f142
commit 0d036d6a7c
27 changed files with 122 additions and 82 deletions

View File

@ -23,6 +23,8 @@ transform_boot_image: false
# virtual machines for the hardware instead of real hardware.
testing: false
ci_testing: false
# Use Rabbit MQ as a message bus.
use_rabbitmq: true
# set to true to skip installing ironic dependencies
skip_package_install: False

View File

@ -10,7 +10,6 @@ mysql_service_name: mysql
tftp_service_name: tftpd-hpa
required_packages:
- mysql-server
- rabbitmq-server
- python-dev
- python-mysqldb
- python-configparser

View File

@ -8,7 +8,6 @@ nginx_user: www-data
mysql_service_name: mysql
required_packages:
- mysql-server
- rabbitmq-server
- python-dev
- python-mysqldb
- python-configparser

View File

@ -11,7 +11,6 @@ tftp_service_name: tftp
required_packages:
- mariadb-server
- dnsmasq
- rabbitmq-server
- python-devel
- MySQL-python
- libselinux-python

View File

@ -11,7 +11,6 @@ tftp_service_name: tftp
required_packages:
- mariadb-server
- dnsmasq
- rabbitmq-server
- python-devel
- MySQL-python
- libselinux-python

View File

@ -11,7 +11,6 @@ tftp_service_name: tftp
required_packages:
- mariadb-server
- dnsmasq
- rabbitmq-server
- python-devel
- MySQL-python
- libselinux-python

View File

@ -11,7 +11,6 @@ tftp_service_name: tftp
required_packages:
- mariadb-server
- dnsmasq
- rabbitmq-server
- python-devel
- MySQL-python
- python-iniparse

View File

@ -17,7 +17,6 @@ required_packages:
- python-selinux
- mariadb-server
- dnsmasq
- rabbitmq-server
- python-devel
- python-MySQL-python
- python-iniparse

View File

@ -4,7 +4,6 @@ init_dest_dir: /lib/systemd/system/
init_ext: .service
required_packages:
- mysql-server
- rabbitmq-server
- python-dev
- python-mysqldb
- python-configparser

View File

@ -17,7 +17,6 @@ required_packages:
- python-selinux
- mariadb-server
- dnsmasq
- rabbitmq-server
- python-devel
- python-iniparse
- libffi-devel

View File

@ -42,43 +42,6 @@
service: name={{ mysql_service_name }} state=started enabled=yes
when: ironic.database.host == 'localhost'
# NOTE(hwoarang): The erlang SUSE package forces epmd to listen on localhost
# address which breaks rabbitmq-server when listening on a different address.
# https://build.opensuse.org/package/view_file/devel:languages:erlang:Factory/erlang/README.SUSE?expand=1
- name: "Make epmd listen to all addresses on SUSE"
block:
- blockinfile:
dest: "/etc/systemd/system/epmd.socket.d/port.conf"
content: |
[Socket]
ListenStream=
ListenStream=0.0.0.0:4369
create: yes
marker: "# {mark} ANSIBLE MANAGED BLOCK"
- systemd: daemon_reload=yes
- service: name={{ item }} state=stopped enabled=no
with_items:
- epmd.socket
- epmd
when: ansible_os_family == 'Suse'
- name: "Start rabbitmq-server"
service: name=rabbitmq-server state=started enabled=yes
# NOTE(cinerama): on some systems, rabbit may not be ready when we want to
# make changes to users if we don't wait first
# TODO(TheJulia): This needs to be changed to a variable, however
# should update this playbook all at once with new variable structures.
- name: "Wait for rabbitmq"
wait_for: port=5672 delay=5
- name: "Ensure guest user is removed from rabbitmq"
rabbitmq_user:
user: "guest"
state: absent
force: yes
- name: "Create ironic user in RabbitMQ"
rabbitmq_user:
user: "ironic"
@ -89,6 +52,7 @@
write_priv: ".*"
read_priv: ".*"
no_log: true
when: use_rabbitmq
- name: "Set mysql_username if environment variable mysql_user is set"
set_fact:

View File

@ -51,6 +51,11 @@
- "../defaults/required_defaults_{{ ansible_distribution | regex_replace(' ', '_') }}_{{ ansible_distribution_version }}.yml"
- "../defaults/dummy-defaults.yml"
- name: "Install RabbitMQ if required"
import_role:
name: bifrost-rabbitmq
when: use_rabbitmq
- name: "Install Ironic deps"
include: install.yml
when: skip_package_install | bool != True

View File

@ -24,8 +24,10 @@
- name: "Start database service"
service: name={{ mysql_service_name }} state=started enabled=yes
- name: "Start rabbitmq-server"
service: name=rabbitmq-server state=started enabled=yes
- import_role:
name: bifrost-rabbitmq
tasks_from: start
when: use_rabbitmq
- name: "start ironic-inspector"
include: inspector_start.yml

View File

@ -15,7 +15,11 @@ debug = {{ inspector_debug | bool }}
log_dir = {{ inspector_log_dir }}
{% endif %}
{% if use_rabbitmq is defined and use_rabbitmq | bool == true %}
transport_url = rabbit://ironic:{{ironic_db_password }}@{{ message_queue_host | default('127.0.0.1') }}:{{ message_queue_port | default('5672') }}/{{ rabbit_virtual_host | default('') }}
{% else %}
transport_url = fake://
{% endif %}
[database]
connection=mysql+pymysql://{{ ironic_inspector.database.username }}:{{ ironic_inspector.database.password }}@{{ ironic_inspector.database.host }}/{{ ironic_inspector.database.name }}?charset=utf8

View File

@ -22,7 +22,11 @@ enabled_deploy_interfaces = {{ enabled_deploy_interfaces }}
enabled_hardware_types = {{ enabled_hardware_types }}
{% if use_rabbitmq is defined and use_rabbitmq | bool == true %}
transport_url = rabbit://ironic:{{ironic_db_password }}@{{ message_queue_host | default('127.0.0.1') }}:{{ message_queue_port | default('5672') }}/{{ rabbit_virtual_host | default('') }}
{% else %}
rpc_transport = json-rpc
{% endif %}
{% if enable_keystone is defined and enable_keystone | bool == true %}
auth_strategy = keystone
@ -119,3 +123,16 @@ region_name = {{ keystone.bootstrap.region_name | default('RegionOne')}}
auth_type = none
{% endif %}
endpoint_override = http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:6385
[json_rpc]
{% if enable_keystone is defined and enable_keystone | bool == true %}
auth_url = {{ ironic.service_catalog.auth_url }}
auth_type = password
project_name = {{ ironic.service_catalog.project_name }}
username = {{ ironic.service_catalog.username }}
password = {{ ironic.service_catalog.password }}
user_domain_id = default
project_domain_id = default
{% else %}
auth_type = none
{% endif %}

View File

@ -3,7 +3,7 @@ bifrost-keystone-install
This role installs keystone for a bifrost/stand-alone ironic deployment
with all required substrate to allow for keystone configuration,
including MySQL, RabbitMQ, dnsmasq, and nginx.
including MySQL, dnsmasq, and nginx.
Requirements
------------

View File

@ -6,7 +6,7 @@ keystone_git_folder: /opt/stack/keystone
# set to true to skip installing ironic dependencies
skip_package_install: False
# set to true to skip generation of configs, ironic db and rabbitmq configuration
# set to true to skip generation of configs and ironic db configuration
skip_bootstrap: False
# set to true to skip starting ironic services and dependencies
skip_start: False

View File

@ -6,7 +6,6 @@ nginx_user: www-data
mysql_service_name: mysql
required_packages:
- mysql-server
- rabbitmq-server
- python-dev
- python-mysqldb
- python-configparser

View File

@ -6,7 +6,6 @@ nginx_user: www-data
mysql_service_name: mysql
required_packages:
- mysql-server
- rabbitmq-server
- python-dev
- python-mysqldb
- python-configparser

View File

@ -11,7 +11,6 @@ mysql_service_name: mariadb
tftp_service_name: tftp
required_packages:
- mariadb-server
- rabbitmq-server
- python-devel
- MySQL-python
- python-iniparse

View File

@ -6,7 +6,6 @@ mysql_service_name: mysql
required_packages:
- python-selinux
- mariadb
- rabbitmq-server
- python-devel
- python-MySQL-python
- python-iniparse

View File

@ -4,7 +4,6 @@ init_dest_dir: /lib/systemd/system/
init_ext: .service
required_packages:
- mysql-server
- rabbitmq-server
- python-dev
- python-mysqldb
- python-configparser

View File

@ -29,36 +29,11 @@
register: keystone_install_prefix
environment: "{{ bifrost_venv_env if enable_venv else {} }}"
# NOTE(sean-k-mooney) only the RabbitMQ server and MySQL db are started
# during bootstrapping. all other services are started in the Start phase.
# NOTE(sean-k-mooney) only the MySQL db is started during bootstrapping.
# all other services are started in the Start phase.
- name: "Start database service"
service: name={{ mysql_service_name }} state=started enabled=yes
- name: "Start rabbitmq-server"
service: name=rabbitmq-server state=started enabled=yes
# NOTE(cinerama): on some systems, rabbit may not be ready when we want to
# make changes to users if we don't wait first
- name: "Wait for rabbitmq"
wait_for: port="{{ keystone.message_queue.port | default('5672') }}" delay=5
- name: "Ensure guest user is removed from rabbitmq"
rabbitmq_user:
user: "guest"
state: absent
force: yes
- name: "Create keystone user in RabbitMQ"
rabbitmq_user:
user: "{{ keystone.message_queue.username }}"
password: "{{ keystone.message_queue.password }}"
force: yes
state: present
configure_priv: ".*"
write_priv: ".*"
read_priv: ".*"
no_log: true
- name: "Set mysql_username if environment variable mysql_user is set"
set_fact:
mysql_username: "{{ lookup('env', 'mysql_user') }}"

View File

@ -0,0 +1,6 @@
---
skip_package_install: false
# This seems to be the same for all supported distributions.
rabbitmq_package: rabbitmq-server
rabbitmq_port: 5672
rabbitmq_service: rabbitmq-server

View File

@ -0,0 +1,48 @@
# 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: Install RabbitMQ package
package:
name: "{{ rabbitmq_package }}"
state: present
when: skip_package_install | bool != True
# NOTE(hwoarang): The erlang SUSE package forces epmd to listen on localhost
# address which breaks rabbitmq-server when listening on a different address.
# https://build.opensuse.org/package/view_file/devel:languages:erlang:Factory/erlang/README.SUSE?expand=1
- name: "Make epmd listen to all addresses on SUSE"
block:
- blockinfile:
dest: "/etc/systemd/system/epmd.socket.d/port.conf"
content: |
[Socket]
ListenStream=
ListenStream=0.0.0.0:4369
create: yes
marker: "# {mark} ANSIBLE MANAGED BLOCK"
- systemd: daemon_reload=yes
- service: name={{ item }} state=stopped enabled=no
with_items:
- epmd.socket
- epmd
when: ansible_os_family == 'Suse'
- import_tasks: start.yml
- name: "Ensure guest user is removed from rabbitmq"
rabbitmq_user:
user: "guest"
state: absent
force: yes

View File

@ -0,0 +1,27 @@
# 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: "Start rabbitmq-server"
service:
name: "{{ rabbitmq_service }}"
state: started
enabled: yes
# NOTE(cinerama): on some systems, rabbit may not be ready when we want to
# make changes to users if we don't wait first
# TODO(TheJulia): This needs to be changed to a variable, however
# should update this playbook all at once with new variable structures.
- name: "Wait for rabbitmq"
wait_for:
port: "{{ rabbitmq_port }}"
delay: 5

View File

@ -0,0 +1,4 @@
features:
- |
Adds support to disable RabbitMQ via the new ``use_rabbitmq`` variable
in favour of JSON RPC (in ironic) and fake transport (in ironic-inspector).