Detect LXC version from VagrantFile
ragusa87 opened this issue · 2 comments
Since the configuration keys have changed in LXC version 3. I would like to be able to detect the version used inside my Vagrant file.
I found no way to access the driver's method `supports_new_config_format
vagrant-lxc/lib/vagrant-lxc/driver.rb
Line 218 in dd24cdc
I would like to adapt something like this:
config.vm.provider "lxc" do |lxc, override|
lxc.customize 'aa_profile', 'unconfined'
end
To
config.vm.provider "lxc" do |lxc, override|
if lxc.supports_new_config_format
lxc.customize 'apparmor.profile', 'unconfined'
else
lxc.customize 'aa_profile', 'unconfined'
end
end
Thanks for your help !
@ragusa87 It may be impossible expose support_new_config_format
, because configuration interface is running before driver instance created.
You can add parameter to select lxc customization such as
require 'getoptlong'
opts = GetoptLong.new(
[ '--lxc-new-config', GetoptLong::OPTIONAL_ARGUMENT ]
)
opts.ordering=(GetoptLong::REQUIRE_ORDER)
is_lxc3=false
opts.each do |opt, arg|
case opt
when '--lxc-new-config'
is_lxc3=true
end
end
config.vm.provider "lxc" do |lxc, override|
if is_lxc3
lxc.customize 'apparmor.profile', 'unconfined'
else
lxc.customize 'aa_profile', 'unconfined'
end
end
reference: SO How to pass parameter on 'vagrant up' and have it in the scope of Vagrantfile?
and add a document to help user to set it according to their environment.