Skip to content

Instantly share code, notes, and snippets.

@dalmosantos
Last active January 5, 2021 21:31
Show Gist options
  • Save dalmosantos/8e83dceaaf48ff224c008919264ff981 to your computer and use it in GitHub Desktop.
Save dalmosantos/8e83dceaaf48ff224c008919264ff981 to your computer and use it in GitHub Desktop.
Vagrantfile-cluster-centos-docker
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos/7"
config.vm.synced_folder ".", "/vagrant"
config.vm.provider :libvirt do |libvirt, override|
libvirt.memory = 2048
libvirt.nested = true
end
config.vm.provision "shell", inline: <<-SHELL
yum clean all && yum repolist && yum update -y
curl -fsSL get.docker.com | bash
usermod -aG docker vagrant
systemctl enable docker
init 6
SHELL
config.vm.define "swarm-master" do |node|
node.vm.hostname = "swarm-master"
node.vm.network "private_network", ip: "10.100.199.200"
node.vm.network "forwarded_port", guest: 8080, host: 8080
node.vm.network "forwarded_port", guest: 80, host: 80
node.vm.network "forwarded_port", guest: 8443, host: 8443
node.vm.network "forwarded_port", guest: 443, host: 443
node.vm.network "forwarded_port", guest: 2376, host: 2376
node.vm.network "forwarded_port", guest: 2375, host: 2375
end
(1..2).each do |i|
config.vm.define "swarm-node-0#{i}" do |node|
node.vm.hostname = "swarm-node-0#{i}"
node.vm.network "private_network", ip: "10.100.199.20#{i}"
end
end
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.box_check_update = true
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
(51..53).each do |i|
config.vm.define "docker#{i}" do |node|
node.vm.hostname = "docker#{i}"
node.vm.network "private_network", ip: "192.168.33.#{i}"
end
end
config.vm.provision "shell", inline: <<-SHELL
yum clean all
yum -y install gcc libstdc++-devel gcc-c++ curl-devel libxml2-devel openssl-devel mailcap rsync yum-utils
curl -fsSL get.docker.com -o get-docker.sh
bash get-docker.sh
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment