summaryrefslogtreecommitdiff
path: root/lib/chef/provider/user/useradd.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/provider/user/useradd.rb')
-rw-r--r--lib/chef/provider/user/useradd.rb88
1 files changed, 0 insertions, 88 deletions
diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb
deleted file mode 100644
index 96736a27a8..0000000000
--- a/lib/chef/provider/user/useradd.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require File.join(File.dirname(__FILE__), "..", "user")
-
-class Chef
- class Provider
- class User
- class Useradd < Chef::Provider::User
- def create_user
- command = "useradd"
- command << set_options
- run_command(:command => command)
- end
-
- def manage_user
- command = "usermod"
- command << set_options
- run_command(:command => command)
- end
-
- def remove_user
- command = "userdel"
- command << " -r" if @new_resource.supports[:manage_home]
- command << " #{@new_resource.username}"
- run_command(:command => command)
- end
-
- def lock_user
- run_command(:command => "usermod -L #{@new_resource.username}")
- end
-
- def unlock_user
- run_command(:command => "usermod -U #{@new_resource.username}")
- end
-
- def set_options
- opts = ''
-
- field_list = {
- 'comment' => "-c",
- 'home' => "-d",
- 'gid' => "-g",
- 'uid' => "-u",
- 'shell' => "-s",
- 'password' => "-p"
- }
- field_list.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)
- Chef::Log.debug("Setting #{@new_resource} #{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}")
- case @node[:operatingsystem]
- when "Fedora","RedHat","CentOS"
- opts << " -M"
- else
- opts << " -m"
- end
- end
- opts << " #{@new_resource.username}"
- opts
- end
-
- end
- end
- end
-end \ No newline at end of file