Day 62: Deploying your Windows Recipe from your Chef Server

In last week’s post, Chef: A Simple Recipe and Cookbook for Windows, we demonstrated how to create a simple Chef Cookbook with a functional recipe for deploying the Web-Server and Web-Mgmt-Tools Features; along with a simple web page for Windows Server 2012 R2. This week, we’ll be going over how to upload our Recipe onto our Chef Server and deploy it out to our Windows Host.


We need to undo the configurations made to our Windows Host from last week before continuing on. Start by uninstalling the Web-Server and Web-Mgmt-Console Features on the Windows Host.


Next, open up the file file Default.htm in C:\inetpub\wwwroot\ ; clear out the contents of the file and then save it.

Afterwards, restart the Windows Host.


Chef highly recommends using a version control system, such as GitHub, for managing your Chef Infrastructure. Since the focus of this series has been about getting started using Chef, we have left the focus on using version control out. However, a very quick and effective 15 minute tutorial on getting started with GitHub can be found here.

There are various methods by which you can copy over your Cookbook from last week’s post to your Chef Ubuntu Workstation; I would recommend using WinSCP. Just make sure that the Cookbook is copied over into the ~/chef-repo/cookbooks directory.


On the Ubuntu Chef Workstation, a text editor must be set in the knife.rb file before we are able to edit any nodes in the Chef Environment. My recommendation would be to set it to either nano or vim. For the example below, it will be set to vim.

On the Ubuntu Chef Workstation, cd to the chef-repo directory.

Open up the knife.rb file in the hidden chef directory.

Add the following line to the bottom of the file

Save and close out of knife.rb

Now you will be able to manually edit the node configuration of your Windows Host. If you do not do this step and attempt to manually edit a node configuration, you will receive the following error message:



Deploying the Recipe from your Chef Server to your Windows Host

Run the following command from the Ubuntu Chef Workstation to upload the W2K12R2_IIS Cookbook


Next, add the recipe to the Run List of the node by running the following command:


Wait a couple of minutes and login to the Windows Host to verify that the Cookbook was applied successfully.

Run the following PowerShell Command to verify that the Web-Server and Web-Mgmt-Console Features are now installed:


Additionally, you can push out the Recipe from the Chef Server Console once the Cookbook has been uploaded to it.



A third option is to manually edit the node using knife by using the following command


Once the file is open in the text editor (which we set previously), you’ll a section called Run List where you can add/remove recipes.



This week’s post has demonstrated how to add your Recipe to your Chef Server and then deploy it from the Chef Server to your Windows Server 2012 R2 Host.


Previous Installments

100 Days of DevOps with PowerShell








Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.