Skip to content

Instantly share code, notes, and snippets.

@HarryRybacki-zz
Created December 15, 2015 13:57
Show Gist options
  • Save HarryRybacki-zz/8f786411cf55a8926212 to your computer and use it in GitHub Desktop.
Save HarryRybacki-zz/8f786411cf55a8926212 to your computer and use it in GitHub Desktop.
ansible-lint wrapper for linting directories (WIP)
#! /bin/bash
EX_OK=0
EX_ER=1
EX_USAGE=64
# Verify ansible-lint is acessible
verify_tool() {
if ! hash ansible-lint; then
echo "'ansible-lint' not found. Are you sure it is installed and accessible from your current path?"
fi
}
verify_tool;
usage() {
# Print usage message
cat << EOF
Usage $0 [options]
ansible-lint for directories
OPTIONS:
-h Show this message
EOF
}
# If executed with no options
if [ $# -eq 0 ]; then
find . -type f -name '*.yml' | xargs -n 1 ansible-lint
exit $EX_OK
fi
while getopts ":h" opt; do
case "$opt" in
h)
# Display help message
usage
exit $EX_OK
;;
*)
# All other flags enter default case
usage
exit $EX_USAGE
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment