forked from bparry02/ansible-tower-hashicorp-vault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
70 lines (58 loc) · 2.25 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Hostmanager vagrant plugin edits /etc/hosts for guest vms.
# This allows network communication via hostname to work between vms.
config.hostmanager.enabled = true
# Disable replacing the vagrant insecure private key to be able to
# use the same key for all hosts
config.ssh.insert_key = false
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
#vb.gui = true
# Customize the amount of memory on the VM:
#vb.memory = "1024"
end
config.vm.define "tower" do |tower|
tower.vm.box = "ansible/tower"
tower.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vb.cpus = 2
end
# Create a private network, which allows host-only access to the machine
# using a specific IP.
tower.vm.network "private_network", ip: "172.28.128.6"
#tower.vm.network "private_network", ip: "10.42.0.42"
config.vm.provision "shell" do |s|
ssh_insecure_key = File.read("#{Dir.home}/.vagrant.d/insecure_private_key")
s.inline = <<-SHELL
echo "#{ssh_insecure_key}" > /home/vagrant/.ssh/id_rsa
chown vagrant:vagrant /home/vagrant/.ssh/id_rsa
chmod 400 /home/vagrant/.ssh/id_rsa
SHELL
end
end
N = 2
(1..N).each do |id|
config.vm.define "host-#{id}" do |host|
host.vm.box = "centos/7"
host.vm.provider "virtualbox" do |vb|
vb.memory = 1024
vb.cpus = 1
end
# Create a private network, which allows host-only access to the machine
# using a specific IP.
host.vm.network "private_network", ip: "172.28.128.#{id + 20}"
#host.vm.network "private_network", ip: "10.42.0.#{id + 50}"
host.vm.hostname = "host-#{id}"
end
end
end