diff options
author | Adam Jacob <adam@opscode.com> | 2011-04-04 21:52:39 -0700 |
---|---|---|
committer | Daniel DeLeo <dan@opscode.com> | 2011-04-06 14:16:03 -0700 |
commit | d063ab55637778542ad45b1ad43284af3b916d26 (patch) | |
tree | 0ab19aa9e00f1045e701fa436663324da9be8648 /chef/lib | |
parent | 6743c229a7970822bba4ae6670e569dacad83e3d (diff) | |
download | chef-d063ab55637778542ad45b1ad43284af3b916d26.tar.gz |
Updating log messages for user providers
Diffstat (limited to 'chef/lib')
-rw-r--r-- | chef/lib/chef/provider/user.rb | 27 | ||||
-rw-r--r-- | chef/lib/chef/provider/user/dscl.rb | 4 | ||||
-rw-r--r-- | chef/lib/chef/provider/user/pw.rb | 8 | ||||
-rw-r--r-- | chef/lib/chef/provider/user/useradd.rb | 6 | ||||
-rw-r--r-- | chef/lib/chef/provider/user/windows.rb | 6 |
5 files changed, 25 insertions, 26 deletions
diff --git a/chef/lib/chef/provider/user.rb b/chef/lib/chef/provider/user.rb index 2d2705440b..2c0471f556 100644 --- a/chef/lib/chef/provider/user.rb +++ b/chef/lib/chef/provider/user.rb @@ -51,7 +51,7 @@ class Chef user_info = Etc.getpwnam(@new_resource.username) rescue ArgumentError => e @user_exists = false - Chef::Log.debug("User #{@new_resource.username} does not exist") + Chef::Log.debug("#{@new_resource} user does not exist") user_info = nil end @@ -67,7 +67,6 @@ class Chef begin require 'shadow' rescue LoadError - Chef::Log.error("You must have ruby-shadow installed for password support!") raise Chef::Exceptions::MissingLibrary, "You must have ruby-shadow installed for password support!" else shadow_info = Shadow::Passwd.getspnam(@new_resource.username) @@ -97,11 +96,11 @@ class Chef def action_create if !@user_exists create_user - Chef::Log.info("Created #{@new_resource}") + Chef::Log.info("#{@new_resource} created") @new_resource.updated_by_last_action(true) elsif compare_user manage_user - Chef::Log.info("Altered #{@new_resource}") + Chef::Log.info("#{@new_resource} altered") @new_resource.updated_by_last_action(true) end end @@ -110,7 +109,7 @@ class Chef if @user_exists remove_user @new_resource.updated_by_last_action(true) - Chef::Log.info("Removed #{@new_resource}") + Chef::Log.info("#{@new_resource} removed") end end @@ -122,7 +121,7 @@ class Chef if @user_exists && compare_user manage_user @new_resource.updated_by_last_action(true) - Chef::Log.info("Managed #{@new_resource}") + Chef::Log.info("#{@new_resource} managed") end end @@ -135,10 +134,10 @@ class Chef if compare_user manage_user @new_resource.updated_by_last_action(true) - Chef::Log.info("Modified #{@new_resource}") + Chef::Log.info("#{@new_resource} modified") end else - raise Chef::Exceptions::User, "Cannot modify #{@new_resource} - user does not exist!" + raise Chef::Exceptions::User, "Cannot modify user - does not exist!" end end @@ -147,12 +146,12 @@ class Chef if check_lock() == false lock_user @new_resource.updated_by_last_action(true) - Chef::Log.info("Locked #{@new_resource}") + Chef::Log.info("#{@new_resource} locked") else - Chef::Log.debug("No need to lock #{@new_resource}") + Chef::Log.debug("#{@new_resource} already locked - nothing to do") end else - raise Chef::Exceptions::User, "Cannot lock #{@new_resource} - user does not exist!" + raise Chef::Exceptions::User, "Cannot lock user - does not exist!" end end @@ -169,12 +168,12 @@ class Chef if check_lock() == true unlock_user @new_resource.updated_by_last_action(true) - Chef::Log.info("Unlocked #{@new_resource}") + Chef::Log.info("#{@new_resource} unlocked") else - Chef::Log.debug("No need to unlock #{@new_resource}") + Chef::Log.debug("#{@new_resource} already unlocked - nothing to do") end else - raise Chef::Exceptions::User, "Cannot unlock #{@new_resource} - user does not exist!" + raise Chef::Exceptions::User, "Cannot unlock user - does not exist!" end end diff --git a/chef/lib/chef/provider/user/dscl.rb b/chef/lib/chef/provider/user/dscl.rb index 95608bc36e..19a755ad0f 100644 --- a/chef/lib/chef/provider/user/dscl.rb +++ b/chef/lib/chef/provider/user/dscl.rb @@ -117,7 +117,7 @@ class Chef if @new_resource.password shadow_hash = nil - Chef::Log.debug("#{new_resource}: updating password") + Chef::Log.debug("#{new_resource} updating password") if osx_shadow_hash?(@new_resource.password) shadow_hash = @new_resource.password.upcase else @@ -257,7 +257,7 @@ class Chef end def move_home - Chef::Log.debug("moving #{self} home from #{@current_resource.home} to #{@new_resource.home}") + Chef::Log.debug("#{@new_resource} moving #{self} home from #{@current_resource.home} to #{@new_resource.home}") src = @current_resource.home FileUtils.mkdir_p(@new_resource.home) diff --git a/chef/lib/chef/provider/user/pw.rb b/chef/lib/chef/provider/user/pw.rb index 9004291bc1..4f6393da89 100644 --- a/chef/lib/chef/provider/user/pw.rb +++ b/chef/lib/chef/provider/user/pw.rb @@ -80,13 +80,13 @@ class Chef field_symbol = field.to_sym if @current_resource.send(field_symbol) != @new_resource.send(field_symbol) if @new_resource.send(field_symbol) - Chef::Log.debug("Setting #{@new_resource} #{field} to #{@new_resource.send(field_symbol)}") + Chef::Log.debug("#{@new_resource} setting #{field} to #{@new_resource.send(field_symbol)}") opts << " #{option} '#{@new_resource.send(field_symbol)}'" end end end if @new_resource.supports[:manage_home] - Chef::Log.debug("Managing the home directory for #{@new_resource}") + Chef::Log.debug("#{@new_resource} is managing the users home directory") opts << " -m" end opts @@ -94,7 +94,7 @@ class Chef def modify_password if @current_resource.password != @new_resource.password - Chef::Log.debug("#{new_resource}: updating password") + Chef::Log.debug("#{new_resource} updating password") command = "pw usermod #{@new_resource.username} -H 0" status = popen4(command, :waitlast => true) do |pid, stdin, stdout, stderr| stdin.puts "#{@new_resource.password}" @@ -104,7 +104,7 @@ class Chef raise Chef::Exceptions::User, "pw failed - #{status.inspect}!" end else - Chef::Log.debug("#{new_resource}: no change needed to password") + Chef::Log.debug("#{new_resource} no change needed to password") end end end diff --git a/chef/lib/chef/provider/user/useradd.rb b/chef/lib/chef/provider/user/useradd.rb index 3603537d02..fc5abf862e 100644 --- a/chef/lib/chef/provider/user/useradd.rb +++ b/chef/lib/chef/provider/user/useradd.rb @@ -98,17 +98,17 @@ class Chef UNIVERSAL_OPTIONS.each do |field, option| if @current_resource.send(field) != @new_resource.send(field) if @new_resource.send(field) - Chef::Log.debug("Setting #{@new_resource} #{field} to #{@new_resource.send(field)}") + Chef::Log.debug("#{@new_resource} setting #{field} to #{@new_resource.send(field)}") opts << " #{option} '#{@new_resource.send(field)}'" end end end if updating_home? if managing_home_dir? - Chef::Log.debug("Managing the home directory for #{@new_resource}") + Chef::Log.debug("#{@new_resource} managing the users home directory") opts << " -d '#{@new_resource.home}'" else - Chef::Log.debug("Setting #{@new_resource} home to #{@new_resource.home}") + Chef::Log.debug("#{@new_resource} setting home to #{@new_resource.home}") opts << " -d '#{@new_resource.home}'" end end diff --git a/chef/lib/chef/provider/user/windows.rb b/chef/lib/chef/provider/user/windows.rb index c65a17f949..6bbb2a088c 100644 --- a/chef/lib/chef/provider/user/windows.rb +++ b/chef/lib/chef/provider/user/windows.rb @@ -39,7 +39,7 @@ class Chef user_info = @net_user.get_info rescue @user_exists = false - Chef::Log.debug("User #{@new_resource.username} does not exist") + Chef::Log.debug("#{@new_resource} does not exist") end if user_info @@ -60,7 +60,7 @@ class Chef # <false>:: If the users are identical def compare_user unless @net_user.validate_credentials(@new_resource.password) - Chef::Log.debug("User #{@new_resource.username} password has changed") + Chef::Log.debug("#{@new_resource} password has changed") return true end [ :uid, :gid, :comment, :home, :shell ].any? do |user_attrib| @@ -109,7 +109,7 @@ class Chef if @current_resource.send(field_symbol) != @new_resource.send(field_symbol) if @new_resource.send(field_symbol) unless field_symbol == :password - Chef::Log.debug("Setting #{@new_resource} #{field} to #{@new_resource.send(field_symbol)}") + Chef::Log.debug("#{@new_resource} setting #{field} to #{@new_resource.send(field_symbol)}") end opts[option.to_sym] = @new_resource.send(field_symbol) end |