Created
October 4, 2019 06:59
-
-
Save BhavaniShekhar/0275ceb832cc5f2321b84c8031c8da2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $setup_docker = <<SCRIPT | |
| apt-get update; | |
| DEBIAN_FRONTEND=noninteractive apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common; | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -; | |
| add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
| apt-get update; | |
| mkdir -p /etc/systemd/system/docker.service.d | |
| echo "[Service]" >> /etc/systemd/system/docker.service.d/http-proxy.conf | |
| echo "EnvironmentFile=-/etc/sysconfig/docker">> /etc/systemd/system/docker.service.d/http-proxy.conf | |
| apt-get install -y docker-ce docker-ce-cli containerd.io; | |
| sed -i 's|-H fd://|-H fd:// -H tcp://0.0.0.0:2375|g' /lib/systemd/system/docker.service; | |
| systemctl daemon-reload && systemctl restart docker.service; | |
| SCRIPT | |
| Vagrant.configure(2) do |config| | |
| config.vm.provider "virtualbox" do |vb| | |
| vb.memory = "1024" | |
| end | |
| config.vm.define "master" do |config| | |
| config.vm.box = "ubuntu/bionic64" | |
| config.vm.hostname = "master.devopshunter.localdomain" | |
| config.vm.network "private_network", ip: "192.168.33.110" | |
| config.vm.provision "shell", inline: $setup_docker | |
| end | |
| config.vm.define "swarmnode1" do |config| | |
| config.vm.box = "ubuntu/bionic64" | |
| config.vm.hostname = "swarmnode1.devopshunter.localdomain" | |
| config.vm.network "private_network", ip: "192.168.33.111" | |
| config.vm.provision "shell", inline: $setup_docker | |
| end | |
| config.vm.define "swarmnode2" do |config| | |
| config.vm.box = "ubuntu/bionic64" | |
| config.vm.hostname = "swarmnode2.devopshunter.localdomain" | |
| config.vm.network "private_network", ip: "192.168.33.112" | |
| config.vm.provision "shell", inline: $setup_docker | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Vagrantfile is using inline shell script that will be executed at the time of VM creation time.
Getting Started:
Install the latest version of Vagrant
Install the latest version of Oracle Virtualbox