Class: Wright::Resource::User

Inherits:
Wright::Resource show all
Defined in:
lib/wright/resource/user.rb

Overview

User resource, represents a user.

Examples:

johndoe = Wright::Resource::User.new('johndoe')
johndoe.home = '/home/johndoe'
johndoe.create

Instance Attribute Summary collapse

Attributes inherited from Wright::Resource

#action, #ignore_failure, #name, #resource_name

Instance Method Summary collapse

Methods inherited from Wright::Resource

#log_error, #might_update_resource, #on_update=, #provider_for_resource, #provider_name, #resource_class, #run_action, #run_update_action

Constructor Details

#initialize(name) ⇒ User

Initializes a user.

Parameters:

  • name (String)

    the user's name


40
41
42
43
44
# File 'lib/wright/resource/user.rb', line 40

def initialize(name)
  super
  @action = :create
  @system = false
end

Instance Attribute Details

#full_nameString

Returns the user's intended full name.

Returns:

  • (String)

    the user's intended full name


17
18
19
# File 'lib/wright/resource/user.rb', line 17

def full_name
  @full_name
end

#groupsArray<String>

Returns the user's intended groups.

Returns:

  • (Array<String>)

    the user's intended groups


20
21
22
# File 'lib/wright/resource/user.rb', line 20

def groups
  @groups
end

#homeString Also known as: homedir

Returns the user's intended home directory path.

Returns:

  • (String)

    the user's intended home directory path


26
27
28
# File 'lib/wright/resource/user.rb', line 26

def home
  @home
end

#primary_groupString, Integer Also known as: login_group

Returns the user's intended primary group.

Returns:

  • (String, Integer)

    the user's intended primary group


30
31
32
# File 'lib/wright/resource/user.rb', line 30

def primary_group
  @primary_group
end

#shellString

Returns the user's intended shell.

Returns:

  • (String)

    the user's intended shell


23
24
25
# File 'lib/wright/resource/user.rb', line 23

def shell
  @shell
end

#systemBool

Returns true if the user should be a system user. Ignored if #uid is set.

Returns:

  • (Bool)

    true if the user should be a system user. Ignored if #uid is set.


35
36
37
# File 'lib/wright/resource/user.rb', line 35

def system
  @system
end

#uidInteger

Returns the user's intended user id.

Returns:

  • (Integer)

    the user's intended user id


14
15
16
# File 'lib/wright/resource/user.rb', line 14

def uid
  @uid
end

Instance Method Details

#createBool

Creates or updates the user.

Returns:

  • (Bool)

    true if the user was updated and false otherwise


50
51
52
53
54
# File 'lib/wright/resource/user.rb', line 50

def create
  might_update_resource do
    @provider.create
  end
end

#removeBool

Removes the user.

Returns:

  • (Bool)

    true if the user was updated and false otherwise


60
61
62
63
64
# File 'lib/wright/resource/user.rb', line 60

def remove
  might_update_resource do
    @provider.remove
  end
end