Skip to content

Instantly share code, notes, and snippets.

@matthew-brett
Last active March 26, 2024 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthew-brett/714b50bd3159d416981a to your computer and use it in GitHub Desktop.
Save matthew-brett/714b50bd3159d416981a to your computer and use it in GitHub Desktop.
# Vagrant file for creating travis-ci -like image for Pythons
# Use with:
#
# $ mkdir travis_vagrant
# $ cd travis_vagrant
# $ git clone https://github.com/travis-ci/travis-cookbooks cookbooks
# <copy this Vagrant file here as `Vagrantfile`>
# $ vagrant up
#
# This file slightly edited from example file in:
# https://github.com/travis-ci/travis-cookbooks/blob/master/README.md
#
# Clues for right Python invocation from:
# https://github.com/travis-ci/travis-images/blob/master/templates/worker.python.yml
#
# To get into any of the Python virtualenvs:
# $ vagrant ssh
# $ source ~/virtualenv/python2.6/bin/activate
Vagrant.configure("2") do |config|
# Use Official Ubuntu Server 12.04 LTS daily builds from Canonical
config.vm.box = "ubuntu/precise64"
# Optionally enable Vagrant plugins like vagrant-cachier and vagrant-vbguest
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
if Vagrant.has_plugin?("vagrant-vbguest")
config.vbguest.auto_update = true
end
# Tune virtual hardware
config.vm.provider :virtualbox do |p|
p.customize ["modifyvm", :id, "--memory", 2048]
end
# Install Chef if not present in the Vagrant basebox
config.vm.provision :shell, :inline => <<EOS
set -e
if ! command -V chef-solo >/dev/null 2>/dev/null; then
sudo apt-get update -qq
sudo apt-get install -qq curl
curl -L https://www.opscode.com/chef/install.sh | bash -s -- -v 11.12.2
fi
EOS
# Provision with Chef Solo
# See also the exact composition of Travis VMs at
# https://github.com/travis-ci/travis-images/tree/master/templates
config.vm.provision :chef_solo do |chef|
chef.log_level = :info
chef.cookbooks_path = [ "cookbooks/ci_environment" ]
chef.add_recipe 'apt'
chef.add_recipe 'travis_build_environment'
# The cookbooks being developed:
chef.add_recipe 'git::ppa'
chef.add_recipe 'java'
chef.add_recipe 'build-essential'
chef.add_recipe 'python::pyenv'
chef.add_recipe 'python::system'
chef.add_recipe 'python::devshm'
chef.json = {
"apt" => {
:mirror => 'us'
},
"travis_build_environment" => {
"user" => 'vagrant'
},
}
end
end
# vim: ft=ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment