Merge "re-add rabbitmq config for clustering interface"

This commit is contained in:
Zuul 2022-03-25 09:52:10 +00:00 committed by Gerrit Code Review
commit 60f8b7410d
6 changed files with 64 additions and 3 deletions

View File

@ -79,6 +79,24 @@
notify:
- Restart rabbitmq container
- name: Copying over advanced.config
become: true
vars:
service: "{{ rabbitmq_services['rabbitmq'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/{{ project_name }}/advanced.config"
mode: "0660"
with_first_found:
- "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/advanced.config"
- "{{ node_custom_config }}/rabbitmq/advanced.config"
- "advanced.config.j2"
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
notify:
- Restart rabbitmq container
- name: Copying over definitions.json
become: true
vars:

View File

@ -0,0 +1,7 @@
[
{kernel, [
{inet_dist_use_interface, {% raw %}{{% endraw %}{{ api_interface_address | put_address_in_context('rabbitmq') }}}},
{inet_dist_listen_min, {{ role_rabbitmq_cluster_port }}},
{inet_dist_listen_max, {{ role_rabbitmq_cluster_port }}}
]}
].

View File

@ -19,6 +19,12 @@
"owner": "rabbitmq",
"perm": "0600"
},
{
"source": "{{ container_config_directory }}/advanced.config",
"dest": "/etc/rabbitmq/advanced.config",
"owner": "rabbitmq",
"perm": "0600"
},
{
"source": "{{ container_config_directory }}/definitions.json",
"dest": "/etc/rabbitmq/definitions.json",

View File

@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from ipaddress import ip_address
from kolla_ansible.exception import FilterError
@ -27,18 +28,32 @@ def put_address_in_context(address, context):
:returns: string with address in proper context
"""
if context not in ['url', 'memcache']:
if context not in ['url', 'memcache', 'rabbitmq']:
raise FilterError("Unknown context '{context}'"
.format(context=context))
if ':' not in address:
if ':' not in address and context != 'rabbitmq':
return address
# must be IPv6 raw address
if context == 'url':
return '[{address}]'.format(address=address)
elif context == 'memcache':
if context == 'memcache':
return 'inet6:[{address}]'.format(address=address)
# rabbitmq/erlang has special syntax for ip addresses in IPv4 and IPv6
# see: https://www.erlang.org/doc/man/inet.html
# replacing dots and colons with decimal points
# and converting IPv6 as described here:
# https://www.erlang.org/doc/man/inet.html#type-ip6_address
if context == 'rabbitmq':
if ip_address(address).version == 6:
return (",".join(['16#%x' % int(x, 16)
for x in
ip_address(address).exploded.split(':')]))
return address.replace('.', ',')
return address

View File

@ -51,6 +51,15 @@ class TestAddressContextFilter(unittest.TestCase):
self.assertEqual(put_address_in_context(addr, context),
'inet6:[{}]'.format(addr))
def test_rabbitmq_context(self):
context = 'rabbitmq'
addr = '192.168.1.1'
self.assertEqual(put_address_in_context(addr, context),
'192,168,1,1')
addr = 'fd::'
self.assertEqual(put_address_in_context(addr, context),
'16#fd,16#0,16#0,16#0,16#0,16#0,16#0,16#0')
def test_unknown_context(self):
self.assertRaises(FilterError, put_address_in_context, '', 'lol')

View File

@ -0,0 +1,6 @@
---
fixes:
- |
adds back the option to configure the rabbitmq
clustering interface via kolla
`LP#1900160 <https://bugs.launchpad.net/kolla-ansible/+bug/1900160>`