up until about a month or so ago, my recipe worked fine where after I installed SQL I was able to stop the services and set them to run as a sQL service account we have set up. But now, I till stop them and assign the users, but wont’ start back up. I manually log into the servers and click start. The credentials are good, but it just won’t start the services. See below for the blocks in question.
windows_service 'SQLSERVERAGENT' do
action :stop
end
windows_service 'MSSQLSERVER' do
action :stop
end
windows_service 'MSSQLSERVER' do
run_as_user node['Relativity']['SQLServer']['Service_Account']
run_as_password node['Relativity']['SQLServer']['Service_Account_Password']
action :start
end
windows_service 'SQLSERVERAGENT' do
run_as_user node['Relativity']['SQLServer']['Service_Account']
run_as_password node['Relativity']['SQLServer']['Service_Account_Password']
action :start
end
I think this is unrelated to the service failures but that event log message regarding the insecure configuration is likely due to the AllowUnencrypted = true setting. Its best not to set that to true. Some chef tooling (knife-windows and test-kitchen) required that in the past but if you are using recent versions its unnecessary.
I was recently working on this use case and ran into the same challenge. Just as another example of a way forward, setting up a retry worked for me (the below also includes idempotency via the only_if guard):
windows_service 'SQLSERVERAGENT' do
action :stop
guard_interpreter :powershell_script
only_if '(Get-WMIObject Win32_Service | where-object { $_.name -eq "SQLSERVERAGENT" }| where-object {$_.startname -eq ".\foo_bar"}) -eq $null'
end
windows_service 'MSSQLSERVER' do
action :stop
guard_interpreter :powershell_script
only_if '(Get-WMIObject Win32_Service | where-object { $_.name -eq "MSSQLSERVER" }| where-object {$_.startname -eq ".\foo_bar"}) -eq $null'
end
windows_service 'MSSQLSERVER' do
run_as_user '.\foo_bar'
run_as_password 'FooBar!'
action :start
retries 5
retry_delay 10
end
windows_service 'SQLSERVERAGENT' do
run_as_user '.\foo_bar'
run_as_password 'FooBar!'
action :start
retries 5
retry_delay 10
end
Hope that’s of help for anyone else running into this. Or if I google around in the future and run into my own post