Docker support for Rabbit cluster
diff --git a/rabbitmq/cluster.sls b/rabbitmq/cluster.sls
index b5aaa1b..2d55684 100644
--- a/rabbitmq/cluster.sls
+++ b/rabbitmq/cluster.sls
@@ -5,7 +5,7 @@
 - linux.network.host
 - rabbitmq.server.service
 
-{% if cluster.get('role', 'slave') == 'master' %}
+{% if cluster.get('role', 'None') == 'master' %}
 
 rabbitmq_cluster_name:
   cmd.run:
@@ -16,7 +16,7 @@
   - require:
     - service: rabbitmq_service
 
-{% else %}
+{% elif cluster.get('role', 'None') == 'slave' %}
 
 rabbit@master:
   rabbitmq_cluster.join:
@@ -28,6 +28,10 @@
   - require:
     - service: rabbitmq_service
 
+{%- else %}
+
+{# Container deployment role independent #}
+
 {%- endif %}
 
 {%- endif %}
diff --git a/rabbitmq/files/entrypoint.sh b/rabbitmq/files/entrypoint.sh
index 41b85be..d73b748 100644
--- a/rabbitmq/files/entrypoint.sh
+++ b/rabbitmq/files/entrypoint.sh
@@ -1,6 +1,36 @@
-{%- from "rabbitmq/map.jinja" import server with context -%}
+{%- from "rabbitmq/map.jinja" import server,cluster with context -%}
 #!/bin/bash -e
 
+cat /srv/salt/pillar/rabbitmq-server.sls | envsubst > /tmp/rabbitmq-server.sls
+mv /tmp/rabbitmq-server.sls /srv/salt/pillar/rabbitmq-server.sls
+
+{%- if cluster.get('enabled', False) %}
+
+# if NUM_NODES not passed, default to 3
+NUM_NODES=${NUM_NODES:-3}
+
+# loop through number of nodes
+for num in `seq 1 $NUM_NODES`; do
+  NODE_SERVICE_HOST="RABBITMQ_SERVER_NODE0${num}_SERVICE_HOST"
+
+  # if set
+  if [ -n "${!NODE_SERVICE_HOST}" ]; then
+    # if not its own IP, then add it
+    if [ $(expr "$HOSTNAME" : "rabbitmq-server-node0${num}") -eq 0 ]; then
+      # set role cluster role slave for salt
+      sed -i -e 's,^\([\ \t]*role: \)[Nn]one,\1slave,g' /srv/salt/pillar/rabbitmq-server.sls
+      # set master dns for cluster join
+      sed -i -e 's,^\([\ \t]*master: \)[Nn]one,\1rabbitmq-server-node0'${num}',g' /srv/salt/pillar/rabbitmq-server.sls
+      break
+    else
+      # set role cluster role master for salt
+      sed -i -e 's,^\([\ \t]*role: \)[Nn]one,\1master,g' /srv/salt/pillar/rabbitmq-server.sls
+    fi
+  fi
+done
+
+{%- endif %}
+
 salt-call --local --retcode-passthrough state.highstate
 service {{ server.service }} stop || true
 
diff --git a/rabbitmq/map.jinja b/rabbitmq/map.jinja
index 2172794..9a24324 100644
--- a/rabbitmq/map.jinja
+++ b/rabbitmq/map.jinja
@@ -23,7 +23,7 @@
         },
     },
     'Debian': {
-        'pkgs': ['rabbitmq-server'],
+        'pkgs': ['rabbitmq-server', 'gettext-base'],
         'service': 'rabbitmq-server',
         'config_file': '/etc/rabbitmq/rabbitmq.config',
         'cookie_file': '/var/lib/rabbitmq/.erlang.cookie',