Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

chef-provisioning

> 编程语言
Open source

A library for creating machines and infrastructures idempotently in Chef.

518 stars0 likes0 views
WebsiteGitHub

About

A library for creating machines and infrastructures idempotently in Chef.

Chef Provisioning was officially end-of-life on August 31, 2019 and is no longer included with Chef DK. The Chef Provisioning source code and drivers have been moved into the chef-boneyard organization. If you are a current user of Chef Provisioning, please contact your Chef Customer Success Manager or Account Representative to review your options.

Chef Provisioning

Please join us in Slack by signing up at http://community-slack.chef.io/ and joining #chef-provisioning

Overview

Chef Provisioning is a Cookbook and Recipe based approach for managing your infrastructure. Users can codify their infrastructure and use Chef to converge their infrastructure to the desired state. It has a plugin model (called Drivers) to manage different infrastructures, including AWS, Azure and Fog.

Chef Provisioning is maintained according to the Chef Maintenance Policy.

Drivers

Due to the age and engagement level with different Drivers they have fallen into two categories - maintained and unmaintained.

Maintained drivers have a representative in the maintenance policy and get triaged / discussed during office hours. They are

AWS Fog

Maintained by Chef-Partners:

  • vSphere
  • vra

Maintained, not by Chef:

  • AzureRM

Unmaintained Drivers are at risk of becoming stale. They are:

  • Docker
  • ssh
  • Vagrant
  • LXC
  • Hanlon

Target Audience

Chef Provisioning is a good fit for people who use or want to use the Chef ecosystem to manage their infrastructure. Infrastructure is represented as Chef Resources and managed in Chef Recipes and Cookbooks. These recipes run on a provisioner node and attempt to converge the infrastructure idempotently. The AWS driver is the most used, the most tested and receives the most updates.

Chef Provisioning and its Drivers are maintained by the open source community. They currently have a slow tempo for issue triage and pull request merging. Troubleshooting a bug may require stepping through the Ruby Chef codebase and engaging the community.

If you are new to Chef and Chef Provisioning, learning both can be daunting. If you are not familiar with Ruby as well, double the learning curve. Successful provisioning users know how they want to manage their cookbooks. Generally this is some CI/CD pipeline.

Chef is very flexible which allows customized provisioning solutions at the cost of high complexity. This makes it hard to document all the possible use cases. Patterns (for example, how to manage the provisioning node and run the provisioning recipes) are not well documented.

Chef Provisioning should be used to manage infrastructure (CRUD operations) and register Chef nodes with the server for the first time only. Other use cases (like scheduling chef runs, node inventory or reporting) are not supported.

Documentation

These are the primary documents to help learn about using Provisioning and creating Provisioning drivers:

  • Chef Docs
  • Frequently Asked Questions
  • Configuration
  • Writing Drivers
  • Embedding

Media

This video explains the basics of chef-provisioning (though provisioners are now called drivers). Slides (more up to date) are here.

Date Blog
2014-12-15 Using Chef Provisioning to Build Chef Server
2014-11-12 Chef Launches Policy-Based Provisioning
2014-11-12 Chef Provisioning: Infrastructure As Code
2014-06-03 machine_batch and parallelization
2014-06-03 Chef Provisioning, Configuration and Drivers
2014-03-04 Chef Metal 0.2: Overview - this is a pretty good overview (though dated).
2013-12-20 Chef Metal Alpha

Try It Out

You can try out Chef Provisioning in many different flavors.

Vagrant

To give it a spin, install the latest ChefDK, Vagrant and VirtualBox. Run the following from the chef-provisioning/docs/examples directory:

bash
export CHEF_DRIVER=vagrant
export VAGRANT_DEFAULT_PROVIDER=virtualbox
chef-client -z vagrant_linux.rb simple.rb

This will create two vagrant precise64 linux boxes, "mario" and "luigi1", in ~/machinetest, bootstrapped to an empty runlist. For Windows, you can replace myapp::linux with myapp::windows, but you'll need your own Windows vagrant box to do that (licensing!).

AWS

If you have an AWS account, you can spin up a machine there like this:

bash
export CHEF_DRIVER=aws
chef-client -z simple.rb

This will create two linux boxes in the AWS account referenced by your default profile in ~/.aws/config (or your environment variables).

DigitalOcean

If you are on DigitalOcean and using the tugboat gem, you can do this:

bash
export CHEF_DRIVER=fog:DigitalOcean
chef-client -z simple.rb

If you aren't using the tugboat gem, you can put driver and driver_options into your .chef/knife.rb file.

This will use your tugboat settings to create whatever sort of instance you normally create.

Cleaning up

When you are done with the examples, run this to clean up:

chef-client -z destroy_all.rb

What Is Chef Provisioning?

Chef Provisioning has two major abstractions: the machine resource, and drivers.

The machine resource

You declare what your machines do (recipes, tags, etc.) with the machine resource, the fundamental unit of Chef Provisioning. You will typically declare machine resources in a separate, OS/provisioning-independent file that declares the topology of your app--your machines and the recipes that will run on them.

The machine resources from the cluster.rb example are pretty straightforward. Here's a copy/paste:

ruby
# Database!
machine 'mario' do
  recipe 'postgresql'
  recipe 'mydb'
  tag 'mydb_master'
end

num_webservers = 1

# Web servers!
1.upto(num_webservers) do |i|
  machine "luigi#{i}" do
    recipe 'apache'
    recipe 'mywebapp'
  end
end

You will notice the dynamic nature of the number of web servers. It's all code, your imagination is the limit :)

Drivers

Drivers handle the real work of getting those abstract definitions into real, physical form. They handle the following tasks, idempotently (you can run the resource again and again and it will only create the machine once--though it may notice things are wrong and fix them!):

  • Acquiring machines from the cloud, creating containers or VMs, or grabbing bare metal
  • Connecting to those machines via ssh, winrm, or other transports
  • Bootstrapping chef onto the machines and converging the recipes you suggested

The driver API is separated out so that new drivers can be made with minimal effort (without having to rewrite ssh, tunneling, bootstrapping, and OS support). But to the user, they appear as a single thing, so that the machine acquisition can use its smarts to autodetect the other bits (transports, OS's, etc.).

Drivers save their data in the Chef node itself, so that they will be accessible to everyone who is using the Chef server to manage the nodes.

Machine options

You can pass machine options that will be used by machine, machine_batch and machine_image to configure the machine:

…

This options hash can be supplied to either with_machine_options or directly into the machine_options attribute.

Individual drivers will often add their own driver specific config. For example, AWS expects a :bootstrap_options hash at the same level as :convergence_options.

Anatomy of a Recipe

The ChefDK comes with a provisioner for Vagrant, an abstraction that covers VirtualBox, VMware and other Virtual Machine drivers. In docs/examples, you can run this to try it:

ruby
export CHEF_DRIVER=vagrant
export VAGRANT_DEFAULT_PROVIDER=virtualbox
chef-client -z vagrant_linux.rb simple.rb

To use with VMware, simply update the prior example to read export VAGRANT_DEFAULT_PROVIDER=vmware_fusion

This is a chef-client run, which runs multiple recipes. Chef Provisioning is nothing but resources you put in recipes.

The driver is specified on the command line. Drivers are URLs. You could use vagrant:~/vms or `fog:AWS:default:us-east-1' as driver URLs. More information here.

The vagrant_linux.rb recipe handles the physical specification of the machines and Vagrant box:

ruby
require 'chef/provisioning/vagrant_driver'

vagrant_box 'precise64' do
  url 'http://files.vagrantup.com/precise64.box'
end

with_machine_options :vagrant_options => {
  'vm.box' => 'precise64'
}

require 'chef/provisioning/vagrant_driver' is how we bring in the vagrant_box resource.

vagrant_box makes sure a particular vagrant box exists, and lets you specify machine_options for things like port forwarding, OS definitions, and any other vagrant-isms.

Typically, you declare these in separate files from your machine resources. Chef Provisioning picks up the drivers and machine_options you have declared, and uses them to instantiate the machines you request. The actual machine definitions, in this case, are in simple.rb, and are generic--you could use them against Azure or EC2 as well:

ruby
machine 'mario' do
  tag 'itsame'
end

Other directives, like recipe 'apache', help you set run lists and other information about the machine.

Pointing Boxes at Chef Servers

By default, Chef Provisioning will put your boxes on the same Chef server you started chef-client with (in the case of -z, that's a local chef-zero server). Sometimes you want to put your boxes on different servers. There are a couple of ways to do that:

ruby
with_chef_local_server :chef_repo_path => '~/repo'

with_chef_local_server is a generic directive that creates a chef-zero server pointed at the given repository. nodes, clients, data bags, and all data will be stored here on your provisioner machine if you do this.

You can use with_chef_server instead if you want to point at OSS, Hos

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言