Added custom::rootpassword class which set's root password to given hash.
This commit is contained in:
parent
d384b2aa57
commit
685ecc9810
1 changed files with 32 additions and 0 deletions
|
@ -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}",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue