forked from theforeman/forklift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
87 lines (69 loc) · 2.71 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
require 'yaml'
require './lib/katello_deploy'
VAGRANTFILE_API_VERSION = '2'
SUPPORT_SSH_INSERT_KEY = Gem.loaded_specs['vagrant'].version >= Gem::Version.create('1.7')
module KatelloDeploy
@box_loader = BoxLoader.new
@boxes = @box_loader.add_boxes('config/base_boxes.yaml')
@boxes = @box_loader.add_boxes('boxes.yaml') if File.exists?('boxes.yaml')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@boxes.each do |name, box|
define_vm config, box
end
config.vm.provider :libvirt do |domain|
domain.memory = 3560
domain.cpus = 2
end
config.vm.provider :virtualbox do |domain|
domain.memory = 3560
domain.cpus = 2
domain.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
domain.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
end
end
def self.plugin_vagrantfiles
current = File.dirname(__FILE__)
Dir.glob "#{current}/plugins/*/Vagrantfile"
end
plugin_vagrantfiles.each { |f| load f }
def self.define_vm(config, box = {})
config.vm.define box.fetch('name'), primary: box.fetch('default', false) do |machine|
machine.vm.box = box.fetch('box_name')
machine.vm.hostname = "katello-#{box.fetch('name').to_s.gsub('.','-')}.example.com"
config.ssh.insert_key = false if SUPPORT_SSH_INSERT_KEY
if box['shell']
machine.vm.provision :shell do |shell|
shell.inline = box.fetch('shell')
shell.privileged = false if box.key?('privileged')
end
end
machine.vm.provider :libvirt do |p, override|
override.vm.box_url = box.fetch('libvirt')
override.vm.synced_folder ".", "/vagrant", type: "rsync"
override.vm.network :public_network, :dev => box.fetch('bridged'), :mode => 'bridge' if box.fetch('bridged', false)
end
if box.key?('virtualbox')
machine.vm.provider :virtualbox do |p, override|
override.vm.box_url = box.fetch('virtualbox')
if box.fetch('name').to_s.include?('devel')
config.vm.network :forwarded_port, guest: 3000, host: 3330
config.vm.network :forwarded_port, guest: 443, host: 4430
else
override.vm.network :forwarded_port, guest: 80, host: 8080
override.vm.network :forwarded_port, guest: 443, host: 4433
end
end
end
if box.fetch('image_name', false)
machine.vm.provider :rackspace do |p, override|
override.vm.box = 'dummy'
p.server_name = machine.vm.hostname
p.flavor = /4GB/
p.image = box.fetch('image_name')
override.ssh.pty = true if box.fetch('pty')
end
end
yield machine if block_given?
end
end
end