This repository has been archived by the owner on Jan 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Vagrantfile.local.rb
72 lines (60 loc) · 2.23 KB
/
Vagrantfile.local.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
#
# This file is intended to be included in another Vagrantfile. It
# copies local SSL CAs from the host to the new guest VM, and injects
# any HTTP proxy settings from the enclosing environments into the
# /etc/environment file.
#
# The canonical path for locally installed CAs on Linux is
# /usr/local/share/ca-certificates. This path is shared from the host
# to the guest using the vboxsf driver, then the guest updates its CAs
# using the host's local certificates.
#
# If $http_proxy or $https_proxy is set when Vagrant is invoked, this
# file's provisioners will copy those settings into /etc/environment.
#
Vagrant.configure('2') do |config|
config.vm.define 'bootstrap' do |bs|
# load any local SSL certificates if present
local_ca = ENV.fetch 'LOCAL_CERTS', '/usr/local/share/ca-certificates'
if Dir.exist?(local_ca)
debian_bundle_path = '/etc/ssl/certs/ca-certificates.crt'
bs.vm.synced_folder local_ca, '/usr/local/share/ca-certificates',
type: 'rsync'
bs.vm.provision 'deploy-certs', type: 'shell', inline: <<~eos
DEBIAN_TOOL_PATH=/usr/sbin/update-ca-certificates
# Debian/Ubuntu
if [[ -x $DEBIAN_TOOL_PATH ]]; then
SSL_PATH=#{debian_bundle_path}
$DEBIAN_TOOL_PATH
else
exit -1
fi
echo "SSL_CERT_FILE=$SSL_PATH" >> \
/etc/environment
umask 0277
echo 'Defaults env_keep += "SSL_CERT_FILE"' > \
/etc/sudoers.d/ssl
eos
# Note: the box_download_ca_cert is used on the host, not the guest.
bs.vm.box_download_ca_cert = debian_bundle_path
end
# set proxies if present
bs.vm.provision 'propagate-proxies', type:'shell', inline: <<~eos
if [ -n "#{ENV['https_proxy']}" ]; then
echo 'https_proxy=#{ENV['https_proxy']}' >> \
/etc/environment
fi
if [ -n "#{ENV['http_proxy']}" ]; then
echo 'http_proxy=#{ENV['http_proxy']}' >> \
/etc/environment
fi
if [ -n "#{ENV['no_proxy']}" ]; then
echo "no_proxy='#{ENV['no_proxy']}'" >> \
/etc/environment
fi
umask 0277
echo 'Defaults env_keep += "http_proxy https_proxy no_proxy"' > \
/etc/sudoers.d/proxy
eos
end
end