Skip to content

Instantly share code, notes, and snippets.

@christophschubert
Last active April 6, 2020 03:51
Show Gist options
  • Save christophschubert/1c1d0ba5817ab51bf6ac7a71c36253e3 to your computer and use it in GitHub Desktop.
Save christophschubert/1c1d0ba5817ab51bf6ac7a71c36253e3 to your computer and use it in GitHub Desktop.
Create multiple machines in a single Vagrantfile and ensure that we can ssh into them without using vagrant.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# create multiple machines in a single Vagrantfile and ensure that we can ssh into them without using vagrant.
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.ssh.insert_key = false
config.ssh.private_key_path = ["~/.vagrant.d/insecure_private_key", "~/.ssh/terraform"]
config.vm.provision "file", source: "~/.ssh/terraform.pub", destination: "~/.ssh/authorized_kets"
zookeeper_base = 100
broker_base = 110
# Bring up VMs for Zookeeper ensemble
(1..3).each do |machine_id|
config.vm.define "zookeeper-#{machine_id}" do |machine|
machine.vm.hostname = "zookeeper-#{machine_id}"
machine.vm.network "private_network", ip: "192.168.77.#{zookeeper_base + machine_id}"
end
end
# Bring up VMs for the broker
(1..3).each do |machine_id|
config.vm.define "broker-#{machine_id}" do |machine|
machine.vm.hostname = "broker-#{machine_id}"
machine.vm.network "private_network", ip: "192.168.77.#{broker_base + machine_id}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment