|
| 1 | +# -*- mode: ruby -*- |
| 2 | +# vi: set ft=ruby : |
| 3 | + |
| 4 | +# README |
| 5 | +# |
| 6 | +# Getting Started: |
| 7 | +# 1. vagrant plugin install vagrant-hostmanager |
| 8 | +# 2. vagrant up |
| 9 | +# 3. vagrant ssh |
| 10 | +# |
| 11 | +# This should put you at the control host |
| 12 | +# with access, by name, to other vms |
| 13 | +Vagrant.configure(2) do |config| |
| 14 | + config.hostmanager.enabled = true |
| 15 | + |
| 16 | + config.vm.box = "ubuntu/trusty64" |
| 17 | + |
| 18 | + config.vm.define "control", primary: true do |h| |
| 19 | + h.vm.network "private_network", ip: "192.168.135.10" |
| 20 | + h.vm.provision :shell, :inline => <<'EOF' |
| 21 | +if [ ! -f "/home/vagrant/.ssh/id_rsa" ]; then |
| 22 | + ssh-keygen -t rsa -N "" -f /home/vagrant/.ssh/id_rsa |
| 23 | +fi |
| 24 | +cp /home/vagrant/.ssh/id_rsa.pub /vagrant/control.pub |
| 25 | +
|
| 26 | +cat << 'SSHEOF' > /home/vagrant/.ssh/config |
| 27 | +Host * |
| 28 | + StrictHostKeyChecking no |
| 29 | + UserKnownHostsFile=/dev/null |
| 30 | +SSHEOF |
| 31 | +
|
| 32 | +chown -R vagrant:vagrant /home/vagrant/.ssh/ |
| 33 | +EOF |
| 34 | + end |
| 35 | + |
| 36 | + config.vm.define "lb01" do |h| |
| 37 | + h.vm.network "private_network", ip: "192.168.135.101" |
| 38 | + h.vm.provision :shell, inline: 'cat /vagrant/control.pub >> /home/vagrant/.ssh/authorized_keys' |
| 39 | + end |
| 40 | + |
| 41 | + config.vm.define "app01" do |h| |
| 42 | + h.vm.network "private_network", ip: "192.168.135.111" |
| 43 | + h.vm.provision :shell, inline: 'cat /vagrant/control.pub >> /home/vagrant/.ssh/authorized_keys' |
| 44 | + end |
| 45 | + |
| 46 | + config.vm.define "app02" do |h| |
| 47 | + h.vm.network "private_network", ip: "192.168.135.112" |
| 48 | + h.vm.provision :shell, inline: 'cat /vagrant/control.pub >> /home/vagrant/.ssh/authorized_keys' |
| 49 | + end |
| 50 | + |
| 51 | + config.vm.define "db01" do |h| |
| 52 | + h.vm.network "private_network", ip: "192.168.135.121" |
| 53 | + h.vm.provision :shell, inline: 'cat /vagrant/control.pub >> /home/vagrant/.ssh/authorized_keys' |
| 54 | + end |
| 55 | +end |
0 commit comments