class Wright::Resource::User
User
resource, represents a user.
@example
johndoe = Wright::Resource::User.new('johndoe', home: '/home/johndoe') johndoe.create
Attributes
@return [String] the user's intended full name
@return [Array<String>] the user's intended groups
@return [String] the user's intended home directory path
@return [String] the user's intended home directory path
@return [String, Integer] the user's intended primary group
@return [String, Integer] the user's intended primary group
@return [String] the user's intended shell
@return [Bool] true if the user should be a system
user. Ignored if {#uid} is set.
@return [Integer] the user's intended user id
Public Class Methods
Initializes a user.
@param name [String] the user's name @param args [Hash] the arguments @option args [Symbol] :action (:create) the action @option args [Integer] :uid the user's uid @option args [String] :full_name the user's full name @option args [Array<String>] :groups the user's groups @option args [String] :shell the user's shell @option args [String] :home the user's home directory @option args [String] :primary_group the user's primary group @option args [Bool] :system (false) denotes whether the user
should be a system user or not
Wright::Resource::new
# File lib/wright/resource/user.rb, line 49 def initialize(name, args = {}) super @action = args.fetch(:action, :create) @uid = args.fetch(:uid, nil) @full_name = args.fetch(:full_name, nil) @groups = args.fetch(:groups, nil) @shell = args.fetch(:shell, nil) @home = fetch_last(args, [:home, :homedir], nil) @primary_group = fetch_last(args, [:primary_group, :login_group], nil) @system = args.fetch(:system, false) end
Public Instance Methods
Creates or updates the user.
@return [Bool] true if the user was updated and false
otherwise
# File lib/wright/resource/user.rb, line 65 def create might_update_resource do provider.create end end
Removes the user.
@return [Bool] true if the user was updated and false
otherwise
# File lib/wright/resource/user.rb, line 75 def remove might_update_resource do provider.remove end end
Private Instance Methods
# File lib/wright/resource/user.rb, line 83 def fetch_last(hash, candidate_keys, default = nil) Wright::Util.fetch_last(hash, candidate_keys, default) end