1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00
iiab/runtags
2017-10-26 20:46:01 -04:00

54 lines
1 KiB
Bash
Executable file

#!/bin/bash
PLAYBOOK="iiab.yml"
INVENTORY="ansible_hosts"
# Pass cmdline options for ansible
if [ -f /etc/iiab/iiab.env ]
then
. /etc/iiab/iiab.env
cd $IIAB_DIR
fi
CWD=`pwd`
if [ ! -f $PLAYBOOK ]
then
echo "IIAB Playbook not found."
echo "Please run this command from the top level of the git repo."
echo "Exiting."
exit
fi
tags=$(echo $1 | tr "," "\n")
if [ "$tags" == "" ]
then
echo " usage: ./runtags <tagname>"
echo " usage: ./runtags <tagname1>,<tagname2>,<tagname3>"
echo " Can take a single value or a comma-separated list (no spaces within the list!)"
echo " Now retrieving a list of possible Ansible playbook and tagname values..."
ansible-playbook -i ansible_hosts iiab.yml --connection=local --list-tag
exit 0
fi
found="N"
for tag in $tags
do
if [ "$tag" == "0-init" ]
then
found="Y"
fi
done
# echo $found
taglist=$1
if [ "$found" == "N" ]
then
taglist="0-init,"$taglist
fi
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
ansible-playbook -i ansible_hosts iiab.yml --connection=local --tags="""$taglist"""