forked from performancecopilot/pcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
346 lines (276 loc) · 11.9 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Leave this alone
VAGRANTFILE_API_VERSION = "2"
# VM Configs
VM_MEM = "1024"
VM_CPU = "1"
# QA Flags
QA_FLAGS = ""
#QA_FLAGS = "022"
#QA_FLAGS = "-g pmda.linux"
# Arch Specific Config Files
############################################################
# CentOS
############################################################
$script_centos = <<SCRIPT
# Setup EPEL
cat <<EOM >/etc/yum.repos.d/epel-bootstrap.repo
[epel]
name=Bootstrap EPEL
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-\\\$releasever&arch=\\\$basearch
failovermethod=priority
enabled=0
gpgcheck=0
EOM
yum --enablerepo=epel -y install epel-release
rm -f /etc/yum.repos.d/epel-bootstrap.repo
yum -y groupinstall 'Development Tools'
yum -y install git ncurses-devel readline-devel man libmicrohttpd-devel qt4-devel python26 python26-devel perl-JSON sysstat perl-TimeDate \
perl-XML-TokeParser perl-ExtUtils-MakeMaker perl-Time-HiRes systemd-devel bc cairo-devel cyrus-sasl-devel \
systemd-devel libibumad-devel libibmad-devel papi-devel libpfm-devel rpm-devel perl-Spreadsheet-WriteExcel \
perl-Text-CSV_XS bind-utils httpd python-devel nspr-devel nss-devel python-ctypes nss-tools perl-Spreadsheet-XLSX \
ed cpan valgrind time xdpyinfo rrdtool-perl
# Lots of avahi errors on Centos511, likely due to my environment
# avahi-devel
cd /vagrant
sudo -H -u vagrant env PYTHON=python2.6 ./Makepkgs
rpm -ivh pcp-*/build/rpm/*.rpm
# Doesn't start automatically on all distributions
/sbin/service pmcd start
echo 'pcpqa ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
SCRIPT
############################################################
# SUSE
############################################################
$script_suse = <<SCRIPT
zypper -n in -t pattern devel_basis devel_C_C++ devel_rpm_build
zypper -n in git ncurses-devel readline-devel man libmicrohttpd-devel libqt4-devel perl-JSON sysstat perl-TimeDate perl-ExtUtils-MakeMaker bc \
cyrus-sasl-devel systemd-devel avahi-devel rpm-devel perl-Text-CSV_XS \
bind-utils python-devel python-curses
# These dont have the right "provides" in opensuse
# libibumad-devel libibmad-devel papi-devel libpfm-devel
#SUSE doesn't get the right perms in /vagrant, hmm
chown -R vagrant /vagrant
cd /vagrant
sudo -H -u vagrant ./Makepkgs
rpm -ivh pcp-*/build/rpm/*.rpm
# Doesn't start automatically on all distributions
/sbin/service pmcd start
echo 'pcpqa ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
SCRIPT
############################################################
# Ubuntu
############################################################
$script_ubuntu = <<SCRIPT
apt-get update
# Use a regex for some of the more obscure packages so apt doesn't exit if missing
# Trying to not have one script per box
apt-get install -y '^(libreadline|libpapi|libpfm4|libcoin80|libicu)-dev$' \
bc bison curl flex git g++ dpkg-dev pkg-config debhelper chrpath \
python-all python-all-dev libnspr4-dev libnss3-dev libsasl2-dev libmicrohttpd-dev libavahi-common-dev \
libqt4-dev autotools-dev autoconf gawk libxml-tokeparser-perl libspreadsheet-read-perl gdb sysv-rc-conf \
libcairo2-dev sysstat valgrind apache2 realpath unbound \
libibumad-dev libsoqt-dev libsoqt-dev-common libnss3-tools libibmad-dev x11-utils
cd /vagrant
sudo -H -u vagrant ./Makepkgs
dpkg -i build/deb/*.deb
echo 'pcpqa ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
SCRIPT
############################################################
# Ubuntu EOL
############################################################
$script_EOLubuntu = <<SCRIPT
# Fix the repo names
sed -i.bak -r 's/(us.)?(archive|security).ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
apt-get update
apt-get install -y '^(libreadline|libpapi|libpfm4|libcoin80|libicu)-dev$' \
bc bison curl flex git g++ dpkg-dev pkg-config debhelper chrpath \
python-all python-all-dev libnspr4-dev libnss3-dev libsasl2-dev libmicrohttpd-dev libavahi-common-dev \
libqt4-dev autotools-dev autoconf gawk libxml-tokeparser-perl libspreadsheet-read-perl gdb sysv-rc-conf \
libcairo2-dev sysstat valgrind apache2 realpath unbound \
libibumad-dev libsoqt-dev libsoqt-dev-common libnss3-tools libibmad-dev x11-utils
cd /vagrant
sudo -H -u vagrant ./Makepkgs
dpkg -i build/deb/*.deb
echo 'pcpqa ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
SCRIPT
############################################################
# Debian
############################################################
$script_debian = <<SCRIPT
apt-get update
apt-get install -y '^(libreadline|libpapi|libpfm4|libcoin80)-dev$' \
bc bison flex git g++ dpkg-dev pkg-config debhelper chrpath \
python-all python-all-dev libnspr4-dev libnss3-dev libsasl2-dev libmicrohttpd-dev libavahi-common-dev \
libqt4-dev autotools-dev autoconf gawk libxml-tokeparser-perl libspreadsheet-read-perl ed gdb sysv-rc-conf \
libcairo2-dev libibumad-dev libibmad-dev sysstat valgrind apache2 realpath unbound libsoqt-dev \
libsoqt-dev-common libnss3-tools x11-utils
cd /vagrant
sudo -H -u vagrant ./Makepkgs
dpkg -i build/deb/*.deb
echo 'pcpqa ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
SCRIPT
############################################################
# Fedora
############################################################
$script_fedora = <<SCRIPT
# For sudo to work from a script
sed -i '/requiretty/d' /etc/sudoers
yum -y group install 'Development Tools' 'C Development Tools and Libraries' 'RPM Development Tools'
yum -y install perl-ExtUtils-MakeMaker bison flex libmicrohttpd-devel qt-devel fedora-packager systemd-devel perl-JSON \
sysstat perl-Digest-MD5 bc ed cpan cairo-devel cyrus-sasl-devel libibumad-devel libibmad-devel avahi-devel \
papi-devel libpfm-devel rpm-devel perl-TimeDate perl-XML-TokeParser perl-Spreadsheet-WriteExcel \
perl-Text-CSV_XS bind-utils httpd python-devel nspr-devel nss-devel perl-Spreadsheet-XLSX time xorg-x11-utils
# Remove too old libraries
pfmvers=`rpm -q --qf "%{VERSION}\n" libpfm`
[ "$pfmvers" = "`echo -e "$pfmvers\n4.3.9" | sort -V | head -n1`" ] && rpm -e libpfm libpfm-devel papi papi-devel
cd /vagrant
sudo -H -u vagrant ./Makepkgs
rpm -ivh pcp-*/build/rpm/*.rpm
# Doesn't start automatically on all distributions
/sbin/service pmcd start
echo 'pcpqa ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
SCRIPT
############################################################
# Host Definititions
############################################################
pcp_hosts = {
:ubuntu1204 => {
:hostname => "ubuntu1204",
:ipaddress => "10.100.10.10",
:box => "ubuntu/precise64",
:script => "#{$script_ubuntu}"
},
:ubuntu1304 => {
:hostname => "ubuntu1304",
:ipaddress => "10.100.10.11",
:box => "chef/ubuntu-13.04",
:script => "#{$script_EOLubuntu}"
},
:ubuntu1404 => {
:hostname => "ubuntu1404",
:ipaddress => "10.100.10.12",
:box => "ubuntu/trusty64",
:script => "#{$script_ubuntu}"
},
:centos511 => {
:hostname => "centos511",
:ipaddress => "10.100.10.20",
:box => "chef/centos-5.11",
:script => "#{$script_centos}"
},
:centos511_32 => {
:hostname => "centos511-32",
:ipaddress => "10.100.10.21",
:box => "chef/centos-5.11-i386",
:script => "#{$script_centos}"
},
:centos65 => {
:hostname => "centos65",
:ipaddress => "10.100.10.22",
:box => "chef/centos-6.5",
:script => "#{$script_centos}"
},
:centos7 => {
:hostname => "centos7",
:ipaddress => "10.100.10.23",
:box => "chef/centos-7.0",
:script => "#{$script_centos}"
},
:fedora19 => {
:hostname => "fedora19",
:ipaddress => "10.100.10.30",
:box => "chef/fedora-19",
:script => "#{$script_fedora}"
},
:fedora20 => {
:hostname => "fedora20",
:ipaddress => "10.100.10.31",
:box => "chef/fedora-20",
:script => "#{$script_fedora}"
},
:debian76 => {
:hostname => "debian76",
:ipaddress => "10.100.10.40",
:box => "chef/debian-7.6",
:script => "#{$script_debian}"
}
# Built locally from : https://github.com/opscode/bento
# NAT comes up but not the host interface
# :opensuse132 => {
# :hostname => "opensuse132",
# :ipaddress => "10.100.10.51",
# :box => "minnus-opensuse-13.2",
# :script => "#{$script_suse}"
# }
# Networking wont come up
# :opensuse131 => {
# :hostname => "opensuse131",
# :ipaddress => "10.100.10.50",
# :box => "chef/opensuse-13.1",
# :script => "#{$script_suse}"
# }
}
############################################################
# Common Config Setup, hostnames, etc
# So VMs could talk to each other if we wanted
############################################################
$script_common = ""
# We set our own IP
$script_common << "sed -i '/127.0.1.1/d' /etc/hosts\n"
# Fix bogus entries that some os use
$script_common << "sed -i '/127.0.0.1/d' /etc/hosts\n"
$script_common << "echo \"127.0.0.1 localhost.localdomain localhost\" >> /etc/hosts\n"
pcp_hosts.each_pair do |name, options|
ipaddr = options[:ipaddress]
hostname = options[:hostname]
$script_common << "echo \"#{ipaddr} #{hostname} #{hostname}.localdomain\" >> /etc/hosts\n"
end
$script_common << "domainname localdomain"
############################################################
# QA run script
############################################################
$script_qa = <<SCRIPT
touch /tmp/runqa.sh
echo "#!/bin/sh" >> /tmp/runqa.sh
echo "cd /var/lib/pcp/testsuite" >> /tmp/runqa.sh
echo "./check #{QA_FLAGS} >/tmp/runqa.out 2>&1" >> /tmp/runqa.sh
echo "cp /tmp/runqa.out /qaresults" >> /tmp/runqa.sh
echo "cp /var/lib/pcp/testsuite/*.bad /qaresults" >> /tmp/runqa.sh
chmod 777 /tmp/runqa.sh
sudo -b -H -u pcpqa sh -c '/tmp/runqa.sh'
SCRIPT
############################################################
# Main Vagrant Init : Loop over Host configs
############################################################
Vagrant.configure(VAGRANTFILE_API_VERSION) do |global_config|
global_config.ssh.forward_x11 = true
global_config.ssh.forward_agent = true
global_config.ssh.insert_key = false
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
# Global shared folder for pcp source. Copy it so we have our own to muck around in
global_config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync_auto: false, :rsync__exclude => ["qaresults/"]
pcp_hosts.each_pair do |name, options|
global_config.vm.define name do |config|
config.vm.provider "virtualbox" do |v|
v.name = "Vagrant PCP - #{name}"
v.customize ["modifyvm", :id, "--groups", "/VagrantPCP", "--memory", VM_MEM, "--cpus", VM_CPU]
end
config.vm.box = options[:box]
# VM specific shared folder for qa results
config.vm.synced_folder "./qaresults/#{name}", "/qaresults", mount_options: ["dmode=777", "fmode=666"], create: true
#config.vm.hostname = "#{name}"
config.vm.hostname = "#{options[:hostname]}"
config.vm.network :private_network, ip: options[:ipaddress]
# Setup networking etc
config.vm.provision :shell, :inline => $script_common
# Do platfrom specifics: install packages, etc
config.vm.provision :shell, :inline => options[:script]
# Run QA and copy results back to host
config.vm.provision :shell, :inline => $script_qa
end
end
end