Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status


sql_server (65) Versions 5.1.0

Installs/Configures Microsoft SQL Server

cookbook 'sql_server', '= 5.1.0', :supermarket
cookbook 'sql_server', '= 5.1.0'
knife supermarket install sql_server
knife supermarket download sql_server
Quality 67%

sql_server Cookbook

Travis Build Status Cookbook VersionAppVeyor Build status

Installs and configures Microsoft SQL Server 2008 R2 SP2 and Microsoft SQL Server 2012 server and client. By default the Express edition is installed, but the sql_server::server recipe supports installation of other editions (see Usage below).



  • Windows Server 2008 R2 (SP2)
  • Windows Server 2012 (R1, R2)


  • Chef 12.6+


  • windows



The following attributes are used by both client and server recipes.

  • node['sql_server']['accept_eula'] - indicate that you accept the terms of the end user license, default is 'false'
  • node['sql_server']['product_key'] - Specifies the product key for the edition of SQL Server, default is nil (not needed for SQL Server 2008 R2 Express installs)


This file also contains download url, checksum and package name for all client installation packages. See the Usage section below for more details.


  • node['sql_server']['install_dir'] - main directory for installation, default is C:\Program Files\Microsoft SQL Server
  • node['sql_server']['instance_name'] - name of the default instance, default is SQLEXPRESS
  • node['sql_server']['instance_dir'] - root directory of the default instance, default is C:\Program Files\Microsoft SQL Server
  • node['sql_server']['shared_wow_dir'] - root directory of the shared WOW directory, default is C:\Program Files (x86)\Microsoft SQL Server
  • node['sql_server']['agent_account'] - Agent account name, default is NT AUTHORITY\NETWORK SERVICE
  • node['sql_server']['agent_startup'] - Agent service startup mode, default is Disabled
  • node['sql_server']['rs_mode'] - Reporting Services install mode, default is FilesOnlyMode
  • node['sql_server']['rs_account'] - Reporting Services account name, default is NT AUTHORITY\NETWORK SERVICE
  • node['sql_server']['rs_startup'] - Reporting Services startup mode, default is Automatic
  • node['sql_server']['browser_startup'] - Browser Service startup mode, default is Disabled
  • node['sql_server']['sysadmins'] - Windows accounts that are SQL administrators, default is Administrator
  • node['sql_server']['sql_account'] - SQL service account name, default is NT AUTHORITY\NETWORK SERVICE

This file also contains download url, checksum and package name for the server installation package.


  • node['sql_server']['tcp_enabled'] - Enables TCP listener, default is true
  • node['sql_server']['port'] - Static TCP port server should listen on for client connections, default is 1433
  • node['sql_server']['tcp_dynamic_ports'] - Dynamic TCP ports server should listen on for client connections, default is ''
  • node['sql_server']['np_enabled'] - Enables Named pipes listener, default is false
  • node['sql_server']['sm_enabled'] - Enables Shared Memory listener, default is true
  • node['sql_server']['via_default_port'] - VIA default listener port, default is 0:1433
  • node['sql_server']['via_enabled'] - Enables VIA listener, default is false
  • node['sql_server']['via_listen_info'] - VIA listener info, default is 0:1433



Includes the sql_server::client recipe.


Installs required the SQL Server Native Client and all required dependancies. These include:

The SQL Server Native Client contains the SQL Server ODBC driver and the SQL Server OLE DB provider in one native dynamic link library (DLL) supporting applications using native-code APIs (ODBC, OLE DB and ADO) to Microsoft SQL Server. In simple terms these packages should allow any other node to act as a client of a SQL Server instance.


Configures SQL Server registry keys via attributes, and restart the Engine service if required.

Current supported settings are mostly connection listeners:
- TCP or VIA listener ports
- TCP, Named Pipes, Shared Memory or VIA listener activation.

NOTE: It could be very dangerous to change these settings on a production server!

This recipe is included by the sql_server::server recipe, but can be included independently if you setup SQL Server by yourself.


Installs SQL Server 2008 R2 Express or SQL Server 2012 Express.

By default, the cookbook installs SQL Server 2008 R2 Express. There are two options to install a different version.

NOTE: For this recipe to run you must set the node['sql_server']['server_sa_password'] in an environment, role, or wrapper cookbook.

NOTE: This recipe will request a reboot at the end of the Chef Client run if SQL Server was installed.. If you do not want to reboot after the installation, use the reboot resource to cancel the pending reboot.

Option 1: From a role, environment, or wrapper cookbook, set node['sql_server']['version'] to '2008R2' to install SQL Server 2008 R2 Express, '2012' to install SQL Server 2012 Express or '2014' to install SQL Server 2014 Express.

Option 2: From a role, environment, or wrapper cookbook, set these node attributes to specify the URL, checksum, and name of the package (as it appears in the Windows Registry).


The installation is done using the package resource and ConfigurationFile generated from a template resource. The installation is slightly opinionated and does the following:

  • Enables Mixed Mode (Windows Authentication and SQL Server Authentication) authentication
  • Auto-generates and sets a strong password for the 'sa' account
  • sets a static TCP port which is configurable via an attribute, using the sql_server::configure recipe.

Installing any of the SQL Server server or client packages in an unattended/automated way requires you to explicitly indicate that you accept the terms of the end user license. The hooks have been added to all recipes to do this via an attribute. Create a role to set the node['sql_server']['accept_eula'] attribute to 'true'. For example:

name "sql_server"
description "SQL Server database master"
  "sql_server" => {
    "accept_eula" => true

Out of the box this recipe installs the Express edition of SQL Server 2008 R2. If you would like to install the Standard edition create a role as follows:

name "sql_server_standard"
description "SQL Server Stadard edition database master"
  "sql_server" => {
    "instance_name" => "MSSQLSERVER",
    "product_key" => "YOUR_PRODUCT_KEY_HERE",
    "accept_eula" => true,
    "server" => {
      "checksum" => "SHA256_OF_INSTALLATION_PACKAGE"

Depending on your base Windows installation you may also need to open the configured static port in the Windows Firewall. In the name of security we do not do this by default but the follow code should get the job done:

# unlock port in firewall
# this should leverage firewall_rule resource
# once COOK-689 is completed
firewall_rule_name = "#{node['sql_server']['instance_name']} Static Port"

execute "open-static-port" do
  command "netsh advfirewall firewall add rule name=\"#{firewall_rule_name}\" dir=in action=allow protocol=TCP localport=#{node['sql_server']['port']}"
  returns [0,1,42] # *sigh* cmd.exe return codes are wonky
  not_if { SqlServer::Helper.firewall_rule_enabled?(firewall_rule_name) }

Installing SQL Server remotely

SQL Server does not support remote installation over WinRM. For example, the installation fails when you run knife bootstrap windows winrm or knife winrm 'chef-client' with a run-list that includes server.rb. However, you can use a scheduled task or run chef-client as a service. Learn more in this Learn Chef tutorial.

License & Authors

Author: Cookbook Engineering Team (

Copyright: 2011-2016, Chef Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Dependent cookbooks

windows >= 2.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

sql_server Cookbook CHANGELOG

This file is used to list changes made in each version of the sql_server cookbook.

5.1.0 (2016-12-20)

  • Move server configuration in a new sql_server::configure recipe
  • Add attributes to control network listeners via registry keys.

5.0.0 (2016-11-22)

  • Avoid deprecation warnings with windows_package by using package instead. This requires Chef 12.6+ and Windows cookbook 2.0+
  • Adding support for SQL Server Version 2014
  • Default to SQL Server 2012
  • Move a good chunk of the version logic to helpers instead of doing it in the recipes
  • Use secure links to download older SQL express releases
  • Add basic sql express 2016 support
  • Don’t fail if the SQL version specified is an int and not a string
  • Avoid blank lines if the optional configs aren’t passed

4.0.0 (2016-11-18)

  • Remove relation between client & server recipes. This was not working correctly. You'll want to include both if you want client packages on your server now.
  • Added Filestream Support
  • Improved password escaping
  • Remove SQL Server 2008 R2 / 2008 R2 SP1. You must now be using 2008 R2 SP2+

3.0.0 (2016-09-07)

  • Correct attribute to accept eula
  • Require Chef 12+
  • Testing updates


  • README updates


  • PR #69 Duplicate service restart
  • Clean up rake file, maintainers toml/markdown


  • PR #59 Support Named Instances
  • PR #61 Restart Command For SQL Server
  • PR #67 Updates for Standard Edition
  • PR #68 Clarify remote install note


  • Enable multiple sysadmin names.
  • Removed the logic that auto generated node['sql_server']['server_sa_password'] and saved it to the node. The user will now need to set this to use the server recipe
  • Removed the gem install of tiny_tds. This is not directly used by this cookbook. If you require this for the database cookbook you should install it in your own wrapper cookbook.
  • Added support for SQL Server Client 2008 R2 SP2/SP2 and 2012 package installation
  • Added the ability to specify the directories for system dbs, user dbs, logs, and tempdb in ConfigurationFile.ini
  • Removed assumptions that C: is your system drive
  • Added support SQL 2014 server in ConfigurationFile.ini
  • Added the ability to pass account passwords to the installer vs. placing them in ConfigurationFile.ini
  • Added ability to configure tempdb path, sqlbackupdir path, and sqlcollation in ConfigurationFile.ini
  • Fixed computation of the reg_version and service_name variables
  • Clarified the system and chef requirements in the readme
  • Removed the Berksfile.lock
  • Added Test Kitchen config with client and server suite
  • Added updated contributing and testing docs
  • Added Travis config
  • Added Rakefile for simplified testing
  • Added Rubocop config and resolved all warnings
  • Added Gemfile with testing deps
  • Added Maintainers files
  • Added travis and cookbook version badges to the readme
  • Added source_url and issues_url metadata for Supermarket

v2.4.0 (2014-08-13)

  • Fixing Checksums
  • Changes to attribute interface

v2.2.3 (2014-02-18)

  • reverting OpenSSL module namespace change

v2.2.2 (2014-02-17)

  • updating to use the latest openssl

v2.2.0 (2014-03-27)

  • [COOK-4355] - Fix support for SQL server by using the right registry path

v2.0.0 (2014-02-27)

[COOK-4253] - Make install options configurable

v1.4.4 (2014-02-21)


  • COOK-4268 - sql_server does not support installing SQL 2012

v1.4.1 (2014-02-21)


  • COOK-3892 - sql_server cookbook uses deprecated windows_registry LWRP


  • COOK-3725 - sql_server randomly-generated SA password sometimes not strong enough



  • COOK-3507 - Broken SQLExpress download links...


  • COOK-3506 - SQLEXPRESS on 32 bits systems does not support INSTALLSHAREDWOWDIR
  • COOK-3388 - Mixlib::ShellOut::CommandTimeout: command timed out error


  • See (v1.2.1), made a mistake with DevOdd releases





  • [COOK-3085]: Sql server configuration is incorrect when trying to install non-express version


  • [COOK-1049] - remove unneeded external restart script from sql_server::server recipe


  • bump windows cookbook dependency version to pick up Ruby 1.9 compat fixes


  • [COOK-773] win_friendly_path is no longer a module_function
  • rename accept_license_terms attribute to accept_eula for consistency with other cookbooks like iis


  • [COOK-681] initial release

Collaborator Number Metric

5.1.0 passed this metric

Foodcritic Metric

5.1.0 failed this metric

FC009: Resource attribute not recognised: /tmp/65f70b2efe1ad51d58855e0e/sql_server/recipes/client.rb:22
FC009: Resource attribute not recognised: /tmp/65f70b2efe1ad51d58855e0e/sql_server/recipes/server.rb:68
Run with Foodcritic Version 8.1.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

License Metric

5.1.0 passed this metric