Skip to content

Commit

Permalink
Vagrantfile: Don't error on platforms where lxc-ls doesn't exist.
Browse files Browse the repository at this point in the history
Apparently vagrant executes the configuration code for all providers,
not just the one that's actually selected.

Fixes zulip#461.
  • Loading branch information
timabbott committed Feb 8, 2016
1 parent cbf9b76 commit 3a6889e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

VAGRANTFILE_API_VERSION = "2"

def command?(name)
`which #{name}`
$?.success?
end

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# For LXC. VirtualBox hosts use a different box, described below.
Expand All @@ -15,11 +20,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# Specify LXC provider before VirtualBox provider so it's preferred.
config.vm.provider "lxc" do |lxc|
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
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
end
end

Expand Down

0 comments on commit 3a6889e

Please sign in to comment.