summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
commit686113531d23f30e9973d659c456ae33eb9cff1f (patch)
treef225de7251a8b49b8d183dd168bab0a0addbe23f /lib/chef/provider
parentd1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff)
downloadchef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces 1860 Style/SpaceAroundOperators 1336 Style/SpaceInsideBlockBraces 1292 Style/AlignHash 997 Style/SpaceAfterComma 860 Style/SpaceAroundEqualsInParameterDefault 310 Style/EmptyLines 294 Style/IndentationConsistency 267 Style/TrailingWhitespace 238 Style/ExtraSpacing 212 Style/SpaceBeforeBlockBraces 166 Style/MultilineOperationIndentation 144 Style/TrailingBlankLines 120 Style/EmptyLineBetweenDefs 101 Style/IndentationWidth 82 Style/SpaceAroundBlockParameters 40 Style/EmptyLinesAroundMethodBody 29 Style/EmptyLinesAroundAccessModifier 1 Style/RescueEnsureAlignment
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/apt_update.rb1
-rw-r--r--lib/chef/provider/cron.rb6
-rw-r--r--lib/chef/provider/deploy.rb11
-rw-r--r--lib/chef/provider/deploy/revision.rb4
-rw-r--r--lib/chef/provider/dsc_resource.rb6
-rw-r--r--lib/chef/provider/dsc_script.rb6
-rw-r--r--lib/chef/provider/env.rb18
-rw-r--r--lib/chef/provider/execute.rb6
-rw-r--r--lib/chef/provider/file.rb6
-rw-r--r--lib/chef/provider/git.rb28
-rw-r--r--lib/chef/provider/group.rb2
-rw-r--r--lib/chef/provider/group/aix.rb2
-rw-r--r--lib/chef/provider/group/dscl.rb10
-rw-r--r--lib/chef/provider/group/groupadd.rb2
-rw-r--r--lib/chef/provider/group/groupmod.rb2
-rw-r--r--lib/chef/provider/group/windows.rb2
-rw-r--r--lib/chef/provider/http_request.rb12
-rw-r--r--lib/chef/provider/ifconfig.rb3
-rw-r--r--lib/chef/provider/ifconfig/aix.rb3
-rw-r--r--lib/chef/provider/ifconfig/debian.rb2
-rw-r--r--lib/chef/provider/link.rb4
-rw-r--r--lib/chef/provider/mdadm.rb2
-rw-r--r--lib/chef/provider/mount/aix.rb6
-rw-r--r--lib/chef/provider/mount/mount.rb8
-rw-r--r--lib/chef/provider/mount/solaris.rb2
-rw-r--r--lib/chef/provider/osx_profile.rb13
-rw-r--r--lib/chef/provider/package.rb6
-rw-r--r--lib/chef/provider/package/aix.rb6
-rw-r--r--lib/chef/provider/package/chocolatey.rb12
-rw-r--r--lib/chef/provider/package/dpkg.rb8
-rw-r--r--lib/chef/provider/package/easy_install.rb16
-rw-r--r--lib/chef/provider/package/freebsd/base.rb4
-rw-r--r--lib/chef/provider/package/freebsd/pkg.rb4
-rw-r--r--lib/chef/provider/package/freebsd/pkgng.rb2
-rw-r--r--lib/chef/provider/package/freebsd/port.rb4
-rw-r--r--lib/chef/provider/package/macports.rb1
-rw-r--r--lib/chef/provider/package/openbsd.rb6
-rw-r--r--lib/chef/provider/package/pacman.rb5
-rw-r--r--lib/chef/provider/package/paludis.rb2
-rw-r--r--lib/chef/provider/package/portage.rb9
-rw-r--r--lib/chef/provider/package/rubygems.rb30
-rw-r--r--lib/chef/provider/package/smartos.rb4
-rw-r--r--lib/chef/provider/package/windows.rb4
-rw-r--r--lib/chef/provider/package/windows/msi.rb12
-rw-r--r--lib/chef/provider/package/yum.rb53
-rw-r--r--lib/chef/provider/package/zypper.rb4
-rw-r--r--lib/chef/provider/powershell_script.rb6
-rw-r--r--lib/chef/provider/registry_key.rb8
-rw-r--r--lib/chef/provider/remote_directory.rb4
-rw-r--r--lib/chef/provider/remote_file/cache_control_data.rb3
-rw-r--r--lib/chef/provider/remote_file/http.rb2
-rw-r--r--lib/chef/provider/remote_file/local_file.rb2
-rw-r--r--lib/chef/provider/route.rb366
-rw-r--r--lib/chef/provider/service.rb14
-rw-r--r--lib/chef/provider/service/aix.rb2
-rw-r--r--lib/chef/provider/service/aixinit.rb10
-rw-r--r--lib/chef/provider/service/arch.rb6
-rw-r--r--lib/chef/provider/service/debian.rb17
-rw-r--r--lib/chef/provider/service/freebsd.rb2
-rw-r--r--lib/chef/provider/service/macosx.rb2
-rw-r--r--lib/chef/provider/service/openbsd.rb2
-rw-r--r--lib/chef/provider/service/redhat.rb2
-rw-r--r--lib/chef/provider/service/simple.rb3
-rw-r--r--lib/chef/provider/service/solaris.rb2
-rw-r--r--lib/chef/provider/service/upstart.rb4
-rw-r--r--lib/chef/provider/service/windows.rb5
-rw-r--r--lib/chef/provider/subversion.rb12
-rw-r--r--lib/chef/provider/template_finder.rb1
-rw-r--r--lib/chef/provider/user.rb3
-rw-r--r--lib/chef/provider/user/aix.rb3
-rw-r--r--lib/chef/provider/user/dscl.rb35
-rw-r--r--lib/chef/provider/user/pw.rb2
-rw-r--r--lib/chef/provider/user/useradd.rb2
-rw-r--r--lib/chef/provider/user/windows.rb8
-rw-r--r--lib/chef/provider/windows_script.rb2
75 files changed, 443 insertions, 446 deletions
diff --git a/lib/chef/provider/apt_update.rb b/lib/chef/provider/apt_update.rb
index 00c3ad16bb..449b298804 100644
--- a/lib/chef/provider/apt_update.rb
+++ b/lib/chef/provider/apt_update.rb
@@ -51,6 +51,7 @@ class Chef
end
private
+
# Determines whether we need to run `apt-get update`
#
# @return [Boolean]
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index 01351603ca..36b67ab6a5 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -67,7 +67,7 @@ class Chef
if cron_found
@current_resource.time($2.to_sym)
@current_resource.command($3)
- cron_found=false
+ cron_found = false
end
when CRON_PATTERN
if cron_found
@@ -77,11 +77,11 @@ class Chef
@current_resource.month($4)
@current_resource.weekday($5)
@current_resource.command($6)
- cron_found=false
+ cron_found = false
end
next
else
- cron_found=false # We've got a Chef comment with no following crontab line
+ cron_found = false # We've got a Chef comment with no following crontab line
next
end
end
diff --git a/lib/chef/provider/deploy.rb b/lib/chef/provider/deploy.rb
index d53cce1311..7274ab2e8f 100644
--- a/lib/chef/provider/deploy.rb
+++ b/lib/chef/provider/deploy.rb
@@ -56,7 +56,7 @@ class Chef
@shared_path = @new_resource.shared_path
end
- def sudo(command,&block)
+ def sudo(command, &block)
execute(command, &block)
end
@@ -93,7 +93,6 @@ class Chef
a.whyrun("Would assume callback file #{callback_file} included in release")
end
end
-
end
def action_deploy
@@ -175,7 +174,7 @@ class Chef
restart
end
- def callback(what, callback_code=nil)
+ def callback(what, callback_code = nil)
@collection = Chef::ResourceCollection.new
case callback_code
when Proc
@@ -201,7 +200,7 @@ class Chef
converge_by("execute migration command #{@new_resource.migration_command}") do
Chef::Log.info "#{@new_resource} migrating #{@new_resource.user} with environment #{env_info}"
- shell_out!(@new_resource.migration_command,run_options(:cwd=>release_path, :log_level => :info))
+ shell_out!(@new_resource.migration_command, run_options(:cwd => release_path, :log_level => :info))
end
end
end
@@ -221,7 +220,7 @@ class Chef
else
converge_by("restart app using command #{@new_resource.restart_command}") do
Chef::Log.info("#{@new_resource} restarting app")
- shell_out!(@new_resource.restart_command,run_options(:cwd=>@new_resource.current_path))
+ shell_out!(@new_resource.restart_command, run_options(:cwd => @new_resource.current_path))
end
end
end
@@ -391,7 +390,7 @@ class Chef
end
end
- def run_options(run_opts={})
+ def run_options(run_opts = {})
run_opts[:user] = @new_resource.user if @new_resource.user
run_opts[:group] = @new_resource.group if @new_resource.group
run_opts[:environment] = @new_resource.environment if @new_resource.environment
diff --git a/lib/chef/provider/deploy/revision.rb b/lib/chef/provider/deploy/revision.rb
index 0bd30ce762..9e2bb94f5b 100644
--- a/lib/chef/provider/deploy/revision.rb
+++ b/lib/chef/provider/deploy/revision.rb
@@ -56,11 +56,11 @@ class Chef
protected
def release_created(release)
- sorted_releases {|r| r.delete(release); r << release }
+ sorted_releases { |r| r.delete(release); r << release }
end
def release_deleted(release)
- sorted_releases { |r| r.delete(release)}
+ sorted_releases { |r| r.delete(release) }
end
def release_slug
diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb
index 1f6a8f0ef6..eac8a829bd 100644
--- a/lib/chef/provider/dsc_resource.rb
+++ b/lib/chef/provider/dsc_resource.rb
@@ -132,7 +132,7 @@ class Chef
create_reboot_resource if return_dsc_resource_result(result, "RebootRequired")
result.return_value
end
-
+
def add_dsc_verbose_log(result)
# We really want this information from the verbose stream,
# however in some versions of WMF, Invoke-DscResource is not correctly
@@ -148,7 +148,7 @@ class Chef
end
end
- def invoke_resource(method, output_format=:object)
+ def invoke_resource(method, output_format = :object)
properties = translate_type(@new_resource.properties)
switches = "-Method #{method} -Name #{@new_resource.resource}"\
" -Property #{properties} -Verbose"
@@ -160,7 +160,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 b8686c4450..79769d9773 100644
--- a/lib/chef/provider/dsc_script.rb
+++ b/lib/chef/provider/dsc_script.rb
@@ -37,7 +37,7 @@ class Chef
},
:test => Proc.new { |config_manager, document, shellout_flags|
config_manager.test_configuration(document, shellout_flags)
- }}
+ } }
end
def action_run
@@ -138,7 +138,7 @@ class Chef
@dsc_resource.configuration_data_script
elsif @dsc_resource.configuration_data
configuration_data_path = "#{config_directory}/chef_dsc_config_data.psd1"
- ::File.open(configuration_data_path, "wt") do | script |
+ ::File.open(configuration_data_path, "wt") do |script|
script.write(@dsc_resource.configuration_data)
end
configuration_data_path
@@ -165,7 +165,7 @@ class Chef
if resource.changes_state?
# We ignore the last log message because it only contains the time it took, which looks weird
cleaned_messages = resource.change_log[0..-2].map { |c| c.sub(/^#{Regexp.escape(resource.name)}/, "").strip }
- "converge DSC resource #{resource.name} by #{cleaned_messages.find_all{ |c| c != ''}.join("\n")}"
+ "converge DSC resource #{resource.name} by #{cleaned_messages.find_all { |c| c != '' }.join("\n")}"
else
# This is needed because a dsc script can have resources that are both converged and not
"converge DSC resource #{resource.name} by doing nothing because it is already converged"
diff --git a/lib/chef/provider/env.rb b/lib/chef/provider/env.rb
index fda41aca39..5b252dd344 100644
--- a/lib/chef/provider/env.rb
+++ b/lib/chef/provider/env.rb
@@ -108,15 +108,15 @@ class Chef
not new_values.include?(item)
end.join(@new_resource.delim)
- if new_value.empty?
- return false #nothing left here, delete the key
- else
- old_value = @new_resource.value(new_value)
- create_env
- Chef::Log.debug("#{@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
- end
+ if new_value.empty?
+ return false #nothing left here, delete the key
+ else
+ old_value = @new_resource.value(new_value)
+ create_env
+ Chef::Log.debug("#{@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
+ end
end
end
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
index fde60ba33f..45f0ad5488 100644
--- a/lib/chef/provider/execute.rb
+++ b/lib/chef/provider/execute.rb
@@ -40,9 +40,9 @@ class Chef
def define_resource_requirements
# @todo: this should change to raise in some appropriate major version bump.
- if creates && creates_relative? && !cwd
- Chef::Log.warn "Providing a relative path for the creates attribute without the cwd is deprecated and will be changed to fail in the future (CHEF-3819)"
- end
+ if creates && creates_relative? && !cwd
+ Chef::Log.warn "Providing a relative path for the creates attribute without the cwd is deprecated and will be changed to fail in the future (CHEF-3819)"
+ end
end
def timeout
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index 2be01889af..7f85085eeb 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -130,7 +130,7 @@ class Chef
if ::File.exist?(@new_resource.path)
requirements.assert(:delete) do |a|
a.assertion { ::File.writable?(@new_resource.path) }
- a.failure_message(Chef::Exceptions::InsufficientPermissions,"File #{@new_resource.path} exists but is not writable so it cannot be deleted")
+ a.failure_message(Chef::Exceptions::InsufficientPermissions, "File #{@new_resource.path} exists but is not writable so it cannot be deleted")
end
end
@@ -266,7 +266,7 @@ class Chef
else
[ Chef::Exceptions::FileTypeMismatch,
"File #{path} exists, but is a symlink to #{real_path} which is a #{file_type_string(real_path)}. " +
- "Disable manage_symlink_source and set force_unlink to remove it.",
+ "Disable manage_symlink_source and set force_unlink to remove it.",
"Assuming symlink #{path} or source file #{real_path} would have been fixed by a previous resource",
]
end
@@ -464,7 +464,7 @@ class Chef
def short_cksum(checksum)
return "none" if checksum.nil?
- checksum.slice(0,6)
+ checksum.slice(0, 6)
end
def load_resource_attributes_from_file(resource)
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index f197729367..f8a8dabb46 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -53,9 +53,9 @@ class Chef
a.assertion { !(@new_resource.revision =~ /^origin\//) }
a.failure_message Chef::Exceptions::InvalidRemoteGitReference,
"Deploying remote branches is not supported. " +
- "Specify the remote branch as a local branch for " +
- "the git repository you're deploying from " +
- "(ie: '#{@new_resource.revision.gsub('origin/', '')}' rather than '#{@new_resource.revision}')."
+ "Specify the remote branch as a local branch for " +
+ "the git repository you're deploying from " +
+ "(ie: '#{@new_resource.revision.gsub('origin/', '')}' rather than '#{@new_resource.revision}')."
end
requirements.assert(:all_actions) do |a|
@@ -65,8 +65,8 @@ class Chef
a.assertion { target_revision != nil }
a.failure_message Chef::Exceptions::UnresolvableGitReference,
"Unable to parse SHA reference for '#{@new_resource.revision}' in repository '#{@new_resource.repository}'. " +
- "Verify your (case-sensitive) repository URL and revision.\n" +
- "`git ls-remote '#{@new_resource.repository}' '#{rev_search_pattern}'` output: #{@resolved_reference}"
+ "Verify your (case-sensitive) repository URL and revision.\n" +
+ "`git ls-remote '#{@new_resource.repository}' '#{rev_search_pattern}'` output: #{@resolved_reference}"
end
end
@@ -86,7 +86,7 @@ class Chef
def action_export
action_checkout
converge_by("complete the export by removing #{@new_resource.destination}.git after checkout") do
- FileUtils.rm_rf(::File.join(@new_resource.destination,".git"))
+ FileUtils.rm_rf(::File.join(@new_resource.destination, ".git"))
end
end
@@ -113,14 +113,14 @@ class Chef
end
def target_dir_non_existent_or_empty?
- !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination).sort == [".",".."]
+ !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination).sort == [".", ".."]
end
def find_current_revision
Chef::Log.debug("#{@new_resource} finding current git revision")
if ::File.exist?(::File.join(cwd, ".git"))
# 128 is returned when we're not in a git repo. this is fine
- result = shell_out!("git rev-parse HEAD", :cwd => cwd, :returns => [0,128]).stdout.strip
+ result = shell_out!("git rev-parse HEAD", :cwd => cwd, :returns => [0, 128]).stdout.strip
end
sha_hash?(result) ? result : nil
end
@@ -189,10 +189,9 @@ class Chef
def setup_remote_tracking_branches(remote_name, remote_url)
converge_by("set up remote tracking branches for #{remote_url} at #{remote_name}") do
- Chef::Log.debug "#{@new_resource} configuring remote tracking branches for repository #{remote_url} "+
- "at remote #{remote_name}"
+ Chef::Log.debug "#{@new_resource} configuring remote tracking branches for repository #{remote_url} " + "at remote #{remote_name}"
check_remote_command = "git config --get remote.#{remote_name}.url"
- remote_status = shell_out!(check_remote_command, run_options(:cwd => @new_resource.destination, :returns => [0,1,2]))
+ remote_status = shell_out!(check_remote_command, run_options(:cwd => @new_resource.destination, :returns => [0, 1, 2]))
case remote_status.exitstatus
when 0, 2
# * Status 0 means that we already have a remote with this name, so we should update the url
@@ -200,7 +199,7 @@ class Chef
# * Status 2 means that we have multiple urls assigned to the same remote (not a good idea)
# which we can fix by replacing them all with our target url (hence the --replace-all option)
- if multiple_remotes?(remote_status) || !remote_matches?(remote_url,remote_status)
+ if multiple_remotes?(remote_status) || !remote_matches?(remote_url, remote_status)
update_remote_url_command = "git config --replace-all remote.#{remote_name}.url #{remote_url}"
shell_out!(update_remote_url_command, run_options(:cwd => @new_resource.destination))
end
@@ -259,7 +258,7 @@ class Chef
found.size == 1 ? found.first[0] : nil
end
- def find_revision(refs, revision, suffix="")
+ def find_revision(refs, revision, suffix = "")
found = refs_search(refs, rev_match_pattern("refs/tags/", revision) + suffix)
found = refs_search(refs, rev_match_pattern("refs/heads/", revision) + suffix) if found.empty?
found = refs_search(refs, revision + suffix) if found.empty?
@@ -293,7 +292,7 @@ class Chef
private
- def run_options(run_opts={})
+ def run_options(run_opts = {})
env = {}
if @new_resource.user
run_opts[:user] = @new_resource.user
@@ -314,7 +313,6 @@ class Chef
env.merge!(@new_resource.environment) if @new_resource.environment
run_opts[:environment] = env unless env.empty?
run_opts
-
end
def cwd
diff --git a/lib/chef/provider/group.rb b/lib/chef/provider/group.rb
index 0c98730155..efcbef8014 100644
--- a/lib/chef/provider/group.rb
+++ b/lib/chef/provider/group.rb
@@ -86,7 +86,7 @@ class Chef
# <false>:: If a change is not required
def compare_group
@change_desc = [ ]
- if @new_resource.gid.to_s != @current_resource.gid.to_s
+ if @new_resource.gid.to_s != @current_resource.gid.to_s
@change_desc << "change gid #{@current_resource.gid} to #{@new_resource.gid}"
end
diff --git a/lib/chef/provider/group/aix.rb b/lib/chef/provider/group/aix.rb
index 196ce1345a..4a02d5ef8c 100644
--- a/lib/chef/provider/group/aix.rb
+++ b/lib/chef/provider/group/aix.rb
@@ -69,7 +69,7 @@ class Chef
def set_options
opts = ""
- { :gid => "id" }.sort { |a,b| a[0] <=> b[0] }.each do |field, option|
+ { :gid => "id" }.sort { |a, b| a[0] <=> b[0] }.each do |field, option|
if @current_resource.send(field) != @new_resource.send(field)
if @new_resource.send(field)
Chef::Log.debug("#{@new_resource} setting #{field} to #{@new_resource.send(field)}")
diff --git a/lib/chef/provider/group/dscl.rb b/lib/chef/provider/group/dscl.rb
index b433d57a03..08661f21b8 100644
--- a/lib/chef/provider/group/dscl.rb
+++ b/lib/chef/provider/group/dscl.rb
@@ -35,8 +35,8 @@ class Chef
def safe_dscl(*args)
result = dscl(*args)
return "" if ( args.first =~ /^delete/ ) && ( result[1].exitstatus != 0 )
- raise(Chef::Exceptions::Group,"dscl error: #{result.inspect}") unless result[1].exitstatus == 0
- raise(Chef::Exceptions::Group,"dscl error: #{result.inspect}") if result[2] =~ /No such key: /
+ raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") unless result[1].exitstatus == 0
+ raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") if result[2] =~ /No such key: /
return result[2]
end
@@ -69,7 +69,7 @@ class Chef
end
# get a free GID greater than 200
- def get_free_gid(search_limit=1000)
+ def get_free_gid(search_limit = 1000)
gid = nil; next_gid_guess = 200
groups_gids = safe_dscl("list /Groups gid")
while(next_gid_guess < search_limit + 200)
@@ -90,8 +90,8 @@ class Chef
end
def set_gid
- @new_resource.gid(get_free_gid) if [nil,""].include? @new_resource.gid
- raise(Chef::Exceptions::Group,"gid is already in use") if gid_used?(@new_resource.gid)
+ @new_resource.gid(get_free_gid) if [nil, ""].include? @new_resource.gid
+ raise(Chef::Exceptions::Group, "gid is already in use") if gid_used?(@new_resource.gid)
safe_dscl("create /Groups/#{@new_resource.group_name} PrimaryGroupID #{@new_resource.gid}")
end
diff --git a/lib/chef/provider/group/groupadd.rb b/lib/chef/provider/group/groupadd.rb
index 8f87054262..bc6b5d0208 100644
--- a/lib/chef/provider/group/groupadd.rb
+++ b/lib/chef/provider/group/groupadd.rb
@@ -113,7 +113,7 @@ class Chef
# <string>:: A string containing the option and then the quoted value
def set_options
opts = ""
- { :gid => "-g" }.sort { |a,b| a[0] <=> b[0] }.each do |field, option|
+ { :gid => "-g" }.sort { |a, b| a[0] <=> b[0] }.each do |field, option|
if @current_resource.send(field) != @new_resource.send(field)
if @new_resource.send(field)
opts << " #{option} '#{@new_resource.send(field)}'"
diff --git a/lib/chef/provider/group/groupmod.rb b/lib/chef/provider/group/groupmod.rb
index 8169e50595..379d00e286 100644
--- a/lib/chef/provider/group/groupmod.rb
+++ b/lib/chef/provider/group/groupmod.rb
@@ -111,7 +111,7 @@ class Chef
#
# ==== Returns
# <string>:: A string containing the option and then the quoted value
- def set_options(overwrite_gid=false)
+ def set_options(overwrite_gid = false)
opts = ""
if overwrite_gid || @new_resource.gid && (@current_resource.gid != @new_resource.gid)
opts << " -g '#{@new_resource.gid}'"
diff --git a/lib/chef/provider/group/windows.rb b/lib/chef/provider/group/windows.rb
index 3c052cb92a..64b4587487 100644
--- a/lib/chef/provider/group/windows.rb
+++ b/lib/chef/provider/group/windows.rb
@@ -28,7 +28,7 @@ class Chef
provides :group, os: "windows"
- def initialize(new_resource,run_context)
+ def initialize(new_resource, run_context)
super
@net_group = Chef::Util::Windows::NetGroup.new(@new_resource.group_name)
end
diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb
index 9a261b8d79..b52368f472 100644
--- a/lib/chef/provider/http_request.rb
+++ b/lib/chef/provider/http_request.rb
@@ -109,13 +109,13 @@ class Chef
private
- def check_message(message)
- if message.kind_of?(Proc)
- message.call
- else
- message
- end
+ def check_message(message)
+ if message.kind_of?(Proc)
+ message.call
+ else
+ message
end
+ end
end
end
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index 50b05304ff..d00d5cd155 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -67,7 +67,7 @@ class Chef
@status.stdout.each_line do |line|
if !line[0..9].strip.empty?
@int_name = line[0..9].strip
- @interfaces[@int_name] = {"hwaddr" => (line =~ /(HWaddr)/ ? ($') : "nil").strip.chomp }
+ @interfaces[@int_name] = { "hwaddr" => (line =~ /(HWaddr)/ ? ($') : "nil").strip.chomp }
else
@interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? ($1) : "nil") if line =~ /inet addr:/
@interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? ($1) : "nil") if line =~ /Bcast:/
@@ -193,6 +193,7 @@ class Chef
end
private
+
def add_command
command = "ifconfig #{@new_resource.device} #{@new_resource.target}"
command << " netmask #{@new_resource.mask}" if @new_resource.mask
diff --git a/lib/chef/provider/ifconfig/aix.rb b/lib/chef/provider/ifconfig/aix.rb
index 65c559a150..81164db304 100644
--- a/lib/chef/provider/ifconfig/aix.rb
+++ b/lib/chef/provider/ifconfig/aix.rb
@@ -67,6 +67,7 @@ class Chef
end
private
+
def add_command
# ifconfig changes are temporary, chdev persist across reboots.
raise Chef::Exceptions::Ifconfig, "interface metric attribute cannot be set for :add action" if @new_resource.metric
@@ -88,7 +89,7 @@ class Chef
def hex_to_dec_netmask(netmask)
# example '0xffff0000' -> '255.255.0.0'
dec = netmask[2..3].to_i(16).to_s(10)
- [4,6,8].each { |n| dec = dec + "." + netmask[n..n+1].to_i(16).to_s(10) }
+ [4, 6, 8].each { |n| dec = dec + "." + netmask[n..n + 1].to_i(16).to_s(10) }
dec
end
diff --git a/lib/chef/provider/ifconfig/debian.rb b/lib/chef/provider/ifconfig/debian.rb
index 4752f784ae..872b0db152 100644
--- a/lib/chef/provider/ifconfig/debian.rb
+++ b/lib/chef/provider/ifconfig/debian.rb
@@ -67,7 +67,7 @@ iface <%= @new_resource.device %> inet static
dir.run_action(:create)
new_resource.updated_by_last_action(true) if dir.updated_by_last_action?
# roll our own file_edit resource, this will not get reported until we have a file_edit resource
- interfaces_dot_d_for_regexp = INTERFACES_DOT_D_DIR.gsub(/\./, '\.') # escape dots for the regexp
+ interfaces_dot_d_for_regexp = INTERFACES_DOT_D_DIR.gsub(/\./, '\.') # escape dots for the regexp
regexp = %r{^\s*source\s+#{interfaces_dot_d_for_regexp}/\*\s*$}
unless ::File.exists?(INTERFACES_FILE) && regexp.match(IO.read(INTERFACES_FILE))
converge_by("modifying #{INTERFACES_FILE} to source #{INTERFACES_DOT_D_DIR}") do
diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb
index b8cffee695..116efccaef 100644
--- a/lib/chef/provider/link.rb
+++ b/lib/chef/provider/link.rb
@@ -75,7 +75,7 @@ class Chef
a.assertion do
if @current_resource.to
@current_resource.link_type == @new_resource.link_type and
- (@current_resource.link_type == :symbolic or @current_resource.to != "")
+ (@current_resource.link_type == :symbolic or @current_resource.to != "")
else
true
end
@@ -118,7 +118,7 @@ class Chef
end
if @new_resource.link_type == :symbolic
converge_by("create symlink at #{@new_resource.target_file} to #{@new_resource.to}") do
- file_class.symlink(canonicalize(@new_resource.to),@new_resource.target_file)
+ file_class.symlink(canonicalize(@new_resource.to), @new_resource.target_file)
Chef::Log.debug("#{@new_resource} created #{@new_resource.link_type} link from #{@new_resource.target_file} -> #{@new_resource.to}")
Chef::Log.info("#{@new_resource} created")
end
diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb
index f99dcc1fd3..d047b6913e 100644
--- a/lib/chef/provider/mdadm.rb
+++ b/lib/chef/provider/mdadm.rb
@@ -39,7 +39,7 @@ class Chef
Chef::Log.debug("#{@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/aix.rb b/lib/chef/provider/mount/aix.rb
index 9df2e63bf4..12f0d67e6b 100644
--- a/lib/chef/provider/mount/aix.rb
+++ b/lib/chef/provider/mount/aix.rb
@@ -42,7 +42,7 @@ class Chef
# lsfs o/p = #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
# search only for current mount point
- shell_out("lsfs -c #{@new_resource.mount_point}").stdout.each_line do | line |
+ shell_out("lsfs -c #{@new_resource.mount_point}").stdout.each_line do |line|
case line
when /^#\s/
next
@@ -61,7 +61,7 @@ class Chef
Chef::Log.debug("Found mount #{device_fstab} to #{@new_resource.mount_point} in /etc/filesystems")
next
when /^#{Regexp.escape(@new_resource.mount_point)}/
- enabled=false
+ enabled = false
Chef::Log.debug("Found conflicting mount point #{@new_resource.mount_point} in /etc/filesystems")
end
end
@@ -167,7 +167,7 @@ class Chef
end
end
::File.open("/etc/filesystems", "w") do |fstab|
- contents.each { |line| fstab.puts line}
+ contents.each { |line| fstab.puts line }
end
else
Chef::Log.debug("#{@new_resource} is not enabled - nothing to do")
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index 0daacbf96d..f8b8684a1b 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -170,7 +170,7 @@ class Chef
found = false
::File.readlines("/etc/fstab").reverse_each do |line|
if !found && line =~ /^#{device_fstab_regex}\s+#{Regexp.escape(@new_resource.mount_point)}\s/
- found = true
+ found = true
Chef::Log.debug("#{@new_resource} is removed from fstab")
next
else
@@ -179,7 +179,7 @@ class Chef
end
::File.open("/etc/fstab", "w") do |fstab|
- contents.reverse_each { |line| fstab.puts line}
+ contents.reverse_each { |line| fstab.puts line }
end
else
Chef::Log.debug("#{@new_resource} is not enabled - nothing to do")
@@ -237,13 +237,13 @@ class Chef
def device_mount_regex
if network_device?
# ignore trailing slash
- Regexp.escape(device_real)+"/?"
+ Regexp.escape(device_real) + "/?"
elsif ::File.symlink?(device_real)
# This regular expression tries to match device_real. If that does not match it will try to match the target of device_real.
# So given a symlink like this:
# /dev/mapper/vgroot-tmp.vol -> /dev/dm-9
# First it will try to match "/dev/mapper/vgroot-tmp.vol". If there is no match it will try matching for "/dev/dm-9".
- "(?:#{Regexp.escape(device_real)}|#{Regexp.escape(::File.expand_path(::File.readlink(device_real),::File.dirname(device_real)))})"
+ "(?:#{Regexp.escape(device_real)}|#{Regexp.escape(::File.expand_path(::File.readlink(device_real), ::File.dirname(device_real)))})"
else
Regexp.escape(device_real)
end
diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb
index 4d2381b6d8..a5a7a327cb 100644
--- a/lib/chef/provider/mount/solaris.rb
+++ b/lib/chef/provider/mount/solaris.rb
@@ -236,7 +236,7 @@ class Chef
found = false
::File.readlines(VFSTAB).reverse_each do |line|
if !found && line =~ /^#{device_regex}\s+\S+\s+#{Regexp.escape(mount_point)}/
- found = true
+ found = true
Chef::Log.debug("#{new_resource} is removed from vfstab")
next
end
diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb
index 2f5454ac15..e93d29bd1f 100644
--- a/lib/chef/provider/osx_profile.rb
+++ b/lib/chef/provider/osx_profile.rb
@@ -51,7 +51,7 @@ class Chef
@new_profile_identifier = @new_profile_hash["PayloadIdentifier"]
else
@new_profile_identifier = @new_resource.identifier ||
- @new_resource.profile_name
+ @new_resource.profile_name
end
if all_profiles.empty?
@@ -62,7 +62,6 @@ class Chef
end
end
@current_resource.profile(current_profile)
-
end
def define_resource_requirements
@@ -70,15 +69,15 @@ class Chef
if @new_profile_identifier
a.assertion {
!@new_profile_identifier.nil? and
- !@new_profile_identifier.end_with?(".mobileconfig") and
- /^\w+(?:\.\w+)+$/.match(@new_profile_identifier)
+ !@new_profile_identifier.end_with?(".mobileconfig") and
+ /^\w+(?:\.\w+)+$/.match(@new_profile_identifier)
}
a.failure_message RuntimeError, "when removing using the identifier attribute, it must match the profile identifier"
else
- new_profile_name = @new_resource.profile_name
+ new_profile_name = @new_resource.profile_name
a.assertion {
!new_profile_name.end_with?(".mobileconfig") and
- /^\w+(?:\.\w+)+$/.match(new_profile_name)
+ /^\w+(?:\.\w+)+$/.match(new_profile_name)
}
a.failure_message RuntimeError, "When removing by resource name, it must match the profile identifier "
end
@@ -206,7 +205,7 @@ class Chef
shellout_results.exitstatus
end
- def get_installed_profiles(update=nil)
+ def get_installed_profiles(update = nil)
if update
node.run_state[:config_profiles] = query_installed_profiles
else
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index a051a5fedd..ca9b526920 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -74,7 +74,7 @@ class Chef
# not, but as with the above comment, we don't yet enforce such a thing,
# so we'll just leave things as-is for now.
requirements.assert(:upgrade, :install) do |a|
- a.assertion { candidates_exist_for_all_uninstalled? || new_resource.source }
+ a.assertion { candidates_exist_for_all_uninstalled? || new_resource.source }
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}")
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured")
end
@@ -147,7 +147,7 @@ class Chef
def action_remove
if removing_package?
- description = @new_resource.version ? "version #{@new_resource.version} of " : ""
+ description = @new_resource.version ? "version #{@new_resource.version} of " : ""
converge_by("remove #{description}package #{@current_resource.package_name}") do
multipackage_api_adapter(@current_resource.package_name, @new_resource.version) do |name, version|
remove_package(name, version)
@@ -558,7 +558,7 @@ class Chef
# @param args [String] variable number of string arguments
# @return [String] nicely concatenated string or empty string
def a_to_s(*args)
- args.reject {|i| i.nil? || i == "" }.join(" ")
+ args.reject { |i| i.nil? || i == "" }.join(" ")
end
end
end
diff --git a/lib/chef/provider/package/aix.rb b/lib/chef/provider/package/aix.rb
index 732ca00b71..a1709c4af7 100644
--- a/lib/chef/provider/package/aix.rb
+++ b/lib/chef/provider/package/aix.rb
@@ -53,7 +53,7 @@ class Chef
if @package_source_found
Chef::Log.debug("#{@new_resource} checking pkg status")
ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
- ret.stdout.each_line do | line |
+ ret.stdout.each_line do |line|
case line
when /#{@new_resource.package_name}:/
fields = line.split(":")
@@ -66,7 +66,7 @@ class Chef
Chef::Log.debug("#{@new_resource} checking install state")
ret = shell_out_with_timeout("lslpp -lcq #{@current_resource.package_name}")
- ret.stdout.each_line do | line |
+ ret.stdout.each_line do |line|
case line
when /#{@current_resource.package_name}/
fields = line.split(":")
@@ -85,7 +85,7 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
- ret.stdout.each_line do | line |
+ ret.stdout.each_line do |line|
case line
when /\w:#{Regexp.escape(@new_resource.package_name)}:(.*)/
fields = line.split(":")
diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb
index 0d320a3aad..14613b0218 100644
--- a/lib/chef/provider/package/chocolatey.rb
+++ b/lib/chef/provider/package/chocolatey.rb
@@ -63,7 +63,7 @@ EOS
# and not a package specific alternate source like other providers
# so we want to assert candidates exist for the alternate source
requirements.assert(:upgrade, :install) do |a|
- a.assertion { candidates_exist_for_all_uninstalled? }
+ a.assertion { candidates_exist_for_all_uninstalled? }
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}")
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured")
end
@@ -84,8 +84,8 @@ EOS
def install_package(names, versions)
name_versions_to_install = desired_name_versions.select { |n, v| lowercase_names(names).include?(n) }
- name_nil_versions = name_versions_to_install.select { |n,v| v.nil? }
- name_has_versions = name_versions_to_install.reject { |n,v| v.nil? }
+ name_nil_versions = name_versions_to_install.select { |n, v| v.nil? }
+ name_has_versions = name_versions_to_install.reject { |n, v| v.nil? }
# choco does not support installing multiple packages with version pins
name_has_versions.each do |name, version|
@@ -106,8 +106,8 @@ EOS
def upgrade_package(names, versions)
name_versions_to_install = desired_name_versions.select { |n, v| lowercase_names(names).include?(n) }
- name_nil_versions = name_versions_to_install.select { |n,v| v.nil? }
- name_has_versions = name_versions_to_install.reject { |n,v| v.nil? }
+ name_nil_versions = name_versions_to_install.select { |n, v| v.nil? }
+ name_has_versions = name_versions_to_install.reject { |n, v| v.nil? }
# choco does not support installing multiple packages with version pins
name_has_versions.each do |name, version|
@@ -220,7 +220,7 @@ EOS
# @param args [String] variable number of string arguments
# @return [String] nicely concatenated string or empty string
def args_to_string(*args)
- args.reject {|i| i.nil? || i == "" }.join(" ")
+ args.reject { |i| i.nil? || i == "" }.join(" ")
end
# Available packages in chocolatey as a Hash of names mapped to versions
diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb
index f57b779ffa..a5a80e14d6 100644
--- a/lib/chef/provider/package/dpkg.rb
+++ b/lib/chef/provider/package/dpkg.rb
@@ -145,14 +145,14 @@ class Chef
#
# @return [Boolean] True if all sources exist
def source_files_exist?
- resolved_source_array.all? {|s| s && ::File.exist?(s) }
+ resolved_source_array.all? { |s| s && ::File.exist?(s) }
end
# Helper to return all the nanes of the missing sources for error messages.
#
# @return [Array<String>] Array of missing sources
def missing_sources
- resolved_source_array.select {|s| s.nil? || !::File.exist?(s) }
+ resolved_source_array.select { |s| s.nil? || !::File.exist?(s) }
end
def current_package_name_array
@@ -187,14 +187,14 @@ class Chef
def name_candidate_version
@name_candidate_version ||=
begin
- Hash[name_pkginfo.map {|k, v| [k, v ? v.split("\t")[1].strip : nil] }]
+ Hash[name_pkginfo.map { |k, v| [k, v ? v.split("\t")[1].strip : nil] }]
end
end
def name_package_name
@name_package_name ||=
begin
- Hash[name_pkginfo.map {|k, v| [k, v ? v.split("\t")[0] : nil] }]
+ Hash[name_pkginfo.map { |k, v| [k, v ? v.split("\t")[0] : nil] }]
end
end
diff --git a/lib/chef/provider/package/easy_install.rb b/lib/chef/provider/package/easy_install.rb
index e4752cf3e7..a876258d04 100644
--- a/lib/chef/provider/package/easy_install.rb
+++ b/lib/chef/provider/package/easy_install.rb
@@ -32,10 +32,10 @@ class Chef
begin
# first check to see if we can import it
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{name}\"", :returns=>[0,1]).stderr
+ output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{name}\"", :returns => [0, 1]).stderr
if output.include? "ImportError"
# then check to see if its on the path
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout
+ output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns => [0, 1]).stdout
if output.downcase.include? "#{name.downcase}"
check = true
end
@@ -75,9 +75,9 @@ class Chef
output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{module_name}; print #{module_name}.__version__\"").stdout
package_version = output.strip
rescue
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout
+ output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns => [0, 1]).stdout
- output_array = output.gsub(/[\[\]]/,"").split(/\s*,\s*/)
+ output_array = output.gsub(/[\[\]]/, "").split(/\s*,\s*/)
package_path = ""
output_array.each do |entry|
@@ -103,12 +103,12 @@ class Chef
end
def candidate_version
- return @candidate_version if @candidate_version
+ return @candidate_version if @candidate_version
# do a dry run to get the latest version
- result = shell_out_with_timeout!("#{easy_install_binary_path} -n #{@new_resource.package_name}", :returns=>[0,1])
- @candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3]
- @candidate_version
+ result = shell_out_with_timeout!("#{easy_install_binary_path} -n #{@new_resource.package_name}", :returns => [0, 1])
+ @candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3]
+ @candidate_version
end
def install_package(name, version)
diff --git a/lib/chef/provider/package/freebsd/base.rb b/lib/chef/provider/package/freebsd/base.rb
index 81c27845ba..7104a71f70 100644
--- a/lib/chef/provider/package/freebsd/base.rb
+++ b/lib/chef/provider/package/freebsd/base.rb
@@ -57,8 +57,8 @@ class Chef
def makefile_variable_value(variable, dir = nil)
options = dir ? { :cwd => dir } : {}
- make_v = shell_out_with_timeout!("make -V #{variable}", options.merge!(:env => nil, :returns => [0,1]))
- make_v.exitstatus.zero? ? make_v.stdout.strip.split($\).first : nil # $\ is the line separator, i.e. newline.
+ make_v = shell_out_with_timeout!("make -V #{variable}", options.merge!(:env => nil, :returns => [0, 1]))
+ make_v.exitstatus.zero? ? make_v.stdout.strip.split($\).first : nil # $\ is the line separator, i.e. newline.
end
end
diff --git a/lib/chef/provider/package/freebsd/pkg.rb b/lib/chef/provider/package/freebsd/pkg.rb
index 339693a3d5..b42bd62c61 100644
--- a/lib/chef/provider/package/freebsd/pkg.rb
+++ b/lib/chef/provider/package/freebsd/pkg.rb
@@ -41,7 +41,7 @@ class Chef
Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
when /^\//
- shell_out_with_timeout!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , "LC_ALL"=>nil}).status
+ shell_out_with_timeout!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , "LC_ALL" => nil }).status
Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
else
@@ -72,7 +72,7 @@ class Chef
end
def current_installed_version
- pkg_info = shell_out_with_timeout!("pkg_info -E \"#{package_name}*\"", :env => nil, :returns => [0,1])
+ pkg_info = shell_out_with_timeout!("pkg_info -E \"#{package_name}*\"", :env => nil, :returns => [0, 1])
pkg_info.stdout[/^#{Regexp.escape(package_name)}-(.+)/, 1]
end
diff --git a/lib/chef/provider/package/freebsd/pkgng.rb b/lib/chef/provider/package/freebsd/pkgng.rb
index e3fa0ad571..de7bea6387 100644
--- a/lib/chef/provider/package/freebsd/pkgng.rb
+++ b/lib/chef/provider/package/freebsd/pkgng.rb
@@ -44,7 +44,7 @@ class Chef
end
def current_installed_version
- pkg_info = shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70])
+ pkg_info = shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0, 70])
pkg_info.stdout[/^Version +: (.+)$/, 1]
end
diff --git a/lib/chef/provider/package/freebsd/port.rb b/lib/chef/provider/package/freebsd/port.rb
index 39b7b00988..3eb3c5ab01 100644
--- a/lib/chef/provider/package/freebsd/port.rb
+++ b/lib/chef/provider/package/freebsd/port.rb
@@ -35,9 +35,9 @@ class Chef
def current_installed_version
pkg_info = if @new_resource.supports_pkgng?
- shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70])
+ shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0, 70])
else
- shell_out_with_timeout!("pkg_info -E \"#{@new_resource.package_name}*\"", :env => nil, :returns => [0,1])
+ shell_out_with_timeout!("pkg_info -E \"#{@new_resource.package_name}*\"", :env => nil, :returns => [0, 1])
end
pkg_info.stdout[/^#{Regexp.escape(@new_resource.package_name)}-(.+)/, 1]
end
diff --git a/lib/chef/provider/package/macports.rb b/lib/chef/provider/package/macports.rb
index c7ea71ac8c..b110207d8a 100644
--- a/lib/chef/provider/package/macports.rb
+++ b/lib/chef/provider/package/macports.rb
@@ -81,6 +81,7 @@ class Chef
end
private
+
def get_response_from_command(command)
output = nil
status = shell_out_with_timeout(command)
diff --git a/lib/chef/provider/package/openbsd.rb b/lib/chef/provider/package/openbsd.rb
index 3e209bcf99..2120b9aa48 100644
--- a/lib/chef/provider/package/openbsd.rb
+++ b/lib/chef/provider/package/openbsd.rb
@@ -72,7 +72,7 @@ class Chef
if parts = name.match(/^(.+?)--(.+)/) # use double-dash for stems with flavors, see man page for pkg_add
name = parts[1]
end
- shell_out_with_timeout!("pkg_add -r #{name}#{version_string(version)}", :env => {"PKG_PATH" => pkg_path}).status
+ shell_out_with_timeout!("pkg_add -r #{name}#{version_string(version)}", :env => { "PKG_PATH" => pkg_path }).status
Chef::Log.debug("#{new_resource.package_name} installed")
end
end
@@ -92,7 +92,7 @@ class Chef
else
name = new_resource.package_name
end
- pkg_info = shell_out_with_timeout!("pkg_info -e \"#{name}->0\"", :env => nil, :returns => [0,1])
+ pkg_info = shell_out_with_timeout!("pkg_info -e \"#{name}->0\"", :env => nil, :returns => [0, 1])
result = pkg_info.stdout[/^inst:#{Regexp.escape(name)}-(.+?)\s/, 1]
Chef::Log.debug("installed_version of '#{new_resource.package_name}' is '#{result}'")
result
@@ -101,7 +101,7 @@ class Chef
def candidate_version
@candidate_version ||= begin
results = []
- shell_out_with_timeout!("pkg_info -I \"#{new_resource.package_name}#{version_string(new_resource.version)}\"", :env => nil, :returns => [0,1]).stdout.each_line do |line|
+ shell_out_with_timeout!("pkg_info -I \"#{new_resource.package_name}#{version_string(new_resource.version)}\"", :env => nil, :returns => [0, 1]).stdout.each_line do |line|
if parts = new_resource.package_name.match(/^(.+?)--(.+)/)
results << line[/^#{Regexp.escape(parts[1])}-(.+?)\s/, 1]
else
diff --git a/lib/chef/provider/package/pacman.rb b/lib/chef/provider/package/pacman.rb
index ad7db25f49..22fa9c2307 100644
--- a/lib/chef/provider/package/pacman.rb
+++ b/lib/chef/provider/package/pacman.rb
@@ -52,14 +52,14 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
- repos = ["extra","core","community"]
+ repos = ["extra", "core", "community"]
if(::File.exists?("/etc/pacman.conf"))
pacman = ::File.read("/etc/pacman.conf")
repos = pacman.scan(/\[(.+)\]/).flatten
end
- package_repos = repos.map {|r| Regexp.escape(r) }.join("|")
+ package_repos = repos.map { |r| Regexp.escape(r) }.join("|")
status = shell_out_with_timeout("pacman -Sl")
status.stdout.each_line do |line|
@@ -80,7 +80,6 @@ class Chef
end
@candidate_version
-
end
def install_package(name, version)
diff --git a/lib/chef/provider/package/paludis.rb b/lib/chef/provider/package/paludis.rb
index 51437025e1..e1b2ea1cf4 100644
--- a/lib/chef/provider/package/paludis.rb
+++ b/lib/chef/provider/package/paludis.rb
@@ -59,7 +59,7 @@ class Chef
else
pkg = "#{@new_resource.package_name}"
end
- shell_out!("cave -L warning resolve -x#{expand_options(@new_resource.options)} \"#{pkg}\"",:timeout => @new_resource.timeout)
+ shell_out!("cave -L warning resolve -x#{expand_options(@new_resource.options)} \"#{pkg}\"", :timeout => @new_resource.timeout)
end
def upgrade_package(name, version)
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
index 4d99d75ca2..688509889c 100644
--- a/lib/chef/provider/package/portage.rb
+++ b/lib/chef/provider/package/portage.rb
@@ -35,11 +35,11 @@ class Chef
@current_resource = Chef::Resource::Package.new(@new_resource.name)
@current_resource.package_name(@new_resource.package_name)
- category, pkg = %r{^#{PACKAGE_NAME_PATTERN}$}.match(@new_resource.package_name)[1,2]
+ category, pkg = %r{^#{PACKAGE_NAME_PATTERN}$}.match(@new_resource.package_name)[1, 2]
globsafe_category = category ? Chef::Util::PathHelper.escape_glob(category) : nil
globsafe_pkg = Chef::Util::PathHelper.escape_glob(pkg)
- possibilities = Dir["/var/db/pkg/#{globsafe_category || "*"}/#{globsafe_pkg}-*"].map {|d| d.sub(%r{/var/db/pkg/}, "") }
+ possibilities = Dir["/var/db/pkg/#{globsafe_category || "*"}/#{globsafe_pkg}-*"].map { |d| d.sub(%r{/var/db/pkg/}, "") }
versions = possibilities.map do |entry|
if(entry =~ %r{[^/]+/#{Regexp.escape(pkg)}\-(\d[\.\d]*((_(alpha|beta|pre|rc|p)\d*)*)?(-r\d+)?)})
[$&, $1]
@@ -47,8 +47,8 @@ class Chef
end.compact
if versions.size > 1
- atoms = versions.map {|v| v.first }.sort
- categories = atoms.map {|v| v.split("/")[0] }.uniq
+ atoms = versions.map { |v| v.first }.sort
+ categories = atoms.map { |v| v.split("/")[0] }.uniq
if !category && categories.size > 1
raise Chef::Exceptions::Package, "Multiple packages found for #{@new_resource.package_name}: #{atoms.join(" ")}. Specify a category."
end
@@ -103,7 +103,6 @@ class Chef
end
@candidate_version
-
end
def install_package(name, version)
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index b176114a15..7a2db6b32b 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -47,7 +47,7 @@ class Chef
# alternate value and overwrite it with the defaults.
Gem.configuration
- DEFAULT_UNINSTALLER_OPTS = {:ignore => true, :executables => true}
+ DEFAULT_UNINSTALLER_OPTS = { :ignore => true, :executables => true }
##
# The paths where rubygems should search for installed gems.
@@ -133,7 +133,7 @@ class Chef
def candidate_version_from_file(gem_dependency, source)
spec = spec_from_file(source)
if spec.satisfies_requirement?(gem_dependency)
- logger.debug {"#{@new_resource} found candidate gem version #{spec.version} from local gem package #{source}"}
+ logger.debug { "#{@new_resource} found candidate gem version #{spec.version} from local gem package #{source}" }
spec.version
else
# This is probably going to end badly...
@@ -189,7 +189,7 @@ class Chef
# === Options
# :sources rubygems servers to use
# Other options are passed to Gem::DependencyInstaller.new
- def install(gem_dependency, options={})
+ def install(gem_dependency, options = {})
with_gem_sources(*options.delete(:sources)) do
with_correct_verbosity do
dependency_installer(options).install(gem_dependency)
@@ -203,7 +203,7 @@ class Chef
# Otherwise, all versions are uninstalled.
# === Options
# Options are passed to Gem::Uninstaller.new
- def uninstall(gem_name, gem_version=nil, opts={})
+ def uninstall(gem_name, gem_version = nil, opts = {})
gem_version ? opts[:version] = gem_version : opts[:all] = true
with_correct_verbosity do
uninstaller(gem_name, opts).uninstall
@@ -218,11 +218,11 @@ class Chef
yield
end
- def dependency_installer(opts={})
+ def dependency_installer(opts = {})
Gem::DependencyInstaller.new(opts)
end
- def uninstaller(gem_name, opts={})
+ def uninstaller(gem_name, opts = {})
Gem::Uninstaller.new(gem_name, DEFAULT_UNINSTALLER_OPTS.merge(opts))
end
@@ -358,7 +358,7 @@ class Chef
include Chef::Mixin::GetSourceFromPackage
- def initialize(new_resource, run_context=nil)
+ def initialize(new_resource, run_context = nil)
super
@cleanup_gem_env = true
if new_resource.gem_binary
@@ -398,7 +398,7 @@ class Chef
Chef::Log.debug("#{@new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}")
# Omnibus installs to a static path because of linking on unix, find it.
true
- elsif RbConfig::CONFIG["bindir"].sub(/^[\w]:/, "") == "/opscode/chef/embedded/bin"
+ elsif RbConfig::CONFIG["bindir"].sub(/^[\w]:/, "") == "/opscode/chef/embedded/bin"
Chef::Log.debug("#{@new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}")
# windows, with the drive letter removed
true
@@ -436,7 +436,7 @@ class Chef
# is the current version
if !matching_installed_versions.empty?
gemspec = matching_installed_versions.last
- logger.debug { "#{@new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}"}
+ logger.debug { "#{@new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}" }
gemspec
# If no version matching the requirements exists, the latest installed
# version is the current version.
@@ -445,7 +445,7 @@ class Chef
logger.debug { "#{@new_resource} newest installed version of gem #{gemspec.name} is #{gemspec.version}" }
gemspec
else
- logger.debug { "#{@new_resource} no installed version found for #{gem_dependency}"}
+ logger.debug { "#{@new_resource} no installed version found for #{gem_dependency}" }
nil
end
end
@@ -519,7 +519,7 @@ class Chef
elsif @new_resource.gem_binary.nil?
@gem_env.install(@new_resource.source)
else
- install_via_gem_command(name,version)
+ install_via_gem_command(name, version)
end
true
end
@@ -538,9 +538,9 @@ class Chef
src = @new_resource.source && " --source=#{@new_resource.source} --source=https://rubygems.org"
end
if !version.nil? && version.length > 0
- shell_out_with_timeout!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env=>nil)
+ shell_out_with_timeout!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env => nil)
else
- shell_out_with_timeout!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env=>nil)
+ shell_out_with_timeout!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env => nil)
end
end
@@ -564,9 +564,9 @@ class Chef
def uninstall_via_gem_command(name, version)
if version
- shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :env=>nil)
+ shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :env => nil)
else
- shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", :env=>nil)
+ shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", :env => nil)
end
end
diff --git a/lib/chef/provider/package/smartos.rb b/lib/chef/provider/package/smartos.rb
index 5ef8ae2cbe..3f09bef212 100644
--- a/lib/chef/provider/package/smartos.rb
+++ b/lib/chef/provider/package/smartos.rb
@@ -43,7 +43,7 @@ class Chef
def check_package_state(name)
Chef::Log.debug("#{@new_resource} checking package #{name}")
version = nil
- info = shell_out_with_timeout!("/opt/local/sbin/pkg_info", "-E", "#{name}*", :env => nil, :returns => [0,1])
+ info = shell_out_with_timeout!("/opt/local/sbin/pkg_info", "-E", "#{name}*", :env => nil, :returns => [0, 1])
if info.stdout
version = info.stdout[/^#{@new_resource.package_name}-(.+)/, 1]
@@ -58,7 +58,7 @@ class Chef
return @candidate_version if @candidate_version
name = nil
version = nil
- pkg = shell_out_with_timeout!("/opt/local/bin/pkgin", "se", new_resource.package_name, :env => nil, :returns => [0,1])
+ pkg = shell_out_with_timeout!("/opt/local/bin/pkgin", "se", new_resource.package_name, :env => nil, :returns => [0, 1])
pkg.stdout.each_line do |line|
case line
when /^#{new_resource.package_name}/
diff --git a/lib/chef/provider/package/windows.rb b/lib/chef/provider/package/windows.rb
index c5aed43c9b..dc22de7ad5 100644
--- a/lib/chef/provider/package/windows.rb
+++ b/lib/chef/provider/package/windows.rb
@@ -79,7 +79,7 @@ class Chef
if new_resource.installer_type
new_resource.installer_type
elsif source_location.nil?
- inferred_registry_type
+ inferred_registry_type
else
basename = ::File.basename(source_location)
file_extension = basename.split(".").last.downcase
@@ -220,7 +220,7 @@ class Chef
r.backup(false)
if new_resource.remote_file_attributes
- new_resource.remote_file_attributes.each do |(k,v)|
+ new_resource.remote_file_attributes.each do |(k, v)|
r.send(k.to_sym, v)
end
end
diff --git a/lib/chef/provider/package/windows/msi.rb b/lib/chef/provider/package/windows/msi.rb
index 62c3be1e25..ac771688e7 100644
--- a/lib/chef/provider/package/windows/msi.rb
+++ b/lib/chef/provider/package/windows/msi.rb
@@ -67,22 +67,22 @@ class Chef
def install_package
# We could use MsiConfigureProduct here, but we'll start off with msiexec
Chef::Log.debug("#{new_resource} installing MSI package '#{new_resource.source}'")
- shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", {:timeout => new_resource.timeout, :returns => new_resource.returns})
+ shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", { :timeout => new_resource.timeout, :returns => new_resource.returns })
end
def remove_package
# We could use MsiConfigureProduct here, but we'll start off with msiexec
if !new_resource.source.nil? && ::File.exist?(new_resource.source)
Chef::Log.debug("#{new_resource} removing MSI package '#{new_resource.source}'")
- shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", {:timeout => new_resource.timeout, :returns => new_resource.returns})
+ shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", { :timeout => new_resource.timeout, :returns => new_resource.returns })
else
uninstall_version = new_resource.version || installed_version
uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) }
.map { |version| version.uninstall_string }.uniq.each do |uninstall_string|
- Chef::Log.debug("#{new_resource} removing MSI package version using '#{uninstall_string}'")
- uninstall_string += expand_options(new_resource.options)
- uninstall_string += " /Q" unless uninstall_string =~ / \/Q\b/
- shell_out!(uninstall_string, {:timeout => new_resource.timeout, :returns => new_resource.returns})
+ Chef::Log.debug("#{new_resource} removing MSI package version using '#{uninstall_string}'")
+ uninstall_string += expand_options(new_resource.options)
+ uninstall_string += " /Q" unless uninstall_string =~ / \/Q\b/
+ shell_out!(uninstall_string, { :timeout => new_resource.timeout, :returns => new_resource.returns })
end
end
end
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index a0629842f2..aeecf3869e 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -63,7 +63,7 @@ class Chef
end
end
- version = evr[lead,tail]
+ version = evr[lead, tail]
if version.empty?
version = nil
end
@@ -159,12 +159,12 @@ class Chef
end
# copy the segment but not the unmatched character that x_seg_pos will
# refer to
- x_comp = x[x_pos,x_seg_pos - x_pos]
+ x_comp = x[x_pos, x_seg_pos - x_pos]
while (y_seg_pos <= y_pos_max) and isdigit(y[y_seg_pos])
y_seg_pos += 1
end
- y_comp = y[y_pos,y_seg_pos - y_pos]
+ y_comp = y[y_pos, y_seg_pos - y_pos]
else
# we are comparing strings
x_seg_is_num = false
@@ -172,12 +172,12 @@ class Chef
while (x_seg_pos <= x_pos_max) and isalpha(x[x_seg_pos])
x_seg_pos += 1
end
- x_comp = x[x_pos,x_seg_pos - x_pos]
+ x_comp = x[x_pos, x_seg_pos - x_pos]
while (y_seg_pos <= y_pos_max) and isalpha(y[y_seg_pos])
y_seg_pos += 1
end
- y_comp = y[y_pos,y_seg_pos - y_pos]
+ y_comp = y[y_pos, y_seg_pos - y_pos]
end
# if y_seg_pos didn't advance in the above loop it means the segments are
@@ -240,7 +240,7 @@ class Chef
@r = args[2]
else
raise ArgumentError, "Expecting either 'epoch-version-release' or 'epoch, " +
- "version, release'"
+ "version, release'"
end
end
attr_reader :e, :v, :r
@@ -286,7 +286,7 @@ class Chef
# 2:1.2-1 == 2:1.2
# 2:1.2-1 == 2:
#
- def compare_versions(y, partial=false)
+ def compare_versions(y, partial = false)
x = self
# compare epoch
@@ -344,12 +344,12 @@ class Chef
e = args[1].to_i
v = args[2]
r = args[3]
- @version = RPMVersion.new(e,v,r)
+ @version = RPMVersion.new(e, v, r)
@a = args[4]
@provides = args[5]
else
raise ArgumentError, "Expecting either 'name, epoch-version-release, arch, provides' " +
- "or 'name, epoch, version, release, arch, provides'"
+ "or 'name, epoch, version, release, arch, provides'"
end
# We always have one, ourselves!
@@ -429,11 +429,11 @@ class Chef
e = args[1].to_i
v = args[2]
r = args[3]
- @version = RPMVersion.new(e,v,r)
+ @version = RPMVersion.new(e, v, r)
@flag = args[4] || :==
else
raise ArgumentError, "Expecting either 'name, epoch-version-release, flag' or " +
- "'name, epoch, version, release, flag'"
+ "'name, epoch, version, release, flag'"
end
end
attr_reader :name, :version, :flag
@@ -690,15 +690,15 @@ class Chef
when :installed
reset_installed
# fast
- opts=" --installed"
+ opts = " --installed"
when :all
reset
# medium
- opts=" --options --installed-provides"
+ opts = " --options --installed-provides"
when :provides
reset
# slow!
- opts=" --options --all-provides"
+ opts = " --options --all-provides"
else
raise ArgumentError, "Unexpected value in next_refresh: #{@next_refresh}"
end
@@ -870,7 +870,7 @@ class Chef
end
# Check if a package-version.arch is available to install
- def version_available?(package_name, desired_version, arch=nil)
+ def version_available?(package_name, desired_version, arch = nil)
version(package_name, arch, true, false) do |v|
return true if desired_version == v
end
@@ -879,7 +879,7 @@ class Chef
end
# Return the source repository for a package-version.arch
- def package_repository(package_name, desired_version, arch=nil)
+ def package_repository(package_name, desired_version, arch = nil)
package(package_name, arch, true, false) do |pkg|
return pkg.repoid if desired_version == pkg.version.to_s
end
@@ -888,13 +888,13 @@ class Chef
end
# Return the latest available version for a package.arch
- def available_version(package_name, arch=nil)
+ def available_version(package_name, arch = nil)
version(package_name, arch, true, false)
end
alias :candidate_version :available_version
# Return the currently installed version for a package.arch
- def installed_version(package_name, arch=nil)
+ def installed_version(package_name, arch = nil)
version(package_name, arch, false, true)
end
@@ -922,7 +922,7 @@ class Chef
private
- def version(package_name, arch=nil, is_available=false, is_installed=false)
+ def version(package_name, arch = nil, is_available = false, is_installed = false)
package(package_name, arch, is_available, is_installed) do |pkg|
if block_given?
yield pkg.version.to_s
@@ -939,7 +939,7 @@ class Chef
end
end
- def package(package_name, arch=nil, is_available=false, is_installed=false)
+ def package(package_name, arch = nil, is_available = false, is_installed = false)
refresh
packages = @rpmdb[package_name]
if packages
@@ -1049,7 +1049,7 @@ class Chef
def yum_command(command)
command = "#{yum_binary} #{command}"
Chef::Log.debug("#{@new_resource}: yum command: \"#{command}\"")
- status = shell_out_with_timeout(command, {:timeout => Chef::Config[:yum_timeout]})
+ status = shell_out_with_timeout(command, { :timeout => Chef::Config[:yum_timeout] })
# This is fun: rpm can encounter errors in the %post/%postun scripts which aren't
# considered fatal - meaning the rpm is still successfully installed. These issue
@@ -1066,7 +1066,7 @@ class Chef
if l =~ %r{^error: %(post|postun)\(.*\) scriptlet failed, exit status \d+$}
Chef::Log.warn("#{@new_resource} caught non-fatal scriptlet issue: \"#{l}\". Can't trust yum exit status " +
"so running install again to verify.")
- status = shell_out_with_timeout(command, {:timeout => Chef::Config[:yum_timeout]})
+ status = shell_out_with_timeout(command, { :timeout => Chef::Config[:yum_timeout] })
break
end
end
@@ -1126,7 +1126,6 @@ class Chef
end
end
-
@current_resource = Chef::Resource::Package.new(@new_resource.name)
@current_resource.package_name(@new_resource.package_name)
@@ -1225,7 +1224,7 @@ class Chef
else
# we bail like yum when the package is older
raise Chef::Exceptions::Package, "Installed package #{n}-#{current_version_array[idx]} is newer " +
- "than candidate package #{n}-#{v}"
+ "than candidate package #{n}-#{v}"
end
end
end
@@ -1258,7 +1257,7 @@ class Chef
yum_command("-d0 -e0 -y#{expand_options(@new_resource.options)} #{method} #{pkg_string}")
else
raise Chef::Exceptions::Package, "Version #{version} of #{name} not found. Did you specify both version " +
- "and release? (version-release, e.g. 1.84-10.fc6)"
+ "and release? (version-release, e.g. 1.84-10.fc6)"
end
end
@@ -1359,7 +1358,7 @@ class Chef
# matching them up with an actual package so the standard resource handling can apply.
#
# There is currently no support for filename matching.
- def parse_dependency(name,version)
+ def parse_dependency(name, version)
# Transform the package_name into a requirement
# If we are passed a version or a version constraint we have to assume it's a requirement first. If it can't be
@@ -1412,7 +1411,7 @@ class Chef
new_package_version = nil
end
- [new_package_name,new_package_version]
+ [new_package_name, new_package_version]
end
end
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index 5d42772a48..2441b46013 100644
--- a/lib/chef/provider/package/zypper.rb
+++ b/lib/chef/provider/package/zypper.rb
@@ -42,10 +42,10 @@ class Chef
candidate_version = $1
Chef::Log.debug("#{new_resource} version #{$1}")
when /^Installed: Yes$/
- is_installed=true
+ is_installed = true
Chef::Log.debug("#{new_resource} is installed")
when /^Status: out-of-date \(version (.+) installed\)$/
- current_version=$1
+ current_version = $1
Chef::Log.debug("#{new_resource} out of date version #{$1}")
end
end
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb
index 77aaa080a9..6365f6a171 100644
--- a/lib/chef/provider/powershell_script.rb
+++ b/lib/chef/provider/powershell_script.rb
@@ -79,7 +79,7 @@ class Chef
def validate_script_syntax!
interpreter_arguments = default_interpreter_flags.join(" ")
- Tempfile.open(["chef_powershell_script-user-code", ".ps1"]) do | user_script_file |
+ Tempfile.open(["chef_powershell_script-user-code", ".ps1"]) do |user_script_file|
# Wrap the user's code in a PowerShell script block so that
# it isn't executed. However, syntactically invalid script
# in that block will still trigger a syntax error which is
@@ -110,7 +110,7 @@ EOH
# means a non-zero return and thus a syntactically invalid script.
with_os_architecture(node, architecture: new_resource.architecture) do
- shell_out!(validation_command, {returns: [0]})
+ shell_out!(validation_command, { returns: [0] })
end
end
end
@@ -146,7 +146,7 @@ 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
+ <<-EOH
# Chef Client wrapper for powershell_script resources
# LASTEXITCODE can be uninitialized -- make it explictly 0
diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb
index 3d3d2a01a4..2e00fd08e1 100644
--- a/lib/chef/provider/registry_key.rb
+++ b/lib/chef/provider/registry_key.rb
@@ -72,22 +72,22 @@ class Chef
def define_resource_requirements
requirements.assert(:create, :create_if_missing, :delete, :delete_key) do |a|
- a.assertion{ registry.hive_exists?(@new_resource.key) }
+ a.assertion { registry.hive_exists?(@new_resource.key) }
a.failure_message(Chef::Exceptions::Win32RegHiveMissing, "Hive #{@new_resource.key.split("\\").shift} does not exist")
end
requirements.assert(:create) do |a|
- a.assertion{ registry.key_exists?(@new_resource.key) }
+ a.assertion { registry.key_exists?(@new_resource.key) }
a.whyrun("Key #{@new_resource.key} does not exist. Unless it would have been created before, attempt to modify its values would fail.")
end
requirements.assert(:create, :create_if_missing) do |a|
#If keys missing in the path and recursive == false
- a.assertion{ !registry.keys_missing?(@current_resource.key) || @new_resource.recursive }
+ a.assertion { !registry.keys_missing?(@current_resource.key) || @new_resource.recursive }
a.failure_message(Chef::Exceptions::Win32RegNoRecursive, "Intermediate keys missing but recursive is set to false")
a.whyrun("Intermediate keys in #{@new_resource.key} go not exist. Unless they would have been created earlier, attempt to modify them would fail.")
end
requirements.assert(:delete_key) do |a|
#If key to be deleted has subkeys but recurssive == false
- a.assertion{ !registry.key_exists?(@new_resource.key) || !registry.has_subkeys?(@new_resource.key) || @new_resource.recursive }
+ a.assertion { !registry.key_exists?(@new_resource.key) || !registry.has_subkeys?(@new_resource.key) || @new_resource.recursive }
a.failure_message(Chef::Exceptions::Win32RegNoRecursive, "#{@new_resource.key} has subkeys but recursive is set to false.")
a.whyrun("#{@current_resource.key} has subkeys, but recursive is set to false. attempt to delete would fails unless subkeys were deleted prior to this action.")
end
diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb
index 7479ef9e85..b592b13ccf 100644
--- a/lib/chef/provider/remote_directory.rb
+++ b/lib/chef/provider/remote_directory.rb
@@ -106,7 +106,7 @@ class Chef
if purge
Dir.glob(::File.join(Chef::Util::PathHelper.escape_glob(path), "**", "*"), ::File::FNM_DOTMATCH).sort!.reverse!.each do |file|
# skip '.' and '..'
- next if [".",".."].include?(Pathname.new(file).basename().to_s)
+ next if [".", ".."].include?(Pathname.new(file).basename().to_s)
# Clean the path. This is required because of the ::File.join
file = Chef::Util::PathHelper.cleanpath(file)
@@ -251,7 +251,7 @@ class Chef
# Windows will handle inheritance.
if dir == path
rights.each do |r|
- r = r.dup # do not update the new_resource
+ r = r.dup # do not update the new_resource
permissions = r.delete(:permissions)
principals = r.delete(:principals)
res.rights(permissions, principals, r)
diff --git a/lib/chef/provider/remote_file/cache_control_data.rb b/lib/chef/provider/remote_file/cache_control_data.rb
index b100ebf4a0..7aa059f4cb 100644
--- a/lib/chef/provider/remote_file/cache_control_data.rb
+++ b/lib/chef/provider/remote_file/cache_control_data.rb
@@ -177,10 +177,9 @@ class Chef
def sanitized_cache_file_basename
uri_sha2 = Chef::Digester.instance.generate_checksum(StringIO.new(uri))
- cache_file_basename(uri_sha2[0,32])
+ cache_file_basename(uri_sha2[0, 32])
end
-
def sanitized_cache_file_basename_md5
# Old way of creating the file basename
uri_md5 = Chef::Digester.instance.generate_md5_checksum(StringIO.new(uri))
diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb
index 0e44f06ca7..6fa574e777 100644
--- a/lib/chef/provider/remote_file/http.rb
+++ b/lib/chef/provider/remote_file/http.rb
@@ -95,7 +95,7 @@ class Chef
end
def http_client_opts
- opts={}
+ opts = {}
# CHEF-3140
# 1. If it's already compressed, trying to compress it more will
# probably be counter-productive.
diff --git a/lib/chef/provider/remote_file/local_file.rb b/lib/chef/provider/remote_file/local_file.rb
index b02d575999..613db02337 100644
--- a/lib/chef/provider/remote_file/local_file.rb
+++ b/lib/chef/provider/remote_file/local_file.rb
@@ -35,7 +35,7 @@ class Chef
# CHEF-4472: Remove the leading slash from windows paths that we receive from a file:// URI
def fix_windows_path(path)
- path.gsub(/^\/([a-zA-Z]:)/,'\1')
+ path.gsub(/^\/([a-zA-Z]:)/, '\1')
end
def source_path
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index d325c65d2a..3dd0e33cd1 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -22,208 +22,208 @@ require "chef/provider"
require "ipaddr"
class Chef::Provider::Route < Chef::Provider
- include Chef::Mixin::Command
-
- provides :route
-
- attr_accessor :is_running
-
- MASK = {"0.0.0.0" => "0",
- "128.0.0.0" => "1",
- "192.0.0.0" => "2",
- "224.0.0.0" => "3",
- "240.0.0.0" => "4",
- "248.0.0.0" => "5",
- "252.0.0.0" => "6",
- "254.0.0.0" => "7",
- "255.0.0.0" => "8",
- "255.128.0.0" => "9",
- "255.192.0.0" => "10",
- "255.224.0.0" => "11",
- "255.240.0.0" => "12",
- "255.248.0.0" => "13",
- "255.252.0.0" => "14",
- "255.254.0.0" => "15",
- "255.255.0.0" => "16",
- "255.255.128.0" => "17",
- "255.255.192.0" => "18",
- "255.255.224.0" => "19",
- "255.255.240.0" => "20",
- "255.255.248.0" => "21",
- "255.255.252.0" => "22",
- "255.255.254.0" => "23",
- "255.255.255.0" => "24",
- "255.255.255.128" => "25",
- "255.255.255.192" => "26",
- "255.255.255.224" => "27",
- "255.255.255.240" => "28",
- "255.255.255.248" => "29",
- "255.255.255.252" => "30",
- "255.255.255.254" => "31",
- "255.255.255.255" => "32" }
-
- def hex2ip(hex_data)
- # Cleanup hex data
- hex_ip = hex_data.to_s.downcase.gsub(/[^0-9a-f]/, "")
-
- # Check hex data format (IP is a 32bit integer, so should be 8 chars long)
- return nil if hex_ip.length != hex_data.length || hex_ip.length != 8
-
- # Extract octets from hex data
- octets = hex_ip.scan(/../).reverse.collect { |octet| [octet].pack("H2").unpack("C").first }
-
- # Validate IP
- ip = octets.join(".")
- begin
- IPAddr.new(ip, Socket::AF_INET).to_s
- rescue ArgumentError
- Chef::Log.debug("Invalid IP address data: hex=#{hex_ip}, ip=#{ip}")
- return nil
- end
- end
-
- def whyrun_supported?
- true
+ include Chef::Mixin::Command
+
+ provides :route
+
+ attr_accessor :is_running
+
+ MASK = { "0.0.0.0" => "0",
+ "128.0.0.0" => "1",
+ "192.0.0.0" => "2",
+ "224.0.0.0" => "3",
+ "240.0.0.0" => "4",
+ "248.0.0.0" => "5",
+ "252.0.0.0" => "6",
+ "254.0.0.0" => "7",
+ "255.0.0.0" => "8",
+ "255.128.0.0" => "9",
+ "255.192.0.0" => "10",
+ "255.224.0.0" => "11",
+ "255.240.0.0" => "12",
+ "255.248.0.0" => "13",
+ "255.252.0.0" => "14",
+ "255.254.0.0" => "15",
+ "255.255.0.0" => "16",
+ "255.255.128.0" => "17",
+ "255.255.192.0" => "18",
+ "255.255.224.0" => "19",
+ "255.255.240.0" => "20",
+ "255.255.248.0" => "21",
+ "255.255.252.0" => "22",
+ "255.255.254.0" => "23",
+ "255.255.255.0" => "24",
+ "255.255.255.128" => "25",
+ "255.255.255.192" => "26",
+ "255.255.255.224" => "27",
+ "255.255.255.240" => "28",
+ "255.255.255.248" => "29",
+ "255.255.255.252" => "30",
+ "255.255.255.254" => "31",
+ "255.255.255.255" => "32" }
+
+ def hex2ip(hex_data)
+ # Cleanup hex data
+ hex_ip = hex_data.to_s.downcase.gsub(/[^0-9a-f]/, "")
+
+ # Check hex data format (IP is a 32bit integer, so should be 8 chars long)
+ return nil if hex_ip.length != hex_data.length || hex_ip.length != 8
+
+ # Extract octets from hex data
+ octets = hex_ip.scan(/../).reverse.collect { |octet| [octet].pack("H2").unpack("C").first }
+
+ # Validate IP
+ ip = octets.join(".")
+ begin
+ IPAddr.new(ip, Socket::AF_INET).to_s
+ rescue ArgumentError
+ Chef::Log.debug("Invalid IP address data: hex=#{hex_ip}, ip=#{ip}")
+ return nil
end
+ end
- def load_current_resource
- self.is_running = false
+ def whyrun_supported?
+ true
+ end
- # cidr or quad dot mask
- if @new_resource.netmask
- new_ip = IPAddr.new("#{@new_resource.target}/#{@new_resource.netmask}")
- else
- new_ip = IPAddr.new(@new_resource.target)
- end
-
- # For linux, we use /proc/net/route file to read proc table info
- if node[:os] == "linux"
- route_file = ::File.open("/proc/net/route", "r")
-
- # Read all routes
- while (line = route_file.gets)
- # Get all the fields for a route
- iface,destination,gateway,flags,refcnt,use,metric,mask,mtu,window,irtt = line.split
-
- # Convert hex-encoded values to quad-dotted notation (e.g. 0064A8C0 => 192.168.100.0)
- destination = hex2ip(destination)
- gateway = hex2ip(gateway)
- mask = hex2ip(mask)
-
- # Skip formatting lines (header, etc)
- next unless destination && gateway && mask
- Chef::Log.debug("#{@new_resource} system has route: dest=#{destination} mask=#{mask} gw=#{gateway}")
-
- # check if what were trying to configure is already there
- # use an ipaddr object with ip/mask this way we can have
- # a new resource be in cidr format (i don't feel like
- # expanding bitmask by hand.
- #
- running_ip = IPAddr.new("#{destination}/#{mask}")
- Chef::Log.debug("#{@new_resource} new ip: #{new_ip.inspect} running ip: #{running_ip.inspect}")
- self.is_running = true if running_ip == new_ip && gateway == @new_resource.gateway
- end
+ def load_current_resource
+ self.is_running = false
- route_file.close
- end
+ # cidr or quad dot mask
+ if @new_resource.netmask
+ new_ip = IPAddr.new("#{@new_resource.target}/#{@new_resource.netmask}")
+ else
+ new_ip = IPAddr.new(@new_resource.target)
end
- def action_add
- # check to see if load_current_resource found the route
- if is_running
- Chef::Log.debug("#{@new_resource} route already active - nothing to do")
- else
- command = generate_command(:add)
- converge_by ("run #{ command } to add route") do
- run_command( :command => command )
- Chef::Log.info("#{@new_resource} added")
- end
+ # For linux, we use /proc/net/route file to read proc table info
+ if node[:os] == "linux"
+ route_file = ::File.open("/proc/net/route", "r")
+
+ # Read all routes
+ while (line = route_file.gets)
+ # Get all the fields for a route
+ iface, destination, gateway, flags, refcnt, use, metric, mask, mtu, window, irtt = line.split
+
+ # Convert hex-encoded values to quad-dotted notation (e.g. 0064A8C0 => 192.168.100.0)
+ destination = hex2ip(destination)
+ gateway = hex2ip(gateway)
+ mask = hex2ip(mask)
+
+ # Skip formatting lines (header, etc)
+ next unless destination && gateway && mask
+ Chef::Log.debug("#{@new_resource} system has route: dest=#{destination} mask=#{mask} gw=#{gateway}")
+
+ # check if what were trying to configure is already there
+ # use an ipaddr object with ip/mask this way we can have
+ # a new resource be in cidr format (i don't feel like
+ # expanding bitmask by hand.
+ #
+ running_ip = IPAddr.new("#{destination}/#{mask}")
+ Chef::Log.debug("#{@new_resource} new ip: #{new_ip.inspect} running ip: #{running_ip.inspect}")
+ self.is_running = true if running_ip == new_ip && gateway == @new_resource.gateway
end
- #for now we always write the file (ugly but its what it is)
- generate_config
+ route_file.close
end
-
- def action_delete
- if is_running
- command = generate_command(:delete)
- converge_by ("run #{ command } to delete route ") do
- run_command( :command => command )
- Chef::Log.info("#{@new_resource} removed")
- end
- else
- Chef::Log.debug("#{@new_resource} route does not exist - nothing to do")
+ end
+
+ def action_add
+ # check to see if load_current_resource found the route
+ if is_running
+ Chef::Log.debug("#{@new_resource} route already active - nothing to do")
+ else
+ command = generate_command(:add)
+ converge_by ("run #{ command } to add route") do
+ run_command( :command => command )
+ Chef::Log.info("#{@new_resource} added")
end
+ end
+
+ #for now we always write the file (ugly but its what it is)
+ generate_config
+ end
- #for now we always write the file (ugly but its what it is)
- generate_config
+ def action_delete
+ if is_running
+ command = generate_command(:delete)
+ converge_by ("run #{ command } to delete route ") do
+ run_command( :command => command )
+ Chef::Log.info("#{@new_resource} removed")
+ end
+ else
+ Chef::Log.debug("#{@new_resource} route does not exist - nothing to do")
end
- def generate_config
- conf = Hash.new
- case node[:platform]
- when "centos", "redhat", "fedora"
- # walk the collection
- run_context.resource_collection.each do |resource|
- if resource.is_a? Chef::Resource::Route
- # default to eth0
- if resource.device
- dev = resource.device
- else
- dev = "eth0"
- end
-
- conf[dev] = String.new if conf[dev].nil?
- case @action
- when :add
- conf[dev] << config_file_contents(:add, :target => resource.target, :netmask => resource.netmask, :gateway => resource.gateway)
- when :delete
- # need to do this for the case when the last route on an int
- # is removed
- conf[dev] << config_file_contents(:delete)
- end
+ #for now we always write the file (ugly but its what it is)
+ generate_config
+ end
+
+ def generate_config
+ conf = Hash.new
+ case node[:platform]
+ when "centos", "redhat", "fedora"
+ # walk the collection
+ run_context.resource_collection.each do |resource|
+ if resource.is_a? Chef::Resource::Route
+ # default to eth0
+ if resource.device
+ dev = resource.device
+ else
+ dev = "eth0"
end
- end
- conf.each do |k, v|
- network_file_name = "/etc/sysconfig/network-scripts/route-#{k}"
- converge_by ("write route route.#{k}\n#{conf[k]} to #{ network_file_name }") do
- network_file = ::File.new(network_file_name, "w")
- network_file.puts(conf[k])
- Chef::Log.debug("#{@new_resource} writing route.#{k}\n#{conf[k]}")
- network_file.close
+
+ conf[dev] = String.new if conf[dev].nil?
+ case @action
+ when :add
+ conf[dev] << config_file_contents(:add, :target => resource.target, :netmask => resource.netmask, :gateway => resource.gateway)
+ when :delete
+ # need to do this for the case when the last route on an int
+ # is removed
+ conf[dev] << config_file_contents(:delete)
end
end
end
- end
-
- def generate_command(action)
- common_route_items = ""
- common_route_items << "/#{MASK[@new_resource.netmask.to_s]}" if @new_resource.netmask
- common_route_items << " via #{@new_resource.gateway} " if @new_resource.gateway
-
- case action
- when :add
- command = "ip route replace #{@new_resource.target}"
- command << common_route_items
- command << " dev #{@new_resource.device} " if @new_resource.device
- when :delete
- command = "ip route delete #{@new_resource.target}"
- command << common_route_items
+ conf.each do |k, v|
+ network_file_name = "/etc/sysconfig/network-scripts/route-#{k}"
+ converge_by ("write route route.#{k}\n#{conf[k]} to #{ network_file_name }") do
+ network_file = ::File.new(network_file_name, "w")
+ network_file.puts(conf[k])
+ Chef::Log.debug("#{@new_resource} writing route.#{k}\n#{conf[k]}")
+ network_file.close
+ end
end
-
- return command
+ end
+ end
+
+ def generate_command(action)
+ common_route_items = ""
+ common_route_items << "/#{MASK[@new_resource.netmask.to_s]}" if @new_resource.netmask
+ common_route_items << " via #{@new_resource.gateway} " if @new_resource.gateway
+
+ case action
+ when :add
+ command = "ip route replace #{@new_resource.target}"
+ command << common_route_items
+ command << " dev #{@new_resource.device} " if @new_resource.device
+ when :delete
+ command = "ip route delete #{@new_resource.target}"
+ command << common_route_items
end
- def config_file_contents(action, options={})
- content = ""
- case action
- when :add
- content << "#{options[:target]}"
- content << "/#{options[:netmask]}" if options[:netmask]
- content << " via #{options[:gateway]}" if options[:gateway]
- content << "\n"
- end
-
- return content
+ return command
+ end
+
+ def config_file_contents(action, options = {})
+ content = ""
+ case action
+ when :add
+ content << "#{options[:target]}"
+ content << "/#{options[:netmask]}" if options[:netmask]
+ content << " via #{options[:gateway]}" if options[:gateway]
+ content << "\n"
end
+
+ return content
+ end
end
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
index 95ff28e368..390330aed2 100644
--- a/lib/chef/provider/service.rb
+++ b/lib/chef/provider/service.rb
@@ -62,13 +62,13 @@ class Chef
end
def define_resource_requirements
- requirements.assert(:reload) do |a|
- a.assertion { supports[:reload] || @new_resource.reload_command }
- a.failure_message Chef::Exceptions::UnsupportedAction, "#{self} does not support :reload"
- # if a service is not declared to support reload, that won't
- # typically change during the course of a run - so no whyrun
- # alternative here.
- end
+ requirements.assert(:reload) do |a|
+ a.assertion { supports[:reload] || @new_resource.reload_command }
+ a.failure_message Chef::Exceptions::UnsupportedAction, "#{self} does not support :reload"
+ # if a service is not declared to support reload, that won't
+ # typically change during the course of a run - so no whyrun
+ # alternative here.
+ end
end
def action_enable
diff --git a/lib/chef/provider/service/aix.rb b/lib/chef/provider/service/aix.rb
index 6f0eba7737..201f9ff5f9 100644
--- a/lib/chef/provider/service/aix.rb
+++ b/lib/chef/provider/service/aix.rb
@@ -90,6 +90,7 @@ class Chef
end
protected
+
def determine_current_status!
Chef::Log.debug "#{@new_resource} using lssrc to check the status"
begin
@@ -126,4 +127,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb
index c6483c3f59..6b451d649a 100644
--- a/lib/chef/provider/service/aixinit.rb
+++ b/lib/chef/provider/service/aixinit.rb
@@ -57,14 +57,14 @@ class Chef
end
def enable_service
- Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f)}
+ Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
if @new_resource.priority.is_a? Integer
create_symlink(2, "S", @new_resource.priority)
elsif @new_resource.priority.is_a? Hash
- @new_resource.priority.each do |level,o|
- create_symlink(level,(o[0] == :start ? "S" : "K"),o[1])
+ @new_resource.priority.each do |level, o|
+ create_symlink(level, (o[0] == :start ? "S" : "K"), o[1])
end
else
create_symlink(2, "S", "")
@@ -75,9 +75,9 @@ class Chef
Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
if @new_resource.priority.is_a? Integer
- create_symlink(2, "K",100 - @new_resource.priority)
+ create_symlink(2, "K", 100 - @new_resource.priority)
elsif @new_resource.priority.is_a? Hash
- @new_resource.priority.each do |level,o|
+ @new_resource.priority.each do |level, o|
create_symlink(level, "K", 100 - o[1]) if o[0] == :stop
end
else
diff --git a/lib/chef/provider/service/arch.rb b/lib/chef/provider/service/arch.rb
index 66504390e8..9c66fb4098 100644
--- a/lib/chef/provider/service/arch.rb
+++ b/lib/chef/provider/service/arch.rb
@@ -32,8 +32,8 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
end
def load_current_resource
- raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exists?("/etc/rc.conf")
- raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
+ raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exists?("/etc/rc.conf")
+ raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
super
@current_resource.enabled(daemons.include?(@current_resource.service_name))
@@ -50,7 +50,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
def daemons
entries = []
if ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
- entries += $1.gsub(/\\?[\r\n]/, " ").gsub(/# *[^ ]+/," ").split(" ") if $1.length > 0
+ entries += $1.gsub(/\\?[\r\n]/, " ").gsub(/# *[^ ]+/, " ").split(" ") if $1.length > 0
end
yield(entries) if block_given?
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index e67f5ca95d..6550c85b2a 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -55,18 +55,18 @@ class Chef
requirements.assert(:all_actions) do |a|
a.assertion { @priority_success }
- a.failure_message Chef::Exceptions::Service, "/usr/sbin/update-rc.d -n -f #{current_resource.service_name} failed - #{@rcd_status.inspect}"
+ a.failure_message Chef::Exceptions::Service, "/usr/sbin/update-rc.d -n -f #{current_resource.service_name} failed - #{@rcd_status.inspect}"
# This can happen if the service is not yet installed,so we'll fake it.
a.whyrun ["Unable to determine priority of service, assuming service would have been correctly installed earlier in the run.",
"Assigning temporary priorities to continue.",
"If this service is not properly installed prior to this point, this will fail."] do
- temp_priorities = {"6"=>[:stop, "20"],
- "0"=>[:stop, "20"],
- "1"=>[:stop, "20"],
- "2"=>[:start, "20"],
- "3"=>[:start, "20"],
- "4"=>[:start, "20"],
- "5"=>[:start, "20"]}
+ temp_priorities = { "6" => [:stop, "20"],
+ "0" => [:stop, "20"],
+ "1" => [:stop, "20"],
+ "2" => [:start, "20"],
+ "3" => [:start, "20"],
+ "4" => [:start, "20"],
+ "5" => [:start, "20"] }
current_resource.priority(temp_priorities)
end
end
@@ -148,7 +148,6 @@ class Chef
shell_out!("/usr/sbin/update-rc.d -f #{new_resource.service_name} remove")
shell_out!("/usr/sbin/update-rc.d #{new_resource.service_name} defaults")
end
-
end
def disable_service
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb
index fc0743d5e4..7e475fc878 100644
--- a/lib/chef/provider/service/freebsd.rb
+++ b/lib/chef/provider/service/freebsd.rb
@@ -51,7 +51,7 @@ class Chef
Chef::Log.debug("#{current_resource} found at #{init_command}")
@status_load_success = true
- determine_current_status! # see Chef::Provider::Service::Simple
+ determine_current_status! # see Chef::Provider::Service::Simple
determine_enabled_status!
current_resource
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 4206f29aef..63485903c3 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -83,7 +83,7 @@ class Chef
end
requirements.assert(:all_actions) do |a|
- a.assertion {::File.exists?(@plist.to_s) }
+ a.assertion { ::File.exists?(@plist.to_s) }
a.failure_message Chef::Exceptions::Service,
"Could not find plist for #{@new_resource}"
end
diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb
index 4fc10cff5c..c31df25e68 100644
--- a/lib/chef/provider/service/openbsd.rb
+++ b/lib/chef/provider/service/openbsd.rb
@@ -117,7 +117,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(' ')}")
end
end
end
diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb
index 58c8d4d30a..a76622ee8f 100644
--- a/lib/chef/provider/service/redhat.rb
+++ b/lib/chef/provider/service/redhat.rb
@@ -75,7 +75,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? or run_levels.empty?
all_levels_match = true
chkconfig.stdout.split(/\s+/)[1..-1].each do |level|
diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb
index b954a118dd..d76779a74b 100644
--- a/lib/chef/provider/service/simple.rb
+++ b/lib/chef/provider/service/simple.rb
@@ -66,7 +66,7 @@ class Chef
end
requirements.assert(:restart) do |a|
- a.assertion { @new_resource.restart_command || ( @new_resource.start_command && @new_resource.stop_command ) }
+ a.assertion { @new_resource.restart_command || ( @new_resource.start_command && @new_resource.stop_command ) }
a.failure_message Chef::Exceptions::Service, "#{self} requires a restart_command or both start_command and stop_command be set in order to perform a restart"
end
@@ -109,6 +109,7 @@ class Chef
end
protected
+
def determine_current_status!
if @new_resource.status_command
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb
index b302441a60..0787392094 100644
--- a/lib/chef/provider/service/solaris.rb
+++ b/lib/chef/provider/service/solaris.rb
@@ -28,7 +28,7 @@ class Chef
provides :service, os: "solaris2"
- def initialize(new_resource, run_context=nil)
+ def initialize(new_resource, run_context = nil)
super
@init_command = "/usr/sbin/svcadm"
@status_command = "/bin/svcs"
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 2aacdf3915..edd41dba7e 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -89,7 +89,7 @@ class Chef
end
requirements.assert(:all_actions) do |a|
- a.assertion { @config_file_found }
+ a.assertion { @config_file_found }
# no failure here, just document the assumptions made.
a.whyrun "Could not find #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}. Assuming service is disabled."
end
@@ -130,7 +130,7 @@ class Chef
# Get enabled/disabled state by reading job configuration file
if ::File.exists?("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
Chef::Log.debug("#{@new_resource} found #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
- ::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}","r") do |file|
+ ::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}", "r") do |file|
while line = file.gets
case line
when /^start on/
diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb
index 8c7c76df3f..2705aa5c02 100644
--- a/lib/chef/provider/service/windows.rb
+++ b/lib/chef/provider/service/windows.rb
@@ -45,7 +45,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
START_PENDING = "start pending"
STOP_PENDING = "stop pending"
- TIMEOUT = 60
+ TIMEOUT = 60
SERVICE_RIGHT = "SeServiceLogonRight"
@@ -75,7 +75,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
service_name: @new_resource.service_name,
service_start_name: @new_resource.run_as_user,
password: @new_resource.run_as_password,
- }.reject { |k,v| v.nil? || v.length == 0 }
+ }.reject { |k, v| v.nil? || v.length == 0 }
Win32::Service.configure(new_config)
Chef::Log.info "#{@new_resource} configured with #{new_config.inspect}"
@@ -238,6 +238,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
end
private
+
def grant_service_logon(username)
begin
Chef::ReservedNames::Win32::Security.add_account_right(canonicalize_username(username), SERVICE_RIGHT)
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index e8c25c1740..45002de244 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -48,7 +48,7 @@ class Chef
end
def define_resource_requirements
- requirements.assert(:all_actions) do |a|
+ requirements.assert(:all_actions) do |a|
# Make sure the parent dir exists, or else fail.
# for why run, print a message explaining the potential error.
parent_directory = ::File.dirname(@new_resource.destination)
@@ -115,7 +115,7 @@ class Chef
def export_command
args = ["--force"]
args << @new_resource.svn_arguments << verbose << authentication <<
- "-r#{revision_int}" << @new_resource.repository << @new_resource.destination
+ "-r#{revision_int}" << @new_resource.repository << @new_resource.destination
c = scm :export, *args
Chef::Log.info "#{@new_resource} exported #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
c
@@ -130,7 +130,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
@@ -142,7 +142,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
@@ -151,7 +151,7 @@ class Chef
(!@current_resource.revision.nil?) && (revision_int.strip.to_i == @current_resource.revision.strip.to_i)
end
- def run_options(run_opts={})
+ def run_options(run_opts = {})
run_opts[:user] = @new_resource.user if @new_resource.user
run_opts[:group] = @new_resource.group if @new_resource.group
run_opts[:timeout] = @new_resource.timeout if @new_resource.timeout
@@ -201,7 +201,7 @@ class Chef
end
def target_dir_non_existent_or_empty?
- !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination).sort == [".",".."]
+ !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination).sort == [".", ".."]
end
def svn_binary
diff --git a/lib/chef/provider/template_finder.rb b/lib/chef/provider/template_finder.rb
index ede6103885..67342a86ea 100644
--- a/lib/chef/provider/template_finder.rb
+++ b/lib/chef/provider/template_finder.rb
@@ -41,6 +41,7 @@ class Chef
end
protected
+
def template_source_name(name, options)
if options[:source]
options[:source]
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb
index 3b8fe61171..85bd674d8d 100644
--- a/lib/chef/provider/user.rb
+++ b/lib/chef/provider/user.rb
@@ -98,7 +98,7 @@ class Chef
a.assertion { @shadow_lib_ok }
a.failure_message Chef::Exceptions::MissingLibrary, "You must have ruby-shadow installed for password support!"
a.whyrun "ruby-shadow is not installed. Attempts to set user password will cause failure. Assuming that this gem will have been previously installed." +
- "Note that user update converge may report false-positive on the basis of mismatched password. "
+ "Note that user update converge may report false-positive on the basis of mismatched password. "
end
requirements.assert(:modify, :lock, :unlock) do |a|
a.assertion { @user_exists }
@@ -125,7 +125,6 @@ class Chef
end
def action_create
-
if !@user_exists
converge_by("create user #{@new_resource.username}") do
create_user
diff --git a/lib/chef/provider/user/aix.rb b/lib/chef/provider/user/aix.rb
index 019fe88a04..42798a5f62 100644
--- a/lib/chef/provider/user/aix.rb
+++ b/lib/chef/provider/user/aix.rb
@@ -48,7 +48,7 @@ class Chef
end
raise Chef::Exceptions::User, "Cannot determine if #{@new_resource} is locked!" if lock_info.stdout.empty?
- status = /\S+\s+account_locked=(\S+)/.match(lock_info.stdout)
+ status = /\S+\s+account_locked=(\S+)/.match(lock_info.stdout)
if status && status[1] == "true"
@locked = true
else
@@ -67,6 +67,7 @@ class Chef
end
private
+
def add_password
if @current_resource.password != @new_resource.password && @new_resource.password
Chef::Log.debug("#{@new_resource.username} setting password to #{@new_resource.password}")
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 995d3bf30b..e81a01c764 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -109,7 +109,6 @@ in 'password', with the associated 'salt' and 'iterations'.")
Mac OS X version 10.7. Please specify a SALTED-SHA512 shadow hash in 'password' attribute to set the \
user password using shadow hash.")
end
-
end
def load_current_resource
@@ -145,7 +144,7 @@ user password using shadow hash.")
# Convert the salt from Base64 encoding to hex before consuming them
current_resource.salt(shadow_hash["SALTED-SHA512-PBKDF2"]["salt"].string.unpack("H*").first)
else
- raise(Chef::Exceptions::User,"Unknown shadow_hash format: #{shadow_hash.keys.join(' ')}")
+ raise(Chef::Exceptions::User, "Unknown shadow_hash format: #{shadow_hash.keys.join(' ')}")
end
end
@@ -226,7 +225,7 @@ user password using shadow hash.")
# Find the next available uid on the system. starting with 200 if `system` is set,
# 500 otherwise.
#
- def get_free_uid(search_limit=1000)
+ def get_free_uid(search_limit = 1000)
uid = nil
base_uid = new_resource.system ? 200 : 500
next_uid_guess = base_uid
@@ -308,7 +307,7 @@ user password using shadow hash.")
def validate_home_dir_specification!
unless new_resource.home =~ /^\//
- raise(Chef::Exceptions::InvalidHomeDirectory,"invalid path spec for User: '#{new_resource.username}', home directory: '#{new_resource.home}'")
+ raise(Chef::Exceptions::InvalidHomeDirectory, "invalid path spec for User: '#{new_resource.username}', home directory: '#{new_resource.home}'")
end
end
@@ -322,9 +321,9 @@ user password using shadow hash.")
def ditto_home
skel = "/System/Library/User Template/English.lproj"
- raise(Chef::Exceptions::User,"can't find skel at: #{skel}") unless ::File.exists?(skel)
+ raise(Chef::Exceptions::User, "can't find skel at: #{skel}") unless ::File.exists?(skel)
shell_out! "ditto '#{skel}' '#{new_resource.home}'"
- ::FileUtils.chown_R(new_resource.username,new_resource.gid.to_s,new_resource.home)
+ ::FileUtils.chown_R(new_resource.username, new_resource.gid.to_s, new_resource.home)
end
def move_home
@@ -332,10 +331,10 @@ user password using shadow hash.")
src = current_resource.home
FileUtils.mkdir_p(new_resource.home)
- files = ::Dir.glob("#{Chef::Util::PathHelper.escape_glob(src)}/*", ::File::FNM_DOTMATCH) - ["#{src}/.","#{src}/.."]
- ::FileUtils.mv(files,new_resource.home, :force => true)
+ files = ::Dir.glob("#{Chef::Util::PathHelper.escape_glob(src)}/*", ::File::FNM_DOTMATCH) - ["#{src}/.", "#{src}/.."]
+ ::FileUtils.mv(files, new_resource.home, :force => true)
::FileUtils.rmdir(src)
- ::FileUtils.chown_R(new_resource.username,new_resource.gid.to_s,new_resource.home)
+ ::FileUtils.chown_R(new_resource.username, new_resource.gid.to_s, new_resource.home)
end
#
@@ -384,7 +383,7 @@ user password using shadow hash.")
# Prepares the password shadow info based on the platform version.
#
def prepare_password_shadow_info
- shadow_info = { }
+ shadow_info = {}
entropy = nil
salt = nil
iterations = nil
@@ -420,7 +419,7 @@ user password using shadow hash.")
)
end
- pbkdf_info = { }
+ pbkdf_info = {}
pbkdf_info["entropy"] = StringIO.new
pbkdf_info["entropy"].string = entropy
pbkdf_info["salt"] = StringIO.new
@@ -465,7 +464,7 @@ user password using shadow hash.")
# Unlocks the user
#
def unlock_user
- auth_string = authentication_authority.gsub(/AuthenticationAuthority: /,"").gsub(/;DisabledUser;/,"").strip
+ auth_string = authentication_authority.gsub(/AuthenticationAuthority: /, "").gsub(/;DisabledUser;/, "").strip
run_dscl("create /Users/#{new_resource.username} AuthenticationAuthority '#{auth_string}'")
end
@@ -655,16 +654,16 @@ user password using shadow hash.")
def run_dscl(*args)
result = shell_out("dscl . -#{args.join(' ')}")
return "" if ( args.first =~ /^delete/ ) && ( result.exitstatus != 0 )
- raise(Chef::Exceptions::DsclCommandFailed,"dscl error: #{result.inspect}") unless result.exitstatus == 0
- raise(Chef::Exceptions::DsclCommandFailed,"dscl error: #{result.inspect}") if result.stdout =~ /No such key: /
+ raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") unless result.exitstatus == 0
+ raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if result.stdout =~ /No such key: /
result.stdout
end
def run_plutil(*args)
result = shell_out("plutil -#{args.join(' ')}")
- raise(Chef::Exceptions::PlistUtilCommandFailed,"plutil error: #{result.inspect}") unless result.exitstatus == 0
+ raise(Chef::Exceptions::PlistUtilCommandFailed, "plutil error: #{result.inspect}") unless result.exitstatus == 0
if result.stdout.encoding == Encoding::ASCII_8BIT
- result.stdout.encode("utf-8", "binary", :undef => :replace, :invalid => :replace, :replace => "?")
+ result.stdout.encode("utf-8", "binary", :undef => :replace, :invalid => :replace, :replace => "?")
else
result.stdout
end
@@ -675,7 +674,7 @@ user password using shadow hash.")
end
def convert_to_binary(string)
- string.unpack("a2"*(string.size/2)).collect { |i| i.hex.chr }.join
+ string.unpack("a2" * (string.size / 2)).collect { |i| i.hex.chr }.join
end
def salted_sha512?(string)
@@ -684,7 +683,7 @@ user password using shadow hash.")
def salted_sha512_password_match?
# Salt is included in the first 4 bytes of shadow data
- salt = current_resource.password.slice(0,8)
+ salt = current_resource.password.slice(0, 8)
shadow = OpenSSL::Digest::SHA512.hexdigest(convert_to_binary(salt) + new_resource.password)
current_resource.password == salt + shadow
end
diff --git a/lib/chef/provider/user/pw.rb b/lib/chef/provider/user/pw.rb
index 8bb234700e..949a21790b 100644
--- a/lib/chef/provider/user/pw.rb
+++ b/lib/chef/provider/user/pw.rb
@@ -77,7 +77,7 @@ class Chef
"uid" => "-u",
"shell" => "-s",
}
- field_list.sort{ |a,b| a[0] <=> b[0] }.each do |field, option|
+ field_list.sort { |a, b| a[0] <=> b[0] }.each do |field, option|
field_symbol = field.to_sym
if @current_resource.send(field_symbol) != @new_resource.send(field_symbol)
if @new_resource.send(field_symbol)
diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb
index 4779dedd94..aabd4b5f68 100644
--- a/lib/chef/provider/user/useradd.rb
+++ b/lib/chef/provider/user/useradd.rb
@@ -55,7 +55,7 @@ class Chef
def check_lock
# we can get an exit code of 1 even when it's successful on
# rhel/centos (redhat bug 578534). See additional error checks below.
- passwd_s = shell_out!("passwd", "-S", new_resource.username, :returns => [0,1])
+ passwd_s = shell_out!("passwd", "-S", new_resource.username, :returns => [0, 1])
if whyrun_mode? && passwd_s.stdout.empty? && passwd_s.stderr.match(/does not exist/)
# if we're in whyrun mode and the user is not yet created we assume it would be
return false
diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb
index 0a7505ddc3..9545b1fd59 100644
--- a/lib/chef/provider/user/windows.rb
+++ b/lib/chef/provider/user/windows.rb
@@ -29,7 +29,7 @@ class Chef
provides :user, os: "windows"
- def initialize(new_resource,run_context)
+ def initialize(new_resource, run_context)
super
@net_user = Chef::Util::Windows::NetUser.new(@new_resource.username)
end
@@ -37,7 +37,7 @@ class Chef
def load_current_resource
if @new_resource.gid
Chef::Log.warn("The 'gid' attribute is not implemented by the Windows platform. Please use the 'group' resource to assign a user to a group.")
- end
+ end
@current_resource = Chef::Resource::User.new(@new_resource.name)
@current_resource.username(@new_resource.username)
@@ -98,7 +98,7 @@ class Chef
end
def set_options
- opts = {:name => @new_resource.username}
+ opts = { :name => @new_resource.username }
field_list = {
"comment" => "full_name",
@@ -108,7 +108,7 @@ class Chef
"password" => "password",
}
- field_list.sort{ |a,b| a[0] <=> b[0] }.each do |field, option|
+ field_list.sort { |a, b| a[0] <=> b[0] }.each do |field, option|
field_symbol = field.to_sym
if @current_resource.send(field_symbol) != @new_resource.send(field_symbol)
if @new_resource.send(field_symbol)
diff --git a/lib/chef/provider/windows_script.rb b/lib/chef/provider/windows_script.rb
index e500e16c8b..2de127addf 100644
--- a/lib/chef/provider/windows_script.rb
+++ b/lib/chef/provider/windows_script.rb
@@ -29,7 +29,7 @@ class Chef
include Chef::Mixin::WindowsArchitectureHelper
- def initialize( new_resource, run_context, script_extension="")
+ def initialize( new_resource, run_context, script_extension = "")
super( new_resource, run_context )
@script_extension = script_extension