Skip to content

Add support to override default_{user,pass,vhost} and the Erlang cookie from the environment #3299

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conversation

dumbbell
Copy link
Collaborator

Historically, the Docker image allowed the user to override the default user/password and vhost as well as the Erlang cookie from environment variables among other things. After some discussion in docker-library/rabbitmq#506 (comment), support for environment variables specific to the Docker image was removed in docker-library/rabbitmq#467.

Several users were impacted by this removal (see docker-library/rabbitmq#508). After some more discussion, it was decided to re-introduce some variables directly into RabbitMQ itself. The following variables are added by this patch:

  • $RABBITMQ_DEFAULT_USER (overrides default_user)
  • $RABBITMQ_DEFAULT_PASS (overrides default_pass)
  • $RABBITMQ_DEFAULT_VHOST (overrides default_vhost)
  • $RABBITMQ_ERLANG_COOKIE (overrides the Erlang cookie file content)

Fixes docker-library/rabbitmq#508

…ANG_COOKIE vars

Those environment variables are unset by default. The default values are
set in the `rabbit` application environment and can be configured in the
configuration file. However, the environment variables will take
precedence over them respectively if they are set.
They are the equivalent of the `default_{user,pass,vhost}` configuration
settings. Each set environment variable will take precedence over its
configuration file counterpart.

Fixes docker-library/rabbitmq#508.
It is the equivalent of the content of the Erlang cookie file. Note this
variable IS the cookie value, NOT the path to a cookie file.

If it is set, it will take precedence over the content of the Erlang
cookie file.

Fixes docker-library/rabbitmq#508.
@dumbbell dumbbell force-pushed the add-env-vars-to-set-default-user-pass-vhost-and-erlang-cookie branch from 5b99759 to bd39027 Compare August 11, 2021 13:50
@michaelklishin
Copy link
Collaborator

It works as expected:

RABBITMQ_DEFAULT_VHOST=pr-3299-vhost RABBITMQ_DEFAULT_USER=pr-3299 RABBITMQ_DEFAULT_PASS=pr-3299 gmake run-broker
rabbitmqctl list_users
# => Listing users ...
# => user	tags
# => pr-3299	[administrator]
rabbitmqctl list_vhosts
# => Listing vhosts ...
# => name
# => pr-3299-vhost

@michaelklishin
Copy link
Collaborator

RABBITMQ_ERLANG_COOKIE=abcd gmake run-broker

Makes CLI authentication fail unless --erlang-cookie abcd is provided.

as it can be really difficult to troubleshoot such cookie changes
@michaelklishin michaelklishin marked this pull request as ready for review August 11, 2021 17:36
@michaelklishin michaelklishin added this to the 3.9.4 milestone Aug 11, 2021
@michaelklishin michaelklishin merged commit 1eacbaa into master Aug 11, 2021
@michaelklishin michaelklishin deleted the add-env-vars-to-set-default-user-pass-vhost-and-erlang-cookie branch August 11, 2021 20:06
@michaelklishin michaelklishin restored the add-env-vars-to-set-default-user-pass-vhost-and-erlang-cookie branch August 11, 2021 20:06
@michaelklishin michaelklishin deleted the add-env-vars-to-set-default-user-pass-vhost-and-erlang-cookie branch August 11, 2021 20:06
@michaelklishin
Copy link
Collaborator

@Mergifyio backport v3.9.x

@mergify
Copy link

mergify bot commented Aug 11, 2021

Command backport v3.9.x: success

Backports have been created

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cant use as service in gitlab ci since 3.9
2 participants