1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00
iiab/runansible
2017-10-28 17:26:28 -05:00

74 lines
1.8 KiB
Bash
Executable file

#!/bin/bash -e
# running from a git repo
PLAYBOOK="iiab-steps.yml"
INVENTORY="ansible_hosts"
CWD=`pwd`
# Pass cmdline options for ansible
ARGS="$@"
export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
if [ ! -f /etc/ansible/facts.d/local_facts.fact ]; then
mkdir -p /etc/ansible/facts.d
fi
cp ./scripts/local_facts.fact /etc/ansible/facts.d/local_facts.fact
STAGE=""
if [ -f /etc/iiab/iiab.env ]
then
OLD=`grep XSCE /etc/iiab/iiab.env | wc -l`
if [ "$OLD" != 0 ]
then
echo "Found old XSCE install - re-installing from scratch"
rm /etc/iiab/iiab.env
# check ansible version here and force ansible upgrade if needed
else
source /etc/iiab/iiab.env
if [ ! $STAGE == 9 ]
then
echo "Restarting STAGE=$STAGE"
fi
if [ $STAGE == 9 ]
then
# place keeper
echo "offer 'Y' dialog box and --debug option to override"
echo "need to rewrite STAGE= before ansible is called or rm iiab.env"
sleep 5
# exit 0
fi
fi
else
mkdir -p /etc/iiab
fi
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 1
fi
# if vars/local_vars.yml is missing, put a default one in place - First Run
if [ ! -f ./vars/local_vars.yml ]; then
OS=`grep ^ID= /etc/*release|cut -d= -f2`
OS=${OS//\"/}
case $OS in
OLPC | fedora)
cp ./vars/olpc.localvars ./vars/local_vars.yml
;;
centos | debian | ubuntu | raspbian)
cp ./vars/medium.localvars ./vars/local_vars.yml
;;
*)
echo "IIAB supports raspbian, debian, ubuntu, centos, and OLPC - exiting now..."
exit 1
;;
esac
fi
echo "Running local playbooks! "
ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local