Skip to content

Instantly share code, notes, and snippets.

@esciara
Created December 11, 2014 23:02
Show Gist options
  • Save esciara/def7c0010da945d068bd to your computer and use it in GitHub Desktop.
Save esciara/def7c0010da945d068bd to your computer and use it in GitHub Desktop.
Examples in Chef Provisioning 0.16.1 do not seem to work
require 'chef/provisioning'
machine_batch do
machines search(:node, '*:*').map { |n| n.name }
action :destroy
end
# knife.rb used from http://chef.leopard.in.ua/
# This file exists mainly to ensure we don't pick up knife.rb from anywhere else
local_mode true
config_dir "#{File.expand_path('..', __FILE__)}/" # Wherefore art config_dir, chef?
# Chef 11.14 binds to "localhost", which interferes with port forwarding on IPv6 machines for some reason
begin
chef_zero.host '127.0.0.1'
rescue
end
$ chef-client -z vagrant.rb destroy_all.rb
Starting Chef Client, version 12.0.1
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Compiling Cookbooks...
[2014-12-11T23:50:53+01:00] WARN: Node Ems-MacBook-Pro.local has an empty run list.
Converging 2 resources
Recipe: @recipe_files::/Users/emmanuelsciara/Documents/Development/git-repos/chef-provisioning-test/vagrant.rb
* vagrant_box[precise64] action create (up to date)
Recipe: @recipe_files::/Users/emmanuelsciara/Documents/Development/git-repos/chef-provisioning-test/destroy_all.rb
* machine_batch[default] action destroy (up to date)
Running handlers:
Running handlers complete
Chef Client finished, 0/2 resources updated in 6.982235 seconds
require 'chef/provisioning'
machine 'mario' do
tag 'itsa_me'
converge true
end
require 'chef/provisioning/vagrant_driver'
with_driver 'vagrant' # <=== was not in original example file... had to add it to have it work.
vagrant_box 'precise64' do
url 'http://files.vagrantup.com/precise64.box'
end
with_machine_options :vagrant_options => {
'vm.box' => 'precise64'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment