Skip to content

Instantly share code, notes, and snippets.

@aderixon
Created May 20, 2014 15:08
Show Gist options
  • Save aderixon/863e730bc61dea958abe to your computer and use it in GitHub Desktop.
Save aderixon/863e730bc61dea958abe to your computer and use it in GitHub Desktop.
Example of enabling password history in PAM using Puppet/Augeas
class pam::passwd_history(
$num = 4
) {
case $::osfamily {
/(?i-mx:redhat)/: {
# enable password history
# if not present:
augeas { 'passwd-hist':
context => '/files/etc/pam.d/system-auth',
changes => ["set *[module =~ regexp('.*pam_unix.so')][type = 'password']/argument[last()+1] remember=${num}"],
onlyif => "match *[module =~ regexp('.*pam_unix.so')][type = 'password'][argument = 'remember=${num}'] size == 0"
}
}
default: {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment