Creating your infrastructure using Chef Provisioning
You know how to use Chef to manage the software on individual machines and you know how to use knife to bootstrap individual nodes. Chef Provisioning helps you to use the power of Chef to create your whole infrastructure for you.
No matter whether you want to create a cluster of Vagrant boxes, Docker instances, or Cloud servers, Chef Provisioning lets you define your infrastructure in a simple recipe and run it idempotently.
Let's see how to create a Vagrant machine using a Chef recipe.
Getting ready
Make sure that you have your Berksfile
, my_cookbook
and web_server
roles ready to create an nginx site, as described in Creating nginx virtual hosts section in chapter 6, Users and Applications.
How to do it...
Let's see how to create a Vagrant machine and install nginx on it:
Describe your Vagrant machine in a recipe called
mycluster.rb
:mma@laptop:~/chef-repo $ subl mycluster.rb
require 'chef/provisioning' with_driver 'vagrant' with_machine_options...