From 0c7862f3a435b3c429ebe2bc149566b6b4429a9a Mon Sep 17 00:00:00 2001 From: Aaron Greengrass Date: Thu, 23 Jan 2014 13:25:46 -0800 Subject: [PATCH] Extend user creation with more granularity Changes: groups now a variable with a preset, since there may be instances where sudo/admin will NOT be desired. home now entirely a variable, defaults to previous action, but handles cases where created user may not belong in /home managed home flag, defaulted to enabled. No impact to current functionality. Allows for more granular changes in the future. Typo fix for managehome. Change-Id: Id0921f5b28ea0ffd2230d94e87673e6b39ac060e --- modules/user/manifests/virtual/localuser.pp | 27 ++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/modules/user/manifests/virtual/localuser.pp b/modules/user/manifests/virtual/localuser.pp index 540f3034b0..8b4b21f341 100644 --- a/modules/user/manifests/virtual/localuser.pp +++ b/modules/user/manifests/virtual/localuser.pp @@ -1,8 +1,16 @@ +# usage +# +# user::virtual::localuser['username'] + define user::virtual::localuser( $realname, - $sshkeys = '', - $shell = '/bin/bash' + $groups = [ 'sudo', 'admin', ], + $sshkeys = '', + $shell = '/bin/bash', + $home = "/home/${title}", + $managehome = true ) { + group { $title: ensure => present, } @@ -11,20 +19,17 @@ define user::virtual::localuser( ensure => present, comment => $realname, gid => $title, - groups => [ - 'sudo', - 'admin', - ], - home => "/home/${title}", - managehome => true, # creates home directory, does not manage it + groups => $groups, + home => $home, + managehome => $managehome, membership => 'minimum', - require => Group[$title], shell => $shell, + require => Group[$title], } file { "${title}_sshdir": ensure => directory, - name => "/home/${title}/.ssh", + name => "${home}/.ssh", owner => $title, group => $title, mode => '0700', @@ -36,7 +41,7 @@ define user::virtual::localuser( content => $sshkeys, group => $title, mode => '0400', - name => "/home/${title}/.ssh/authorized_keys", + name => "${home}/.ssh/authorized_keys", owner => $title, require => File["${title}_sshdir"], }