forked from openstack/devstack-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
144 lines (122 loc) · 5.08 KB
/
Copy pathVagrantfile
File metadata and controls
144 lines (122 loc) · 5.08 KB
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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2" if not defined? VAGRANTFILE_API_VERSION
require 'yaml'
if File.file?('config.yaml')
conf = YAML.load_file('config.yaml')
else
raise "Configuration file 'config.yaml' does not exist."
end
def configure_vm(name, vm, conf)
vm.hostname = conf["hostname_#{name}"] || name
if conf["use_bridge"] == false
if conf["ip_address_#{name}"]
vm.network :private_network, ip: conf["ip_address_#{name}"]
else
vm.network :private_network, type: "dhcp"
end
else
# we do an L2 bridge directly onto the physical network, which means
# that your OpenStack hosts (manager, compute) are directly in the
# same network as your physical host. Your OpenStack guests (2nd
# level guests that you create in nova) will be also on the same L2,
# however they will be in a different address space (10.0.0.0/24 by
# default).
#
# :use_dhcp_assigned_default_route true is important to let your
# guests actually route all the way out to the real internet.
vm.network :public_network, :bridge => conf['bridge_int'], :use_dhcp_assigned_default_route => true
end
vm.provider :virtualbox do |vb|
# Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "4096"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
# you need this for openstack guests to talk to each other
vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
# if specified assign a static MAC address
if conf["mac_address_#{name}"]
vb.customize ["modifyvm", :id, "--macaddress2", conf["mac_address_#{name}"]]
end
end
# puppet provisioning
vm.provision "puppet" do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.module_path = "puppet/modules"
puppet.manifest_file = "default.pp"
#puppet.options = "--verbose --debug"
## custom facts provided to Puppet
puppet.facter = {
## tells default.pp that we're running in Vagrant
"is_vagrant" => true,
"is_compute" => (name != "manager"),
"use_ldap" => conf["use_ldap"] || false,
}
# add all the rest of the content in the conf file
conf.each do |k, v|
puppet.facter[k] = v
end
end
if conf['setup_mode'] == "devstack"
vm.provision "shell" do |shell|
shell.inline = "sudo su - stack -c 'cd ~/devstack && ./stack.sh'"
end
end
if conf['setup_mode'] == "grenade"
vm.provision "shell" do |shell|
shell.inline = "sudo su - stack -c 'cd ~/grenade && ./grenade.sh'"
end
end
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Step 1: what's you base box that you are going to use
#
# - if you specify a local box_name on your system, we'll use that
# - else we're going to use an upstream box from the cloud at 14.04 level
# - lastly, let you override the url in case you have something cached locally
#
# The boot time is long for these, so I recommend that you convert to a local
# version as soon as you can.
config.vm.box = conf['box_name'] || 'ubuntu/trusty64'
config.vm.box_url = conf['box_url'] if conf['box_url']
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
if Vagrant.has_plugin?("vagrant-proxyconf") && conf['proxy']
config.proxy.http = conf['proxy']
config.proxy.no_proxy = "localhost,127.0.0.1,#{hostname_manager},#{hostname_compute}"
end
# NOTE(berendt): This solves the Ubuntu-specific Vagrant issue 1673.
# https://github.com/mitchellh/vagrant/issues/1673
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
if Vagrant.has_plugin?("vagrant-hostmanager")
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
end
config.vm.define "manager", primary: true do |manager|
configure_vm("manager", manager.vm, conf)
manager.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
manager.vm.network "forwarded_port", guest: 6080, host: 6080, host_ip: "127.0.0.1"
end
if conf['hostname_compute']
config.vm.define "compute" do |compute|
configure_vm("compute", compute.vm, conf)
end
end
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
config.ssh.forward_agent = true
# 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"
if conf['local_openstack_tree']
config.vm.synced_folder conf['local_openstack_tree'], "/home/vagrant/openstack"
end
end