O Puppet não entende curingas no tipo de arquivo. Se você usa algo assim:
file { "/home/*":
ensure => directory,
owner => $username,
group => $username,
mode => 700,
require => [ User[$username], Group[$username] ]
}
ele criará a pasta /home/\*
.
Portanto, você deve criar a estrutura de diretório que deseja como abaixo:
define add_user ( $fullname, $uid ) {
$username = $title
$firstletter = regsubst($username, '(.).*', '')
$secondletter = regsubst($username, '.(.).*', '')
user { $username:
comment => "$fullname",
home => "/home/$firstletter/$secondletter/$username",
shell => "/bin/bash",
uid => $uid,
require => [ File["/home/$firstletter"], File["/home/$firstletter/$secondletter"] ]
}
group { $username:
gid => $uid,
require => User[$username]
}
file { "/home/$firstletter":
ensure => directory,
owner => root,
group => root,
mode => 755
}
file { "/home/$firstletter/$secondletter":
ensure => directory,
owner => root,
group => root,
mode => 755,
require => File["/home/$firstletter"]
}
file { "/home/$firstletter/$secondletter/$username":
ensure => directory,
owner => $username,
group => $username,
mode => 700,
require => [ File["/home/$firstletter/$secondletter"], User[$username], Group[$username] ]
}
file { "/home/$firstletter/$secondletter/$username/.ssh":
ensure => directory,
owner => $username,
group => $username,
mode => 700,
require => File["/home/$firstletter/$secondletter/$username"]
}
# now make sure that the ssh key authorized files is around
file { "/home/$firstletter/$secondletter/$username/.ssh/authorized_keys":
ensure => present,
owner => $username,
group => $username,
mode => 600,
require => File["/home/$firstletter/$secondletter/$username"]
}
}
e ligue para:
node 'test_node' {
add_user { lars:
fullname => "Larry Page",
uid => 510
}
}