Skip to content

Instantly share code, notes, and snippets.

@momijiame
Created August 12, 2016 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save momijiame/1dc33c45e47c75d03408a44e63c7daa7 to your computer and use it in GitHub Desktop.
Save momijiame/1dc33c45e47c75d03408a44e63c7daa7 to your computer and use it in GitHub Desktop.
Vagrantfile for Docker Swarm
#!/usr/bin/env sh
set -x
set -e
: "prepare" && {
yum -y update
cat << 'EOF' | tee /etc/yum.repos.d/docker.repo > /dev/null
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
yum clean all
}
: "Open port" && {
systemctl stop firewalld
systemctl disable firewalld
yum -y install iptables-services
systemctl start iptables
systemctl enable iptables
for i in 80 2377 7946 4789; do iptables -I INPUT -j ACCEPT -p tcp --dport $i; done;
for i in 7946 4789; do iptables -I INPUT -j ACCEPT -p udp --dport $i; done;
service iptables save
}
: "install docker" && {
yum -y install docker-engine
}
: "start docker daemon" && {
systemctl start docker
systemctl enable docker
}
Vagrant.configure("2") do |config|
(1..3).each do |i|
config.vm.define "node#{i}" do |node|
node.vm.hostname = "node#{i}.example.com"
node.vm.box = "bento/centos-7.2"
node.vm.network "private_network", ip: "192.168.33.1#{i}"
node.vm.provision :shell do |shell|
shell.path = "deploy.sh"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment