-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathVagrantfile
168 lines (140 loc) · 4.83 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# -*- mode: ruby -*-
# vi: set ft=ruby :
$:.unshift File.join(File.dirname(__FILE__), "lib")
require 'lab/helpers'
require 'lab/vagrant_middleware'
# razor node and router/dhcp server
def build_razor_node(config)
config.vm.define :razor do |vm_config|
vm_config.vm.box = "opscode-ubuntu-12.04"
vm_config.vm.box_url = oc_box_url(vm_config.vm.box)
vm_config.vm.hostname = "razor.razornet.local"
vm_config.vm.network :private_network, :ip => razor_ip
vm_config.berkshelf.enabled = true
vm_config.vm.provision :chef_solo do |chef|
chef.data_bags_path = "data_bags"
chef.run_list = [
"recipe[apt]",
"recipe[router]",
"recipe[dhcp::server]",
"recipe[djbdns::internal_server]",
"recipe[djbdns::cache]",
"recipe[razor]"
]
chef.json = {
:dhcp => {
:networks => ["172-16-33-0_24"],
:options => {
'domain-name-servers' => "172.16.33.11",
'domain-name' => "\"razornet.local\""
},
:parameters => {
'next-server' => "172.16.33.11",
},
:interfaces => [ "eth1" ]
},
:djbdns => {
:domain => 'razornet.local',
:public_dnscache_ipaddress => razor_ip,
:public_dnscache_allowed_networks => [ "172.16.33" ],
:tinydns_internal_resolved_domain => 'razornet.local'
},
:razor => {
:app => {
:git_rev => '7ce9619eb0e9e99be4b714939d4ad4586b3aba7d'
},
:bind_address => razor_ip,
:images => {
"rz_mk_#{mk_type}-image.#{mk_version}" => {
'type' => 'mk',
'url' => mk_url
}
}
}
}
end
end
end
# create some razor client nodes
def build_client_nodes(config)
razor_nodes.to_i.times do |i|
config.vm.define :"node#{i+1}" do |vm_config|
vm_config.vm.box = "blank-amd64"
vm_config.vm.box_url = "https://s3.amazonaws.com/fnichol/vagrant-base-boxes/blank-amd64-20121109.box"
vm_config.vm.provider "virtualbox" do |virtualbox|
virtualbox.gui = true unless ENV['NO_GUI']
# generate a new mac address for each node, to make them unique
virtualbox.customize ["modifyvm", :id, "--macaddress1", "auto"]
# put primary network interface into hostonly network segement
virtualbox.customize ["modifyvm", :id, "--nic1", "hostonly"]
virtualbox.customize ["modifyvm", :id, "--hostonlyadapter1", "vboxnet0"]
# pxe boot the node
virtualbox.customize ["modifyvm", :id, "--boot1", "net"]
end
end
end
end
# chef server for the razor chef broker
def build_chef_node(config)
config.vm.define :chef do |vm_config|
vm_config.vm.box = "opscode-ubuntu-12.04"
vm_config.vm.box_url = oc_box_url(vm_config.vm.box)
vm_config.vm.hostname = "chef.razornet.local"
vm_config.vm.network :private_network, :ip => chef_server_ip
vm_config.vm.provider "virtualbox" do |virtualbox|
virtualbox.customize ["modifyvm", :id, "--cpus", 2]
virtualbox.customize ["modifyvm", :id, "--memory", 1024]
end
vm_config.vm.provision :chef_solo do |chef|
chef.log_level = :debug
chef.provisioning_path = "/vagrant/tmp/chef_cache"
chef.run_list = [
"recipe[apt]",
"recipe[chef-server::default]"
]
chef.json = {
'chef-server' => {
'package_file' => 'http://opscode-omnitruck-release.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.4-1.ubuntu.12.04_amd64.deb',
'package_checksum' => 'f3564ce57e36633c0d92017e6b17ea218c83e954ebfdcdb487eccb0b4c2e4932'
}
}
end
# set up chef server with cookbooks and a web_server role
vm_config.vm.provision :shell, :inline => postinstall_script(:chef)
end
end
# puppetmaster for the razor puppet broker
def build_puppet_node(config)
config.vm.define :puppet do |vm_config|
vm_config.vm.box = "opscode-ubuntu-12.04"
vm_config.vm.box_url = oc_box_url(vm_config.vm.box)
vm_config.vm.hostname = "puppet.razornet.local"
vm_config.vm.network :private_network, :ip => puppetmaster_ip
vm_config.vm.provision :chef_solo do |chef|
chef.run_list = [
"recipe[apt]",
"recipe[puppet::master]"
]
chef.json = {
:puppet => {
:master_conf => {
:master => {
:autosign => 'true'
}
}
}
}
end
# set up all puppet nodes to be an apache web server
vm_config.vm.provision :shell, :inline => postinstall_script(:puppet)
end
end
Vagrant.configure("2") do |config|
include Lab::Helpers
config.berkshelf.enabled = true
config.omnibus.chef_version = :latest
build_razor_node(config)
build_chef_node(config)
build_puppet_node(config)
build_client_nodes(config)
end