From 685ecc9810eb8d5be9df700af6b8cb477b8ef38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20M=E4kinen?= Date: Thu, 17 Sep 2009 17:06:34 +0300 Subject: [PATCH] Added custom::rootpassword class which set's root password to given hash. --- custom/manifests/init.pp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/custom/manifests/init.pp b/custom/manifests/init.pp index 4b37c4c..5720a52 100644 --- a/custom/manifests/init.pp +++ b/custom/manifests/init.pp @@ -18,3 +18,35 @@ class custom { } } + + +# Set root password +# +# === Global variables +# +# $root_password: +# Root password hash to set. +# +class custom::rootpassword { + + if ! $root_password { + fail("Root password hash not defined.") + } + + case $operatingsystem { + openbsd: { + exec { "usermod -p \${SECRET} root": + environment => "SECRET=${root_password}", + path => "/bin:/usr/bin:/sbin:/usr/sbin", + unless => 'test "`sed -n \'s/^root:\([a-zA-Z0-9\.\$]*\):.*/\1/p\' /etc/master.passwd`" = "${SECRET}"', + } + } + default: { + user { "root": + ensure => present, + password => "${root_password}", + } + } + } + +}