Skip to content

Instantly share code, notes, and snippets.

@frimik
Created February 27, 2013 15:27
Show Gist options
  • Save frimik/5048736 to your computer and use it in GitHub Desktop.
Save frimik/5048736 to your computer and use it in GitHub Desktop.
user::root class
class user::root {
# Whitelist means we DON'T manage the passwords.
# For the old fashioned people who don't know what an ENC is.
$whitelist_fqdn_array = ['funkyserver1.domain.int']
# valid password regexes
$valid_password_array = ['^\$1\$.{25,}', '^\$foreman\$.{15,}']
if $::root_pw and !member($whitelist_fqdn_array, $::fqdn) {
# If root_pw is set and matches one of our well known password formats, go
# ahead and set it
case $::manage_root_password {
true,"true": {
validate_re($::root_pw, $valid_password_array)
class{"user::root::password":
ensure => present,
password => $::root_pw,
stage => "setup",
}
}
default: {
# What do you know? It's a no-op!
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment