From 2545d2977baae9e51ce256d4d9a0043a78a1ca33 Mon Sep 17 00:00:00 2001 From: Chai Feng Date: Sat, 1 Dec 2018 12:32:33 +0800 Subject: [PATCH] allow re-provision for vagrant --- Vagrantfile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 91fb7f1..c3bf240 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -52,9 +52,18 @@ Vagrant.configure('2') do |config| master.vm.hostname = "master" master.vm.network "private_network", ip: "#{ip_prefix}.130" + master.vm.provision "docker-registry", type: 'docker' do |d| + d.run "registry", + image: "registry:2", + args: "-p 5000:5000", + restart: "always", + daemonize: true + end + master.vm.provision "swarm-init", type: 'shell', inline: <<-SHELL set -ex - docker run -d -p 5000:5000 --restart=always --name registry registry:2 + docker info | fgrep 'Swarm: active' && exit 0 + docker swarm init --advertise-addr eth1 docker swarm join-token worker --quiet > /vagrant/.vagrant/docker-join-token SHELL @@ -67,6 +76,8 @@ Vagrant.configure('2') do |config| node.vm.provision "swarm-join", type: 'shell', inline: <<-SHELL set -ex + docker info | fgrep 'Swarm: active' && exit 0 + [[ -f /vagrant/.vagrant/docker-join-token ]] && docker swarm join --token "$(