Created
December 12, 2015 21:57
-
-
Save JonTheNiceGuy/1bb411bb415c7d05c2b2 to your computer and use it in GitHub Desktop.
Want to set a username and password in Puppet? Keep getting "You reset the password for a user 8m times" in your logs? This may be the gist for you! Only really works if you've got a consistent user salt across all your boxes :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define createuser ( | |
$username = $title, | |
$password = 'defaultpw', | |
$groups = ['users'], | |
$home = "/home/${username}" | |
$shell = '/bin/bash') { | |
user { $username: | |
ensure => present, | |
password => generate( | |
'/bin/sh', | |
'-c', | |
"mkpasswd -m sha-512 ${password} \$(</etc/shadow awk -v user=${username} -F : 'user == \$1 {print \$2}' | cut -d '$' -f 3) | tr -d '\n'" | |
), | |
home => $home, | |
groups => $groups, | |
shell => $shell, | |
managehome => yes | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment