forked from Foxlik/salt-docker-formula
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile_local.erb
162 lines (143 loc) · 4.45 KB
/
Vagrantfile_local.erb
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
<% config[:vagrantfiles].each do |vagrantfile| %>
require "<%= vagrantfile %>"
<% end %>
Vagrant.configure("2") do |c|
c.berkshelf.enabled = false if Vagrant.has_plugin?("vagrant-berkshelf")
c.vm.box = "<%= config[:box] %>"
if Vagrant.has_plugin?("vagrant-cachier") and Vagrant.has_plugin?('vagrant-vbguest')
<% if [ 'debian/wheezy64', 'debian/jessie64', 'centos/7'].include? config[:box] %>
c.vbguest.auto_update = true
<% else %>
c.vbguest.auto_update = false
<% end %>
c.cache.auto_detect = true
c.cache.scope = :box
else
c.cache.auto_detect = false
end
<% if config[:box_url] %>
c.vm.box_url = "<%= config[:box_url] %>"
<% end %>
<% if config[:box_version] %>
c.vm.box_version = "<%= config[:box_version] %>"
<% end %>
<% if !config[:box_check_update].nil? %>
c.vm.box_check_update = "<%= config[:box_check_update] %>"
<% end %>
<% if !config[:box_download_insecure].nil? %>
c.vm.box_download_insecure = "<%= config[:box_download_insecure] %>"
<% end %>
<% if config[:vm_hostname] %>
c.vm.hostname = "<%= config[:vm_hostname] %>"
<% end %>
<% if config[:communicator] %>
c.vm.communicator = "<%= config[:communicator] %>"
<% end %>
<% if config[:guest] %>
c.vm.guest = "<%= config[:guest] %>"
<% end %>
<% if config[:communicator] %>
<% if config[:username] %>
c.<%= config[:communicator] %>.username = "<%= config[:username] %>"
<% end %>
<% if config[:password] %>
c.<%= config[:communicator] %>.password = "<%= config[:password] %>"
<% end %>
<% else %>
<% if config[:username] %>
c.ssh.username = "<%= config[:username] %>"
<% end %>
<% if config[:password] %>
c.ssh.password = "<%= config[:password] %>"
<% end %>
<% end %>
<% if config[:ssh_key] %>
c.ssh.private_key_path = "<%= config[:ssh_key] %>"
<% end %>
<% config[:ssh].each do |key, value| %>
c.ssh.<%= key %> = "<%= value %>"
<% end %>
<% if config[:winrm] %>
<% config[:winrm].each do |key, value| %>
c.winrm.<%= key %> = <%= value %>
<% end %>
<% end %>
<% if config[:boot_timeout] %>
c.vm.boot_timeout = <%= config[:boot_timeout] %>
<% end %>
<% Array(config[:network]).each do |opts| %>
c.vm.network(:<%= opts[0] %>, <%= opts[1..-1].join(", ") %>)
<% end %>
c.vm.synced_folder ".", "/vagrant", disabled: true
<% config[:synced_folders].each do |source, destination, options| %>
c.vm.synced_folder "<%= source %>", "<%= destination %>", <%= options %>
<% end %>
c.vm.provider :<%= config[:provider] %> do |p|
<% case config[:provider]
when "virtualbox", /^vmware_/
if config[:gui] == true || config[:gui] == false %>
p.gui = <%= config[:gui] %>
<% end
end %>
<% config[:customize].each do |key, value| %>
<% case config[:provider]
when "libvirt" %>
<% if value.is_a? String %>
p.<%= key %> = "<%= value%>"
<% else %>
p.<%= key %> = <%= value%>
<% end %>
<% when "lxc" %>
<% if key == :container_name %>
p.container_name = <%= value == ":machine" ? value : "\"#{value}\"" %>
<% elsif key == :backingstore %>
p.backingstore = "<%= value %>"
<% elsif key == :backingstore_options %>
<% config[:customize][:backingstore_options].each do |opt, opt_val| %>
p.backingstore_option "--<%= opt %>", "<%= opt_val %>"
<% end %>
<% else %>
p.customize "<%= key %>", "<%= value %>"
<% end %>
<% when "managed" %>
<% if key == :server %>
p.server = "<%= value %>"
<% end %>
<% when "parallels" %>
<% if key == :memory || key == :cpus %>
p.<%= key %> = <%= value %>
<% else %>
p.customize ["set", :id, "--<%= key.to_s.gsub('_', '-') %>", "<%= value %>"]
<% end %>
<% when "rackspace" %>
p.<%= key %> = "<%= value%>"
<% when "softlayer" %>
<% if key == :disk_capacity %>
p.<%= key %> = <%= value %>
<% else %>
p.<%= key %> = "<%= value %>"
<% end %>
<% when "virtualbox" %>
p.customize ["modifyvm", :id, "--<%= key %>", "<%= value %>"]
<% when /^vmware_/ %>
<% if key == :memory %>
<% unless config[:customize].include?(:memsize) %>
p.vmx["memsize"] = "<%= value %>"
<% end %>
<% elsif key == :cpus %>
<% unless config[:customize].include?(:numvcpus) %>
p.vmx["numvcpus"] = "<%= value %>"
<% end %>
<% else %>
p.vmx["<%= key %>"] = "<%= value %>"
<% end %>
<% when "openstack", "cloudstack" %>
<% if value.is_a? String %>
p.<%= key %> = "<%= value%>"
<% else %>
p.<%= key %> = <%= value%>
<% end %>
<% end %>
<% end %>
end
end