Hi,
Our security policy states we lock *nix accounts that have no passwords. I wrote a bash script that does the job but my onlyif statement isn't working. I want it to check and only trigger when true - not every time. I'm new to puppet trying to learn how to write 'onlyif' statements - can someone point me in the right direction?
Here is manifest - the onlyif statement and the bash lock-out-no-password-account.sh script are working in isolation. Augeas would be ideal to handle this kind of task but I have yet to find one to suit. Help & guidance is appreciated.
exec { 'lock-accout-no-pass' :
command => "/admin/scripts/lock-out-no-password-account.sh",
onlyif => "/bin/cat /etc/shadow | /bin/awk -F : '{ print $2 }' | /bin/grep ^$ | tail -1 | /bin/grep -c ^$"
}
#!/bin/bash
#
# Lock out active accounts with no password
for NAME in `awk -F: '( $2 == "" ) { print $1 }' /etc/shadow`; do
MyUID=`id -u $NAME`
if [ $MyUID -gt 500 -a $NAME != 'root' ]; then
usermod -L -s /dev/null $NAME
fi
done
Thanks,
Brian.