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

80 lines
1.7 KiB
Text
Raw Normal View History

#!/bin/bash
2017-05-27 18:09:50 +00:00
# copy var files to /etc/iiab for subsequent use
mkdir -p /etc/iiab
if [ ! -f /etc/iiab/config_vars.yml ]; then
echo "{}" > /etc/iiab/config_vars.yml
2017-05-27 18:09:50 +00:00
fi
# if vars/local_vars.yml is missing, put a default one in place
if [ ! -f ./vars/local_vars.yml ]; then
2017-07-05 02:31:19 +00:00
OS=`grep ^ID= /etc/*release|cut -d= -f2`
OS=${OS//\"/}
case $OS in
OLPC)
cp ./vars/olpc.localvars ./vars/local_vars.yml
2017-07-11 03:51:41 +00:00
;;
centos | debian | ubuntu | raspbian)
cp ./vars/medium.localvars ./vars/local_vars.yml
2017-07-05 02:31:19 +00:00
;;
*)
echo "IIAB supports raspbian, debian, ubuntu, centos, and OLPC - exiting now..."
2017-07-05 02:31:19 +00:00
exit 0
;;
esac
2017-05-27 18:09:50 +00:00
fi
if [ -f /etc/iiab/iiab.env ]
2017-05-27 18:09:50 +00:00
then
. /etc/iiab/iiab.env
2017-05-27 18:09:50 +00:00
cd $XSCE_DIR
else
XSCE_DIR=/opt/iiab/iiab
2017-05-27 18:09:50 +00:00
fi
if [ ! -f iiab.yml ]
2017-05-27 18:09:50 +00:00
then
2017-07-05 02:31:19 +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
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
PLAYBOOK="iiab.yml"
2017-05-27 18:09:50 +00:00
INVENTORY="ansible_hosts"
CWD=`pwd`
echo "Running local playbooks! "
XSDOMAIN=""
# Pass in Existing Domain
if [ -f /etc/sysconfig/xs_domain_name ]
then
XSDOMAIN=`cat /etc/sysconfig/xs_domain_name`
fi
# Or accept Domain on command line
if [ x"$1" != x ]
then
XSDOMAIN=$1
fi
# Pass in git location
if [ x"$XSDOMAIN" != x ]
then
ARGS="--extra-vars '{\"iiab_domain\":\"$XSDOMAIN\"}'"
2017-05-27 18:09:50 +00:00
else
ARGS=""
fi
export ANSIBLE_LOG_PATH="$XSCE_DIR/iiab-install.log"
2017-05-27 18:09:50 +00:00
ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local