Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Last active December 22, 2015 15:49
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 toritori0318/6495139 to your computer and use it in GitHub Desktop.
Save toritori0318/6495139 to your computer and use it in GitHub Desktop.
vagrant provision test
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'pp'
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos"
config.vm.network :forwarded_port, guest: 80, host: 8888
config.vm.network :private_network, ip: "192.168.33.10"
# web
config.vm.define :web do |web|
web.vm.box = "centos"
web.vm.network :private_network, ip:"192.168.66.1"
end
# provision
config.vm.provision :chef_solo do |chef|
p 'caller'
pp caller
pp @machine # nil
# pp machine # error
end
end
#### result
# % vagrant provision web
# "caller"
# ["/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/kernel_v2/config/vm_provisioner.rb:42:in `call'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/kernel_v2/config/vm_provisioner.rb:42:in `initialize'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/kernel_v2/config/vm.rb:205:in `new'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/kernel_v2/config/vm.rb:205:in `provision'",
# "/Users/toriitsuyoshi/vagrant/centos/Vagrantfile:17:in `block in <top (required)>'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/config/v2/loader.rb:37:in `call'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/config/v2/loader.rb:37:in `load'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/config/loader.rb:104:in `block (2 levels) in load'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/config/loader.rb:98:in `each'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/config/loader.rb:98:in `block in load'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/config/loader.rb:95:in `each'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/config/loader.rb:95:in `load'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/environment.rb:262:in `config_global'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/environment.rb:513:in `block in action_runner'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/action/runner.rb:28:in `call'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/action/runner.rb:28:in `run'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/environment.rb:275:in `hook'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/environment.rb:136:in `initialize'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/bin/vagrant:62:in `new'",
# "/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/bin/vagrant:62:in `<top (required)>'",
# "/Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in `load'",
#
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment