rabbitmq: Support non-/ vhosts.

Fixes: #30255.
This commit is contained in:
Alex Vandiver 2024-05-31 11:47:15 -04:00 committed by Tim Abbott
parent a4ff6f9ae5
commit 5814583694
4 changed files with 9 additions and 1 deletions

View File

@ -10,6 +10,7 @@ set -eu
RABBITMQ_USERNAME=$("$(dirname "$0")/../get-django-setting" RABBITMQ_USERNAME) RABBITMQ_USERNAME=$("$(dirname "$0")/../get-django-setting" RABBITMQ_USERNAME)
RABBITMQ_PASSWORD=$("$(dirname "$0")/../get-django-setting" RABBITMQ_PASSWORD) RABBITMQ_PASSWORD=$("$(dirname "$0")/../get-django-setting" RABBITMQ_PASSWORD)
RABBITMQ_VHOST=$("$(dirname "$0")/../get-django-setting" RABBITMQ_VHOST)
rabbitmqctl await_startup rabbitmqctl await_startup
rabbitmqctl delete_user "$RABBITMQ_USERNAME" || true rabbitmqctl delete_user "$RABBITMQ_USERNAME" || true
@ -17,4 +18,7 @@ rabbitmqctl delete_user zulip || true
rabbitmqctl delete_user guest || true rabbitmqctl delete_user guest || true
rabbitmqctl add_user "$RABBITMQ_USERNAME" "$RABBITMQ_PASSWORD" rabbitmqctl add_user "$RABBITMQ_USERNAME" "$RABBITMQ_PASSWORD"
rabbitmqctl set_user_tags "$RABBITMQ_USERNAME" administrator rabbitmqctl set_user_tags "$RABBITMQ_USERNAME" administrator
rabbitmqctl set_permissions -p / "$RABBITMQ_USERNAME" '.*' '.*' '.*' if ! rabbitmqctl list_vhosts --no-table-headers --quiet | grep -qx "$RABBITMQ_VHOST"; then
rabbitmqcql add_vhost "$RABBITMQ_VHOST"
fi
rabbitmqctl set_permissions -p "$RABBITMQ_VHOST" "$RABBITMQ_USERNAME" '.*' '.*' '.*'

View File

@ -89,6 +89,7 @@ class QueueClient(Generic[ChannelT], metaclass=ABCMeta):
return pika.ConnectionParameters( return pika.ConnectionParameters(
settings.RABBITMQ_HOST, settings.RABBITMQ_HOST,
port=settings.RABBITMQ_PORT, port=settings.RABBITMQ_PORT,
virtual_host=settings.RABBITMQ_VHOST,
heartbeat=self.rabbitmq_heartbeat, heartbeat=self.rabbitmq_heartbeat,
tcp_options=tcp_options, tcp_options=tcp_options,
ssl_options=ssl_options, ssl_options=ssl_options,

View File

@ -191,6 +191,7 @@ MEMCACHED_LOCATION = "127.0.0.1:11211"
MEMCACHED_USERNAME = None if get_secret("memcached_password") is None else "zulip@localhost" MEMCACHED_USERNAME = None if get_secret("memcached_password") is None else "zulip@localhost"
RABBITMQ_HOST = "127.0.0.1" RABBITMQ_HOST = "127.0.0.1"
RABBITMQ_PORT = 5672 RABBITMQ_PORT = 5672
RABBITMQ_VHOST = "/"
RABBITMQ_USERNAME = "zulip" RABBITMQ_USERNAME = "zulip"
RABBITMQ_USE_TLS = False RABBITMQ_USE_TLS = False
REDIS_HOST = "127.0.0.1" REDIS_HOST = "127.0.0.1"

View File

@ -606,6 +606,8 @@ SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {
## optionally RABBITMQ_PORT, to the hostname and port here. ## optionally RABBITMQ_PORT, to the hostname and port here.
# RABBITMQ_HOST = "127.0.0.1" # RABBITMQ_HOST = "127.0.0.1"
# RABBITMQ_PORT = 5672 # RABBITMQ_PORT = 5672
## To use a different RabbitMQ "virtual host", adjust this.
# RABBITMQ_VHOST = "/"
## To use another RabbitMQ user than the default "zulip", set RABBITMQ_USERNAME here. ## To use another RabbitMQ user than the default "zulip", set RABBITMQ_USERNAME here.
# RABBITMQ_USERNAME = "zulip" # RABBITMQ_USERNAME = "zulip"
## To access the RabbitMQ server over TLS, set this to True; this is ## To access the RabbitMQ server over TLS, set this to True; this is