From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/vagrant/provisioning%2Fchef_solo.html | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 devdocs/vagrant/provisioning%2Fchef_solo.html (limited to 'devdocs/vagrant/provisioning%2Fchef_solo.html') diff --git a/devdocs/vagrant/provisioning%2Fchef_solo.html b/devdocs/vagrant/provisioning%2Fchef_solo.html new file mode 100644 index 00000000..03c6e20b --- /dev/null +++ b/devdocs/vagrant/provisioning%2Fchef_solo.html @@ -0,0 +1,71 @@ +

Chef Solo Provisioner

Provisioner name: chef_solo

The Vagrant Chef Solo provisioner allows you to provision the guest using Chef, specifically with Chef Solo.

Chef Solo is ideal for people who are already experienced with Chef, already have Chef cookbooks, or are looking to learn Chef. Specifically, this documentation page will not go into how to use Chef or how to write Chef cookbooks, since Chef is a complete system that is beyond the scope of a single page of documentation.

Warning: If you are not familiar with Chef and Vagrant already, I recommend starting with the shell provisioner. However, if you are comfortable with Vagrant already, Vagrant is the best way to learn Chef.

+

Options

This section lists the complete set of available options for the Chef Solo provisioner. More detailed examples of how to use the provisioner are available below this section.

In addition to all the options listed above, the Chef Solo provisioner supports the common options for all Chef provisioners.

Specifying a Run List

The easiest way to get started with the Chef Solo provisioner is to just specify a run list. This looks like:

Vagrant.configure("2") do |config|
+  config.vm.provision "chef_solo" do |chef|
+    chef.add_recipe "apache"
+  end
+end
+
+

This causes Vagrant to run Chef Solo with the "apache" cookbook. The cookbooks by default are looked for in the "cookbooks" directory relative to your project root. The directory structure ends up looking like this:

$ tree
+.
+|-- Vagrantfile
+|-- cookbooks
+|   |-- apache
+|       |-- recipes
+|           |-- default.rb
+
+

The order of the calls to add_recipe will specify the order of the run list. Earlier recipes added with add_recipe are run before later recipes added.

Custom Cookbooks Path

Instead of using the default "cookbooks" directory, a custom cookbooks path can also be set via the cookbooks_path configuration directive:

Vagrant.configure("2") do |config|
+  config.vm.provision "chef_solo" do |chef|
+    chef.cookbooks_path = "my_cookbooks"
+  end
+end
+
+

The path can be relative or absolute. If it is relative, it is relative to the project root.

The configuration value can also be an array of paths:

Vagrant.configure("2") do |config|
+  config.vm.provision "chef_solo" do |chef|
+    chef.cookbooks_path = ["cookbooks", "my_cookbooks"]
+  end
+end
+
+

Roles

Vagrant also supports provisioning with Chef roles. This is done by specifying a path to a roles folder where roles are defined and by adding roles to your run list:

Vagrant.configure("2") do |config|
+  config.vm.provision "chef_solo" do |chef|
+    chef.roles_path = "roles"
+    chef.add_role("web")
+  end
+end
+
+

Just like the cookbooks path, the roles path is relative to the project root if a relative path is given.

The configuration value can also be an array of paths on Chef 11.8.0 and newer. On older Chef versions only the first path is used.

Note: The name of the role file must be the same as the role name. For example the web role must be in the roles_path as web.json or web.rb. This is required by Chef itself, and is not a limitation imposed by Vagrant.

Data Bags

Data bags are also supported by the Chef Solo provisioner. This is done by specifying a path to your data bags directory:

Vagrant.configure("2") do |config|
+  config.vm.provision "chef_solo" do |chef|
+    chef.data_bags_path = "data_bags"
+  end
+end
+
+

Custom JSON Data

Additional configuration data for Chef attributes can be passed in to Chef Solo. This is done by setting the json property with a Ruby hash (dictionary-like object), which is converted to JSON and passed in to Chef:

Vagrant.configure("2") do |config|
+  config.vm.provision "chef_solo" do |chef|
+    # ...
+
+    chef.json = {
+      "apache" => {
+        "listen_address" => "0.0.0.0"
+      }
+    }
+  end
+end
+
+

Hashes, arrays, etc. can be used with the JSON configuration object. Basically, anything that can be turned cleanly into JSON works.

Custom Node Name

You can specify a custom node name by setting the node_name property. This is useful for cookbooks that may depend on this being set to some sort of value. Example:

Vagrant.configure("2") do |config|
+  config.vm.provision "chef_solo" do |chef|
+    chef.node_name = "foo"
+  end
+end
+
+

+ © 2010–2018 Mitchell Hashimoto
Licensed under the MPL 2.0 License.
+ https://www.vagrantup.com/docs/provisioning/chef_solo.html +

+
-- cgit v1.2.3