-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
101 lines (79 loc) · 3.23 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# For a complete reference of oconfiguration options, please see the online
# documentation at https://docs.vagrantup.com.
config.vm.box = "centos/7"
config.vm.define (ENV['VAGRANT_BOX_NAME'] || 'simp_tpm2_rpm_builder') do |vm|
vm.vm.synced_folder '.', '/vagrant',
create: true,
type: 'rsync',
rsync_exclude: '.git/',
rsync__verbose: true,
rsync__chown: true
vm.vm.provision 'shell', inline: <<-SHELL
yum install --enablerepo=extras -y vim-enhanced git libicu-devel \
rpm-build rpmdevtools epel-release \
wget
yum install --enablerepo=extras,epel -y haveged selinux-policy-devel \
git make autoconf autoconf-archive \
automake libtool gcc gcc-c++ \
glibc-headers pkgconfig openssl-devel \
curl-devel \
pkgconfig libcmocka-devel dbus-devel glib2-devel \
pandoc
# enable HAVEGED
# --------------------
# This gives the VM's /dev/*random sufficient entropy for all the crypto
# in the build
systemctl start haveged
systemctl enable haveged
### # Install docker
### # --------------------
### yum install --enablerepo=extras,epel -y docker
###
### # You can also append `-G vagrant` to `OPTIONS=` in /etc/sysconfig/docker
### cat <<DOCKAH > /etc/docker/daemon.json
### {
### "live-restore": true,
### "group": "vagrant"
### }
### DOCKAH
###
### # man docker-storage-setup
### # https://bugzilla.redhat.com/show_bug.cgi?id=1316210
### echo 'EXTRA_STORAGE_OPTIONS="--storage-opt overlay2.override_kernel_check=true"' >> /etc/sysconfig/docker-storage-setup
### container-storage-setup
### systemctl start docker
### systemctl enable docker
###
### chown -R vagrant /vagrant # TODO: why is this needed?
### ls -lartZ /var/run/docker.sock
SHELL
# pass on certain environment variables from the `vagrant CMD` cli to the
# rake task run it the VM
_bash_env_string = (
ENV
.to_h
.select{ |k,v| k =~ /^SIMP_.*|^BEAKER_.*|RSYNC_NO_SELINUX_DEPS/ }
.map{|k,v| "#{k}=#{v}"}
)
bash_env_string = _bash_env_string.join(' ')
vm.vm.provision 'shell', privileged: false, inline: <<-NONPRIV_SHELL
# Persist env vars
if [ -n "#{_bash_env_string.join('-')}" ]; then
cat <<ENV > /vagrant/.env
#{_bash_env_string.join("\n")}
#{_bash_env_string.map{|x| 'export ' + x.gsub(/=.*$/,'') }.join("\n")}
ENV
. /vagrant/.env
fi
source /vagrant/scripts/install_rvm.sh
cd /vagrant
[[ -f Gemfile ]] && #{bash_env_string} bundle
source /vagrant/scripts/build_tpm2_sim.sh && \\
source /vagrant/scripts/rebuild_tpm2_rpms.sh && \\
source /vagrant/scripts/install_puppet_agent.sh
NONPRIV_SHELL
end
end