added a generate password function

This commit is contained in:
mh 2008-10-25 20:31:44 +00:00
parent 73c0c1f880
commit 61c653aac0
2 changed files with 25 additions and 1 deletions

View file

@ -113,11 +113,27 @@ define user::define_user(
include $sshkey
}
}
case $password {
'absent': { info("not managing the password for user $name") }
default: {
case $operatingsystem {
openbsd: { info("we can't manage passwords on ${operatingsystem} systems -> we ignore it.") }
default: {
include ruby-libshadow
User[$name]{
password => $password,
require => Package['ruby-libshadow'],
}
}
}
}
}
}
define user::sftp_only(
$password = 'absent'
) {
include user::groups::sftponly
user::define_user{"${name}":
@ -129,6 +145,7 @@ define user::sftp_only(
ubuntu => '/usr/sbin/nologin',
default => '/sbin/nologin'
},
password => $password,
require => Group['sftponly'],
}
}

View file

@ -0,0 +1,7 @@
## mkpasswd("password", "12345678")
## needs an 8-char salt *always*
module Puppet::Parser::Functions
newfunction(:mkpasswd, :type => :rvalue) do |args|
%x{/usr/bin/mkpasswd -H MD5 #{args[0]} #{args[1]}}.chomp
end
end