Skip to content

Instantly share code, notes, and snippets.

@tcnksm tcnksm/Vagrantfile Secret
Created Feb 25, 2014

Embed
What would you like to do?
Vagrant plugin on Vagrantfile
module MyPlugins
class Plugin < Vagrant.plugin("2")
name "install packages"
config(:apt_get, :provisioner) do
class Config < Vagrant.plugin("2", :config)
attr_accessor :packages
def initialize
super
@packages = UNSET_VALUE
end
def finalize!
@packages = [] if @packages == UNSET_VALUE
end
end
Config
end
provisioner :apt_get do
class Provisioner < Vagrant.plugin("2", :provisioner)
def provision
command = "apt-get install -y #{@config.packages.join(' ')}"
@machine.communicate.sudo(command) do |type, data|
@machine.env.ui.info(data.chomp, prefix: false)
end
end
end
end
end
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provision :apt_get do |p|
p.packages = ["htop","wget", "hello"]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.