Does definitions.json file overwrites rabbitmq.config?

1,733 views
Skip to first unread message

eswar472

unread,
Jul 24, 2017, 7:02:50 AM7/24/17
to rabbitmq-users
I have a user defined in /etc/rabbitmq/rabbitmq.config as below
      {default_vhost,       <<"/">>},
      {default_user,        <<"guest">>},
      {default_pass,        <<"guest">>},
      {default_permissions, [<<".*">>, <<".*">>, <<".*">>]},

and at the end of config file, I have 
  { rabbitmq_management, [
      {load_definitions, "/etc/rabbitmq/definitions.json"}
    ]
  }

Content of my definitions.json file is 
{
    "rabbit_version": "3.6.5",
    "vhosts":[
        {"name":"/"}
    ],
    "policies": [{"vhost":"/", "name":"clickstream","pattern":"^OFC_CLICKSTREAM_PACKETIN_EXCHG$","apply-to":"all","definition":{"shards-per-node":4},"priority":0}]
}

After this if I execute "rabbitmqctl list_users",  its not displaying any users. But if I execute "rabbitmqctl environment" and check, it has below fields.
      {default_permissions,[<<".*">>,<<".*">>,<<".*">>]},
      {default_user,<<"guest">>},

An I verified I am not able to connect to RabbitMQ until I create "guest" user again using rabbitmqctl.
Can anyone let me know is it known that definitions.json overwrites rabbitmq.config? If yes, how can I  create policy at startup without affecting other configuration?

Thank you,
Eshwar.

Michael Klishin

unread,
Jul 24, 2017, 3:55:41 PM7/24/17
to rabbitm...@googlegroups.com
Definitions are orthogonal to configuration files. Default user is created on first boot
if the database isn't empty. I highly recommend adding all pre-configured users to the definitions file
if they are critically important.

Or don't rely on guest/guest, which can connect only from localhost by default.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

eswar472

unread,
Jul 26, 2017, 9:45:05 PM7/26/17
to rabbitmq-users
Hi MK,

It worked.

Thank you,
Eshwar.

Vincenzo De Naro Papa

unread,
Sep 2, 2019, 6:57:43 PM9/2/19
to rabbitmq-users
Hello Michael


Definitions are orthogonal to configuration files. Default user is created on first boot
if the database isn't empty.

So do you mean that default user and vhost are created if database already exists? 

I'm trying to run rabbitmq 3.7 container with management plugin and add a definitions.json file to define some policies (I need mirrored queues for some queues).
The problem is if I use a definitions.json file with only the "policies" statements, I get the

{error,<<"Please create virtual host \"\" prior to importing definitions.">>}

If I use a file with vhosts and policies sections, container starts but no default user created (I'm using environment variables to set default user and password).

From the logs, it seems database is not initialized if definitions.file exist and it's not empty. So more than orthogonal, it seems what is defined in definitions.json has precedence of rabbitmq.conf or env variables and it prevents to initialize the database with default values.
Am I missing something?
Thanks
Vincenzo

Michael Klishin

unread,
Oct 3, 2019, 4:54:22 AM10/3/19
to rabbitmq-users
> So do you mean that default user and vhost are created if database already exists?

Yes but the default virtual host creation (seed) happens only once and the default virtual host name can be anything, not just "/".

Your definition file can assume that the "/" virtual host exists  (e.g. there are queues to import in it) but that's  not necessarily the case.
I'd double check  that part (`rabbitmqctl list_vhosts` will provide some useful information).

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/9c73db5b-958f-4040-8830-b51664456278%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages