Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions providers/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,16 @@ def execute_install_script(install_script)
''
end

post_action = if new_resource.post_install_action == 'exec'
new_resource.exec_command
else
license_provided = node['chef_client']['chef_license'] || ''

post_action = if new_resource.post_install_action != 'exec'
''
elsif desired_version.major >= 15
"#{new_resource.exec_command} --chef-license #{license_provided}"
else
new_resource.exec_command
end

license_provided = node['chef_client']['chef_license'] || ''

powershell_script 'Chef Infra Client Upgrade Script' do
code <<-EOH
$command = {
Expand Down Expand Up @@ -564,25 +566,6 @@ def execute_install_script(install_script)
Remove-Item "#{chef_install_dir}/../chef_upgrade.ps1"
c:/windows/system32/schtasks.exe /delete /f /tn Chef_upgrade

if ('#{desired_version}' -ge '15') {

SET CHEF_LICENSE '#{license_provided}'

#{chef_install_dir}/embedded/bin/ruby.exe -e "
begin
require 'chef/VERSION'
require 'license_acceptance/acceptor'
acceptor = LicenseAcceptance::Acceptor.new(provided: '#{license_provided}')
if acceptor.license_required?('chef', Chef::VERSION)
license_id = acceptor.id_from_mixlib('chef')
acceptor.check_and_persist(license_id, Chef::VERSION)
end
rescue LoadError
puts 'License acceptance might not be needed !'
end
"
}

#{post_action}

Get-Service push-jobs-client -ErrorAction SilentlyContinue | start-service
Expand Down