diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-12-21 15:24:40 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-12-22 09:27:20 -0800 |
commit | 7de787be3e792a58285f089c31e2b58b995fde08 (patch) | |
tree | f2a922b614f295aa226511bd1e15ccc3fc5af77a /lib/chef/provider/user.rb | |
parent | a86ec6cbe445a67e887d528989a443372707c621 (diff) | |
download | chef-7de787be3e792a58285f089c31e2b58b995fde08.tar.gz |
user provider cleanup
* removes more run_command
* converts to shell_out_compact
* some other misc style cleanup
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider/user.rb')
-rw-r--r-- | lib/chef/provider/user.rb | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb index 4b05ac8f5e..de94871a87 100644 --- a/lib/chef/provider/user.rb +++ b/lib/chef/provider/user.rb @@ -39,7 +39,7 @@ class Chef if @new_resource.gid.is_a? String @new_resource.gid(Etc.getgrnam(@new_resource.gid).gid) end - rescue ArgumentError => e + rescue ArgumentError @group_name_resolved = false end @@ -53,7 +53,7 @@ class Chef begin user_info = Etc.getpwnam(@new_resource.username) - rescue ArgumentError => e + rescue ArgumentError @user_exists = false Chef::Log.debug("#{@new_resource} user does not exist") user_info = nil @@ -97,7 +97,7 @@ class Chef requirements.assert(:all_actions) do |a| 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." + + 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. " end requirements.assert(:modify, :lock, :unlock) do |a| @@ -137,34 +137,31 @@ class Chef end def action_remove - if @user_exists - converge_by("remove user #{@new_resource.username}") do - remove_user - Chef::Log.info("#{@new_resource} removed") - end + return unless @user_exists + converge_by("remove user #{@new_resource.username}") do + remove_user + Chef::Log.info("#{@new_resource} removed") end end def action_manage - if @user_exists && compare_user - converge_by("manage user #{@new_resource.username}") do - manage_user - Chef::Log.info("#{@new_resource} managed") - end + return unless @user_exists && compare_user + converge_by("manage user #{@new_resource.username}") do + manage_user + Chef::Log.info("#{@new_resource} managed") end end def action_modify - if compare_user - converge_by("modify user #{@new_resource.username}") do - manage_user - Chef::Log.info("#{@new_resource} modified") - end + return unless compare_user + converge_by("modify user #{@new_resource.username}") do + manage_user + Chef::Log.info("#{@new_resource} modified") end end def action_lock - if check_lock() == false + if check_lock == false converge_by("lock the user #{@new_resource.username}") do lock_user Chef::Log.info("#{@new_resource} locked") @@ -175,7 +172,7 @@ class Chef end def action_unlock - if check_lock() == true + if check_lock == true converge_by("unlock user #{@new_resource.username}") do unlock_user Chef::Log.info("#{@new_resource} unlocked") |