Forked from chrisgilbert/gist:58f57c82f74162ed5c0f
Last active
November 19, 2016 14:47
-
-
Save Theaxiom/85fb9c19cd5965c7f9b7 to your computer and use it in GitHub Desktop.
Run Ansible or Ansible-Playbook from Rundeck
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/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
Source: https://groups.google.com/forum/#!topic/rundeck-discuss/8rJWEmjhwnM