1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/runrole
2019-10-30 21:38:06 -05:00

38 lines
896 B
Bash
Executable file

#!/bin/bash
INVENTORY="ansible_hosts"
PLAYBOOK="run-one-role.yml"
ARGS=""
CWD=`pwd`
if [ "$1" == "--reinstall" ]; then
ARGS="$ARGS --extra-vars reinstall=True"
shift 1
fi
if [ $# -eq 2 ]; then
export ANSIBLE_LOG_PATH="$2"
else
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
fi
if [ ! -f $PLAYBOOK ]; then
echo "Exiting: IIAB Playbook not found."
echo "Please run this in /opt/iiab/iiab (top level of the git repo)."
exit 1
fi
# Is the following stanza nec?
if [ ! -f /etc/iiab/config_vars.yml ]; then
mkdir -p /etc/iiab
echo "{}" > /etc/iiab/config_vars.yml
fi
if [[ $# -eq 0 ]] ; then
echo " usage: ./runrole <name of role>"
echo " Can only take a single value."
exit 0
fi
ansible -m setup -i $INVENTORY localhost ${ARGS} --connection=local | grep python
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local -e "role_to_run=$1"