2017-05-27 18:09:50 +00:00
|
|
|
#!/bin/bash
|
2017-10-24 16:39:49 +00:00
|
|
|
PLAYBOOK="iiab.yml"
|
|
|
|
INVENTORY="ansible_hosts"
|
|
|
|
# Pass cmdline options for ansible
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-06-09 23:25:56 +00:00
|
|
|
if [ -f /etc/iiab/iiab.env ]
|
2017-05-27 18:09:50 +00:00
|
|
|
then
|
2017-06-09 23:25:56 +00:00
|
|
|
. /etc/iiab/iiab.env
|
2017-10-24 16:39:49 +00:00
|
|
|
cd $IIAB_DIR
|
2017-05-27 18:09:50 +00:00
|
|
|
fi
|
|
|
|
|
2017-10-24 16:39:49 +00:00
|
|
|
CWD=`pwd`
|
|
|
|
|
|
|
|
if [ ! -f $PLAYBOOK ]
|
2017-05-27 18:09:50 +00:00
|
|
|
then
|
2017-10-24 16:39:49 +00:00
|
|
|
echo "IIAB Playbook not found."
|
2017-05-27 18:09:50 +00:00
|
|
|
echo "Please run this command from the top level of the git repo."
|
|
|
|
echo "Exiting."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
tags=$(echo $1 | tr "," "\n")
|
|
|
|
|
2017-09-16 13:11:34 +00:00
|
|
|
if [ "$tags" == "" ]
|
|
|
|
then
|
2017-09-29 21:50:31 +00:00
|
|
|
echo " usage: ./runtags <tagname>"
|
|
|
|
echo " usage: ./runtags <tagname1>,<tagname2>,<tagname3>"
|
2017-09-29 21:24:35 +00:00
|
|
|
echo " Can take a single value or a comma-separated list (no spaces within the list!)"
|
2017-09-29 21:53:19 +00:00
|
|
|
echo " Now retrieving a list of possible Ansible playbook and tagname values..."
|
2017-09-16 13:11:34 +00:00
|
|
|
ansible-playbook -i ansible_hosts iiab.yml --connection=local --list-tag
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-05-27 18:09:50 +00:00
|
|
|
found="N"
|
|
|
|
|
|
|
|
for tag in $tags
|
|
|
|
do
|
2017-10-27 00:46:01 +00:00
|
|
|
if [ "$tag" == "0-init" ]
|
2017-05-27 18:09:50 +00:00
|
|
|
then
|
|
|
|
found="Y"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# echo $found
|
|
|
|
|
|
|
|
taglist=$1
|
|
|
|
|
|
|
|
if [ "$found" == "N" ]
|
|
|
|
then
|
2017-10-27 00:46:01 +00:00
|
|
|
taglist="0-init,"$taglist
|
2017-05-27 18:09:50 +00:00
|
|
|
fi
|
|
|
|
|
2017-10-24 16:39:49 +00:00
|
|
|
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
|
2017-06-09 23:25:56 +00:00
|
|
|
ansible-playbook -i ansible_hosts iiab.yml --connection=local --tags="""$taglist"""
|