pmrep: reorder methods more logically
[pcp.git] / Vagrantfile
blobdb8bc961e749acd7e2a6afb8582c70143bb86f65
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
4 # Leave this alone
5 VAGRANTFILE_API_VERSION = "2"
7 # VM Configs
8 VM_MEM = "1024"
9 VM_CPU = "1"
11 # QA Flags
12 QA_FLAGS = ""
13 #QA_FLAGS = "022"
14 #QA_FLAGS = "-g pmda.linux"
17 # Arch Specific Config Files
19 ############################################################
20 # CentOS
21 ############################################################
22 $script_centos = <<SCRIPT
24 # Setup EPEL
25 cat <<EOM >/etc/yum.repos.d/epel-bootstrap.repo
26 [epel]
27 name=Bootstrap EPEL
28 mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-\\\$releasever&arch=\\\$basearch
29 failovermethod=priority
30 enabled=0
31 gpgcheck=0
32 EOM
34 yum --enablerepo=epel -y install epel-release
35 rm -f /etc/yum.repos.d/epel-bootstrap.repo
37 yum -y groupinstall 'Development Tools'
38 yum -y install git ncurses-devel readline-devel man libmicrohttpd-devel qt4-devel python26 python26-devel perl-JSON sysstat perl-TimeDate \
39                 perl-XML-TokeParser perl-ExtUtils-MakeMaker perl-Time-HiRes systemd-devel bc cairo-devel cyrus-sasl-devel \
40                 systemd-devel libibumad-devel libibmad-devel papi-devel libpfm-devel rpm-devel perl-Spreadsheet-WriteExcel \
41                 perl-Text-CSV_XS bind-utils httpd python-devel nspr-devel nss-devel python-ctypes nss-tools perl-Spreadsheet-XLSX \
42                 ed cpan valgrind time xdpyinfo rrdtool-perl
44 # Lots of avahi errors on Centos511, likely due to my environment
45 # avahi-devel
47 cd /vagrant
48 sudo -H -u vagrant env PYTHON=python2.6 ./Makepkgs
49 rpm -ivh  pcp-*/build/rpm/*.rpm
51 # Doesn't start automatically on all distributions
52 /sbin/service pmcd start
54 echo 'pcpqa   ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
56 SCRIPT
58 ############################################################
59 # SUSE
60 ############################################################
61 $script_suse = <<SCRIPT
62 zypper -n in -t pattern devel_basis devel_C_C++ devel_rpm_build
63 zypper -n in git ncurses-devel readline-devel man libmicrohttpd-devel libqt4-devel perl-JSON sysstat perl-TimeDate perl-ExtUtils-MakeMaker bc \
64                 cyrus-sasl-devel systemd-devel avahi-devel rpm-devel  perl-Text-CSV_XS \
65                 bind-utils python-devel python-curses
67 # These dont have the right "provides" in opensuse
68 # libibumad-devel libibmad-devel papi-devel libpfm-devel
70 #SUSE doesn't get the right perms in /vagrant, hmm
71 chown -R vagrant /vagrant
73 cd /vagrant
74 sudo -H -u vagrant ./Makepkgs
75 rpm -ivh  pcp-*/build/rpm/*.rpm
77 # Doesn't start automatically on all distributions
78 /sbin/service pmcd start
80 echo 'pcpqa   ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
82 SCRIPT
84 ############################################################
85 # Ubuntu
86 ############################################################
87 $script_ubuntu = <<SCRIPT
88 apt-get update
89 # Use a regex for some of the more obscure packages so apt doesn't exit if missing
90 # Trying to not have one script per box
91 apt-get install -y  '^(libreadline|libpapi|libpfm4|libcoin80|libicu)-dev$' \
92         bc bison curl flex  git  g++  dpkg-dev  pkg-config  debhelper chrpath \
93         python-all  python-all-dev  libnspr4-dev  libnss3-dev  libsasl2-dev  libmicrohttpd-dev  libavahi-common-dev \
94         libqt4-dev  autotools-dev  autoconf  gawk  libxml-tokeparser-perl  libspreadsheet-read-perl gdb sysv-rc-conf \
95         libcairo2-dev sysstat valgrind apache2 realpath unbound \
96         libibumad-dev libsoqt-dev libsoqt-dev-common libnss3-tools libibmad-dev x11-utils build-essential pbuilder
98 cd /vagrant
99 sudo -H -u vagrant ./Makepkgs
100 dpkg -i build/deb/*.deb
102 echo 'pcpqa   ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
104 SCRIPT
106 ############################################################
107 # Ubuntu EOL
108 ############################################################
109 $script_EOLubuntu = <<SCRIPT
111 # Fix the repo names
112 sed -i.bak -r 's/(us.)?(archive|security).ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
114 apt-get update
115 apt-get install  -y '^(libreadline|libpapi|libpfm4|libcoin80|libicu)-dev$' \
116         bc bison curl flex  git  g++  dpkg-dev  pkg-config  debhelper chrpath \
117         python-all  python-all-dev  libnspr4-dev  libnss3-dev  libsasl2-dev  libmicrohttpd-dev  libavahi-common-dev \
118         libqt4-dev  autotools-dev  autoconf  gawk  libxml-tokeparser-perl  libspreadsheet-read-perl gdb sysv-rc-conf \
119         libcairo2-dev sysstat valgrind apache2 realpath unbound \
120         libibumad-dev libsoqt-dev libsoqt-dev-common libnss3-tools libibmad-dev x11-utils build-essential \
121         librrds-perl
123 cd /vagrant
124 sudo -H -u vagrant ./Makepkgs
125 dpkg -i build/deb/*.deb
127 echo 'pcpqa   ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
129 SCRIPT
131 ############################################################
132 # Debian
133 ############################################################
134 $script_debian = <<SCRIPT
135 apt-get update
136 apt-get install -y '^(libreadline|libpapi|libpfm4|libcoin80)-dev$' \
137                 bc bison  flex  git  g++  dpkg-dev  pkg-config  debhelper chrpath \
138                 python-all  python-all-dev  libnspr4-dev  libnss3-dev  libsasl2-dev  libmicrohttpd-dev  libavahi-common-dev \
139                 libqt4-dev  autotools-dev  autoconf  gawk  libxml-tokeparser-perl libspreadsheet-read-perl ed gdb sysv-rc-conf \
140                 libcairo2-dev libibumad-dev libibmad-dev sysstat valgrind apache2 realpath unbound libsoqt-dev \
141                 libsoqt-dev-common libnss3-tools x11-utils build-essential librrds-perl
143 cd /vagrant
144 sudo -H -u vagrant ./Makepkgs
145 dpkg -i build/deb/*.deb
147 echo 'pcpqa   ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
149 SCRIPT
151 ############################################################
152 # Fedora EOL
153 ############################################################
154 $script_fedora_eol = <<SCRIPT
156 # For sudo to work from a script
157 sed -i '/requiretty/d' /etc/sudoers 
159 yum -y group install 'Development Tools' 'C Development Tools and Libraries' 'RPM Development Tools'
160 yum -y install perl-ExtUtils-MakeMaker bison flex libmicrohttpd-devel qt-devel fedora-packager systemd-devel perl-JSON \
161                 sysstat perl-Digest-MD5 bc ed cpan cairo-devel cyrus-sasl-devel libibumad-devel libibmad-devel avahi-devel \
162                 papi-devel libpfm-devel rpm-devel perl-TimeDate perl-XML-TokeParser perl-Spreadsheet-WriteExcel \
163                 perl-Text-CSV_XS bind-utils httpd python-devel nspr-devel nss-devel perl-Spreadsheet-XLSX time xorg-x11-utils
165 # Remove too old libraries
166 pfmvers=`rpm -q --qf "%{VERSION}\n" libpfm`
167 [ "$pfmvers" = "`echo -e "$pfmvers\n4.3.9" | sort -V | head -n1`" ] && rpm -e libpfm libpfm-devel papi papi-devel
169 cd /vagrant
170 sudo -H -u vagrant ./Makepkgs
171 rpm -ivh  pcp-*/build/rpm/*.rpm
173 # Doesn't start automatically on all distributions
174 /sbin/service pmcd start
176 echo 'pcpqa   ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
178 SCRIPT
180 ############################################################
181 # Fedora
182 ############################################################
183 $script_fedora = <<SCRIPT
185 # For sudo to work from a script
186 sed -i '/requiretty/d' /etc/sudoers 
188 dnf -y group install 'Development Tools' 'C Development Tools and Libraries' 'RPM Development Tools'
189 dnf -y install perl-ExtUtils-MakeMaker bison flex libmicrohttpd-devel qt-devel fedora-packager systemd-devel perl-JSON \
190                 sysstat perl-Digest-MD5 bc ed cpan cairo-devel cyrus-sasl-devel libibumad-devel libibmad-devel avahi-devel \
191                 papi-devel libpfm-devel rpm-devel perl-TimeDate perl-XML-TokeParser perl-Spreadsheet-WriteExcel \
192                 perl-Text-CSV_XS bind-utils httpd python-devel nspr-devel nss-devel perl-Spreadsheet-XLSX time xorg-x11-utils \
193                 ncurses-devel readline-devel rrdtool-perl
195 # Remove too old libraries
196 pfmvers=`rpm -q --qf "%{VERSION}\n" libpfm`
197 [ "$pfmvers" = "`echo -e "$pfmvers\n4.3.9" | sort -V | head -n1`" ] && rpm -e libpfm libpfm-devel papi papi-devel
199 cd /vagrant
200 sudo -H -u vagrant ./Makepkgs
201 rpm -ivh  pcp-*/build/rpm/*.rpm
203 # Doesn't start automatically on all distributions
204 /sbin/service pmcd start
206 echo 'pcpqa   ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
208 SCRIPT
211 ############################################################
212 # Host Definititions
213 ############################################################
215 pcp_hosts = {
216         :ubuntu1204 => {
217                 :hostname => "ubuntu1204",
218                 :ipaddress => "10.100.10.10",
219                 :box => "ubuntu/precise64",
220                 :script => "#{$script_ubuntu}"
221         },
222 #        :ubuntu1304 => {
223 #                :hostname => "ubuntu1304",
224 #                :ipaddress => "10.100.10.11",
225 #                :box => "chef/ubuntu-13.04",
226 #                :script => "#{$script_EOLubuntu}"
227 #        },
228         :ubuntu1404 => {
229                 :hostname => "ubuntu1404",
230                 :ipaddress => "10.100.10.12",
231                 :box => "ubuntu/trusty64",
232                 :script => "#{$script_ubuntu}"
233         },
234 #       :centos511 => {
235 #                :hostname => "centos511",
236 #                :ipaddress => "10.100.10.20",
237 #                :box => "chef/centos-5.11",
238 #                :script => "#{$script_centos}"
239 #        },
240 #        :centos511_32 => {
241 #                :hostname => "centos511-32",
242 #                :ipaddress => "10.100.10.21",
243 #                :box => "chef/centos-5.11-i386",
244 #                :script => "#{$script_centos}"
245 #        },
246 #        :centos65 => {
247 #               :hostname => "centos65",
248 #                :ipaddress => "10.100.10.22",
249 #                :box => "chef/centos-6.5",
250 #                :script => "#{$script_centos}"
251 #        },
252         :centos7 => {
253                 :hostname => "centos7",
254                 :ipaddress => "10.100.10.23",
255                 :box => "centos/7",
256                 :script => "#{$script_centos}"
257         },
258         :fedora23 => {
259                 :hostname => "fedora23",
260                 :ipaddress => "10.100.10.30",
261                 :box => "fedora/23-cloud-base",
262                 :script => "#{$script_fedora}"
263         },
264         :debian76 => {
265                 :hostname => "debianwheezy",
266                 :ipaddress => "10.100.10.40",
267                 :box => "debian/wheezy64",
268                 :script => "#{$script_debian}"
269         },
270         :debian8 => {
271                 :hostname => "debianjessie",
272                 :ipaddress => "10.100.10.40",
273                 :box => "debian/jessie64",
274                 :script => "#{$script_debian}"
275         }
276 # Built locally from : https://github.com/opscode/bento
277 # NAT comes up but not the host interface
278 #        :opensuse132 => {
279 #                :hostname => "opensuse132",
280 #                :ipaddress => "10.100.10.51",
281 #                :box => "minnus-opensuse-13.2",
282 #                :script => "#{$script_suse}"
283 #        }
284 # Networking wont come up
285 #        :opensuse131 => {
286 #                :hostname => "opensuse131",
287 #                :ipaddress => "10.100.10.50",
288 #                :box => "chef/opensuse-13.1",
289 #                :script => "#{$script_suse}"
290 #        }
291 # Possible opensuse box?
292 #        :opensuseleap42 => {
293 #                :hostname => "opensuse42",
294 #                :ipaddress => "10.100.10.52",
295 #                :box => "opensuse/openSUSE-42.1-x86_64",
296 #                :script => "#{$script_suse}"
297 #        }
300 ############################################################
301 # Common Config Setup, hostnames, etc
302 # So VMs could talk to each other if we wanted
303 ############################################################
305 $script_common = ""
307 # We set our own IP
308 $script_common << "sed -i '/127.0.1.1/d' /etc/hosts\n"
309 # Fix bogus entries that some os use
310 $script_common << "sed -i '/127.0.0.1/d' /etc/hosts\n"
311 $script_common << "echo \"127.0.0.1 localhost.localdomain localhost\" >> /etc/hosts\n"
313 pcp_hosts.each_pair do |name, options|
314         ipaddr = options[:ipaddress]
315         hostname = options[:hostname]
316         $script_common << "echo \"#{ipaddr} #{hostname} #{hostname}.localdomain\" >> /etc/hosts\n"
319 $script_common << "domainname localdomain"
321 ############################################################
322 # QA run script
323 ############################################################
325 $script_qa = <<SCRIPT
327 touch /tmp/runqa.sh
328 echo "#!/bin/sh" >> /tmp/runqa.sh
329 echo "cd /var/lib/pcp/testsuite" >> /tmp/runqa.sh
330 echo "./check #{QA_FLAGS} >/tmp/runqa.out 2>&1" >> /tmp/runqa.sh
331 echo "cp /tmp/runqa.out /qaresults" >> /tmp/runqa.sh
332 echo "cp /var/lib/pcp/testsuite/*.bad /qaresults" >> /tmp/runqa.sh
334 chmod 777 /tmp/runqa.sh
335 sudo -b -H -u pcpqa sh -c '/tmp/runqa.sh'
337 SCRIPT
339 ############################################################
340 # Main Vagrant Init : Loop over Host configs
341 ############################################################
343 Vagrant.configure(VAGRANTFILE_API_VERSION) do |global_config|
345   global_config.ssh.forward_x11 = true
346   global_config.ssh.forward_agent = true
347   global_config.ssh.insert_key = false
350   if Vagrant.has_plugin?("vagrant-cachier")
351     global_config.cache.scope = :box
352   end
354   # Global shared folder for pcp source.  Copy it so we have our own to muck around in
355   global_config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync_auto: false, :rsync__exclude => ["qaresults/"]
357   pcp_hosts.each_pair do |name, options|
359         global_config.vm.define name do |config|
361            config.vm.provider "virtualbox" do |v|
362                 v.name = "Vagrant PCP - #{name}"
363                 v.customize ["modifyvm", :id, "--groups", "/VagrantPCP", "--memory", VM_MEM, "--cpus", VM_CPU]
364            end
366            config.vm.box = options[:box]
367            
368            # VM specific shared folder for qa results
369 #          config.vm.synced_folder "./qaresults/#{name}", "/qaresults", mount_options: ["dmode=777", "fmode=666"], create: true
370            config.vm.synced_folder "./qaresults/#{name}", "/qaresults", create: true
372            #config.vm.hostname = "#{name}"
373            config.vm.hostname = "#{options[:hostname]}"
374            config.vm.network :private_network, ip: options[:ipaddress]
376            # Setup networking etc
377            config.vm.provision :shell, :inline => $script_common
379            # Do platfrom specifics: install packages, etc
380            config.vm.provision :shell, :inline => options[:script]
382            # Run QA and copy results back to host
383            config.vm.provision :shell, :inline => $script_qa
384         end
385   end