Ability to retrieve swarm join-token from pillar instead of Salt mine (#16)
diff --git a/docker/swarm.sls b/docker/swarm.sls
index 7992697..67c982c 100644
--- a/docker/swarm.sls
+++ b/docker/swarm.sls
@@ -52,9 +52,17 @@
{%- else %}
+{%- set join_token = None %}
+
{%- for node_name, node_grains in salt['mine.get']('*', swarm.mine_function).iteritems() %}
{%- if node_grains.get("docker_swarm_AdvertiseAddr", None) == swarm.master.host|string+":"+swarm.master.port|string %}
{%- set join_token = node_grains.get('docker_swarm_tokens').get(swarm.role, "unknown") %}
+{%- endif %}
+{%- endfor %}
+
+{%- set join_token = swarm.get('join_token', {}).get(swarm.role, join_token) %}
+
+{%- if join_token %}
docker_swarm_join:
cmd.run:
@@ -69,7 +77,6 @@
- service: docker_service
{%- endif %}
-{%- endfor %}
{%- endif %}