Skip to content

Commit

Permalink
Updates for Standard Edition
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rhealitycheck committed May 10, 2016
1 parent e06a3e3 commit 39f0819
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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'

0 comments on commit 39f0819

Please sign in to comment.