Last active
December 1, 2021 14:28
-
-
Save baztian/5a7b87ebc223fd6f6fe7cc4cbeb7156e to your computer and use it in GitHub Desktop.
Execute ansible role
This file contains hidden or 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
#!/bin/sh | |
set -e | |
if [ $# -lt 1 ]; then | |
echo "Executes a ansible role on localhost" > /dev/stderr | |
echo "Usage $(basename $0) ROLENAME [additional ansible-playbook options]" > /dev/stderr | |
echo "Example: $(basename $0) baztian.keepass -K -b" > /dev/stderr | |
exit 1 | |
fi | |
ROLE=$1 | |
shift | |
TMPFILE="$(mktemp -t playbook-XXXXXX.yml)" | |
cat > $TMPFILE <<HERE | |
--- | |
- hosts: all | |
roles: | |
- role: $ROLE | |
HERE | |
ansible-playbook "$TMPFILE" -c local -i localhost, "$@" | |
rm "$TMPFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment