-
Notifications
You must be signed in to change notification settings - Fork 5
/
Vagrantfile.template.rb
127 lines (112 loc) · 4.17 KB
/
Vagrantfile.template.rb
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
Vagrant.require_version '>= 2.2.7'
ENV['LC_ALL'] = 'en_US.UTF-8'
# Exit early in 2.1.2 due to bug: https://github.com/hashicorp/vagrant/issues/10013
# https://github.com/hashicorp/vagrant/pull/10030
need_restart = false
unless ['plugin'].include? ARGV[0]
[
{
name: 'vagrant-guests-clearlinux',
version: '>= 1.2.4'
}
].each do |plugin|
next if Vagrant.has_plugin?(plugin[:name], plugin[:version])
verb = Vagrant.has_plugin?(plugin[:name]) ? 'update' : 'install'
system("vagrant plugin #{verb} #{plugin[:name]}", chdir: '/tmp') || exit!
need_restart = true
end
end
exec "vagrant #{ARGV.join(' ')}" if need_restart
Vagrant.configure(2) do |config|
name = 'clearlinux'
headless = ENV['HEADLESS'] || true
proxy_whitelisted = (ENV['PROXY_WHITELIST'] || '').to_s
config.vm.hostname = name.to_s
config.vm.define :name.to_s
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.box_check_update = false
# always use Vagrants' insecure key
config.ssh.insert_key = false
config.ssh.username = 'clear'
# no point on todays' networks and only adds extra overhead...
config.ssh.compression = false
['vmware_workstation', 'vmware_fusion', 'vmware_desktop'].each do |vmw|
config.vm.provider(vmw) do |vmware|
vmware.whitelist_verified = true
vmware.gui = !headless
{
'mks.enable3d' => 'TRUE',
# avoid high CPU loads in macOS Catalina hosts (when in gfx mode)
# per https://communities.vmware.com/thread/622273
'mks.enableMTLRenderer' => 'FALSE',
'mks.enableGLRenderer' => 'TRUE',
'cpuid.coresPerSocket' => '1',
'memsize' => '2048',
'numvcpus' => '2'
}.each { |k, v| vmware.vmx[k.to_s] = v.to_s }
(0..7).each do |n|
vmware.vmx["ethernet#{n}.virtualDev"] = 'vmxnet3'
end
end
end
config.vm.provider 'virtualbox' do |vbox|
vbox.gui = !headless
vbox.linked_clone = false
{
'--memory' => 2048,
'--cpus' => 2,
'--hwvirtex' => 'on',
'--nested-hw-virt' => 'on',
'--nestedpaging' => 'on',
'--largepages' => 'on',
'--vtxvpid' => 'on',
'--vtxux' => 'on',
'--graphicscontroller' => 'vmsvga',
'--accelerate3d' => 'on',
'--clipboard-mode' => 'bidirectional',
'--draganddrop' => 'bidirectional'
}.each { |k, v| vbox.customize ['modifyvm', :id, k.to_s, v.to_s] }
(1..8).each do |n|
vbox.customize ['modifyvm', :id, "--nictype#{n}", 'virtio']
end
end
config.vm.provider 'libvirt' do |libvirt, override|
# bellow, it is assumed that the remote libvirt host is running not only
# clearlinux but also is matching our conventions ...
# If it isn't `LIBVIRT_USERNAME` needs to be set to match users' local
# environment.
unless ENV['LIBVIRT_HOST'].nil? || ENV['LIBVIRT_HOST'].empty?
host = ENV['LIBVIRT_HOST']
username = if ENV['LIBVIRT_USERNAME'].nil? ||
ENV['LIBVIRT_USERNAME'].empty?
'clear'
else
ENV['LIBVIRT_USERNAME']
end
libvirt.host = host
libvirt.connect_via_ssh = true
libvirt.username = username
override.ssh.forward_agent = true
override.ssh.proxy_command = "ssh -q -W %h:%p -l #{username} -x #{host}"
end
# XXX: this is the default location in ClearLinux and Debian
libvirt.loader = '/usr/share/qemu/OVMF.fd'
libvirt.driver = 'kvm'
libvirt.cpu_mode = 'host-passthrough'
libvirt.nested = true
libvirt.memory = 2048
libvirt.cpus = 2
libvirt.channel target_name: 'org.qemu.guest_agent.0',
type: 'unix',
target_type: 'virtio'
end
if ENV.keys.grep(/(http(|s)|no)_proxy/i).any? && Vagrant.has_plugin?('vagrant-proxyconf')
w = proxy_whitelisted.empty? ? '' : ",#{proxy_whitelisted}".to_s
config.proxy.http = (ENV['http_proxy'] || ENV['HTTP_PROXY'])
config.proxy.https = (ENV['https_proxy'] || ENV['HTTPS_PROXY'])
config.proxy.no_proxy =
(ENV['no_proxy'] || ENV['NO_PROXY'] || 'localhost,127.0.0.1').to_s + w
# since we've been masking it by default ...
config.proxy.enabled = { docker: false }
end
end