summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2008-10-25 20:31:44 +0000
committermh <mh@immerda.ch>2008-10-25 20:31:44 +0000
commit61c653aac054999d26b1f1cda64e87e05bee03cb (patch)
treefc3170f82e083d2ece4eb8401150236ff2bac266
parent73c0c1f880449c06008c133c233bf5f09d712fa3 (diff)
added a generate password function
-rw-r--r--manifests/defines.pp19
-rw-r--r--plugins/puppet/parser/functions/mkpassword.rb7
2 files changed, 25 insertions, 1 deletions
diff --git a/manifests/defines.pp b/manifests/defines.pp
index a31dd6a..1a440d6 100644
--- a/manifests/defines.pp
+++ b/manifests/defines.pp
@@ -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'],
}
}
diff --git a/plugins/puppet/parser/functions/mkpassword.rb b/plugins/puppet/parser/functions/mkpassword.rb
new file mode 100644
index 0000000..c7ba8c0
--- /dev/null
+++ b/plugins/puppet/parser/functions/mkpassword.rb
@@ -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