Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
General Vagrant configuration for berkshelf cookbooks that works with chef-solo or chef-client and grabs chef-client information from knife.rb.
Gem versions are important due to dependency pinning problems w/ Berkshelf, Chef, and Vagrant
circa March 15th, 2013.
The older version of chef won't impact the version of chef that gets provisioned on your vagrant
box, it's just for loading the knife.rb configuration.
Use bundle exec if you want these things to operate together correctly.
$ bundle exec vagrant up solo
$ bundle exec berks upload
etc...
If you use `vagrant up client` don't forget to clean up your client and node objects.
$ knife node delete <node-name>
$ knife client delete <node-name>
source :rubygems
gem 'chef', "10.18.0"
gem 'berkshelf', "1.2.1"
gem 'ridley', "0.8.3"
gem 'vagrant', "~> 1.0.6"
GEM
remote: http://rubygems.org/
specs:
activesupport (3.2.12)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.3)
archive-tar-minitar (0.5.2)
berkshelf (1.2.1)
activesupport
chozo (>= 0.6.1)
faraday (>= 0.8.5)
hashie (>= 2.0.2)
json (>= 1.5.0)
minitar
mixlib-config
mixlib-shellout
moneta (~> 0.6.0)
multi_json (~> 1.5)
net-ssh-gateway (= 1.1.0)
retryable
ridley (>= 0.8.3)
solve (>= 0.4.2)
thor (~> 0.16.0)
yajl-ruby
bunny (0.7.9)
celluloid (0.12.4)
facter (>= 1.6.12)
timers (>= 1.0.0)
chef (10.18.0)
bunny (>= 0.6.0, < 0.8.0)
erubis
highline (>= 1.6.9)
json (>= 1.4.4, <= 1.6.1)
mixlib-authentication (>= 1.3.0)
mixlib-cli (>= 1.1.0)
mixlib-config (>= 1.1.2)
mixlib-log (>= 1.3.0)
mixlib-shellout
moneta (< 0.7.0)
net-ssh (~> 2.2.2)
net-ssh-multi (~> 1.1.0)
ohai (>= 0.6.0)
rest-client (>= 1.0.4, < 1.7.0)
treetop (~> 1.4.9)
uuidtools
yajl-ruby (~> 1.1)
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
chozo (0.6.1)
activesupport (>= 3.2.0)
hashie (>= 2.0.2)
multi_json (>= 1.3.0)
erubis (2.7.0)
facter (1.6.18)
faraday (0.8.6)
multipart-post (~> 1.1)
ffi (1.4.0)
hashie (2.0.2)
highline (1.6.16)
i18n (0.6.4)
ipaddress (0.8.0)
json (1.6.1)
log4r (1.1.10)
mime-types (1.21)
minitar (0.5.4)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.3.0)
mixlib-config (1.1.2)
mixlib-log (1.4.1)
mixlib-shellout (1.1.0)
moneta (0.6.0)
multi_json (1.6.1)
multipart-post (1.2.0)
net-http-persistent (2.8)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-ssh (2.2.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
net-ssh-multi (1.1)
net-ssh (>= 2.1.4)
net-ssh-gateway (>= 0.99.0)
ohai (6.16.0)
ipaddress
mixlib-cli
mixlib-config
mixlib-log
mixlib-shellout
systemu
yajl-ruby
polyglot (0.3.3)
rest-client (1.6.7)
mime-types (>= 1.16)
retryable (1.3.2)
ridley (0.8.3)
activesupport (>= 3.2.0)
addressable
celluloid
chozo (>= 0.6.0)
erubis
faraday (>= 0.8.4)
json (>= 1.5.0)
mixlib-authentication (>= 1.3.0)
mixlib-config (>= 1.1.0)
mixlib-log (>= 1.3.0)
mixlib-shellout (>= 1.1.0)
multi_json (>= 1.0.4)
net-http-persistent (>= 2.8)
net-ssh
retryable
solve (>= 0.4.1)
solve (0.4.2)
json
systemu (2.5.2)
thor (0.16.0)
timers (1.1.0)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
uuidtools (2.1.3)
vagrant (1.0.7)
archive-tar-minitar (= 0.5.2)
childprocess (~> 0.3.1)
erubis (~> 2.7.0)
i18n (~> 0.6.0)
json (>= 1.5.1, < 1.8.0)
log4r (~> 1.1.9)
net-scp (~> 1.0.4)
net-ssh (~> 2.2.2)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
berkshelf (= 1.2.1)
chef (= 10.18.0)
ridley (= 0.8.3)
vagrant (~> 1.0.6)
require 'chef'
require 'chef/config'
require 'chef/knife'
require 'berkshelf/vagrant'
Chef::Config.from_file(File.expand_path('~/.chef/knife.rb'))
COOKBOOK = "the-cookbook-name"
RUN_LIST = ["recipe[#{COOKBOOK}::default]"]
NODE_JSON = {}
Vagrant::Config.run do |config|
# The path to the Berksfile to use with Vagrant Berkshelf
# config.berkshelf.berksfile_path = "./Berksfile"
# An array of symbols representing groups of cookbook described in the Vagrantfile
# to skip installing and copying to Vagrant's shelf.
# config.berkshelf.only = []
# An array of symbols representing groups of cookbook described in the Vagrantfile
# to skip installing and copying to Vagrant's shelf.
# config.berkshelf.except = []
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
# config.vm.network :bridged
# config.vm.forward_port 80, 8080
# config.vm.share_folder "v-data", "/vagrant_data", "../data"
config.ssh.max_tries = 40
config.ssh.timeout = 120
config.vm.define :solo do |solo_config|
solo_config.vm.provision :chef_solo do |chef|
chef.run_list = RUN_LIST
chef.json = NODE_JSON
end
solo_config.vm.network :hostonly, "33.33.33.10"
solo_config.vm.host_name = "#{COOKBOOK}.solo.vagrant"
end
config.vm.define :client do |client_config|
client_config.vm.provision :chef_client do |chef|
chef.chef_server_url = Chef::Config[:chef_server_url]
chef.validation_key_path = Chef::Config[:validation_key]
chef.validation_client_name = Chef::Config[:validation_client_name]
chef.run_list = RUN_LIST
chef.json = NODE_JSON
end
client_config.vm.network :hostonly, "33.33.33.11"
client_config.vm.host_name = "#{COOKBOOK}.client.vagrant"
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.