Day 82: Deploying SQL Server 2012 using Chef – Part 1

In this week’s post, we are going to build on the previous Windows based Chef Articles and demonstrate how you can deploy a standard configuration of SQL Server 2012 in your environment using Chef.



If you have been following along in this series, then you should have already installed the Chef Deployment Kit onto your Host running Windows Server 2012 R2 as stated in the article Day 57: Chef: a simple Recipe and Cookbook for Windows. Additionally, make sure that you have configured your Windows Host to report to your Chef Server. Those instructions are also in the Day 57 Article.

Additionally you will require an image of SQL Server 2012 (Standard or Enterprise) in ISO format. For the example given below, we will be using SQL Server 2012 Standard with SP1.

A Trial Image can be downloaded from here.

Finally, you need a Web Server to store the SQL Server 2012 ISO file in order to use the Recipe below.



Create the SQL Cookbook and Recipe

From your Windows Server 2012 R2 Host, open up a PowerShell prompt and cd into the directory C:\Users\<Username>chef-repo\cookbooks.

Next, run the following command to generate a cookbook where we will be storing the recipe for deploy SQL Server 2012 Standard on our Windows Host.


Once the cookbook has been generated, cd to C:\Users\<Username>\chef-repo\cookbooks\SQL_Server_2012_STD_x64\recipes and open up default.rb with a text editor of your choosing. Paste in the following configuration:


The Recipe above will perform the following actions:

– Create a Temp Directory at C:\Temp on the Windows Host
– Download the SQL Server 2012 ISO from a specified web URL.
– Mount the SQL Server 2012 ISO
– Install SQL Server 2012 with Default Settings
– Dismount the SQL Server 2012 ISO
– Delete the SQL Server 2012 ISO from the Temp Directory at C:\Temp

Before you run the chef recipe (as shown below) make sure to run to replace the following variables at the top of the recipe with their respective values:

Fear not if you are concerned about storing passwords in this file in clear text, we will be going over how to store those credentials properly in Chef in next week’s post.



Run the Recipe in Local Mode

Once you have put in the respective variable values you can deploy the recipe locally on the Windows Host by running the chef-client command below:


Note that the recipe will take between 5 and 10 minutes to run.

Once the command has finished running, you should be able to open up services.msc and see the SQL Server (MSSQLSERVER) Service Running.




Some of the things that will be covered in next week’s post are as follows:
– Storing SQL Credentials in Chef Data Bags using Encryption
– Deploying the SQL Server 2012 Recipe from your Chef Server



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.