Puppet Function: psick::get_user_home

Defined in:
functions/get_user_home.pp
Function type:
Puppet Language

Overview

psick::get_user_home(String[1] $user)String

This function returns the home directory of the given user handling superuser and OS differences

Examples:


$home_dir_path = psick::get_user_home($user)

Parameters:

  • user (String[1])

Returns:

  • (String)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'functions/get_user_home.pp', line 8

function psick::get_user_home ( String[1] $user ) >> String {
  case $facts['os']['family'] {
    'RedHat', 'Suse': {
      if $user == 'root' {
        $home_dir = '/root'
      } else {
        $home_dir = "/home/${user}"
      }
    }
    'Solaris': {
      if $user == 'root' {
        $home_dir = $facts['os']['release']['full'] ? {
          '5.11'  => '/root',
          default => '/',
        }
      } else {
        $home_dir = "/home/${user}"
      }
    }
    'windows': {
      $home_dir = "C:/Users/${user}"
    }
    default: {
      if $user == 'root' {
        $home_dir = '/root'
      } else {
        $home_dir = "/home/${user}"
      }
    }
  }
}