ほぼログ専門

コンフィグファイルにload_definitionsを設定する。

#Dockerfile
FROM rabbitmq:3.7.8-management

ADD rabbitmq.config /etc/rabbitmq/
ADD definitions.json /etc/rabbitmq/
#rabbitmq.config
[
  {
    rabbit,
      [
        { loopback_users, [] }
      ]
  },
  {
    rabbitmq_management,
      [
        { load_definitions, "/etc/rabbitmq/definitions.json" }
      ]
  }
].

definitions.json

{
  "users": [
    {
      "name": "guest",
      "password_hash": "o2MJjT8UKSRM7eoLDMWvm4LxqaFvDxd2wLg1KQQQ2jXfG5UE",
      "hashing_algorithm": "rabbit_password_hashing_sha256",
      "tags": "administrator"
    }
  ],
  "vhosts": [
    {
      "name": "/"
    }
  ],
  "permissions": [
    {
      "user": "guest",
      "vhost": "/",
      "configure": ".*",
      "write": ".*",
      "read": ".*"
    }
  ],
  "parameters": [],
  "policies": [],
  "exchanges": [
    {
      "name": "example.exchange",
      "vhost": "/",
      "type": "direct",
      "durable": true,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    }
  ],
  "queues": [
    {
      "name": "example.queue",
      "vhost": "/",
      "durable": true,
      "auto_delete": false,
      "arguments": {}
    }
  ],
  "bindings": [
    {
      "source": "example.exchange",
      "vhost": "/",
      "destination": "event.queue",
      "destination_type": "queue",
      "routing_key": "example.routing.key",
      "arguments": {}
    }
  ]
}

参考

追記

passwordのencodeにはrabbitmqctlを使う

このログへのコメント

コメントはありません