blob: 438dac003aefd3a9e58fef504f3bf77182731c30 [file] [log] [blame]
Simon Pasquiera4e38252017-04-28 11:14:29 +02001#!/bin/bash -x
2exec > >(tee -i /tmp/"$(basename "$0" .sh)"_"$(date '+%Y-%m-%d_%H-%M-%S')".log) 2>&1
3
Simon Pasquierd3a0b912017-05-02 15:32:20 +02004# Configure base Docker service
Simon Pasquiera4e38252017-04-28 11:14:29 +02005salt -C 'I@docker:swarm' state.sls docker.host
Simon Pasquierd3a0b912017-05-02 15:32:20 +02006# Configure the Swarm master node
Simon Pasquiera4e38252017-04-28 11:14:29 +02007salt -C 'I@docker:swarm:role:master' state.sls docker.swarm
Simon Pasquierd3a0b912017-05-02 15:32:20 +02008# Send grains to mine for the Swarm slave nodes
Simon Pasquiera4e38252017-04-28 11:14:29 +02009salt -C 'I@docker:swarm' state.sls salt.minion.grains
10salt -C 'I@docker:swarm' mine.update
Simon Pasquierd3a0b912017-05-02 15:32:20 +020011salt -C 'I@docker:swarm' saltutil.refresh_modules
12sleep 5
Olivier Bourdonb1657e52017-08-08 15:36:22 +020013# Rerun Swarm state on master node to properly push Swarm tokens into grains
14salt -C 'I@docker:swarm:role:master' state.sls docker.swarm
Simon Pasquierd3a0b912017-05-02 15:32:20 +020015# Configure Swarm slave nodes
Simon Pasquiera4e38252017-04-28 11:14:29 +020016salt -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1
Simon Pasquierd3a0b912017-05-02 15:32:20 +020017
18# List registered Docker Swarm nodes
Simon Pasquiera4e38252017-04-28 11:14:29 +020019salt -C 'I@docker:swarm:role:master' cmd.run 'docker node ls'