Forked from chrisgilbert/gist:58f57c82f74162ed5c0f
Last active
September 9, 2015 15:28
-
-
Save abeyt/7a7a7be652581f776f49 to your computer and use it in GitHub Desktop.
Run Ansible or Ansible-Playbook from Rundeck
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
#!/bin/bash | |
# Interpret whether the input needs to go to ansible, or ansible-playbook and run appropriately | |
# First update the git repos for each project | |
/usr/bin/update-git-repos | |
export ANSIBLE_FORCE_COLOR=1 | |
export ANSIBLE_RETRY_FILES_ENABLED=False | |
USER=root | |
echo Command line given was: | |
echo $0 $@ | |
echo Rundeck project is $RD_JOB_PROJECT | |
REGEX=".*.yml" | |
if [[ $2 =~ $REGEX ]]; then | |
COMMAND=ansible-playbook | |
ARGS=" $2 -i /etc/ansible/hosts/$RD_JOB_PROJECT -u $3 -vv --limit=$1 $4 $5 $6 $7" | |
else | |
COMMAND=ansible | |
ARGS=" $1 -i /etc/ansible/hosts/$RD_JOB_PROJECT --user=$USER --module-name=$2 --args=\"$3 $4 $5 $6 $7 $8 $9\"" | |
if [ $3 == "rm" ]; then | |
echo RM commands are disabled. | |
exit 1 | |
fi | |
fi | |
echo Running $COMMAND $ARGS | |
eval $COMMAND $ARGS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment