diff options
Diffstat (limited to 'lib/chef/provider')
25 files changed, 145 insertions, 145 deletions
diff --git a/lib/chef/provider/cron/unix.rb b/lib/chef/provider/cron/unix.rb index 15195dbb88..4edd5ba206 100644 --- a/lib/chef/provider/cron/unix.rb +++ b/lib/chef/provider/cron/unix.rb @@ -33,7 +33,7 @@ class Chef private def read_crontab - crontab = shell_out("/usr/bin/crontab -l", :user => @new_resource.user) + crontab = shell_out("/usr/bin/crontab -l", user: @new_resource.user) status = crontab.status.exitstatus logger.trace crontab.format_for_exception if status > 0 @@ -53,7 +53,7 @@ class Chef exit_status = 0 error_message = "" begin - crontab_write = shell_out("/usr/bin/crontab #{tempcron.path}", :user => @new_resource.user) + crontab_write = shell_out("/usr/bin/crontab #{tempcron.path}", user: @new_resource.user) stderr = crontab_write.stderr exit_status = crontab_write.status.exitstatus # solaris9, 10 on some failures for example invalid 'mins' in crontab fails with exit code of zero :( diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb index 9c147cb634..3a209a08a1 100644 --- a/lib/chef/provider/dsc_resource.rb +++ b/lib/chef/provider/dsc_resource.rb @@ -169,7 +169,7 @@ class Chef "Invoke-DscResource #{switches}", output_format ) - cmdlet.run!({}, { :timeout => new_resource.timeout }) + cmdlet.run!({}, { timeout: new_resource.timeout }) end def return_dsc_resource_result(result, property_name) diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb index 7a101fa68b..fd20f34786 100644 --- a/lib/chef/provider/dsc_script.rb +++ b/lib/chef/provider/dsc_script.rb @@ -32,10 +32,10 @@ class Chef @dsc_resource = dsc_resource @resource_converged = false @operations = { - :set => Proc.new do |config_manager, document, shellout_flags| + set: Proc.new do |config_manager, document, shellout_flags| config_manager.set_configuration(document, shellout_flags) end, - :test => Proc.new do |config_manager, document, shellout_flags| + test: Proc.new do |config_manager, document, shellout_flags| config_manager.test_configuration(document, shellout_flags) end } end @@ -86,9 +86,9 @@ class Chef config_manager = Chef::Util::DSC::LocalConfigurationManager.new(@run_context.node, config_directory) shellout_flags = { - :cwd => @dsc_resource.cwd, - :environment => @dsc_resource.environment, - :timeout => @dsc_resource.timeout, + cwd: @dsc_resource.cwd, + environment: @dsc_resource.environment, + timeout: @dsc_resource.timeout, } begin @@ -113,9 +113,9 @@ class Chef def generate_configuration_document(config_directory, configuration_flags) shellout_flags = { - :cwd => @dsc_resource.cwd, - :environment => @dsc_resource.environment, - :timeout => @dsc_resource.timeout, + cwd: @dsc_resource.cwd, + environment: @dsc_resource.environment, + timeout: @dsc_resource.timeout, } generator = Chef::Util::DSC::ConfigurationGenerator.new(@run_context.node, config_directory) diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb index 3d3255260f..1b97dbf464 100644 --- a/lib/chef/provider/execute.rb +++ b/lib/chef/provider/execute.rb @@ -102,7 +102,7 @@ class Chef opts[:log_tag] = new_resource.to_s if (logger.info? || live_stream?) && !sensitive? if run_context.events.formatter? - opts[:live_stream] = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute) + opts[:live_stream] = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute) elsif stream_to_stdout? opts[:live_stream] = STDOUT end diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb index 885d473a7a..e8aad1e896 100644 --- a/lib/chef/provider/http_request.rb +++ b/lib/chef/provider/http_request.rb @@ -37,7 +37,7 @@ class Chef # CHEF-4762: we expect a nil return value from Chef::HTTP for a "200 Success" response # and false for a "304 Not Modified" response modified = @http.head( - "#{new_resource.url}", + (new_resource.url).to_s, new_resource.headers ) logger.info("#{new_resource} HEAD to #{new_resource.url} successful") @@ -54,7 +54,7 @@ class Chef message = check_message(new_resource.message) body = @http.get( - "#{new_resource.url}", + (new_resource.url).to_s, new_resource.headers ) logger.info("#{new_resource} GET to #{new_resource.url} successful") @@ -67,7 +67,7 @@ class Chef converge_by("#{new_resource} PATCH to #{new_resource.url}") do message = check_message(new_resource.message) body = @http.patch( - "#{new_resource.url}", + (new_resource.url).to_s, message, new_resource.headers ) @@ -81,7 +81,7 @@ class Chef converge_by("#{new_resource} PUT to #{new_resource.url}") do message = check_message(new_resource.message) body = @http.put( - "#{new_resource.url}", + (new_resource.url).to_s, message, new_resource.headers ) @@ -95,7 +95,7 @@ class Chef converge_by("#{new_resource} POST to #{new_resource.url}") do message = check_message(new_resource.message) body = @http.post( - "#{new_resource.url}", + (new_resource.url).to_s, message, new_resource.headers ) @@ -108,7 +108,7 @@ class Chef def action_delete converge_by("#{new_resource} DELETE to #{new_resource.url}") do body = @http.delete( - "#{new_resource.url}", + (new_resource.url).to_s, new_resource.headers ) new_resource.updated_by_last_action(true) diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb index c5f15a851a..9b023b1a65 100644 --- a/lib/chef/provider/mdadm.rb +++ b/lib/chef/provider/mdadm.rb @@ -31,7 +31,7 @@ class Chef logger.trace("#{new_resource} checking for software raid device #{current_resource.raid_device}") device_not_found = 4 - mdadm = shell_out!("mdadm --detail --test #{new_resource.raid_device}", :returns => [0, device_not_found]) + mdadm = shell_out!("mdadm --detail --test #{new_resource.raid_device}", returns: [0, device_not_found]) exists = (mdadm.status == 0) current_resource.exists(exists) end diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb index d0da30a30a..52d55f5404 100644 --- a/lib/chef/provider/mount/mount.rb +++ b/lib/chef/provider/mount/mount.rb @@ -232,7 +232,7 @@ class Chef def device_logstring case @new_resource.device_type when :device - "#{device_real}" + (device_real).to_s when :label "#{device_real} with label #{@new_resource.device}" when :uuid diff --git a/lib/chef/provider/mount/windows.rb b/lib/chef/provider/mount/windows.rb index 590b2bfa52..1650d1e43a 100644 --- a/lib/chef/provider/mount/windows.rb +++ b/lib/chef/provider/mount/windows.rb @@ -41,7 +41,7 @@ class Chef def load_current_resource if is_volume(@new_resource.device) @mount = Chef::Util::Windows::Volume.new(@new_resource.mount_point) - else #assume network drive + else # assume network drive @mount = Chef::Util::Windows::NetUse.new(@new_resource.mount_point) end @@ -61,10 +61,10 @@ class Chef def mount_fs unless @current_resource.mounted - @mount.add(:remote => @new_resource.device, - :username => @new_resource.username, - :domainname => @new_resource.domain, - :password => @new_resource.password) + @mount.add(remote: @new_resource.device, + username: @new_resource.username, + domainname: @new_resource.domain, + password: @new_resource.password) logger.trace("#{@new_resource} is mounted at #{@new_resource.mount_point}") else logger.trace("#{@new_resource} is already mounted at #{@new_resource.mount_point}") diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb index 0af4f87d7f..01d8829dd2 100644 --- a/lib/chef/provider/package.rb +++ b/lib/chef/provider/package.rb @@ -307,7 +307,7 @@ class Chef # used by subclasses. deprecated. use #a_to_s instead. def expand_options(options) # its deprecated but still work to do to deprecate it fully - #Chef.deprecated(:package_misc, "expand_options is deprecated, use shell_out instead") + # Chef.deprecated(:package_misc, "expand_options is deprecated, use shell_out instead") if options " #{options.is_a?(Array) ? Shellwords.join(options) : options}" else diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb index c60483d0dc..eb27b23408 100644 --- a/lib/chef/provider/package/chocolatey.rb +++ b/lib/chef/provider/package/chocolatey.rb @@ -31,12 +31,12 @@ class Chef use_multipackage_api PATHFINDING_POWERSHELL_COMMAND = "[System.Environment]::GetEnvironmentVariable('ChocolateyInstall', 'MACHINE')".freeze - CHOCO_MISSING_MSG = <<-EOS.freeze -Could not locate your Chocolatey install. To install chocolatey, we recommend -the 'chocolatey' cookbook (https://github.com/chocolatey/chocolatey-cookbook). -If Chocolatey is installed, ensure that the 'ChocolateyInstall' environment -variable is correctly set. You can verify this with the PowerShell command -'#{PATHFINDING_POWERSHELL_COMMAND}'. + CHOCO_MISSING_MSG = <<~EOS.freeze + Could not locate your Chocolatey install. To install chocolatey, we recommend + the 'chocolatey' cookbook (https://github.com/chocolatey/chocolatey-cookbook). + If Chocolatey is installed, ensure that the 'ChocolateyInstall' environment + variable is correctly set. You can verify this with the PowerShell command + '#{PATHFINDING_POWERSHELL_COMMAND}'. EOS # Responsible for building the current_resource. diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb index 5af73b8b69..31521c3675 100644 --- a/lib/chef/provider/powershell_script.rb +++ b/lib/chef/provider/powershell_script.rb @@ -85,10 +85,10 @@ class Chef # in that block will still trigger a syntax error which is # exactly what we want here -- verify the syntax without # actually running the script. - user_code_wrapped_in_powershell_script_block = <<-EOH -{ - #{new_resource.code} -} + user_code_wrapped_in_powershell_script_block = <<~EOH + { + #{new_resource.code} + } EOH user_script_file.puts user_code_wrapped_in_powershell_script_block @@ -146,75 +146,75 @@ EOH # executed, otherwise 0 or 1 based on whether $? is set to true # (success, where we return 0) or false (where we return 1). def wrapper_script - <<-EOH -# Chef Client wrapper for powershell_script resources - -# In rare cases, such as when PowerShell is executed -# as an alternate user, the new-variable cmdlet is not -# available, so import it just in case -if ( get-module -ListAvailable Microsoft.PowerShell.Utility ) -{ - Import-Module Microsoft.PowerShell.Utility -} - -# LASTEXITCODE can be uninitialized -- make it explictly 0 -# to avoid incorrect detection of failure (non-zero) codes -$global:LASTEXITCODE = 0 - -# Catch any exceptions -- without this, exceptions will result -# In a zero return code instead of the desired non-zero code -# that indicates a failure -trap [Exception] {write-error ($_.Exception.Message);exit 1} - -# Variable state that should not be accessible to the user code -new-variable -name interpolatedexitcode -visibility private -value $#{new_resource.convert_boolean_return} -new-variable -name chefscriptresult -visibility private - -# Initialize a variable we use to capture $? inside a block -$global:lastcmdlet = $null - -# Execute the user's code in a script block -- -$chefscriptresult = -{ - #{new_resource.code} - - # This assignment doesn't affect the block's return value - $global:lastcmdlet = $? -}.invokereturnasis() - -# Assume failure status of 1 -- success cases -# will have to override this -$exitstatus = 1 - -# If convert_boolean_return is enabled, the block's return value -# gets precedence in determining our exit status -if ($interpolatedexitcode -and $chefscriptresult -ne $null -and $chefscriptresult.gettype().name -eq 'boolean') -{ - $exitstatus = [int32](!$chefscriptresult) -} -elseif ($lastcmdlet) -{ - # Otherwise, a successful cmdlet execution defines the status - $exitstatus = 0 -} -elseif ( $LASTEXITCODE -ne $null -and $LASTEXITCODE -ne 0 ) -{ - # If the cmdlet status is failed, allow the Win32 status - # in $LASTEXITCODE to define exit status. This handles the case - # where no cmdlets, only Win32 processes have run since $? - # will be set to $false whenever a Win32 process returns a non-zero - # status. - $exitstatus = $LASTEXITCODE -} - -# Print STDOUT for the script execution -Write-Output $chefscriptresult - -# If this script is launched with -File, the process exit -# status of PowerShell.exe will be $exitstatus. If it was -# launched with -Command, it will be 0 if $exitstatus was 0, -# 1 (i.e. failed) otherwise. -exit $exitstatus + <<~EOH + # Chef Client wrapper for powershell_script resources + + # In rare cases, such as when PowerShell is executed + # as an alternate user, the new-variable cmdlet is not + # available, so import it just in case + if ( get-module -ListAvailable Microsoft.PowerShell.Utility ) + { + Import-Module Microsoft.PowerShell.Utility + } + + # LASTEXITCODE can be uninitialized -- make it explictly 0 + # to avoid incorrect detection of failure (non-zero) codes + $global:LASTEXITCODE = 0 + + # Catch any exceptions -- without this, exceptions will result + # In a zero return code instead of the desired non-zero code + # that indicates a failure + trap [Exception] {write-error ($_.Exception.Message);exit 1} + + # Variable state that should not be accessible to the user code + new-variable -name interpolatedexitcode -visibility private -value $#{new_resource.convert_boolean_return} + new-variable -name chefscriptresult -visibility private + + # Initialize a variable we use to capture $? inside a block + $global:lastcmdlet = $null + + # Execute the user's code in a script block -- + $chefscriptresult = + { + #{new_resource.code} + + # This assignment doesn't affect the block's return value + $global:lastcmdlet = $? + }.invokereturnasis() + + # Assume failure status of 1 -- success cases + # will have to override this + $exitstatus = 1 + + # If convert_boolean_return is enabled, the block's return value + # gets precedence in determining our exit status + if ($interpolatedexitcode -and $chefscriptresult -ne $null -and $chefscriptresult.gettype().name -eq 'boolean') + { + $exitstatus = [int32](!$chefscriptresult) + } + elseif ($lastcmdlet) + { + # Otherwise, a successful cmdlet execution defines the status + $exitstatus = 0 + } + elseif ( $LASTEXITCODE -ne $null -and $LASTEXITCODE -ne 0 ) + { + # If the cmdlet status is failed, allow the Win32 status + # in $LASTEXITCODE to define exit status. This handles the case + # where no cmdlets, only Win32 processes have run since $? + # will be set to $false whenever a Win32 process returns a non-zero + # status. + $exitstatus = $LASTEXITCODE + } + + # Print STDOUT for the script execution + Write-Output $chefscriptresult + + # If this script is launched with -File, the process exit + # status of PowerShell.exe will be $exitstatus. If it was + # launched with -Command, it will be 0 if $exitstatus was 0, + # 1 (i.e. failed) otherwise. + exit $exitstatus EOH end diff --git a/lib/chef/provider/reboot.rb b/lib/chef/provider/reboot.rb index f054af0567..dd07e7448d 100644 --- a/lib/chef/provider/reboot.rb +++ b/lib/chef/provider/reboot.rb @@ -45,10 +45,10 @@ class Chef # @return [void] def request_reboot node.run_context.request_reboot( - :delay_mins => new_resource.delay_mins, - :reason => new_resource.reason, - :timestamp => Time.now, - :requested_by => new_resource.name + delay_mins: new_resource.delay_mins, + reason: new_resource.reason, + timestamp: Time.now, + requested_by: new_resource.name ) end diff --git a/lib/chef/provider/remote_file/sftp.rb b/lib/chef/provider/remote_file/sftp.rb index 21c5c4ca04..66540fea8c 100644 --- a/lib/chef/provider/remote_file/sftp.rb +++ b/lib/chef/provider/remote_file/sftp.rb @@ -58,7 +58,7 @@ class Chef def sftp host = port ? "#{hostname}:#{port}" : hostname - @sftp ||= Net::SFTP.start(host, user, :password => pass) + @sftp ||= Net::SFTP.start(host, user, password: pass) end def pass diff --git a/lib/chef/provider/resource_update.rb b/lib/chef/provider/resource_update.rb index e069a8201c..d3c674dd22 100644 --- a/lib/chef/provider/resource_update.rb +++ b/lib/chef/provider/resource_update.rb @@ -31,7 +31,7 @@ class Chef attr_accessor :type attr_accessor :name - attr_accessor :duration #ms + attr_accessor :duration # ms attr_accessor :status attr_accessor :initial_state attr_accessor :final_state diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb index 552173fbee..126a431742 100644 --- a/lib/chef/provider/service/openbsd.rb +++ b/lib/chef/provider/service/openbsd.rb @@ -116,7 +116,7 @@ class Chef old_list = rc_conf_local.match(/^pkg_scripts="(.*)"/) old_list = old_list ? old_list[1].split(" ") : [] new_list = old_list - [new_resource.service_name] - update_rcl rc_conf_local.sub(/^pkg_scripts="(.*)"/, pkg_scripts = "#{new_list.join(' ')}") + update_rcl rc_conf_local.sub(/^pkg_scripts="(.*)"/, pkg_scripts = (new_list.join(" ")).to_s) end end end diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb index 1da3d7c01a..18ef245083 100644 --- a/lib/chef/provider/service/redhat.rb +++ b/lib/chef/provider/service/redhat.rb @@ -81,7 +81,7 @@ class Chef super if ::File.exists?("/sbin/chkconfig") - chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", :returns => [0, 1]) + chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", returns: [0, 1]) unless run_levels.nil? || run_levels.empty? all_levels_match = true chkconfig.stdout.split(/\s+/)[1..-1].each do |level| diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb index f2b1ec4262..51105bd06f 100644 --- a/lib/chef/provider/service/solaris.rb +++ b/lib/chef/provider/service/solaris.rb @@ -80,7 +80,7 @@ class Chef end def service_status - cmd = shell_out!(@status_command, "-l", @current_resource.service_name, :returns => [0, 1]) + cmd = shell_out!(@status_command, "-l", @current_resource.service_name, returns: [0, 1]) # Example output # $ svcs -l rsyslog # fmri svc:/application/rsyslog:default diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb index badd7695a5..6d5bc338c7 100644 --- a/lib/chef/provider/service/systemd.rb +++ b/lib/chef/provider/service/systemd.rb @@ -79,10 +79,10 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple if new_resource.user uid = Etc.getpwnam(new_resource.user).uid options = { - :environment => { + environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus", }, - :user => new_resource.user, + user: new_resource.user, } args = "--user" else diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb index 487940e84e..2482ce6a5c 100644 --- a/lib/chef/provider/service/windows.rb +++ b/lib/chef/provider/service/windows.rb @@ -33,12 +33,12 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service include Chef::ReservedNames::Win32::API::Error rescue LoadError include Chef::Win32ServiceConstants - #Win32::Service.get_start_type + # Win32::Service.get_start_type AUTO_START = "auto start" MANUAL = "demand start" DISABLED = "disabled" - #Win32::Service.get_current_state + # Win32::Service.get_current_state RUNNING = "running" STOPPED = "stopped" CONTINUE_PENDING = "continue pending" @@ -361,8 +361,8 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service logger.trace "#{@new_resource.name} setting start_type to #{type}" Win32::Service.configure( - :service_name => @new_resource.service_name, - :start_type => startup_type + service_name: @new_resource.service_name, + start_type: startup_type ) @new_resource.updated_by_last_action(true) end diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb index abcc260a78..dec9e06f87 100644 --- a/lib/chef/provider/subversion.rb +++ b/lib/chef/provider/subversion.rb @@ -16,7 +16,7 @@ # limitations under the License. # -#TODO subversion and git should both extend from a base SCM provider. +# TODO subversion and git should both extend from a base SCM provider. require "chef/log" require "chef/provider" @@ -126,7 +126,7 @@ class Chef new_resource.revision else command = scm(:info, new_resource.repository, new_resource.svn_info_args, authentication, "-r#{new_resource.revision}") - svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0, 1])).stdout + svn_info = shell_out!(command, run_options(cwd: cwd, returns: [0, 1])).stdout extract_revision_info(svn_info) end @@ -138,7 +138,7 @@ class Chef def find_current_revision return nil unless ::File.exist?(::File.join(new_resource.destination, ".svn")) command = scm(:info) - svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0, 1])).stdout + svn_info = shell_out!(command, run_options(cwd: cwd, returns: [0, 1])).stdout extract_revision_info(svn_info) end diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb index 0450516d58..44f34fb8d7 100644 --- a/lib/chef/provider/systemd_unit.rb +++ b/lib/chef/provider/systemd_unit.rb @@ -247,8 +247,8 @@ class Chef if new_resource.user uid = Etc.getpwnam(new_resource.user).uid { - :user => new_resource.user, - :environment => { + user: new_resource.user, + environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus", }, } diff --git a/lib/chef/provider/template/content.rb b/lib/chef/provider/template/content.rb index b40794564a..9ac5a89b3e 100644 --- a/lib/chef/provider/template/content.rb +++ b/lib/chef/provider/template/content.rb @@ -29,7 +29,7 @@ class Chef def template_location @template_file_cache_location ||= begin - template_finder.find(new_resource.source, :local => new_resource.local, :cookbook => new_resource.cookbook) + template_finder.find(new_resource.source, local: new_resource.local, cookbook: new_resource.cookbook) end end diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index c22329d0d6..9584e20656 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -326,7 +326,7 @@ user password using shadow hash.") end def ditto_home - shell_out!("/usr/sbin/createhomedir", "-c", "-u", "#{new_resource.username}") + shell_out!("/usr/sbin/createhomedir", "-c", "-u", (new_resource.username).to_s) end def move_home diff --git a/lib/chef/provider/windows_env.rb b/lib/chef/provider/windows_env.rb index 4e7fa34216..e5af49fa8f 100644 --- a/lib/chef/provider/windows_env.rb +++ b/lib/chef/provider/windows_env.rb @@ -63,7 +63,7 @@ class Chef # <false>:: If a change is not required def requires_modify_or_create? if new_resource.delim - #e.g. check for existing value within PATH + # e.g. check for existing value within PATH new_values.inject(0) do |index, val| next_index = current_values.find_index val return true if next_index.nil? || next_index < index @@ -91,18 +91,18 @@ class Chef end end - #e.g. delete a PATH element + # e.g. delete a PATH element # # ==== Returns # <true>:: If we handled the element case and caller should not delete the key # <false>:: Caller should delete the key, either no :delim was specific or value was empty # after we removed the element. def delete_element - return false unless new_resource.delim #no delim: delete the key + return false unless new_resource.delim # no delim: delete the key needs_delete = new_values.any? { |v| current_values.include?(v) } if !needs_delete logger.trace("#{new_resource} element '#{new_resource.value}' does not exist") - return true #do not delete the key + return true # do not delete the key else new_value = current_values.select do |item| @@ -110,13 +110,13 @@ class Chef end.join(new_resource.delim) if new_value.empty? - return false #nothing left here, delete the key + return false # nothing left here, delete the key else old_value = new_resource.value(new_value) create_env logger.trace("#{new_resource} deleted #{old_value} element") new_resource.updated_by_last_action(true) - return true #we removed the element and updated; do not delete the key + return true # we removed the element and updated; do not delete the key end end end diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb index 1676ec3f6b..f8df5dc9a8 100644 --- a/lib/chef/provider/windows_task.rb +++ b/lib/chef/provider/windows_task.rb @@ -46,7 +46,7 @@ class Chef SEP: TaskScheduler::SEPTEMBER, OCT: TaskScheduler::OCTOBER, NOV: TaskScheduler::NOVEMBER, - DEC: TaskScheduler::DECEMBER + DEC: TaskScheduler::DECEMBER, } DAYS_OF_WEEK = { MON: TaskScheduler::MONDAY, @@ -61,7 +61,7 @@ class Chef FIRST: TaskScheduler::FIRST_WEEK, SECOND: TaskScheduler::SECOND_WEEK, THIRD: TaskScheduler::THIRD_WEEK, - FOURTH: TaskScheduler::FOURTH_WEEK + FOURTH: TaskScheduler::FOURTH_WEEK, } DAYS_OF_MONTH = { @@ -95,7 +95,7 @@ class Chef 28 => TaskScheduler::TASK_TWENTY_EIGHTH, 29 => TaskScheduler::TASK_TWENTY_NINTH, 30 => TaskScheduler::TASK_THIRTYETH, - 31 => TaskScheduler::TASK_THIRTY_FIRST + 31 => TaskScheduler::TASK_THIRTY_FIRST, } def load_current_resource @@ -195,7 +195,7 @@ class Chef logger.trace "#{new_resource} task exists" if current_resource.task.status == "not scheduled" converge_by("#{new_resource} task enabled") do - #TODO wind32-taskscheduler currently not having any method to handle this so using schtasks.exe here + # TODO wind32-taskscheduler currently not having any method to handle this so using schtasks.exe here run_schtasks "CHANGE", "ENABLE" => "" end else @@ -212,7 +212,7 @@ class Chef logger.info "#{new_resource} task exists" if %w{ready running}.include?(current_resource.task.status) converge_by("#{new_resource} task disabled") do - #TODO: in win32-taskscheduler there is no method whcih disbales the task so currently calling disable with schtasks.exe + # TODO: in win32-taskscheduler there is no method whcih disbales the task so currently calling disable with schtasks.exe run_schtasks "CHANGE", "DISABLE" => "" end else @@ -256,7 +256,7 @@ class Chef def trigger start_month, start_day, start_year = new_resource.start_day.to_s.split("/") start_hour, start_minute = new_resource.start_time.to_s.split(":") - #TODO currently end_month, end_year and end_year needs to be set to 0. If not set win32-taskscheduler throwing nil into integer error. + # TODO currently end_month, end_year and end_year needs to be set to 0. If not set win32-taskscheduler throwing nil into integer error. trigger_hash = { start_year: start_year.to_i, start_month: start_month.to_i, @@ -268,7 +268,7 @@ class Chef end_year: 0, trigger_type: trigger_type, type: type, - random_minutes_interval: new_resource.random_delay + random_minutes_interval: new_resource.random_delay, } if new_resource.frequency == :minute @@ -318,7 +318,7 @@ class Chef hours.to_i * 60 if hours end - #TODO : Try to optimize this method + # TODO : Try to optimize this method # known issue : Since start_day and time is not mandatory while updating weekly frequency for which start_day is not mentioned by user idempotency # is not gettting maintained as new_resource.start_day is nil and we fetch the day of week from start_day to set and its currently coming as nil and don't match with current_task def task_needs_update?(task) @@ -452,7 +452,7 @@ class Chef def days_of_week if new_resource.day - #this line of code is just to support backward compatibility of wild card * + # this line of code is just to support backward compatibility of wild card * new_resource.day = "mon, tue, wed, thu, fri, sat, sun" if new_resource.day == "*" && new_resource.frequency == :weekly days = new_resource.day.split(",") days.map! { |day| day.to_s.strip.upcase } @@ -475,7 +475,7 @@ class Chef end if new_resource.months - #this line of code is just to support backward compatibility of wild card * + # this line of code is just to support backward compatibility of wild card * new_resource.months = "jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec" if new_resource.months == "*" && new_resource.frequency == :monthly months = new_resource.months.split(",") months.map! { |month| month.to_s.strip.upcase } @@ -539,11 +539,11 @@ class Chef end end - #TODO: while creating the configuration settings win32-taskscheduler it accepts execution time limit values in ISO8601 formata + # TODO: while creating the configuration settings win32-taskscheduler it accepts execution time limit values in ISO8601 formata def config_settings settings = { execution_time_limit: new_resource.execution_time_limit, - enabled: true + enabled: true, } settings[:idle_duration] = new_resource.idle_time if new_resource.idle_time settings[:run_only_if_idle] = true if new_resource.idle_time |