Skip to content

Commit

Permalink
Merge pull request #67 from rhealitycheck/rhealitycheck-updates-for-s…
Browse files Browse the repository at this point in the history
…tandard-edition

Updates for Standard Edition
  • Loading branch information
smurawski committed May 17, 2016
2 parents 4f5e59d + 79ac96b commit 508ba61
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@

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'] != 'MSSQLSERVER'
"MSSQL$#{node['sql_server']['instance_name']}"
else
# 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
"SQLAgent$#{node['sql_server']['instance_name']}"
end

# Compute registry version based on sql server version
reg_version = node['sql_server']['reg_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,9 +112,26 @@
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_account']
service agent_service_name do
action [:start, :enable]
end
service 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

# 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 508ba61

Please sign in to comment.