2015-08-17 06:37:14 +02:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
|
|
|
|
VAGRANTFILE_API_VERSION = "2"
|
|
|
|
|
2016-02-08 06:09:48 +01:00
|
|
|
def command?(name)
|
|
|
|
`which #{name}`
|
|
|
|
$?.success?
|
|
|
|
end
|
|
|
|
|
2015-08-17 06:37:14 +02:00
|
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
|
|
|
2015-08-18 02:05:53 +02:00
|
|
|
# For LXC. VirtualBox hosts use a different box, described below.
|
2015-08-17 06:37:14 +02:00
|
|
|
config.vm.box = "fgrehm/trusty64-lxc"
|
|
|
|
|
2015-08-18 02:05:53 +02:00
|
|
|
# The Zulip development environment runs on 9991 on the guest.
|
2015-08-17 06:37:14 +02:00
|
|
|
config.vm.network "forwarded_port", guest: 9991, host: 9991, host_ip: "127.0.0.1"
|
|
|
|
|
|
|
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
|
|
|
config.vm.synced_folder ".", "/srv/zulip"
|
|
|
|
|
2016-04-09 15:06:07 +02:00
|
|
|
proxy_config_file = ENV['HOME'] + "/.zulip-vagrant-config"
|
|
|
|
if File.file?(proxy_config_file)
|
|
|
|
http_proxy = https_proxy = no_proxy = ""
|
|
|
|
|
|
|
|
IO.foreach(proxy_config_file) do |line|
|
|
|
|
line.chomp!
|
|
|
|
key, value = line.split(nil, 2)
|
|
|
|
case key
|
|
|
|
when /^([#;]|$)/; # ignore comments
|
|
|
|
when "HTTP_PROXY"; http_proxy = value
|
|
|
|
when "HTTPS_PROXY"; https_proxy = value
|
|
|
|
when "NO_PROXY"; no_proxy = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if Vagrant.has_plugin?("vagrant-proxyconf")
|
|
|
|
if http_proxy != ""
|
|
|
|
config.proxy.http = http_proxy
|
|
|
|
end
|
|
|
|
if https_proxy != ""
|
|
|
|
config.proxy.https = https_proxy
|
|
|
|
end
|
|
|
|
if https_proxy != ""
|
|
|
|
config.proxy.no_proxy = no_proxy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-10 01:31:37 +01:00
|
|
|
# Specify LXC provider before VirtualBox provider so it's preferred.
|
|
|
|
config.vm.provider "lxc" do |lxc|
|
2016-02-08 06:09:48 +01:00
|
|
|
if command? "lxc-ls"
|
|
|
|
LXC_VERSION = `lxc-ls --version`.strip unless defined? LXC_VERSION
|
|
|
|
if LXC_VERSION >= "1.1.0"
|
|
|
|
# Allow start without AppArmor, otherwise Box will not Start on Ubuntu 14.10
|
|
|
|
# see https://github.com/fgrehm/vagrant-lxc/issues/333
|
|
|
|
lxc.customize 'aa_allow_incomplete', 1
|
|
|
|
end
|
Vagrantfile: Fix using Vagrant with LXC >= 2.
Apparently LXC 2 removed support for the `-B best` option in
lxc-create, and Vagrant hasn't been updated appropriately yet, so we
need to add a workaround to explicitly specify a backing store.
Fixes #718.
This manifested as errors of the form:
"""
There was an error executing ["sudo",
"/usr/local/bin/vagrant-lxc-wrapper", "lxc-create", "-B", "best",
"--template",
"/home/tabbott/.vagrant.d/gems/gems/vagrant-lxc-1.2.1/scripts/lxc-template",
"--name", "zulip_default_1461801696512_85064", "--", "--tarball",
"/home/tabbott/.vagrant.d/boxes/fgrehm-VAGRANTSLASH-trusty64-lxc/1.2.0/lxc/rootfs.tar.gz",
"--config",
"/home/tabbott/.vagrant.d/boxes/fgrehm-VAGRANTSLASH-trusty64-lxc/1.2.0/lxc/lxc-config"]
"""
2016-04-28 02:06:37 +02:00
|
|
|
if LXC_VERSION >= "2.0.0"
|
|
|
|
lxc.backingstore = 'dir'
|
|
|
|
end
|
2016-01-10 01:31:37 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-17 19:18:40 +02:00
|
|
|
config.vm.provider "virtualbox" do |vb, override|
|
2015-08-17 06:37:14 +02:00
|
|
|
override.vm.box = "ubuntu/trusty64"
|
2016-05-07 22:28:39 +02:00
|
|
|
# It's possible we can get away with just 1GB; more testing needed
|
|
|
|
vb.memory = 1280
|
2015-08-17 06:37:14 +02:00
|
|
|
end
|
2015-08-17 20:14:52 +02:00
|
|
|
|
2015-08-19 04:14:50 +02:00
|
|
|
$provision_script = <<SCRIPT
|
|
|
|
set -x
|
|
|
|
set -e
|
2016-07-06 23:29:33 +02:00
|
|
|
set -o pipefail
|
2016-06-16 12:50:54 +02:00
|
|
|
ln -nsf /srv/zulip ~/zulip
|
2016-07-06 23:29:33 +02:00
|
|
|
/usr/bin/python /srv/zulip/tools/provision.py | sudo tee -a /var/log/zulip_provision.log
|
2015-08-19 04:14:50 +02:00
|
|
|
SCRIPT
|
|
|
|
|
|
|
|
config.vm.provision "shell",
|
|
|
|
# We want provision.py to be run with the permissions of the vagrant user.
|
|
|
|
privileged: false,
|
|
|
|
inline: $provision_script
|
2015-08-17 06:37:14 +02:00
|
|
|
end
|