Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
create ubuntu instance on local
$setup_consul = <<-SCRIPT
#! /bin/sh
echo "Installing required packages..."
sudo apt-get update
# Other Packages required
sudo apt-get install wget unzip curl vim -y
wget https://releases.hashicorp.com/consul/1.6.2/consul_1.6.2_linux_amd64.zip -O consul.zip
unzip consul.zip
sudo chmod +x consul
sudo mv consul /usr/local/bin
echo "Installed consul binary"
SCRIPT
VAGRANTFILE_API_VERSION = "2"
NUM_OF_NODES = 5
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |v|
v.memory = 512
v.cpus = 1
end
config.vm.provision :shell, inline: "echo 'Hello World!'"
(1..NUM_OF_NODES).each do |i|
config.vm.define "node#{i}" do |node|
node.vm.network "private_network", ip: "192.168.1.#{i+1}"
node.vm.hostname = "machine#{i}"
node.vm.provision :shell, inline: $setup_consul
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment