Module: Rudy::Routines::UserHelper

Extended by:
UserHelper
Includes:
HelperBase
Included in:
UserHelper
Defined in:
lib/rudy/routines/helpers/userhelper.rb

Instance Method Summary collapse

Methods included from HelperBase

#command_separator, #execute_rbox_command, #keep_going?

Methods included from Huxtable

change_environment, change_position, change_region, change_role, change_zone, #check_keys, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_size, #current_user, #current_user_keypairpath, debug?, #debug?, domain, domain_exists?, #group_metadata, #has_keypair?, #has_keys?, #has_pem_keys?, #has_root_keypair?, keypair_path_to_name, #known_machine_group?, #root_keypairname, #root_keypairpath, #switch_user, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath

Instance Method Details

#adduser(routine, machine, rbox) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rudy/routines/helpers/userhelper.rb', line 10

def adduser(routine, machine, rbox)
  
  # On Solaris, the user's home directory needs to be specified
  # explicitly so we do it for linux too for fun. 
  homedir = rbox.guess_user_home(routine.adduser.to_s)
  args = [:m, :d, homedir, :s, '/bin/bash', routine.adduser.to_s]
  puts command_separator(rbox.preview_command(:useradd, args), rbox.user)
  
  # NOTE: We'll may to use platform specific code here. 
  # Linux has adduser and useradd commands:
  # adduser can prompt for info which we don't want. 
  # useradd does not prompt (on Debian/Ubuntu at least). 
  # We need to specify bash b/c the default is /bin/sh
  execute_rbox_command { rbox.useradd(args) }
end

#adduser?(routine) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/rudy/routines/helpers/userhelper.rb', line 7

def adduser?(routine)
  (!routine.adduser.nil? && !routine.adduser.to_s.empty?)
end

#authorize(routine, machine, rbox) ⇒ Object



29
30
31
32
# File 'lib/rudy/routines/helpers/userhelper.rb', line 29

def authorize(routine, machine, rbox)
  puts command_separator(:authorize_keys_remote, rbox.user)
  execute_rbox_command { rbox.authorize_keys_remote(routine.authorize) }
end

#authorize?(routine) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rudy/routines/helpers/userhelper.rb', line 26

def authorize?(routine)
  (!routine.authorize.nil? && !routine.authorize.to_s.empty?)
end