Skip to content

Instantly share code, notes, and snippets.

@thamaraiselvam
Created April 6, 2020 09:12
Show Gist options
  • Save thamaraiselvam/a38a93ab702e91ba522b276b83988d21 to your computer and use it in GitHub Desktop.
Save thamaraiselvam/a38a93ab702e91ba522b276b83988d21 to your computer and use it in GitHub Desktop.
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