-
Notifications
You must be signed in to change notification settings - Fork 22
/
Vagrantfile
131 lines (113 loc) · 4.97 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
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
$setup_system = <<~SCRIPT
if [[ $(cat /proc/sys/crypto/fips_enabled) -ne 1 ]]; then
echo "FIPS is not enabled!"
exit 1
fi
cat << EOF > /usr/share/pki/trust/anchors/SUSE_Trust_Root.crt
-----BEGIN CERTIFICATE-----
MIIG6DCCBNCgAwIBAgIBATANBgkqhkiG9w0BAQsFADCBqDELMAkGA1UEBhMCREUx
EjAQBgNVBAgTCUZyYW5jb25pYTESMBAGA1UEBxMJTnVyZW1iZXJnMSEwHwYDVQQK
ExhTVVNFIExpbnV4IFByb2R1Y3RzIEdtYkgxFTATBgNVBAsTDE9QUyBTZXJ2aWNl
czEYMBYGA1UEAxMPU1VTRSBUcnVzdCBSb290MR0wGwYJKoZIhvcNAQkBFg5yZC1h
ZG1Ac3VzZS5kZTAeFw0xMTEyMDYwMDAwMDBaFw00MTEyMDUyMzU5NTlaMIGoMQsw
CQYDVQQGEwJERTESMBAGA1UECBMJRnJhbmNvbmlhMRIwEAYDVQQHEwlOdXJlbWJl
cmcxITAfBgNVBAoTGFNVU0UgTGludXggUHJvZHVjdHMgR21iSDEVMBMGA1UECxMM
T1BTIFNlcnZpY2VzMRgwFgYDVQQDEw9TVVNFIFRydXN0IFJvb3QxHTAbBgkqhkiG
9w0BCQEWDnJkLWFkbUBzdXNlLmRlMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC
C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mRlggEBMAsGA1UdDwQEAwIBhjANBgkqhkiG
9w0BAQsFAAOCAgEAgepNLcNFU7q8Ryg/dssttxjZbs237dY5WCzW2E8tgbGAgeCV
1luG9bN15OMOLIxH9m0fN76hypEWXD8E5MyafOhIa7iZdQlEAjPQMrAFu8k2Hl6r
yWKlqb0ZB2tmLbrfpXuUHwWiaQR0U6cin4BZ/HXPRKKsYLLddhMjRDn2GNz8grv+
WhFRUIOWCezVFQy0SJhNupBjhKd7CnU3/Ur9fSu70rEb3fGZK5orJ4CpHZlvhgkJ
RH3QiH+FkAO3BXOBtnBSQ5Ejvm6Pw9LDQ9esCukAA/fCGwv3CPns2CI/KTTnyaDe
up2ESPng/2VFS4prwrx4i6nfhbmf49bP+DirdAAF/mfAozZ9xDyBGkYfr7c3Y5Vk
OL+vEVNBlzGiU2mPuk/E75V43dhnaI3ktqph5oNq6gEZWArLkze2nksWdexjH7G5
42cij0RBO/+5RjmVzG9IXzmScE2V57McJpVDf0lPV57+xCkn6msqyRiJoDS3DPfV
ySq1QlcPxhQUNSbDIL663gwirdJyf98C4W/zVcwjnUc+zGgxVInqhJVpuWvte9h/
bIf8cLGxGtSyQ616qwdS92vg1atJoG51Jdxw0EhzFtxJ8QVrfkGn1IT2ngUYYaOK
W8NcaXbJ/yeblISOdtHRxuCpZs8P9MxDAQn/X873eYfcim1xfqSimgJ2dpA=
-----END CERTIFICATE-----
EOF
update-ca-certificates
systemctl start docker
pip install tox
SCRIPT
$fips_test_script = <<~SCRIPT
cd /vagrant/
#prevent setuptools_scm barfing because it cannot obtain the version from git
export SETUPTOOLS_SCM_PRETEND_VERSION=0.0.1
tox -e fips -- -n auto
SCRIPT
$registered_test_script = <<~SCRIPT
if [[ ! -n "${REGCODE}" ]]; then
echo "environment variable REGCODE is unset or empty"
exit 1
fi
SUSEConnect --regcode ${REGCODE}
cd /vagrant/
tox -e build -- -k container_build_and_repo -n auto
SCRIPT
def osx_memory_mb
`sysctl -a`.split("\n").each do |t|
return t.split(' ')[1].to_i / (1024 * 1024) if t.start_with?('hw.memsize:')
end
end
def linux_memory_mb
`free -m`.split("\n").each do |t|
return t.split(' ')[1].to_i if t.start_with?('Mem:')
end
end
Vagrant.configure('2') do |config|
config.vm.box = 'SLES-15-SP4-Vagrant.x86_64'
config.vm.box_url = 'https://download.opensuse.org/repositories/home:/dancermak:/SLE-15-SP4/images/boxes/SLES-15-SP4-Vagrant.x86_64.json'
config.vm.synced_folder '.',
'/vagrant',
type: 'rsync',
rsync__exclude: ['.tox/', '*.egg-info', '*/__pycache__/']
require 'etc'
ncpus = [6, Etc.nprocessors].min
if RUBY_PLATFORM.include?('linux')
total_ram_mb = linux_memory_mb
elsif RUBY_PLATFORM.include?('darwin')
total_ram_mb = osx_memory_mb
else
raise StandardError, "Can't get max memory for #{RUBY_PLATFORM}"
end
memory = [4096, total_ram_mb].min
config.vm.provider :libvirt do |libvirt|
libvirt.cpus = ncpus
libvirt.memory = memory
end
config.vm.provider 'virtualbox' do |v|
v.cpus = ncpus
v.memory = memory
end
config.vm.provision 'setup system', type: 'shell', inline: $setup_system
env = Hash[%w[OS_VERSION REGCODE CONTAINER_RUNTIME].collect { |k| [k, ENV[k]] }].compact
config.vm.define 'fips' do |fips|
fips.vm.provision 'run fips test', type: 'shell',
inline: $fips_test_script,
env: env
end
config.vm.define 'registered' do |reg|
reg.vm.provision 'run build tests', type: 'shell',
inline: $registered_test_script,
env: env
end
end