apiVersion: v1
data:
  config.json: |
    {
        "command": "/usr/sbin/rabbitmq-server",
        "config_files": [
            {
                "source": "/var/lib/kolla/config_files/rabbitmq-env.conf",
                "dest": "/etc/rabbitmq/rabbitmq-env.conf",
                "owner": "rabbitmq",
                "perm": "0600"
            },
            {
                "source": "/var/lib/kolla/config_files/rabbitmq.config",
                "dest": "/etc/rabbitmq/rabbitmq.config",
                "owner": "rabbitmq",
                "perm": "0600"
            },
            {
                "source": "/var/lib/kolla/config_files/rabbitmq-clusterer.config",
                "dest": "/etc/rabbitmq/rabbitmq-clusterer.config",
                "owner": "rabbitmq",
                "perm": "0600"
            },
            {
                "source": "/var/lib/kolla/config_files/definitions.json",
                "dest": "/etc/rabbitmq/definitions.json",
                "owner": "rabbitmq",
                "perm": "0600"
            }
        ],
        "permissions": [
            {
                "path": "/var/lib/rabbitmq",
                "owner": "rabbitmq:rabbitmq",
                "recurse": true
            },
            {
                "path": "/var/log/kolla/rabbitmq",
                "owner": "rabbitmq:rabbitmq",
                "recurse": true
            }
        ]
    }
  definitions.json: |
    {
      "vhosts": [
        {"name": "/"}
      ],
      "users": [
        {"name": "openstack", "password": "n8ZKhaSiHmBQgZTwJ8QsKJEkV2cbJnsyqUi6waMl", "tags": "administrator"}
      ],
      "permissions": [
        {"user": "openstack", "vhost": "/", "configure": ".*", "write": ".*", "read": ".*"}
      ],
      "policies":[
        {"vhost": "/", "name": "ha-all", "pattern": ".*", "apply-to": "all", "definition": {"ha-mode":"all"}, "priority":0}
      ]
    }
  rabbitmq-clusterer.config: |
    [
      {version, 1},
      {nodes, [
          {'rabbit@borg', disc}    ]},
      {gospel,
        {node, 'rabbit@borg'}}
    ].
  rabbitmq-env.conf: |
    RABBITMQ_NODENAME=rabbit

    RABBITMQ_LOG_BASE=/var/log/kolla/rabbitmq

    # TODO(sdake, vhosakot)
    # erlang by default binds to wildcard (all interfaces) and can potentially
    # interfere with the neutron external or tenant networks. We should in theory
    # bind epmd to the host's IPv4 address to address the issue however this also
    # has issues and can crash erlang when it is compiled with IPv6 support.
    # See bugs:
    # https://bugs.launchpad.net/ubuntu/+source/erlang/+bug/1374109
    # https://bugs.launchpad.net/kolla/+bug/1562701
    # https://bugzilla.redhat.com/show_bug.cgi?id=1324922
    #export ERL_EPMD_ADDRESS=0.0.0.0
    export ERL_EPMD_PORT=4369
  rabbitmq.config: |
    [
      {kernel, [
        {inet_dist_use_interface, {0,0,0,0}},
        {inet_dist_listen_min, 25672},
        {inet_dist_listen_max, 25672}
      ]},
      {rabbit, [
        {tcp_listeners, [
          {"0.0.0.0", 5672}
        ]}  ]},
      {rabbitmq_management, [
        {listener, [
          {ip, "0.0.0.0"},
          {port, 15672}
        ]},
        {load_definitions, "/etc/rabbitmq/definitions.json"}
      ]}].
    % EOF
kind: ConfigMap
metadata:
  name: rabbitmq
