diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff4d92b..c82eaec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,14 +25,14 @@ jobs: strategy: matrix: os: - - "windows-2016" - "windows-2019" suite: - - "client" - - "install" - - "server2016" - - "server2017" - - "server2019" + - "default" + # - "client" + # - "install" + # - "server2016" + # - "server2017" + # - "server2019" fail-fast: false steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index d8709c9..09f1e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ This file is used to list changes made in each version of the sql_server cookboo ## Unreleased +- Remove recipes and attributes +- Remove duplicate _ConfigurationFile.ini.erb +- Remove specs for recipes +- Move the InSpec test to the correct directory + ## 7.2.6 - *2023-09-28* ## 7.2.5 - *2023-09-04* diff --git a/README.md b/README.md index 439bcbb..2dd0821 100644 --- a/README.md +++ b/README.md @@ -38,367 +38,12 @@ together to maintain important cookbooks. If you’d like to know more please vi ### Chef -- Chef 13+ - -### Cookbooks - -- windows +- Chef 15.3+ ## Resources -### sql_server_install - -#### Actions - -- `:install` - Installs the version of Microsoft SQL server specified. Default install is SQL 2012 Express. - -#### Properties - -- `feature` - An Array of the SQL Instance or Server features that are going to be enabled / installed. - - [SQL 2012 Available Features list](https://technet.microsoft.com/library/cc645993(SQL.110).aspx) - - Instance Features - - `SQLENGINE` = Database Engine - - `REPLICATION` = Replication - - `FULLTEXT` = Full-Text and Semantic Extractions for search - - `DQ` = Data Quality Services - - `AS` = Analysis Services - - `RS` = Reporting Services - Native - - Shared Features - - `RS_SHP` = Reporting Services - SharePoint - - `RS_SHPWFE` = Reporting Services Add-in for SharePoint Products - - `DQC` = Data Quality Client - - `BIDS` = SQL Server data tools - - `CONN` = Client tools connectivity - - `IS` = Integration Services - - `BC` = Client tools backwards compatibility - - `SDK` = Client tools SDK - - `BOL` = Documentation components - - `SSMS` = Management tools - - `SSMS_ADV` = Management tools - Advanced - - `DREPLAY_CTLR` = Distributed replay controller - - `DREPLAY_CLT` = Distributed replay client - - `SNAC_SDK` = SQL client connectivity SDK - - [SQL 2016 Available Features list](https://technet.microsoft.com/library/cc645993(SQL.130).aspx) - - Instance Features - - `ADVANCEDANALYTICS` = R Services (In-Database) - - `POLYBASE` = PolyBase Query Service for External Data - Note: This Feature Requires Java Runtime Environment greater than 7 update 51. Only the standalone Polybase-enabled Instance is currently support by this cookbook. - - Shared Features - - `SQL_SHARED_MR` = R Server (Standalone) - - `MDS` = Master Data Services - - REMOVED for standalone install - - `SSMS` = Management tools - - `SSMS_ADV` = Management tools - Advanced - - [SQL 2017 Available Features list](https://docs.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2017) - - Instance Features - - `ADVANCEDANALYTICS` = Machine Learning services (In-Database) - - `SQL_INST_MPY` = Machine Learning services (In-Database) with Python - - `SQL_INST_MR` = Machine Learning services (In-Database) with R - - Shared Features - - `SQL_SHARED_AA` = Machine Learning Services (Standalone) - - `SQL_SHARED_MR` = Machine Learning services (In-Database) with R - - `SQL_SHARED_MPY` = Machine Learning services (In-Database) with Python - - `IS` = Integrated Services - - `IS_MASTER` - Scale Out Master - - `IS_WORKER` - Scale Out Worker - -- `version` - Version of SQL to be installed. Valid otpions are `2012`, `2016`, `2017`, `2019` or `2022`. Default is `2012` -- `source_url` - Source of the SQL setup.exe install file. Default is built from the helper libraries. -- `package_name` - Package name for the SQL install. If you specify a version this property is not necessary. Default is built from the helper libraries. -- `package_checksum` - Package checksum in SHA256 format for the setup.exe file. Default is built from the helper libraries. -- `sql_reboot` - Determines whether the node will be rebooted after the SQL Server installation. Default setting is true -- `security_mode` - The Autentication mode for SQL. Valid options are `Windows Athentication` or `Mixed Mode Authentication`. Default value is `Windows Authentication` -- `sa_password` - The SQL Administrator password when `Mixed Mode Authentication` is being used. SQL enforces a strong passwords for this value. -- `sysadmins` - The list of Systems Administrators who can access the SQL Instance. This can either be a String or an Array. -- `agent_account` - The Service Account that will be used to run the SQL Agent Service. Default is `NT AUTHORITY\SYSTEM`. -- `agent_startup` - The Agent Service startup type. Valid options are `Automatic`, `Manual`, `Disabled`, or `Automatic (Delayed Start)`. Default is `Disabled`. -- `agent_account_pwd` - Agent Service Account password. -- `sql_account` - Service Account used to run the SQL service. Default is `NT AUTHORITY\NETWORK SERVICE` -- `sql_account_pwd` - Service Account password for the SQL service account. -- `browser_startup` - Service startup type for the SQL Browser Service. Valid options are `Automatic`, `Manual`, `Disabled`, or `Automatic (Delayed Start)`. Default is `Disabled`. -- `installer_timeout` - Time out for the SQL installation. Default is `1500` -- `accept_eula` - Whether or not to accept the end user license agreement. Default is `false` - Note: For SQL 2016 if this will also accept the license for using R if `ADVANCEDANALYTICS` or `SQL_SHARED_MR` is listed in the feature property array. -- `product_key` - Product key for not Express or Evaluation versions. -- `update_enabled` - Whether or not to download updates during install. Default is true. -- `update_source` - The Source Location of Windows Update or WSUS. Default is `MU`. Example = `c:/path/to/update` -- `instance_name` - Name for the instance to be installed. Default is `SQLEXPRESS`. For non-express installs that want the default install it should be set to `MSSQLSERVER`. -- `install_dir` - Directory SQL binaries will be installed to. Default is `C:\Program Files\Microsoft SQL Server` -- `instance_dir` - Directory the Instance will be stored. Default is `C:\Program Files\Microsoft SQL Server` -- `sql_data_dir` - Directory for SQL data -- `sql_backup_dir` - Directory for backups -- `sql_instant_file_init` - Enable instant file initialization for SQL Server service account. Default is `false` -- `sql_user_db_dir` - Directory for the user database -- `sql_user_db_log_dir` - Directory for the user database logs -- `sql_temp_db_dir` - Directory for the temporary database -- `sql_temp_db_log_dir` - Directory for the temporary database logs -- `sql_temp_db_file_count` - Number of TempDB data files. Default is 8 or number of cores, whichever is lower. -- `sql_temp_db_file_size` - Initial size of each TempDB data file in MB. Default is 8. -- `sql_temp_db_file_growth` - Automatic growth increment for each TempDB data file in MB. Default is 64. -- `sql_temp_db_log_file_size` - Initial size of the TempDB log file in MB. Default is 8. -- `sql_temp_db_log_file_growth` - Automatic growth increment for the TempDB log file in MB. Default is 64. -- `filestream_level` - Level to enable the filestream feature, Valid values are 0, 1, 2 or 3. Default is 0 -- `filestream_share_name` - Share name for the filestream feature. Default is `MSSQLSERVER` -- `sql_collation` - SQL Collation type for the instance -- `netfx35_install` - If the .Net 3.5 Windows Feature is installed. This is required to successfully install SQL 2012. Default is true. -- `netfx35_source` - Source location for the .Net 3.5 Windows Features install. Only required for offline installs - -Distributed Replay - -- `dreplay_ctlr_admins` - List of admins for the Distributed Replay Controller. Default is `Administrator`. The `DREPLAY_CTLR` feature needs to be included in the feature Array for this property to work. -- `dreplay_client_name` - Host name of the Distributed Replay Controller that the Client will point to. If the `DREPLAY_CLT` is in the feature list this property needs to be set. - -Reporting Services - -- `rs_account` - Service Account name used to run SQL Reporting Services. To have reporting services it needs to be listed in the `feature` property array. -- `rs_account_pwd` - Service Account password for the Reporting Services Service -- `rs_startup` - Reporting Services service startup type. Valid options are `Automatic`, `Manual`, `Disabled`, or `Automatic (Delayed Start)`. Default is `Automatic`. -- `rs_mode` - Mode the Reporting Services is installed in. Default is `FilesOnlyMode` - -Analysis Services - -- `as_sysadmins` - Analysis Services Systems Administrator list. Default is `Administrator` -- `as_svc_account` - Service Account used by Analysis Services. Default is `NT Service\MSSQLServerOLAPService` - -PolyBase Query Services - -- `polybase_port_range` - Port Range for the PolyBase Query Service. Default is `16450-16460`. - -Integrated Services - -- `is_master_port` - Port for the Integrated Services Scale out Master. Default is 8391. -- `is_master_ssl_cert` - The CNs in the certificate used to protect communications between the integration services scale out worker and scale out master. -- `is_master_cert_thumbprint` - The certificate thumbprint for the scale out master ssl certificate. -- `is_worker_master_url` - The url of the scale out master when installing a scale out worker. - -#### Examples - -Install SQL 2012 Express with all the defaults - -```ruby -sql_server_install 'Install SQL 2012 Express' -``` - -Install SQL 2016 Express - -```ruby -sql_server_install 'Install SQL 2016 Express' do - version '2016' -end -``` - -Install SQL 2012 Evaluation from a local source with default instance name, Integrated Services, Reporting Services, and the SQL Management Tools. - -```ruby -sql_server_install 'Install SQL Server 2012 Evaluation' do - source_url 'C:\\Sources\\SQL 2012 Eval\\setup.exe' - version '2012' - package_checksum '0FE903...420E8F' - accept_eula true - instance_name 'MSSQLSERVER' - feature %w(SQLENGINE IS RS SSMS ADV_SSMS) -end -``` - -### sql_server_configure - -#### Actions - -- `:service` - Configures the ports that SQL be listening on and starts and enables the SQL Service. - -#### Properties - -- `version` - SQL Version of the instance to be configured. Valid otpions are `2012`, `2016`, `2017` or `2019`. Default is `2012` -- `tcp_enabled` - If TCP is enabled for the instance. Default is true -- `sql_port` - Port SQL will listen on. Default is 1433 -- `tcp_dynamic_ports` - Sets the Dynamic port SQL will listen on. Default is an empty string -- `np_enabled` - Whether named pipes is enabled. Default is false -- `sm_enabled` - Whether shared memory is enabled for the instance -- `via_default_port` - Configures the Virtual Interface Adapter default port. Default is `0:1433` -- `via_enabled` - Whether Virtual Interface Adapter is enabled. Default is false -- `via_listen_info` - Configures the Virtual interface listening information. Default is `0:1433` -- `agent_startup` - Configures the SQL Agent Service startup type. Valid options are `Automatic`, `Manual`, `Disabled`, or `Automatic (Delayed Start)`. Default is `Disabled` - -#### Examples - -Configure a SQL 2012 Express install with all the defaults - -```ruby -sql_server_configure 'SQLEXPRESS' -``` - -Configure a SQL 2016 Express install - -```ruby -sql_server_configure 'SQLEXPRESS' do - version '2016' -end -``` - -Configure a SQL 2019 Express install - -```ruby -sql_server_configure 'SQLEXPRESS' do - version '2019' -end -``` - -Configure a SQL 2012 Evaluation install with a different port - -```ruby -sql_server_configure 'MSSQLSERVER' do - version '2012' - sql_port '1434' -end -``` - -## Attributes - -### default - -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 Express installs) - -### client - -This file also contains download url, checksum and package name for all client installation packages. See the **Usage** section below for more details. - -### server - -- `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. - -### configure - -- `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` - -## Recipe Usage - -We highly recommend writing your own wrapper cookbook utilizing the above resources, but this cookbook also ships with legacy recipes that can be used to install sql_server using recipes/attributes. - -### default - -Includes the `sql_server::client` recipe. - -### client - -Installs required the SQL Server Native Client and all required dependencies. 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. - -### configure - -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. - -### server - -Installs SQL Server 2012 Express, SQL Server 2016 Express, or SQL Server 2019 Express. - -By default, the cookbook installs SQL Server 2012 Express. There are two options to install a different version. - -NOTE: For this recipe to run you must set the following attributes in an environment, role, or wrapper cookbook. - -```ruby -node['sql_server']['agent_account_pwd'] -node['sql_server']['rs_account_pwd'] -node['sql_server']['sql_account_pwd'] -``` - -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 '2012' to install SQL Server 2012 Express, or '2016' to install SQL Server 2016 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). - -```ruby -node['sql_server']['server']['url'] -node['sql_server']['server']['checksum'] -node['sql_server']['server']['package_name'] -``` - -The installation is done using the `package` resource and [ConfigurationFile](http://msdn.microsoft.com/en-us/library/dd239405.aspx) generated from a `template` resource. The installation is slightly opinionated and does the following: - -- Enables [Mixed Mode](http://msdn.microsoft.com/en-us/library/aa905171\(v=sql.80\).aspx) (Windows Authentication and SQL Server Authentication) authentication -- 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: - -```ruby -name "sql_server" -description "SQL Server database master" -run_list( - "recipe[sql_server::server]" -) -default_attributes( - "sql_server" => { - "accept_eula" => true - } -) -``` - -Out of the box this recipe installs the Express edition of SQL Server 2012\. If you would like to install the Standard edition create a role as follows: - -```ruby -name "sql_server_standard" -description "SQL Server Stadard edition database master" -run_list( - "recipe[sql_server::server]" -) -default_attributes( - "sql_server" => { - "instance_name" => "MSSQLSERVER", - "product_key" => "YOUR_PRODUCT_KEY_HERE", - "accept_eula" => true, - "server" => { - "url" => "DOWNLOAD_LOCATION_OF_INSTALLATION_PACKAGE", - "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: - -```ruby -# 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) } -end -``` +- [sql_server_install](documentation/sql_server_install.md) +- [sql_server_configure](documentation/sql_server_configure.md) ## Installing SQL Server remotely diff --git a/attributes/client.rb b/attributes/client.rb deleted file mode 100644 index 805d18a..0000000 --- a/attributes/client.rb +++ /dev/null @@ -1,69 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: sql_server -# Attribute:: client -# -# Copyright:: 2011-2019, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -if node['kernel']['machine'] =~ /x86_64/ - case node['sql_server']['version'] - when '2012' - default['sql_server']['native_client']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/sqlncli.msi' - default['sql_server']['native_client']['checksum'] = '5601a1969d12a72a16e3659712bc9727b3fd874b5f6f802fd1e042cac75cc069' - default['sql_server']['native_client']['package_name'] = 'Microsoft SQL Server 2012 Native Client' - - default['sql_server']['command_line_utils']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/SqlCmdLnUtils.msi' - default['sql_server']['command_line_utils']['checksum'] = '3f5cb4b876421286f8fd9666f00345a95d8ce1b6229baa6aeb2f076ef9e4aefe' - default['sql_server']['command_line_utils']['package_name'] = 'Microsoft SQL Server 2012 Command Line Utilities' - - default['sql_server']['clr_types']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/SQLSysClrTypes.msi' - default['sql_server']['clr_types']['checksum'] = '4b2f86c3f001d6a13db25bf993f8144430db04bde43853b9f2e359aa4bd491d0' - default['sql_server']['clr_types']['package_name'] = 'Microsoft SQL Server System CLR Types (x64)' - - default['sql_server']['smo']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/SharedManagementObjects.msi' - default['sql_server']['smo']['checksum'] = '36d174cd87d5fc432beb4861863d8a7f944b812032727a6e7074a1fcab950faa' - default['sql_server']['smo']['package_name'] = 'Microsoft SQL Server 2012 Management Objects (x64)' - - default['sql_server']['ps_extensions']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/PowerShellTools.MSI' - default['sql_server']['ps_extensions']['checksum'] = 'bb33e64659f7500d7f2088e3d5e7ac34a1bf13988736b8ba0075741fce1e67b6' - default['sql_server']['ps_extensions']['package_name'] = 'Windows PowerShell Extensions for SQL Server 2012' - end - -else - case node['sql_server']['version'] - when '2012' - default['sql_server']['native_client']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x86/sqlncli.msi' - default['sql_server']['native_client']['checksum'] = '9bb7b584ecd2cbe480607c4a51728693b2c99c6bc38fa9213b5b54a13c34b7e2' - default['sql_server']['native_client']['package_name'] = 'Microsoft SQL Server 2012 Native Client' - - default['sql_server']['command_line_utils']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x86/SqlCmdLnUtils.msi' - default['sql_server']['command_line_utils']['checksum'] = '0257292d2b038f012777489c9af51ea75b7bee92efa9c7d56bc25803c9e39801' - default['sql_server']['command_line_utils']['package_name'] = 'Microsoft SQL Server 2012 Command Line Utilities' - - default['sql_server']['clr_types']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x86/SQLSysClrTypes.msi' - default['sql_server']['clr_types']['checksum'] = 'a9cf3e40c9a06dd9e9d0f689f3636ba3f58ec701b9405ba67881a802271bbba1' - default['sql_server']['clr_types']['package_name'] = 'Microsoft SQL Server System CLR Types (x86)' - - default['sql_server']['smo']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x86/SharedManagementObjects.msi' - default['sql_server']['smo']['checksum'] = 'afc0eccb35c979801344b0dc04556c23c8b957f1bdee3530bc1a59d5c704ce64' - default['sql_server']['smo']['package_name'] = 'Microsoft SQL Server 2012 Management Objects (x86)' - - default['sql_server']['ps_extensions']['url'] = 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x86/PowerShellTools.MSI' - default['sql_server']['ps_extensions']['checksum'] = '6a181aeb27b4baec88172c2e80f33ea3419c7e86f6aea0ed1846137bc9144fc6' - default['sql_server']['ps_extensions']['package_name'] = 'Windows PowerShell Extensions for SQL Server 2012' - end - -end diff --git a/attributes/configure.rb b/attributes/configure.rb deleted file mode 100644 index 86b398b..0000000 --- a/attributes/configure.rb +++ /dev/null @@ -1,32 +0,0 @@ -# -# Author:: Baptiste Courtois () -# Cookbook:: sql_server -# Attribute:: configure -# -# Copyright:: 2011-2019, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Tcp settings -default['sql_server']['tcp_enabled'] = true -default['sql_server']['port'] = 1433 # Keep port for backward compatibility -default['sql_server']['tcp_dynamic_ports'] = '' -# Named Pipes settings -default['sql_server']['np_enabled'] = false -# Shared Memory settings -default['sql_server']['sm_enabled'] = true -# Via settings -default['sql_server']['via_default_port'] = '0:1433' -default['sql_server']['via_enabled'] = false -default['sql_server']['via_listen_info'] = '0:1433' diff --git a/attributes/default.rb b/attributes/default.rb deleted file mode 100644 index 0bc4e59..0000000 --- a/attributes/default.rb +++ /dev/null @@ -1,23 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: sql_server -# Attribute:: default -# -# Copyright:: 2011-2019, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -default['sql_server']['accept_eula'] = false -default['sql_server']['product_key'] = nil -default['sql_server']['version'] = '2012' diff --git a/attributes/server.rb b/attributes/server.rb deleted file mode 100644 index 425bbe8..0000000 --- a/attributes/server.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: sql_server -# Attribute:: server -# -# Copyright:: 2011-2019, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -default['sql_server']['install_dir'] = 'C:\Program Files\Microsoft SQL Server' -default['sql_server']['instance_name'] = 'SQLEXPRESS' -default['sql_server']['instance_dir'] = 'C:\Program Files\Microsoft SQL Server' -default['sql_server']['shared_wow_dir'] = 'C:\Program Files (x86)\Microsoft SQL Server' -default['sql_server']['feature_list'] = 'SQLENGINE,REPLICATION,SNAC_SDK' -default['sql_server']['agent_account'] = 'NT AUTHORITY\NETWORK SERVICE' -default['sql_server']['agent_startup'] = 'Disabled' -default['sql_server']['rs_mode'] = 'FilesOnlyMode' -default['sql_server']['rs_account'] = 'NT AUTHORITY\NETWORK SERVICE' -default['sql_server']['rs_startup'] = 'Automatic' -default['sql_server']['browser_startup'] = 'Disabled' -default['sql_server']['sysadmins'] = ['Administrator'] -default['sql_server']['sql_account'] = 'NT AUTHORITY\NETWORK SERVICE' -default['sql_server']['update_enabled'] = true # applies to SQL Server 2012 and later -default['sql_server']['filestream_level'] = 0 -default['sql_server']['filestream_share_name'] = 'MSSQLSERVER' - -default['sql_server']['server']['installer_timeout'] = 1500 - -# Set these to specify the URL, checksum, and package name. Otherwise, the cookbook will -# use default values based on the value of node['sql_server']['version'] and the -# server architecture (x86 or x64). -default['sql_server']['server']['url'] = nil -default['sql_server']['server']['checksum'] = nil -default['sql_server']['server']['package_name'] = nil diff --git a/documentation/sql_server_configure.md b/documentation/sql_server_configure.md new file mode 100644 index 0000000..f827287 --- /dev/null +++ b/documentation/sql_server_configure.md @@ -0,0 +1,51 @@ +# sql_server_configure + +## Actions + +- `:service` - Configures the ports that SQL be listening on and starts and enables the SQL Service. + +## Properties + +- `version` - SQL Version of the instance to be configured. Valid options are `2012`, `2016`, `2017`, `2019`, `2022`. Default is `2012` +- `tcp_enabled` - If TCP is enabled for the instance. Default is true +- `sql_port` - Port SQL will listen on. Default is 1433 +- `tcp_dynamic_ports` - Sets the Dynamic port SQL will listen on. Default is an empty string +- `np_enabled` - Whether named pipes is enabled. Default is false +- `sm_enabled` - Whether shared memory is enabled for the instance +- `via_default_port` - Configures the Virtual Interface Adapter default port. Default is `0:1433` +- `via_enabled` - Whether Virtual Interface Adapter is enabled. Default is false +- `via_listen_info` - Configures the Virtual interface listening information. Default is `0:1433` +- `agent_startup` - Configures the SQL Agent Service startup type. Valid options are `Automatic`, `Manual`, `Disabled`, or `Automatic (Delayed Start)`. Default is `Disabled` + +## Examples + +Configure a SQL 2012 Express install with all the defaults + +```ruby +sql_server_configure 'SQLEXPRESS' +``` + +Configure a SQL 2016 Express install + +```ruby +sql_server_configure 'SQLEXPRESS' do + version '2016' +end +``` + +Configure a SQL 2019 Express install + +```ruby +sql_server_configure 'SQLEXPRESS' do + version '2019' +end +``` + +Configure a SQL 2012 Evaluation install with a different port + +```ruby +sql_server_configure 'MSSQLSERVER' do + version '2012' + sql_port '1434' +end +``` diff --git a/documentation/sql_server_install.md b/documentation/sql_server_install.md new file mode 100644 index 0000000..07c0b4a --- /dev/null +++ b/documentation/sql_server_install.md @@ -0,0 +1,162 @@ +# sql_server_install + +## Actions + +- `:install` - Installs the version of Microsoft SQL server specified. Default install is SQL 2012 Express. + +## Properties + +- `feature` - An Array of the SQL Instance or Server features that are going to be enabled / installed. + +### [SQL 2012 Available Features list](https://technet.microsoft.com/library/cc645993(SQL.110).aspx) + +### Instance Features + +- `SQLENGINE` = Database Engine +- `REPLICATION` = Replication +- `FULLTEXT` = Full-Text and Semantic Extractions for search +- `DQ` = Data Quality Services +- `AS` = Analysis Services +- `RS` = Reporting Services - Native + +### Shared Features + +- `RS_SHP` = Reporting Services - SharePoint +- `RS_SHPWFE` = Reporting Services Add-in for SharePoint Products +- `DQC` = Data Quality Client +- `BIDS` = SQL Server data tools +- `CONN` = Client tools connectivity +- `IS` = Integration Services +- `BC` = Client tools backwards compatibility +- `SDK` = Client tools SDK +- `BOL` = Documentation components +- `SSMS` = Management tools +- `SSMS_ADV` = Management tools - Advanced +- `DREPLAY_CTLR` = Distributed replay controller +- `DREPLAY_CLT` = Distributed replay client +- `SNAC_SDK` = SQL client connectivity SDK + +### [SQL 2016 Available Features list](https://technet.microsoft.com/library/cc645993(SQL.130).aspx) + +- Instance Features + - `ADVANCEDANALYTICS` = R Services (In-Database) + - `POLYBASE` = PolyBase Query Service for External Data + Note: This Feature Requires Java Runtime Environment greater than 7 update 51. Only the standalone Polybase-enabled Instance is currently support by this cookbook. +- Shared Features + - `SQL_SHARED_MR` = R Server (Standalone) + - `MDS` = Master Data Services + - REMOVED for standalone install + - `SSMS` = Management tools + - `SSMS_ADV` = Management tools - Advanced + +### [SQL 2017 Available Features list](https://docs.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2017) + +- Instance Features + - `ADVANCEDANALYTICS` = Machine Learning services (In-Database) + - `SQL_INST_MPY` = Machine Learning services (In-Database) with Python + - `SQL_INST_MR` = Machine Learning services (In-Database) with R +- Shared Features + - `SQL_SHARED_AA` = Machine Learning Services (Standalone) + - `SQL_SHARED_MR` = Machine Learning services (In-Database) with R + - `SQL_SHARED_MPY` = Machine Learning services (In-Database) with Python + - `IS` = Integrated Services + - `IS_MASTER` - Scale Out Master + - `IS_WORKER` - Scale Out Worker + +- `version` - Version of SQL to be installed. Valid otpions are `2012`, `2016`, or `2017`. Default is `2012` +- `source_url` - Source of the SQL setup.exe install file. Default is built from the helper libraries. +- `package_name` - Package name for the SQL install. If you specify a version this property is not necessary. Default is built from the helper libraries. +- `package_checksum` - Package checksum in SHA256 format for the setup.exe file. Default is built from the helper libraries. +- `sql_reboot` - Determines whether the node will be rebooted after the SQL Server installation. Default setting is true +- `security_mode` - The Autentication mode for SQL. Valid options are `Windows Athentication` or `Mixed Mode Authentication`. Default value is `Windows Authentication` +- `sa_password` - The SQL Administrator password when `Mixed Mode Authentication` is being used. SQL enforces a strong passwords for this value. +- `sysadmins` - The list of Systems Administrators who can access the SQL Instance. This can either be a String or an Array. +- `agent_account` - The Service Account that will be used to run the SQL Agent Service. Default is `NT AUTHORITY\SYSTEM`. +- `agent_startup` - The Agent Service startup type. Valid options are `Automatic`, `Manual`, `Disabled`, or `Automatic (Delayed Start)`. Default is `Disabled`. +- `agent_account_pwd` - Agent Service Account password. +- `sql_account` - Service Account used to run the SQL service. Default is `NT AUTHORITY\NETWORK SERVICE` +- `sql_account_pwd` - Service Account password for the SQL service account. +- `browser_startup` - Service startup type for the SQL Browser Service. Valid options are `Automatic`, `Manual`, `Disabled`, or `Automatic (Delayed Start)`. Default is `Disabled`. +- `installer_timeout` - Time out for the SQL installation. Default is `1500` +- `accept_eula` - Whether or not to accept the end user license agreement. Default is `false` + Note: For SQL 2016 if this will also accept the license for using R if `ADVANCEDANALYTICS` or `SQL_SHARED_MR` is listed in the feature property array. +- `product_key` - Product key for not Express or Evaluation versions. +- `update_enabled` - Whether or not to download updates during install. Default is true. +- `update_source` - The Source Location of Windows Update or WSUS. Default is `MU`. Example = `c:/path/to/update` +- `instance_name` - Name for the instance to be installed. Default is `SQLEXPRESS`. For non-express installs that want the default install it should be set to `MSSQLSERVER`. +- `install_dir` - Directory SQL binaries will be installed to. Default is `C:\Program Files\Microsoft SQL Server` +- `instance_dir` - Directory the Instance will be stored. Default is `C:\Program Files\Microsoft SQL Server` +- `sql_data_dir` - Directory for SQL data +- `sql_backup_dir` - Directory for backups +- `sql_instant_file_init` - Enable instant file initialization for SQL Server service account. Default is `false` +- `sql_user_db_dir` - Directory for the user database +- `sql_user_db_log_dir` - Directory for the user database logs +- `sql_temp_db_dir` - Directory for the temporary database +- `sql_temp_db_log_dir` - Directory for the temporary database logs +- `sql_temp_db_file_count` - Number of TempDB data files. Default is 8 or number of cores, whichever is lower. +- `sql_temp_db_file_size` - Initial size of each TempDB data file in MB. Default is 8. +- `sql_temp_db_file_growth` - Automatic growth increment for each TempDB data file in MB. Default is 64. +- `sql_temp_db_log_file_size` - Initial size of the TempDB log file in MB. Default is 8. +- `sql_temp_db_log_file_growth` - Automatic growth increment for the TempDB log file in MB. Default is 64. +- `filestream_level` - Level to enable the filestream feature, Valid values are 0, 1, 2 or 3. Default is 0 +- `filestream_share_name` - Share name for the filestream feature. Default is `MSSQLSERVER` +- `sql_collation` - SQL Collation type for the instance +- `netfx35_install` - If the .Net 3.5 Windows Feature is installed. This is required to successfully install SQL 2012. Default is true. +- `netfx35_source` - Source location for the .Net 3.5 Windows Features install. Only required for offline installs + +### Distributed Replay + +- `dreplay_ctlr_admins` - List of admins for the Distributed Replay Controller. Default is `Administrator`. The `DREPLAY_CTLR` feature needs to be included in the feature Array for this property to work. +- `dreplay_client_name` - Host name of the Distributed Replay Controller that the Client will point to. If the `DREPLAY_CLT` is in the feature list this property needs to be set. + +### Reporting Services + +- `rs_account` - Service Account name used to run SQL Reporting Services. To have reporting services it needs to be listed in the `feature` property array. +- `rs_account_pwd` - Service Account password for the Reporting Services Service +- `rs_startup` - Reporting Services service startup type. Valid options are `Automatic`, `Manual`, `Disabled`, or `Automatic (Delayed Start)`. Default is `Automatic`. +- `rs_mode` - Mode the Reporting Services is installed in. Default is `FilesOnlyMode` + +### Analysis Services + +- `as_sysadmins` - Analysis Services Systems Administrator list. Default is `Administrator` +- `as_svc_account` - Service Account used by Analysis Services. Default is `NT Service\MSSQLServerOLAPService` + +### PolyBase Query Services + +- `polybase_port_range` - Port Range for the PolyBase Query Service. Default is `16450-16460`. + +### Integrated Services + +- `is_master_port` - Port for the Integrated Services Scale out Master. Default is 8391. +- `is_master_ssl_cert` - The CNs in the certificate used to protect communications between the integration services scale out worker and scale out master. +- `is_master_cert_thumbprint` - The certificate thumbprint for the scale out master ssl certificate. +- `is_worker_master_url` - The url of the scale out master when installing a scale out worker. + +## Examples + +Install SQL 2012 Express with all the defaults + +```ruby +sql_server_install 'Install SQL 2012 Express' +``` + +Install SQL 2016 Express + +```ruby +sql_server_install 'Install SQL 2016 Express' do + version '2016' +end +``` + +Install SQL 2012 Evaluation from a local source with default instance name, Integrated Services, Reporting Services, and the SQL Management Tools. + +```ruby +sql_server_install 'Install SQL Server 2012 Evaluation' do + source_url 'C:\\Sources\\SQL 2012 Eval\\setup.exe' + version '2012' + package_checksum '0FE903...420E8F' + accept_eula true + instance_name 'MSSQLSERVER' + feature %w(SQLENGINE IS RS SSMS ADV_SSMS) +end +``` diff --git a/kitchen.yml b/kitchen.yml index a4c5c3c..c6af12e 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -15,32 +15,23 @@ provisioner: deprecations_as_errors: true chef_license: accept-no-persist retry_on_exit_code: - - 35 # 35 is the exit code signaling that the node is rebooting + - 35 # 35 is the exit code signaling that the node is rebooting max_retries: 5 wait_for_retry: 90 verifier: name: inspec - inspec_tests: - - path: test/integration/inspec platforms: - - name: windows-2012r2 - driver: - box: tas50/windows_2012r2 - - name: windows-2016 - driver: - box: tas50/windows_2016 - name: windows-2019 driver: box: tas50/windows_2019 - - name: windows-2012r2-chef-13.0 - driver_config: - box: tas50/windows_2012r2 - provisioner: - product_version: 13.0 suites: + - name: default + run_list: + - recipe[test::default] + - name: client run_list: - recipe[sql_server::default] diff --git a/libraries/helper.rb b/libraries/helper.rb index 39610d0..4d71544 100644 --- a/libraries/helper.rb +++ b/libraries/helper.rb @@ -30,6 +30,7 @@ def self.reg_version_string(version) when '2016' then 'MSSQL13.' when '2017' then 'MSSQL14.' when '2019' then 'MSSQL15.' + when '2022' then 'MSSQL16.' else raise "Unsupported sql_server version '#{version}'. Please open a PR to add support for this version." end end @@ -40,6 +41,7 @@ def self.install_dir_version(version) when '2016' then '130' when '2017' then '140' when '2019' then '150' + when '2022' then '160' else raise "SQL Server version #{version} not supported. Please open a PR to add support for this version." end end @@ -56,6 +58,7 @@ def self.sql_server_url(version, x86_64) when '2016' then 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLEXPR_x64_ENU.exe' when '2017' then 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLEXPR_x64_ENU.exe' when '2019' then 'https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPR_x64_ENU.exe' + when '2022' then 'https://download.microsoft.com/download/5/1/4/5145fe04-4d30-4b85-b0d1-39533663a2f1/SQL2022-SSEI-Expr.exe' end else case version.to_s @@ -71,6 +74,7 @@ def self.sql_server_package_name(version, x86_64) when '2016' then 'Microsoft SQL Server 2016 (64-bit)' when '2017' then 'Microsoft SQL Server 2017 (64-bit)' when '2019' then 'Microsoft SQL Server 2019 (64-bit)' + when '2022' then 'Microsoft SQL Server 2022 (64-bit)' end else case version.to_s @@ -86,6 +90,7 @@ def self.sql_server_checksum(version, x86_64) when '2016' then '2A5B64AE64A8285C024870EC4643617AC5146894DD59DD560E75CEA787BF9333' when '2017' then 'F857FF82145E196BF85AF32EEB0193FE38302E57B30BEB54E513630C60D83E0D' when '2019' then 'bea033e778048748eb1c87bf57597f7f5449b6a15bac55ddc08263c57f7a1ca8' + when '2022' then '36e0ec2ac3dd60f496c99ce44722c629209ea7302a2ce9cbfd1e42a73510d7b6' end else case version.to_s diff --git a/recipes/client.rb b/recipes/client.rb deleted file mode 100644 index c5b6d36..0000000 --- a/recipes/client.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: sql_server -# Recipe:: client -# -# Copyright:: 2011-2019, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -%w( native_client command_line_utils clr_types smo ps_extensions ).each do |pkg| - package node['sql_server'][pkg]['package_name'] do - source node['sql_server'][pkg]['url'] - checksum node['sql_server'][pkg]['checksum'] - installer_type :msi - options "IACCEPTSQLNCLILICENSETERMS=#{node['sql_server']['accept_eula'] ? 'YES' : 'NO'}" - action :install - end -end diff --git a/recipes/configure.rb b/recipes/configure.rb deleted file mode 100644 index 78e6db6..0000000 --- a/recipes/configure.rb +++ /dev/null @@ -1,78 +0,0 @@ -# -# Author:: Baptiste Courtois () -# Cookbook:: sql_server -# Recipe:: configure -# -# Copyright:: 2011-2019, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -instance = node['sql_server']['instance_name'] - -# Compute service name based on sql server instance name -service_name = (instance != 'MSSQLSERVER') ? "MSSQL$#{instance}" : instance - -# Agent name needs to be declared because if you use the SQL Agent, you need -# to restart both services as the Agent is dependent on the SQL Service -agent_service_name = (instance == 'MSSQLSERVER') ? 'SQLSERVERAGENT' : "SQLAgent$#{instance}" - -# Compute registry version based on sql server version -reg_version = node['sql_server']['reg_version'] || ::SqlServer::Helper.reg_version_string(node['sql_server']['version']) - -reg_prefix = "HKLM\\SOFTWARE\\Microsoft\\Microsoft SQL Server\\#{reg_version}#{instance}\\MSSQLServer" - -# Configure Tcp settings - static tcp ports -registry_key "#{reg_prefix}\\SuperSocketNetLib\\Tcp\\IPAll" do - values [{ name: 'Enabled', type: :dword, data: node['sql_server']['tcp_enabled'] ? 1 : 0 }, - { name: 'TcpPort', type: :string, data: node['sql_server']['port'].to_s }, - { name: 'TcpDynamicPorts', type: :string, data: node['sql_server']['tcp_dynamic_ports'].to_s }] - recursive true - notifies :restart, "service[#{service_name}]", :immediately -end - -# Configure Named Pipes settings -registry_key "#{reg_prefix}\\SuperSocketNetLib\\Np" do - values [{ name: 'Enabled', type: :dword, data: node['sql_server']['np_enabled'] ? 1 : 0 }] - recursive true - notifies :restart, "service[#{service_name}]", :immediately -end - -# Configure Shared Memory settings -registry_key "#{reg_prefix}\\SuperSocketNetLib\\Sm" do - values [{ name: 'Enabled', type: :dword, data: node['sql_server']['sm_enabled'] ? 1 : 0 }] - recursive true - notifies :restart, "service[#{service_name}]", :immediately -end - -# Configure Via settings -registry_key "#{reg_prefix}\\SuperSocketNetLib\\Via" do - values [{ name: 'DefaultServerPort', type: :string, data: node['sql_server']['via_default_port'].to_s }, - { name: 'Enabled', type: :dword, data: node['sql_server']['via_enabled'] ? 1 : 0 }, - { name: 'ListenInfo', type: :string, data: node['sql_server']['via_listen_info'].to_s }] - recursive true - notifies :restart, "service[#{service_name}]", :immediately -end - -# If you have declared an agent account it will restart both the -# agent service and the sql service. If not only the sql service -if node['sql_server']['agent_startup'] == 'Automatic' - service agent_service_name do - action [:start, :enable] - end -end - -service service_name do - action [:start, :enable] - restart_command %(powershell.exe -C "restart-service '#{service_name}' -force") -end diff --git a/recipes/default.rb b/recipes/default.rb deleted file mode 100644 index e436ef2..0000000 --- a/recipes/default.rb +++ /dev/null @@ -1,21 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: sql_server -# Recipe:: default -# -# Copyright:: 2011-2019, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -include_recipe 'sql_server::client' diff --git a/recipes/server.rb b/recipes/server.rb deleted file mode 100644 index 79e2a96..0000000 --- a/recipes/server.rb +++ /dev/null @@ -1,86 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: sql_server -# Recipe:: server -# -# Copyright:: 2011-2019, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -raise("node['sql_server']['server_sa_password'] must be set for this cookbook to run") if node['sql_server']['server_sa_password'].nil? - -config_file_path = Chef::Util::PathHelper.cleanpath(File.join(Chef::Config[:file_cache_path], 'ConfigurationFile.ini')) - -sql_sys_admin_list = if node['sql_server']['sysadmins'].is_a? Array - node['sql_server']['sysadmins'].map { |account| %("#{account}") }.join(' ') # surround each in quotes, space delimit list - else - %("#{node['sql_server']['sysadmins']}") # surround in quotes - end - -template config_file_path do - source 'ConfigurationFile.ini.erb' - variables( - sqlSysAdminList: sql_sys_admin_list - ) -end - -version = node['sql_server']['version'] -x86_64 = node['kernel']['machine'] =~ /x86_64/ - -package_url = node['sql_server']['server']['url'] || - SqlServer::Helper.sql_server_url(version, x86_64) || - raise("No package URL matches '#{version}'. node['sql_server']['server']['url'] must be set or node['sql_server']['version'] must match a supported version.") - -package_name = node['sql_server']['server']['package_name'] || - SqlServer::Helper.sql_server_package_name(version, x86_64) || - raise("No package name matches '#{version}'. node['sql_server']['server']['package_name'] must be set or node['sql_server']['version'] must match a supported version.") - -package_checksum = node['sql_server']['server']['checksum'] || - SqlServer::Helper.sql_server_checksum(version, x86_64) || - raise("No package checksum matches '#{version}'. node['sql_server']['server']['checksum'] must be set or node['sql_server']['version'] must match a supported version.") - -# Build safe password command line options for the installer -# see http://technet.microsoft.com/library/ms144259 -passwords_options = { - AGTSVCPASSWORD: node['sql_server']['agent_account_pwd'], - RSSVCPASSWORD: node['sql_server']['rs_account_pwd'], - SQLSVCPASSWORD: node['sql_server']['sql_account_pwd'], -}.map do |option, attribute| - next unless attribute - # Escape password double quotes and backslashes - safe_password = attribute.gsub(/["\\]/, '\\\\\0') - # When the number of double quotes is odd, we need to escape the enclosing quotes - enclosing_escape = safe_password.count('"').odd? ? '^' : '' - "/#{option}=\"#{safe_password}#{enclosing_escape}\"" -end.compact.join ' ' - -package package_name do - source package_url - checksum package_checksum - timeout node['sql_server']['server']['installer_timeout'] - installer_type :custom - options "/q /ConfigurationFile=#{config_file_path} #{passwords_options}" - action :install - notifies :request_reboot, 'reboot[sql server install]' - returns [0, 42, 127, 3010] -end - -# SQL Server requires a reboot to complete your install -reboot 'sql server install' do - action :nothing - reason 'Needs to reboot after installing SQL Server' - only_if { reboot_pending? } -end - -include_recipe 'sql_server::configure' diff --git a/resources/client_install.rb b/resources/client_install.rb new file mode 100644 index 0000000..8415538 --- /dev/null +++ b/resources/client_install.rb @@ -0,0 +1,56 @@ +unified_mode true + +property :native_client, + Hash, + default: { + url: 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/sqlncli.msi', + checksum: '5601a1969d12a72a16e3659712bc9727b3fd874b5f6f802fd1e042cac75cc069', + package_name: 'Microsoft SQL Server 2012 Native Client', + } + +property :command_line_utils, + Hash, + default: { + url: 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/SqlCmdLnUtils.msi', + checksum: '3f5cb4b876421286f8fd9666f00345a95d8ce1b6229baa6aeb2f076ef9e4aefe', + package_name: 'Microsoft SQL Server 2012 Command Line Utilities', + } + +property :clr_types, + Hash, + default: { + url: 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/SQLSysClrTypes.msi', + checksum: '4b2f86c3f001d6a13db25bf993f8144430db04bde43853b9f2e359aa4bd491d0', + package_name: 'Microsoft SQL Server System CLR Types (x64)', + } + +property :smo, + Hash, + default: { + url: 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/SharedManagementObjects.msi', + checksum: '36d174cd87d5fc432beb4861863d8a7f944b812032727a6e7074a1fcab950faa', + package_name: 'Microsoft SQL Server 2012 Management Objects (x64)', + } + +property :ps_extensions, + Hash, + default: { + url: 'http://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/PowerShellTools.MSI', + checksum: 'bb33e64659f7500d7f2088e3d5e7ac34a1bf13988736b8ba0075741fce1e67b6', + package_name: 'Windows PowerShell Extensions for SQL Server 2012', + } + +property :accept_eula, [true, false], default: false + +action :install do + %w( native_client command_line_utils clr_types smo ps_extensions ).each do |_pkg| + package new_resource.pkg do + source new_resource.pkg[:source] + url new_resource.pkg[:url] + checksum new_resource.pkg[:checksum] + installer_type :msi + options "IACCEPTSQLNCLILICENSETERMS=#{new_resource.accept_eula ? 'YES' : 'NO'}" + action :install + end + end +end diff --git a/resources/install.rb b/resources/install.rb index 943fca7..c6ff2d3 100644 --- a/resources/install.rb +++ b/resources/install.rb @@ -33,7 +33,7 @@ property :sql_account, String, default: 'NT AUTHORITY\NETWORK SERVICE' property :sql_account_pwd, String property :browser_startup, String, equal_to: ['Automatic', 'Manual', 'Disabled', 'Automatic (Delayed Start)'], default: 'Disabled' -property :version, [Integer, String], default: '2012' +property :version, [Integer, String], default: '2022' property :source_url, String property :package_name, String property :package_checksum, String @@ -43,7 +43,7 @@ property :update_enabled, [true, false], default: true property :update_source, String, default: 'MU' property :instance_name, String, default: 'SQLEXPRESS' -property :feature, [Array, String], default: %w(SQLENGINE REPLICATION SNAC_SDK) +property :feature, [Array, String], default: %w(SQLENGINE REPLICATION) property :install_dir, String, default: 'C:\Program Files\Microsoft SQL Server' property :instance_dir, String, default: 'C:\Program Files\Microsoft SQL Server' property :shared_wow_dir, String, default: lazy { install_dir.gsub(/Program Files/, 'Program Files (x86)') } @@ -99,7 +99,7 @@ dreplay_ctlr_admin_list = build_admin_list(new_resource.dreplay_ctlr_admins) template config_file_path do - source '_ConfigurationFile.ini.erb' + source 'ConfigurationFile.ini.erb' cookbook 'sql_server' variables( sqlSysAdminList: sql_sys_admin_list, diff --git a/spec/unit/recipes/install_spec.rb b/spec/unit/recipes/install_spec.rb deleted file mode 100644 index fefd9e3..0000000 --- a/spec/unit/recipes/install_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -# -# Cookbook:: test -# Spec:: install -# -# Copyright:: 2015-2019, John Snow, All Rights Reserved. - -require 'spec_helper' - -describe 'test::install' do - context 'When all attributes are default on Windows 2012R2, it should converge successfully' do - let(:chef_run) do - runner = ChefSpec::SoloRunner.new(platform: 'windows', version: '2012R2', step_into: ['sql_server_install']) do |node| - node.normal['sql_server']['server_sa_password'] = 'supersecret' - end - runner.converge(described_recipe) - end - - it 'converges successfully' do - chef_run - end - end - - context 'When specifying an Array for admin users for "sysadmins"' do - let(:chef_run) do - runner = ChefSpec::SoloRunner.new(platform: 'windows', version: '2012R2', step_into: ['sql_server_install'], file_cache_path: 'C:/chef/cache') do |node| - node.normal['sql_server']['sysadmins'] = %w(Administrator Fred Barney) - node.normal['sql_server']['server_sa_password'] = 'supersecret' - end - runner.converge(described_recipe) - end - - # Ignore as it requires a lot of mocking to get the template to render - # it 'creates the correct ConfigurationFile.ini template' do - # expect(chef_run).to create_template('C:/chef/cache/ConfigurationFile.ini') - # expect(chef_run).to render_file('C:/chef/cache/ConfigurationFile.ini').with_content(/^SQLSYSADMINACCOUNTS="Administrator" "Fred" "Barney"/) - # end - - it 'converges successfully' do - chef_run - end - end - - context 'When specifying a String for "sysadmins"' do - let(:chef_run) do - runner = ChefSpec::SoloRunner.new(platform: 'windows', version: '2012', step_into: ['sql_server_install'], file_cache_path: 'C:/chef/cache') do |node| - node.normal['sql_server']['sysadmins'] = 'Administrator' - node.normal['sql_server']['server_sa_password'] = 'supersecure' - end - runner.converge(described_recipe) - end - - # Ignore as it requires a lot of mocking to get the template to render - # it 'creates the correct ConfigurationFile.ini template' do - # expect(chef_run).to create_template('C:/chef/cache/ConfigurationFile.ini') - # expect(chef_run).to render_file('C:/chef/cache/ConfigurationFile.ini').with_content(/^SQLSYSADMINACCOUNTS="Administrator"/) - # end - - it 'converges successfully' do - chef_run # This should not raise an error - end - end -end diff --git a/spec/unit/recipes/server_spec.rb b/spec/unit/recipes/server_spec.rb deleted file mode 100644 index bdb5701..0000000 --- a/spec/unit/recipes/server_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -# -# Cookbook:: sql_server -# Spec:: server -# -# Copyright:: 2015-2019, Irving Popovetsky, All Rights Reserved. - -require 'spec_helper' - -describe 'sql_server::server' do - context 'When all attributes are default, on Windows 2012, it should converge successfully' do - let(:chef_run) do - runner = ChefSpec::SoloRunner.new(platform: 'windows', version: '2012') do |node| - node.normal['sql_server']['server_sa_password'] = 'supersecure' - end - runner.converge(described_recipe) - end - - it 'converges successfully' do - chef_run # This should not raise an error - end - end - - context 'When specifying an Array of admin users for "sysadmins"' do - let(:chef_run) do - runner = ChefSpec::SoloRunner.new(platform: 'windows', version: '2012', file_cache_path: 'C:/chef/cache') do |node| - node.normal['sql_server']['sysadmins'] = %w(Administrator Fred Barney) - node.normal['sql_server']['server_sa_password'] = 'supersecure' - end - runner.converge(described_recipe) - end - - # Ignore as it requires a lot of mocking to get the template to render - # it 'creates the correct ConfigurationFile.ini template' do - # expect(chef_run).to create_template('C:\chef\cache\ConfigurationFile.ini') - # expect(chef_run).to render_file('C:\chef\cache\ConfigurationFile.ini').with_content(/^SQLSYSADMINACCOUNTS="Administrator" "Fred" "Barney"/) - # end - - it 'converges successfully' do - chef_run # This should not raise an error - end - end - - context 'When specifying a String for "sysadmins"' do - let(:chef_run) do - runner = ChefSpec::SoloRunner.new(platform: 'windows', version: '2012', file_cache_path: 'C:/chef/cache') do |node| - node.normal['sql_server']['sysadmins'] = 'Administrator' - node.normal['sql_server']['server_sa_password'] = 'supersecure' - end - runner.converge(described_recipe) - end - - # Ignore as it requires a lot of mocking to get the template to render - # it 'creates the correct ConfigurationFile.ini template' do - # expect(chef_run).to create_template('C:\chef\cache\ConfigurationFile.ini') - # expect(chef_run).to render_file('C:\chef\cache\ConfigurationFile.ini').with_content(/^SQLSYSADMINACCOUNTS="Administrator"/) - # end - - it 'converges successfully' do - chef_run # This should not raise an error - end - end -end diff --git a/templates/ConfigurationFile.ini.erb b/templates/ConfigurationFile.ini.erb index 190cb02..b03b769 100644 --- a/templates/ConfigurationFile.ini.erb +++ b/templates/ConfigurationFile.ini.erb @@ -1,28 +1,34 @@ -; SQLSERVER<%= node['sql_server']['version'] %> Configuration File -; Generated by Chef Software Chef +; SQLSERVER<%= @version %> Configuration File +; Generated by Chef for <%= node['fqdn'] %> [OPTIONS] ; Auto accept the license terms -IACCEPTSQLSERVERLICENSETERMS="<%= node['sql_server']['accept_eula'] ? "True" : "False" %>" +IACCEPTSQLSERVERLICENSETERMS="<%= @accept_eula ? "True" : "False" %>" -<% unless (node['sql_server']['product_key'].nil? || node['sql_server']['product_key'].empty?) -%> +<% unless (@product_key.nil? || @product_key.empty?) -%> ; Product Key -PID="<%= node['sql_server']['product_key'] %>" +PID="<%= @product_key %>" <% end -%> ; The default is Windows Authentication. Use "SQL" for Mixed Mode Authentication. +<% unless @security_mode == 'Windows Authentication'%> SECURITYMODE="SQL" -SAPWD="<%= node['sql_server']['server_sa_password'] %>" +SAPWD="<%= @sa_password %>" +<% end %> ; Specify whether SQL Server Setup should discover and include product updates. The valid values are True and False or 1 and 0. By default SQL Server Setup will include updates that are found. -UpdateEnabled="<%= node['sql_server']['update_enabled'] ? "True" : "False" %>" +UpdateEnabled="<%= @update_enabled ? "True" : "False" %>" + +; Specify the location where SQL Server Setup will obtain product updates. The valid values are "MU" to search Microsoft Update, a valid folder path, a relative path such as .\MyUpdates or a UNC share. By default SQL Server Setup will search Microsoft Update or a Windows Update service through the Window Server Update Services. + +UpdateSource= "<%= @update_source %>" ; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will reflect the instance ID of the SQL Server instance. -INSTANCEID="<%= node['sql_server']['instance_name'] %>" +INSTANCEID="<%= @instance_name %>" ; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter. @@ -30,7 +36,11 @@ ACTION="Install" ; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, and Tools. The SQL feature will install the database engine, replication, and full-text. The Tools feature will install Management Tools, Books online, Business Intelligence Development Studio, and other shared components. -FEATURES=<%= node['sql_server']['feature_list'] %> +<% if @feature_list.is_a? Array %> +FEATURES=<%= %("#{@feature_list.join(',')}") %> +<% else %> +FEATURES=<%= %("#{@feature_list}") %> +<% end %> ; Displays the command line parameters usage @@ -48,9 +58,11 @@ QUIET="False" QUIETSIMPLE="False" +<% if @version != '2022' %> ; Specifies that Setup should install into WOW64. This command line argument is not supported on an IA64 or a 32-bit system. X86="False" +<% end%> ; Detailed help for command line argument ROLE has not been defined yet. @@ -70,52 +82,52 @@ ERRORREPORTING="False" ; Specify the root installation directory for native shared components. -INSTALLSHAREDDIR="<%= node['sql_server']['install_dir'] %>" +INSTALLSHAREDDIR="<%= @install_dir %>" <% if node['kernel']['machine'] =~ /x86_64/ %> ; Specify the root installation directory for the WOW64 shared components. -INSTALLSHAREDWOWDIR="<%= node['sql_server']['shared_wow_dir'] %>" +INSTALLSHAREDWOWDIR="<%= @shared_wow_dir %>" <% end %> ; Specify the installation directory. -INSTANCEDIR="<%= node['sql_server']['instance_dir'] %>" -<% unless node['sql_server']['sql_data_dir'].nil? -%> +INSTANCEDIR="<%= @instance_dir %>" +<% unless @sql_data_dir.nil? -%> ; The Database Engine root data directory. -INSTALLSQLDATADIR="<%= node['sql_server']['sql_data_dir'] %>" +INSTALLSQLDATADIR="<%= @sql_data_dir %>" <% end -%> -<% unless node['sql_server']['sql_backup_dir'].nil? -%> +<% unless @sql_backup_dir.nil? -%> ; Default directory for SQL backup files. -SQLBACKUPDIR="<%= node['sql_server']['sql_backup_dir'] %>" +SQLBACKUPDIR="<%= @sql_backup_dir %>" <% end -%> -<% unless node['sql_server']['sql_user_db_dir'].nil? -%> +<% unless @sql_user_db_dir.nil? -%> ; Default directory for the Database Engine user databases. -SQLUSERDBDIR="<%= node['sql_server']['sql_user_db_dir'] %>" +SQLUSERDBDIR="<%= @sql_user_db_dir %>" <% end -%> -<% unless node['sql_server']['sql_user_db_log_dir'].nil? -%> +<% unless @sql_user_db_log_dir.nil? -%> ; Default directory for the Database Engine user database logs. -SQLUSERDBLOGDIR="<%= node['sql_server']['sql_user_db_log_dir'] %>" +SQLUSERDBLOGDIR="<%= @sql_user_db_log_dir %>" <% end -%> -<% unless node['sql_server']['sql_temp_db_dir'].nil? -%> +<% unless @sql_temp_db_dir.nil? -%> ; Directory for Database Engine TempDB files. -SQLTEMPDBDIR="<%= node['sql_server']['sql_temp_db_dir'] %>" +SQLTEMPDBDIR="<%= @sql_temp_db_dir %>" <% end -%> -<% unless node['sql_server']['sql_temp_db_log_dir'].nil? -%> +<% unless @sql_temp_db_log_dir.nil? -%> ; Directory for Database Engine TempDB log files. -SQLTEMPDBLOGDIR="<%= node['sql_server']['sql_temp_db_log_dir'] %>" +SQLTEMPDBLOGDIR="<%= @sql_temp_db_log_dir %>" <% end -%> ; Specify that SQL Server feature usage data can be collected and sent to Microsoft. Specify 1 or True to enable and 0 or False to disable this feature. @@ -124,16 +136,17 @@ SQMREPORTING="False" ; Specify a default or named instance. MSSQLSERVER is the default instance for non-Express editions and SQLExpress for Express editions. This parameter is required when installing the SQL Server Database Engine (SQL), Analysis Services (AS), or Reporting Services (RS). -INSTANCENAME="<%= node['sql_server']['instance_name'] %>" +INSTANCENAME="<%= @instance_name %>" ; Agent account name -AGTSVCACCOUNT="<%= node['sql_server']['agent_account'] %>" +AGTSVCACCOUNT="<%= @agent_account %>" ; Auto-start service after installation. -AGTSVCSTARTUPTYPE="<%= node['sql_server']['agent_startup'] %>" +AGTSVCSTARTUPTYPE="<%= @agent_startup %>" +<% if @feature_list.include?('IS')%> ; Startup type for Integration Services. ISSVCSTARTUPTYPE="Automatic" @@ -141,6 +154,92 @@ ISSVCSTARTUPTYPE="Automatic" ; Account for Integration Services: Domain\User or system account. ISSVCACCOUNT="NT AUTHORITY\NetworkService" +<% end %> + +; A port number used to connect to the SharePoint Central Administration web application. +; The setting 'FARMADMINIPORT' specified is not recognized. +; FARMADMINIPORT="0" + +; Startup type for the SQL Server service. + +SQLSVCSTARTUPTYPE="Automatic" + +; Level to enable FILESTREAM feature at (0, 1, 2 or 3). + +FILESTREAMLEVEL="<%= @filestream_level %>" + +; Name of Windows share to be created for FILESTREAM File I/O. + +FILESTREAMSHARENAME="<%= @filestream_share_name %>" + +; Set to "1" to enable RANU for SQL Server Express. + +ENABLERANU="<%= @instance_name == 'SQLEXPRESS' ? "True" : "False" %>" + +; Specifies a Windows collation or an SQL collation to use for the Database Engine. + +SQLCOLLATION="<%= @sql_collation || 'SQL_Latin1_General_CP1_CI_AS' %>" + +; Account for SQL Server service: Domain\User or system account. + +SQLSVCACCOUNT="<%= @sql_account %>" + +; Windows account(s) to provision as SQL Server system administrators. + +SQLSYSADMINACCOUNTS=<%= @sqlSysAdminList %> + +; Provision current user as a Database Engine system administrator for SQL Server 2008 R2 Express. + +ADDCURRENTUSERASSQLADMIN="<%= @instance_name == 'SQLEXPRESS' ? 'True' : 'False' %>" + +; Specify 0 to disable or 1 to enable the TCP/IP protocol. + +TCPENABLED="1" + +; Specify 0 to disable or 1 to enable the Named Pipes protocol. + +NPENABLED="0" + +; Startup type for Browser Service. + +BROWSERSVCSTARTUPTYPE="<%= @browser_startup %>" + +<% if @feature_list.include?('RS')%> +; Specifies which account the report server NT service should execute under. When omitted or when the value is empty string, the default built-in account for the current operating system. +; The username part of RSSVCACCOUNT is a maximum of 20 characters long and +; The domain part of RSSVCACCOUNT is a maximum of 254 characters long. + +RSSVCACCOUNT="<%= @rs_account %>" + +; Specifies how the startup mode of the report server NT service. When +; Manual - Service startup is manual mode (default). +; Automatic - Service startup is automatic mode. +; Disabled - Service is disabled + +RSSVCSTARTUPTYPE="<%= @rs_startup %>" + +; Specifies which mode report server is installed in. +; Default value: "FilesOnly" + +RSINSTALLMODE="<%= @rs_mode %>" +<% end %> + +<% if @feature_list.include?('FULLTEXT')%> +; Add description of input arguemtn FTSVCACCOUNT + +FTSVCACCOUNT="NT Service\MSSQLFDLauncher" +<% end %> + +<% if @feature_list.include?('RS_SHP') %> +; RSInputSettings_RSInstallMode_Description + +RSSHPINSTALLMODE="SharePointFilesOnlyMode" +<% end %> + +<% if @feature_list.include?('AS')%> +; The name of the account that the Analysis Services service runs under. + +ASSVCACCOUNT=<%= @as_svc_account %> ; Controls the service startup type setting after the service has been created. @@ -174,68 +273,172 @@ ASCONFIGDIR="Config" ASPROVIDERMSOLAP="1" -; A port number used to connect to the SharePoint Central Administration web application. -; The setting 'FARMADMINIPORT' specified is not recognized. -; FARMADMINIPORT="0" +; Specifies whether or not the MSOLAP provider is allowed to run in process. -; Startup type for the SQL Server service. +ASPROVIDERMSOLAP="1" -SQLSVCSTARTUPTYPE="Automatic" +; Specifies the list of administrator accounts that need to be provisioned. -; Level to enable FILESTREAM feature at (0, 1, 2 or 3). +ASSYSADMINACCOUNTS=<%= @asSysAdminList %> -FILESTREAMLEVEL="<%= node['sql_server']['filestream_level'] %>" +; Specifies the server mode of the Analysis Services instance. Valid values are MULTIDIMENSIONAL and TABULAR. The default value is MULTIDIMENSIONAL. -; Name of Windows share to be created for FILESTREAM File I/O. +ASSERVERMODE="MULTIDIMENSIONAL" +<% end %> -FILESTREAMSHARENAME="<%= node['sql_server']['filestream_share_name'] %>" +<% if @feature_list.include?('DREPLAY_CTLR')%> +; The Windows account(s) used to grant permission to the Distributed Replay Controller service. -; Set to "1" to enable RANU for SQL Server Express. +CTLRUSERS=<%= @dreplayCtlrList %> -ENABLERANU="<%= node['sql_server']['instance_name'] == 'SQLEXPRESS' ? "True" : "False" %>" +; The account used by the Distributed Replay Controller service. -; Specifies a Windows collation or an SQL collation to use for the Database Engine. +CTLRSVCACCOUNT="NT Service\SQL Server Distributed Replay Controller" -SQLCOLLATION="<%= node['sql_server']['sql_collation'] || 'SQL_Latin1_General_CP1_CI_AS' %>" +; The startup type for the Distributed Replay Controller service. -; Account for SQL Server service: Domain\User or system account. +CTLRSTARTUPTYPE="Manual" +<% end %> -SQLSVCACCOUNT="<%= node['sql_server']['sql_account'] %>" +<% if @feature_list.include?('DREPLAY_CLT')%> +; The computer name that the client communicates with for the Distributed Replay Controller service. -; Windows account(s) to provision as SQL Server system administrators. +CLTCTLRNAME="<%= @dreplay_client_name %>" -SQLSYSADMINACCOUNTS=<%= @sqlSysAdminList %> +; The account used by the Distributed Replay Client service. -; Provision current user as a Database Engine system administrator for SQL Server 2008 R2 Express. +CLTSVCACCOUNT="NT Service\SQL Server Distributed Replay Client" -ADDCURRENTUSERASSQLADMIN="<%= node['sql_server']['instance_name'] == 'SQLEXPRESS' ? 'True' : 'False' %>" +; The startup type for the Distributed Replay Client service. -; Specify 0 to disable or 1 to enable the TCP/IP protocol. +CLTSTARTUPTYPE="Manual" -TCPENABLED="1" +; The result directory for the Distributed Replay Client service. -; Specify 0 to disable or 1 to enable the Named Pipes protocol. +CLTRESULTDIR="ResultDir" -NPENABLED="0" +; The working directory for the Distributed Replay Client service. -; Startup type for Browser Service. +CLTWORKINGDIR="WorkingDir" +<% end %> -BROWSERSVCSTARTUPTYPE="<%= node['sql_server']['browser_startup'] %>" +<% if @version == '2016' %> +<% if @feature_list.include?('ADVANCEDANALYTICS' || 'SQL_SHARED_MR') %> +IACCEPTROPENLICENSETERMS=<%= @accept_eula %> -; Specifies which account the report server NT service should execute under. When omitted or when the value is empty string, the default built-in account for the current operating system. -; The username part of RSSVCACCOUNT is a maximum of 20 characters long and -; The domain part of RSSVCACCOUNT is a maximum of 254 characters long. +EXTSVCACCOUNT="NT Service\MSSQLLaunchpad" +<% end %> +<% end %> -RSSVCACCOUNT="<%= node['sql_server']['rs_account'] %>" +<% if %w(2016 2017 2019 2022).include? @version %> +; Enables instant file initialization for SQL Server service account. +SQLSVCINSTANTFILEINIT="<%= @sql_instant_file_init ? "True" : "False" %>" -; Specifies how the startup mode of the report server NT service. When -; Manual - Service startup is manual mode (default). -; Automatic - Service startup is automatic mode. -; Disabled - Service is disabled +<% unless @sql_temp_db_file_count.nil? -%> +; The number of Database Engine TempDB files -RSSVCSTARTUPTYPE="<%= node['sql_server']['rs_startup'] %>" +SQLTEMPDBFILECOUNT="<%= @sql_temp_db_file_count %>" +<% end %> -; Specifies which mode report server is installed in. -; Default value: "FilesOnly" +<% unless @sql_temp_db_file_size.nil? -%> +; Specifies the initial size of a Database Engine TempDB data file in MB. + +SQLTEMPDBFILESIZE="<%= @sql_temp_db_file_size %>" +<% end %> + +<% unless @sql_temp_db_file_growth.nil? -%> +; Specifies the automatic growth increment of each Database Engine TempDB data file in MB. + +SQLTEMPDBFILEGROWTH="<%= @sql_temp_db_file_growth %>" +<% end %> + +<% unless @sql_temp_db_log_file_size.nil? -%> +; Specifies the initial size of the Database Engine TempDB log file in MB. + +SQLTEMPDBLOGFILESIZE="<%= @sql_temp_db_log_file_size %>" +<% end %> + +<% unless @sql_temp_db_log_file_growth.nil? -%> +; Specifies the automatic growth increment of the Database Engine TempDB log file in MB. + +SQLTEMPDBLOGFILEGROWTH="<%= @sql_temp_db_log_file_growth %>" +<% end %> -RSINSTALLMODE="<%= node['sql_server']['rs_mode'] %>" +<% if @feature_list.include?('POLYBASE') %> +; PolybasePdwUserNameConfigDescription + +PBENGSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" + +; PolybasePdwStartupConfigDescription + +PBENGSVCSTARTUPTYPE="Automatic" + +; PolybaseDmsUserNameConfigDescription + +PBDMSSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" + +; PolybaseDmsStartupConfigDescription + +PBDMSSVCSTARTUPTYPE="Automatic" + +; PolybaseScaleOutDescription + +PBSCALEOUT="False" + +; PolybasePortRangeDescription + +PBPORTRANGE="<%= @polybase_port_range %>" +<% end %> +<% end %> + +<% if @version == '2017' %> +<% if @feature_list.include?('SQL_INST_MR' || 'SQL_SHARED_MR' || 'SQL_SHARED_AA') %> +IACCEPTROPENLICENSETERMS=<%= @accept_eula %> +<% end%> + +<% if @feature_list.include?('SQL_INST_MPY' || 'SQL_SHARED_MPY' || 'SQL_SHARED_AA') %> +IACCEPTPYTHONLICENSETERMS=<%= @accept_eula %> +<% end %> + +<% if @feature_list.include?('ADVANCEDANALYTICS') %> +EXTSVCACCOUNT="NT Service\MSSQLLaunchpad" +<% end %> + +<% if @feature_list.include?('IS_MASTER')%> +; Startup type for Integration Services Scale Out Master service. + +ISMASTERSVCSTARTUPTYPE="Automatic" + +; Account for Integration Services Scale Out Master service: Domain\User or system account. + +ISMASTERSVCACCOUNT="NT Service\SSISScaleOutMaster140" + +; Port for Integration Services Scale Out Master. + +ISMASTERSVCPORT=<%= @is_master_port %> + +; The CNs in the certificate used to protect communication with Integration Services Scale Out Worker. + +ISMASTERSVCSSLCERTCN=<%= @is_master_ssl_cert %> + +; The thumbprint of certificate used to protect communication with Integration Services Scale Out Worker. + +<% if @is_master_cert_thumbprint %> +ISMASTERSVCTHUMBPRINT=<%= @is_master_cert_thumbprint %> +<% end %> +<% end %> + +<% if @feature_list.include?('IS_WORKER') %> +; Startup type for Integration Services Scale Out Worker service. + +ISWORKERSVCSTARTUPTYPE="Automatic" + +; Account for Integration Services Scale Out Worker service: Domain\User or system account. + +ISWORKERSVCACCOUNT="NT Service\SSISScaleOutWorker140" + +; Master endpoint. + +ISWORKERSVCMASTER=<%= @is_worker_master_url %> +<% end %> +<% end %> diff --git a/templates/_ConfigurationFile.ini.erb b/templates/_ConfigurationFile.ini.erb deleted file mode 100644 index be727f5..0000000 --- a/templates/_ConfigurationFile.ini.erb +++ /dev/null @@ -1,444 +0,0 @@ -; SQLSERVER<%= @version %> Configuration File -; Generated by Chef Software Chef -[OPTIONS] - -; Auto accept the license terms - -IACCEPTSQLSERVERLICENSETERMS="<%= @accept_eula ? "True" : "False" %>" - -<% unless (@product_key.nil? || @product_key.empty?) -%> -; Product Key - -PID="<%= @product_key %>" -<% end -%> -; The default is Windows Authentication. Use "SQL" for Mixed Mode Authentication. - -<% unless @security_mode == 'Windows Authentication'%> -SECURITYMODE="SQL" -SAPWD="<%= @sa_password %>" -<% end %> - -; Specify whether SQL Server Setup should discover and include product updates. The valid values are True and False or 1 and 0. By default SQL Server Setup will include updates that are found. - -UpdateEnabled="<%= @update_enabled ? "True" : "False" %>" - -; Specify the location where SQL Server Setup will obtain product updates. The valid values are "MU" to search Microsoft Update, a valid folder path, a relative path such as .\MyUpdates or a UNC share. By default SQL Server Setup will search Microsoft Update or a Windows Update service through the Window Server Update Services. - -UpdateSource= "<%= @update_source %>" - -; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will reflect the instance ID of the SQL Server instance. - -INSTANCEID="<%= @instance_name %>" - -; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter. - -ACTION="Install" - -; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, and Tools. The SQL feature will install the database engine, replication, and full-text. The Tools feature will install Management Tools, Books online, Business Intelligence Development Studio, and other shared components. - -<% if @feature_list.is_a? Array %> -FEATURES=<%= %("#{@feature_list.join(',')}") %> -<% else %> -FEATURES=<%= %("#{@feature_list}") %> -<% end %> - -; Displays the command line parameters usage - -HELP="False" - -; Specifies that the detailed Setup log should be piped to the console. - -INDICATEPROGRESS="False" - -; Setup will not display any user interface. - -QUIET="False" - -; Setup will display progress only without any user interaction. - -QUIETSIMPLE="False" - -<% if @version != '2022' %> -; Specifies that Setup should install into WOW64. This command line argument is not supported on an IA64 or a 32-bit system. - -X86="False" -<% end%> - -; Detailed help for command line argument ROLE has not been defined yet. - -ROLE="AllFeatures_WithDefaults" - -; Detailed help for command line argument ENU has not been defined yet. - -ENU="True" - -; Parameter that controls the user interface behavior. Valid values are Normal for the full UI, and AutoAdvance for a simplied UI. -; UIMode setting cannot be used in conjunction with /Q or /QS -; UIMODE="Normal" - -; Specify if errors can be reported to Microsoft to improve future SQL Server releases. Specify 1 or True to enable and 0 or False to disable this feature. - -ERRORREPORTING="False" - -; Specify the root installation directory for native shared components. - -INSTALLSHAREDDIR="<%= @install_dir %>" -<% if node['kernel']['machine'] =~ /x86_64/ %> - -; Specify the root installation directory for the WOW64 shared components. - -INSTALLSHAREDWOWDIR="<%= @shared_wow_dir %>" -<% end %> - -; Specify the installation directory. - -INSTANCEDIR="<%= @instance_dir %>" -<% unless @sql_data_dir.nil? -%> - -; The Database Engine root data directory. - -INSTALLSQLDATADIR="<%= @sql_data_dir %>" -<% end -%> -<% unless @sql_backup_dir.nil? -%> - -; Default directory for SQL backup files. - -SQLBACKUPDIR="<%= @sql_backup_dir %>" -<% end -%> -<% unless @sql_user_db_dir.nil? -%> - -; Default directory for the Database Engine user databases. - -SQLUSERDBDIR="<%= @sql_user_db_dir %>" -<% end -%> -<% unless @sql_user_db_log_dir.nil? -%> - -; Default directory for the Database Engine user database logs. - -SQLUSERDBLOGDIR="<%= @sql_user_db_log_dir %>" -<% end -%> -<% unless @sql_temp_db_dir.nil? -%> - -; Directory for Database Engine TempDB files. - -SQLTEMPDBDIR="<%= @sql_temp_db_dir %>" -<% end -%> -<% unless @sql_temp_db_log_dir.nil? -%> - -; Directory for Database Engine TempDB log files. - -SQLTEMPDBLOGDIR="<%= @sql_temp_db_log_dir %>" -<% end -%> - -; Specify that SQL Server feature usage data can be collected and sent to Microsoft. Specify 1 or True to enable and 0 or False to disable this feature. - -SQMREPORTING="False" - -; Specify a default or named instance. MSSQLSERVER is the default instance for non-Express editions and SQLExpress for Express editions. This parameter is required when installing the SQL Server Database Engine (SQL), Analysis Services (AS), or Reporting Services (RS). - -INSTANCENAME="<%= @instance_name %>" - -; Agent account name - -AGTSVCACCOUNT="<%= @agent_account %>" - -; Auto-start service after installation. - -AGTSVCSTARTUPTYPE="<%= @agent_startup %>" - -<% if @feature_list.include?('IS')%> -; Startup type for Integration Services. - -ISSVCSTARTUPTYPE="Automatic" - -; Account for Integration Services: Domain\User or system account. - -ISSVCACCOUNT="NT AUTHORITY\NetworkService" -<% end %> - -; A port number used to connect to the SharePoint Central Administration web application. -; The setting 'FARMADMINIPORT' specified is not recognized. -; FARMADMINIPORT="0" - -; Startup type for the SQL Server service. - -SQLSVCSTARTUPTYPE="Automatic" - -; Level to enable FILESTREAM feature at (0, 1, 2 or 3). - -FILESTREAMLEVEL="<%= @filestream_level %>" - -; Name of Windows share to be created for FILESTREAM File I/O. - -FILESTREAMSHARENAME="<%= @filestream_share_name %>" - -; Set to "1" to enable RANU for SQL Server Express. - -ENABLERANU="<%= @instance_name == 'SQLEXPRESS' ? "True" : "False" %>" - -; Specifies a Windows collation or an SQL collation to use for the Database Engine. - -SQLCOLLATION="<%= @sql_collation || 'SQL_Latin1_General_CP1_CI_AS' %>" - -; Account for SQL Server service: Domain\User or system account. - -SQLSVCACCOUNT="<%= @sql_account %>" - -; Windows account(s) to provision as SQL Server system administrators. - -SQLSYSADMINACCOUNTS=<%= @sqlSysAdminList %> - -; Provision current user as a Database Engine system administrator for SQL Server 2008 R2 Express. - -ADDCURRENTUSERASSQLADMIN="<%= @instance_name == 'SQLEXPRESS' ? 'True' : 'False' %>" - -; Specify 0 to disable or 1 to enable the TCP/IP protocol. - -TCPENABLED="1" - -; Specify 0 to disable or 1 to enable the Named Pipes protocol. - -NPENABLED="0" - -; Startup type for Browser Service. - -BROWSERSVCSTARTUPTYPE="<%= @browser_startup %>" - -<% if @feature_list.include?('RS')%> -; Specifies which account the report server NT service should execute under. When omitted or when the value is empty string, the default built-in account for the current operating system. -; The username part of RSSVCACCOUNT is a maximum of 20 characters long and -; The domain part of RSSVCACCOUNT is a maximum of 254 characters long. - -RSSVCACCOUNT="<%= @rs_account %>" - -; Specifies how the startup mode of the report server NT service. When -; Manual - Service startup is manual mode (default). -; Automatic - Service startup is automatic mode. -; Disabled - Service is disabled - -RSSVCSTARTUPTYPE="<%= @rs_startup %>" - -; Specifies which mode report server is installed in. -; Default value: "FilesOnly" - -RSINSTALLMODE="<%= @rs_mode %>" -<% end %> - -<% if @feature_list.include?('FULLTEXT')%> -; Add description of input arguemtn FTSVCACCOUNT - -FTSVCACCOUNT="NT Service\MSSQLFDLauncher" -<% end %> - -<% if @feature_list.include?('RS_SHP') %> -; RSInputSettings_RSInstallMode_Description - -RSSHPINSTALLMODE="SharePointFilesOnlyMode" -<% end %> - -<% if @feature_list.include?('AS')%> -; The name of the account that the Analysis Services service runs under. - -ASSVCACCOUNT=<%= @as_svc_account %> - -; Controls the service startup type setting after the service has been created. - -ASSVCSTARTUPTYPE="Automatic" - -; The collation to be used by Analysis Services. - -ASCOLLATION="Latin1_General_CI_AS" - -; The location for the Analysis Services data files. - -ASDATADIR="Data" - -; The location for the Analysis Services log files. - -ASLOGDIR="Log" - -; The location for the Analysis Services backup files. - -ASBACKUPDIR="Backup" - -; The location for the Analysis Services temporary files. - -ASTEMPDIR="Temp" - -; The location for the Analysis Services configuration files. - -ASCONFIGDIR="Config" - -; Specifies whether or not the MSOLAP provider is allowed to run in process. - -ASPROVIDERMSOLAP="1" - -; Specifies whether or not the MSOLAP provider is allowed to run in process. - -ASPROVIDERMSOLAP="1" - -; Specifies the list of administrator accounts that need to be provisioned. - -ASSYSADMINACCOUNTS=<%= @asSysAdminList %> - -; Specifies the server mode of the Analysis Services instance. Valid values are MULTIDIMENSIONAL and TABULAR. The default value is MULTIDIMENSIONAL. - -ASSERVERMODE="MULTIDIMENSIONAL" -<% end %> - -<% if @feature_list.include?('DREPLAY_CTLR')%> -; The Windows account(s) used to grant permission to the Distributed Replay Controller service. - -CTLRUSERS=<%= @dreplayCtlrList %> - -; The account used by the Distributed Replay Controller service. - -CTLRSVCACCOUNT="NT Service\SQL Server Distributed Replay Controller" - -; The startup type for the Distributed Replay Controller service. - -CTLRSTARTUPTYPE="Manual" -<% end %> - -<% if @feature_list.include?('DREPLAY_CLT')%> -; The computer name that the client communicates with for the Distributed Replay Controller service. - -CLTCTLRNAME="<%= @dreplay_client_name %>" - -; The account used by the Distributed Replay Client service. - -CLTSVCACCOUNT="NT Service\SQL Server Distributed Replay Client" - -; The startup type for the Distributed Replay Client service. - -CLTSTARTUPTYPE="Manual" - -; The result directory for the Distributed Replay Client service. - -CLTRESULTDIR="ResultDir" - -; The working directory for the Distributed Replay Client service. - -CLTWORKINGDIR="WorkingDir" -<% end %> - -<% if @version == '2016' %> -<% if @feature_list.include?('ADVANCEDANALYTICS' || 'SQL_SHARED_MR') %> -IACCEPTROPENLICENSETERMS=<%= @accept_eula %> - -EXTSVCACCOUNT="NT Service\MSSQLLaunchpad" -<% end %> -<% end %> - -<% if (@version == '2016') || (@version == '2017') || (@version == '2019') || (@version == '2022') %> -; Enables instant file initialization for SQL Server service account. -SQLSVCINSTANTFILEINIT="<%= @sql_instant_file_init ? "True" : "False" %>" - -<% unless @sql_temp_db_file_count.nil? -%> -; The number of Database Engine TempDB files - -SQLTEMPDBFILECOUNT="<%= @sql_temp_db_file_count %>" -<% end %> - -<% unless @sql_temp_db_file_size.nil? -%> -; Specifies the initial size of a Database Engine TempDB data file in MB. - -SQLTEMPDBFILESIZE="<%= @sql_temp_db_file_size %>" -<% end %> - -<% unless @sql_temp_db_file_growth.nil? -%> -; Specifies the automatic growth increment of each Database Engine TempDB data file in MB. - -SQLTEMPDBFILEGROWTH="<%= @sql_temp_db_file_growth %>" -<% end %> - -<% unless @sql_temp_db_log_file_size.nil? -%> -; Specifies the initial size of the Database Engine TempDB log file in MB. - -SQLTEMPDBLOGFILESIZE="<%= @sql_temp_db_log_file_size %>" -<% end %> - -<% unless @sql_temp_db_log_file_growth.nil? -%> -; Specifies the automatic growth increment of the Database Engine TempDB log file in MB. - -SQLTEMPDBLOGFILEGROWTH="<%= @sql_temp_db_log_file_growth %>" -<% end %> - -<% if @feature_list.include?('POLYBASE') %> -; PolybasePdwUserNameConfigDescription - -PBENGSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" - -; PolybasePdwStartupConfigDescription - -PBENGSVCSTARTUPTYPE="Automatic" - -; PolybaseDmsUserNameConfigDescription - -PBDMSSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" - -; PolybaseDmsStartupConfigDescription - -PBDMSSVCSTARTUPTYPE="Automatic" - -; PolybaseScaleOutDescription - -PBSCALEOUT="False" - -; PolybasePortRangeDescription - -PBPORTRANGE="<%= @polybase_port_range %>" -<% end %> -<% end %> - -<% if @version == '2017' %> -<% if @feature_list.include?('SQL_INST_MR' || 'SQL_SHARED_MR' || 'SQL_SHARED_AA') %> -IACCEPTROPENLICENSETERMS=<%= @accept_eula %> -<% end%> - -<% if @feature_list.include?('SQL_INST_MPY' || 'SQL_SHARED_MPY' || 'SQL_SHARED_AA') %> -IACCEPTPYTHONLICENSETERMS=<%= @accept_eula %> -<% end %> - -<% if @feature_list.include?('ADVANCEDANALYTICS') %> -EXTSVCACCOUNT="NT Service\MSSQLLaunchpad" -<% end %> - -<% if @feature_list.include?('IS_MASTER')%> -; Startup type for Integration Services Scale Out Master service. - -ISMASTERSVCSTARTUPTYPE="Automatic" - -; Account for Integration Services Scale Out Master service: Domain\User or system account. - -ISMASTERSVCACCOUNT="NT Service\SSISScaleOutMaster140" - -; Port for Integration Services Scale Out Master. - -ISMASTERSVCPORT=<%= @is_master_port %> - -; The CNs in the certificate used to protect communication with Integration Services Scale Out Worker. - -ISMASTERSVCSSLCERTCN=<%= @is_master_ssl_cert %> - -; The thumbprint of certificate used to protect communication with Integration Services Scale Out Worker. - -<% if @is_master_cert_thumbprint %> -ISMASTERSVCTHUMBPRINT=<%= @is_master_cert_thumbprint %> -<% end %> -<% end %> - -<% if @feature_list.include?('IS_WORKER') %> -; Startup type for Integration Services Scale Out Worker service. - -ISWORKERSVCSTARTUPTYPE="Automatic" - -; Account for Integration Services Scale Out Worker service: Domain\User or system account. - -ISWORKERSVCACCOUNT="NT Service\SSISScaleOutWorker140" - -; Master endpoint. - -ISWORKERSVCMASTER=<%= @is_worker_master_url %> -<% end %> -<% end %> diff --git a/test/cookbooks/test/recipes/default.rb b/test/cookbooks/test/recipes/default.rb new file mode 100644 index 0000000..2c0aebb --- /dev/null +++ b/test/cookbooks/test/recipes/default.rb @@ -0,0 +1,6 @@ +sql_server_install 'Install SQL' do + sa_password 'Supersecurepassword123' + accept_eula true +end + +sql_server_configure 'SQLEXPRESS' diff --git a/test/cookbooks/test/recipes/install.rb b/test/cookbooks/test/recipes/install.rb deleted file mode 100644 index a12b3a2..0000000 --- a/test/cookbooks/test/recipes/install.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Test install of SQL Defaults - -sql_server_install 'Install SQL' do - sa_password node['sql_server']['server_sa_password'] - sysadmins node['sql_server']['sysadmins'] - action :install -end - -sql_server_configure 'SQLEXPRESS' diff --git a/test/integration/inspec/controls/client_spec.rb b/test/integration/server_install/controls/client_spec.rb similarity index 100% rename from test/integration/inspec/controls/client_spec.rb rename to test/integration/server_install/controls/client_spec.rb diff --git a/test/integration/inspec/controls/server_spec.rb b/test/integration/server_install/controls/server_spec.rb similarity index 100% rename from test/integration/inspec/controls/server_spec.rb rename to test/integration/server_install/controls/server_spec.rb diff --git a/test/integration/inspec/inspec.yml b/test/integration/server_install/inspec.yml similarity index 76% rename from test/integration/inspec/inspec.yml rename to test/integration/server_install/inspec.yml index bfe758a..372bc7b 100644 --- a/test/integration/inspec/inspec.yml +++ b/test/integration/server_install/inspec.yml @@ -1,5 +1,5 @@ --- -name: sql_server +name: server_install inputs: - name: version type: Numeric