From 39f0819fdb3d244b71b2b846e41e40e5f6a5577b Mon Sep 17 00:00:00 2001 From: rhealitycheck Date: Tue, 10 May 2016 13:48:47 -0500 Subject: [PATCH 1/2] Updates for Standard Edition Instance name is modified because SQLEXPRESS is used as an instance name for SQL Server. In Standard or Enterprise installs, SQL Server will default to MSSQLSERVER. Any instance name declared by the user will have MSSQL$ appeneded to the front as the service name. 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 If you have declared an agent account it will restart both the agent service and the sql service. If not only restart the sql service SQL Server requires a reboot to complete your install --- recipes/server.rb | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/recipes/server.rb b/recipes/server.rb index c7d46f7..303a63c 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -20,10 +20,20 @@ Chef::Application.fatal!("node['sql_server']['server_sa_password'] must be set for this cookbook to run") if node['sql_server']['server_sa_password'].nil? -service_name = if node['sql_server']['instance_name'] == 'SQLEXPRESS' +# SQLEXPRESS is used as an instance name in Standard or Enterprise installs +# SQL Server it will default to MSSQLSERVER. Any instance name used will +# have MSSQ$ appeneded to the front +service_name = if node['sql_server']['instance_name'] == 'MSSQLSERVER' + node['sql_server']['instance_name'] + else "MSSQL$#{node['sql_server']['instance_name']}" + end +# 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 = if node['sql_server']['instance_name'] == 'MSSQLSERVER' + 'SQLSERVERAGENT' else - node['sql_server']['instance_name'] + "SQLAgent$#{node['sql_server']['instance_name']}" end # Compute registry version based on sql server version @@ -90,6 +100,8 @@ 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 # set the static tcp port @@ -100,8 +112,25 @@ notifies :restart, "service[#{service_name}]", :immediately end -service service_name do - action [:start, :enable] +# 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_account'] + service agent_service_name do + action [:start, :enable] + end + service service_name do + action [:start, :enable] + end +else + service service_name do + action [:start, :enable] + end +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' end include_recipe 'sql_server::client' From 79ac96b920c14fe71ddc60b128efed0c6555c0d9 Mon Sep 17 00:00:00 2001 From: rhealitycheck Date: Tue, 10 May 2016 14:22:00 -0500 Subject: [PATCH 2/2] Update server.rb fixed linting issues. --- recipes/server.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/recipes/server.rb b/recipes/server.rb index 303a63c..fae976a 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -20,8 +20,8 @@ Chef::Application.fatal!("node['sql_server']['server_sa_password'] must be set for this cookbook to run") if node['sql_server']['server_sa_password'].nil? -# SQLEXPRESS is used as an instance name in Standard or Enterprise installs -# SQL Server it will default to MSSQLSERVER. Any instance name used will +# SQLEXPRESS is used as an instance name in Standard or Enterprise installs +# SQL Server it will default to MSSQLSERVER. Any instance name used will # have MSSQ$ appeneded to the front service_name = if node['sql_server']['instance_name'] == 'MSSQLSERVER' node['sql_server']['instance_name'] @@ -31,10 +31,10 @@ # 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 = if node['sql_server']['instance_name'] == 'MSSQLSERVER' - 'SQLSERVERAGENT' - else - "SQLAgent$#{node['sql_server']['instance_name']}" - end + 'SQLSERVERAGENT' + else + "SQLAgent$#{node['sql_server']['instance_name']}" + end # Compute registry version based on sql server version reg_version = node['sql_server']['reg_version'] || @@ -121,10 +121,10 @@ service service_name do action [:start, :enable] end -else - service service_name do - action [:start, :enable] - end +end + +service service_name do + action [:start, :enable] end # SQL Server requires a reboot to complete your install