1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-14 12:12:12 +00:00

runtags cleanup/refactoring

This commit is contained in:
A Holt 2018-03-28 14:01:59 -04:00 committed by GitHub
parent 86aa6a8c43
commit 6e9fbdaf3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

48
runtags
View file

@ -1,19 +1,19 @@
#!/bin/bash
# running from a git repo
PLAYBOOK="iiab.yml"
INVENTORY="ansible_hosts"
PLAYBOOK="iiab.yml"
#PLAYBOOK="iiab-stages.yml"
CWD=`pwd`
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
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
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
@ -21,31 +21,27 @@ 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
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 $INVENTORY $PLAYBOOK --connection=local --list-tags
exit 0
fi
found="N"
for tag in $tags
do
if [ "$tag" == "0-init" ]
then
found="Y"
fi
for tag in $tags; do
if [ "$tag" == "0-init" ]; then
found="Y"
fi
done
taglist=$1
if [ "$found" == "N" ]
then
taglist="0-init,"$taglist
if [ "$found" == "N" ]; then
taglist="0-init,"$taglist
fi
ansible-playbook -i ansible_hosts iiab.yml --connection=local --tags="""$taglist"""
ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local --tags=$taglist