testing: use vagrant for testing ansible CI deployment scripts (
bug 1294805) r?glob,smacleod
Removed a bunch of old vagrant stuff, then added a new Vagrantfile for testing
the mozreview CI server configuration scripts.
MozReview-Commit-ID: JoXFXONsiH1
--- a/testing/jenkins/Vagrantfile
+++ b/testing/jenkins/Vagrantfile
@@ -1,47 +1,59 @@
-$provision = <<SCRIPT
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
-# Give VM some swap.
-if [ ! -e /var/swap ]; then
- dd if=/dev/zero of=/var/swap bs=1048576 count=512
- mkswap /var/swap
-fi
-swapon /var/swap
+PRIVATE_IP="192.168.33.55"
-apt-get -y remove chef puppet python-pip python-virtualenv && apt-get -y autoremove
-# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
-# sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
-apt-get update
-apt-get -y dist-upgrade
-# apt-get -y install btrfs-tools
+Vagrant.configure(2) do |config|
-# if [ ! -e /var/btrfs ]; then
-# dd if=/dev/zero of=/var/btrfs bs=1048576 count=12000
-# mkfs.btrfs /var/btrfs
-# fi
+ # We use the opscode bento project's boxes because they come with 40Gb
+ # disks. Many other official distro images only come with 10Gb disks.
+ # https://github.com/chef/bento
+ config.vm.box = "bento/centos-7.2"
-# if [ ! -d /var/lib/docker ]; then
-# mkdir /var/lib/docker
-# fi
-
-# mount /var/btrfs /var/lib/docker
-
-# Docker may have been started before btrfs was mounted. If so, it would
-# have started in devicemapper mode. Force a restart to pick up btrfs.
-# restart docker
+ config.vm.synced_folder "../..", "/vagrant"
-apt-get -y install git libbz2-dev libffi-dev libldap2-dev libncurses5-dev libreadline-dev libsasl2-dev libsqlite3-0 libsqlite3-dev libssl-dev libxslt1-dev python-dev sqlite3 tcl-dev unzip zlib1g-dev
-# usermod --append -G docker vagrant
-SCRIPT
+ # FIXME: This affects Vagrant 1.8.5. We can remove it with Vagrant 1.8.6.
+ # Use the default key, already part of the bento box build, to prevent
+ # SSH auth errors during 'vagrant up' using the vmware_workstation provider.
+ # See https://github.com/mitchellh/vagrant/issues/7610
+ config.ssh.insert_key = false
-Vagrant.configure('2') do |config|
- config.vm.box = 'ubuntu1404amd64'
- config.vm.box_url = 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box'
+ config.vm.network "private_network", ip: PRIVATE_IP
- config.vm.provider 'virtualbox' do |v|
- v.memory = 2048
- v.cpus = 2
+ config.vm.provider "vmware_fusion" do |v|
+ v.vmx["memsize"] = 4096
+ v.vmx["numvcpus"] = 2
end
- config.vm.synced_folder '../../', '/version-control-tools'
- config.vm.provision "shell", inline: $provision
+ config.vm.provider "vmware_workstation" do |v|
+ v.vmx["memsize"] = 4096
+ v.vmx["numvcpus"] = 2
+ end
+
+ config.vm.provider "virtualbox" do |vb|
+ vb.gui = false
+ vb.memory = 4096
+ vb.cpus = 2
+ end
+
+ # Re-run after dev environment configuration changes with 'vagrant provision'
+ config.vm.provision "ansible_local" do |ansible|
+
+ # Ansible needs to know the private_ip that the guest and host are using
+ # so that it can correctly set up the mozreview services. We'll pass it in
+ # as an extra variable.
+ ansible.extra_vars = {
+ docker_listen_ip: PRIVATE_IP,
+ jenkins_admin_username_override: "admin",
+ jenkins_admin_password_override: "admin"
+ }
+
+ # We add the default host to the mozreview-ci group so that the 'hosts:'
+ # statement in the deploy playbook applies to our vagrant host, too.
+ ansible.groups = {
+ "mozreview-ci" => ["default"]
+ }
+
+ ansible.playbook = "ansible/deploy-mozreview-ci.yml"
+ end
end
deleted file mode 100755
--- a/testing/jenkins/run-main.py
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env python
-
-# Script to run the Jenkins job.
-
-import os
-import subprocess
-import sys
-
-# Unbuffer stdout.
-sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
-
-HERE = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
-
-VAGRANT = None
-
-# ci.mozilla.org requires the vagrant from /opt/vagrant/bin to work.
-# TODO this should be facilitated with proper environment variables.
-for path in ['/opt/vagrant/bin/vagrant'] + os.environ['PATH'].split(':'):
- candidate = os.path.join(path, 'vagrant')
- if os.path.exists(candidate):
- VAGRANT = candidate
- break
-
-if not VAGRANT:
- print('vagrant not found')
- sys.exit(1)
-
-res = 1
-try:
- subprocess.check_call([VAGRANT, 'up', '--provision'], cwd=HERE)
- res = subprocess.call([VAGRANT, 'ssh', '--',
- '/version-control-tools/testing/jenkins/run.sh'],
- cwd=HERE)
-finally:
- subprocess.check_call([VAGRANT, 'halt'], cwd=HERE)
-
-sys.exit(res)
deleted file mode 100755
--- a/testing/jenkins/run.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash
-
-# Build modern Python from source because Ubuntu 14.04 ships with an
-# older one that doesn't support modern SSL and this screws up packaging
-# foo.
-if [ ! -e ~/.pyenv ]; then
- git clone https://github.com/yyuu/pyenv.git ~/.pyenv
-fi
-export PYENV_ROOT="$HOME/.pyenv"
-export PATH="$PYENV_ROOT/bin:$PATH"
-eval "$(pyenv init -)"
-
-if [ ! -e ~/.pyenv/versions/2.7.10 ]; then
- pyenv install 2.7.10
- pyenv rehash
-fi
-
-pyenv shell 2.7.10
-pip install --upgrade pip virtualenv
-
-# Install a modern Mercurial or we may run into issues cloning from the mounted
-# repo since it may be using settings not known by the older Mercurial
-# installed by Ubuntu.
-pip install --upgrade Mercurial
-
-if [ ! -e ~/version-control-tools ]; then
- hg clone --pull /version-control-tools ~/version-control-tools
-fi
-
-cd ~/version-control-tools
-hg pull
-hg --config extensions.purge= purge
-hg up tip
-
-# We always want to update BMO's source code as part of CI.
-export FETCH_BMO=1
-
-./create-test-environment
-source venv/bin/activate
-./run-tests -j2 --all-versions --cover
-result=$?
-
-rm -rf /version-control-tools/coverage
-mv coverage/ /version-control-tools/
-
-# Generate Sphinx documentation.
-make -C docs html
-rm -rf /version-control-tools/sphinx-docs
-mv docs/_build /version-control-tools/sphinx-docs
-
-# Ideally this would be part of running tests. Until then, add it here
-# so Jenkins doesn't bloat.
-# ./d0cker prune-images
-
-exit $result