1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-12 19:22:24 +00:00
iiab/runansible
2017-11-02 01:22:20 -04:00

65 lines
1.6 KiB
Bash
Executable file

#!/bin/bash -e
PLAYBOOK="iiab.yml"
INVENTORY="ansible_hosts"
# Pass cmdline options for ansible
ARGS="$@"
# 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
# copy var files to /etc/iiab for subsequent use
# If iiab.env exists, on second or upgrade run, check for stale variables
# iiab.env gets created at the end of stage-4 on First Run
if [ -f /etc/iiab/iiab.env ]
then
OLD=`grep XSCE /etc/iiab/iiab.env`
if [ x"$OLD" != "x" ]
then
rm /etc/iiab/iiab.env
else
. /etc/iiab/iiab.env
cd $IIAB_DIR
fi
else
mkdir -p /etc/iiab
echo "{}" > /etc/iiab/config_vars.yml
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 1
fi
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
echo "Running local playbooks! "
export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local