From 9137828b979a2eb8ff1bfe3174f7c6ae8047e835 Mon Sep 17 00:00:00 2001
From: Jan Vondra <jan.vondra@ultimum.io>
Date: Thu, 3 Oct 2019 12:01:00 +0200
Subject: [PATCH] Allow passing arguments to RabbitMQ server
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Adds rabbitmq_server_additional_erl_args variable which
is appended to RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS
environment variable to RabbitMQ server startup script.

This can be used to configure the schedulers.

Docs attached.

Change-Id: Id683c8cc6dac61354ffd94f3b460335b42136ba2
Co-authored-by: Radosław Piliszek <radoslaw.piliszek@gmail.com>
Related-bug: #1846467
---
 ansible/roles/rabbitmq/defaults/main.yml      |  1 +
 .../rabbitmq/templates/rabbitmq-env.conf.j2   |  2 +-
 doc/source/reference/index.rst                |  1 +
 doc/source/reference/message-queues/index.rst | 10 +++++++++
 .../reference/message-queues/rabbitmq.rst     | 22 +++++++++++++++++++
 etc/kolla/globals.yml                         | 10 +++++++++
 ...nal-erl-args-passing-653fd619b41a7b0f.yaml |  7 ++++++
 7 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 doc/source/reference/message-queues/index.rst
 create mode 100644 doc/source/reference/message-queues/rabbitmq.rst
 create mode 100644 releasenotes/notes/rabbitmq-server-additional-erl-args-passing-653fd619b41a7b0f.yaml

diff --git a/ansible/roles/rabbitmq/defaults/main.yml b/ansible/roles/rabbitmq/defaults/main.yml
index 24f81c39c..65a6fcc84 100644
--- a/ansible/roles/rabbitmq/defaults/main.yml
+++ b/ansible/roles/rabbitmq/defaults/main.yml
@@ -70,3 +70,4 @@ rabbitmq_user: "openstack"
 rabbitmq_cluster_name: "openstack"
 rabbitmq_hostname: "{{ ansible_hostname }}"
 rabbitmq_pid_file: "/var/lib/rabbitmq/mnesia/rabbitmq.pid"
+rabbitmq_server_additional_erl_args: ""
diff --git a/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2 b/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2
index 8d6069b50..050cb1fd0 100644
--- a/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2
+++ b/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2
@@ -2,7 +2,7 @@ RABBITMQ_NODENAME=rabbit@{{ ansible_hostname }}
 RABBITMQ_LOG_BASE=/var/log/kolla/{{ project_name }}
 RABBITMQ_DIST_PORT={{ role_rabbitmq_cluster_port }}
 RABBITMQ_PID_FILE={{ rabbitmq_pid_file }}
-RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-kernel inetrc '/etc/rabbitmq/erl_inetrc' {% if api_address_family == 'ipv6' %}-proto_dist inet6_tcp {% endif %}"
+RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-kernel inetrc '/etc/rabbitmq/erl_inetrc' {% if api_address_family == 'ipv6' %}-proto_dist inet6_tcp {% endif %}{{ rabbitmq_server_additional_erl_args }}"
 RABBITMQ_CTL_ERL_ARGS="{% if api_address_family == 'ipv6' %}-proto_dist inet6_tcp {% endif %}"
 
 export ERL_EPMD_ADDRESS={{ api_interface_address }}
diff --git a/doc/source/reference/index.rst b/doc/source/reference/index.rst
index 0e1211be0..358aef91e 100644
--- a/doc/source/reference/index.rst
+++ b/doc/source/reference/index.rst
@@ -14,5 +14,6 @@ Projects Deployment Configuration Reference
    logging-and-monitoring/index
    containers/index
    databases/index
+   message-queues/index
    deployment-config/index
    deployment-and-bootstrapping/index
diff --git a/doc/source/reference/message-queues/index.rst b/doc/source/reference/message-queues/index.rst
new file mode 100644
index 000000000..fe756405d
--- /dev/null
+++ b/doc/source/reference/message-queues/index.rst
@@ -0,0 +1,10 @@
+==============
+Message queues
+==============
+
+This section describes configuration of message queue services.
+
+.. toctree::
+   :maxdepth: 1
+
+   rabbitmq
diff --git a/doc/source/reference/message-queues/rabbitmq.rst b/doc/source/reference/message-queues/rabbitmq.rst
new file mode 100644
index 000000000..1457327ce
--- /dev/null
+++ b/doc/source/reference/message-queues/rabbitmq.rst
@@ -0,0 +1,22 @@
+.. _rabbitmq:
+
+========
+RabbitMQ
+========
+
+RabbitMQ is a message broker written in Erlang.
+It is currently the default provider of message queues in Kolla Ansible
+deployments.
+
+Passing arguments to RabbitMQ server's Erlang VM
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Erlang programs run in Erlang VM (virtual machine) and use Erlang runtime.
+Erlang VM can be configured.
+
+Kolla Ansible makes it possible to pass arguments to the Erlang VM via the
+usage of ``rabbitmq_server_additional_erl_args`` variable. The contents of it
+are appended to ``RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS`` environment variable
+passed to RabbitMQ server startup script. Kolla Ansible already configures
+RabbitMQ server for IPv6 (if necessary). Any argument can be passed there as
+documented in https://www.rabbitmq.com/runtime.html
diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml
index cef3e8f9b..b109da5d5 100644
--- a/etc/kolla/globals.yml
+++ b/etc/kolla/globals.yml
@@ -350,6 +350,16 @@
 #enable_zookeeper: "{{ enable_kafka | bool }}"
 #enable_zun: "no"
 
+##################
+# RabbitMQ options
+##################
+# Options passed to RabbitMQ server startup script via the
+# RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS environment var.
+# See Kolla Ansible docs RabbitMQ section for details.
+# These are appended to args already provided by Kolla Ansible
+# to configure IPv6 in RabbitMQ server.
+#rabbitmq_server_additional_erl_args: ""
+
 ##############
 # Ceph options
 ##############
diff --git a/releasenotes/notes/rabbitmq-server-additional-erl-args-passing-653fd619b41a7b0f.yaml b/releasenotes/notes/rabbitmq-server-additional-erl-args-passing-653fd619b41a7b0f.yaml
new file mode 100644
index 000000000..7c6bdef01
--- /dev/null
+++ b/releasenotes/notes/rabbitmq-server-additional-erl-args-passing-653fd619b41a7b0f.yaml
@@ -0,0 +1,7 @@
+---
+features:
+  - |
+    It is now possible to pass ``RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS``
+    to RabbitMQ server's Erlang VM via the newly introduced
+    ``rabbitmq_server_additional_erl_args`` variable.
+    See Kolla Ansible docs RabbitMQ section for details.
-- 
GitLab