2017-10-02 16:59:10 +00:00
|
|
|
#!/bin/bash -e
|
2017-11-25 15:40:22 +00:00
|
|
|
|
|
|
|
echo "Please consider ./iiab-install instead of the lesser-supported ./runansible"
|
|
|
|
|
2017-10-24 16:39:49 +00:00
|
|
|
PLAYBOOK="iiab.yml"
|
|
|
|
INVENTORY="ansible_hosts"
|
|
|
|
# Pass cmdline options for ansible
|
|
|
|
ARGS="$@"
|
2017-10-02 16:37:58 +00:00
|
|
|
|
2017-10-26 20:56:08 +00:00
|
|
|
# if vars/local_vars.yml is missing, put a default one in place - First Run
|
2017-05-27 18:09:50 +00:00
|
|
|
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
|
2017-10-04 02:06:35 +00:00
|
|
|
OLPC | fedora)
|
2017-11-02 05:22:20 +00:00
|
|
|
cp ./vars/olpc.localvars ./vars/local_vars.yml
|
|
|
|
;;
|
2017-09-11 16:23:38 +00:00
|
|
|
centos | debian | ubuntu | raspbian)
|
2017-11-02 05:22:20 +00:00
|
|
|
cp ./vars/medium.localvars ./vars/local_vars.yml
|
|
|
|
;;
|
2017-07-05 02:31:19 +00:00
|
|
|
*)
|
2017-11-02 05:22:20 +00:00
|
|
|
echo "IIAB supports raspbian, debian, ubuntu, centos, and OLPC - exiting now..."
|
|
|
|
exit 1
|
|
|
|
;;
|
2017-07-05 02:31:19 +00:00
|
|
|
esac
|
2017-05-27 18:09:50 +00:00
|
|
|
fi
|
|
|
|
|
2017-10-26 20:56:08 +00:00
|
|
|
# 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
|
2017-06-09 23:25:56 +00:00
|
|
|
if [ -f /etc/iiab/iiab.env ]
|
2017-05-27 18:09:50 +00:00
|
|
|
then
|
2017-10-26 20:56:08 +00:00
|
|
|
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
|
2017-05-27 18:09:50 +00:00
|
|
|
else
|
2017-09-25 18:24:01 +00:00
|
|
|
mkdir -p /etc/iiab
|
2017-10-26 20:56:08 +00:00
|
|
|
echo "{}" > /etc/iiab/config_vars.yml
|
2017-05-27 18:09:50 +00:00
|
|
|
fi
|
2017-10-26 20:56:08 +00:00
|
|
|
|
2017-10-24 16:39:49 +00:00
|
|
|
CWD=`pwd`
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-10-24 16:39:49 +00:00
|
|
|
if [ ! -f $PLAYBOOK ]
|
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."
|
2017-09-26 15:10:41 +00:00
|
|
|
exit 1
|
2017-05-27 18:09:50 +00:00
|
|
|
fi
|
|
|
|
|
2017-07-04 20:07:47 +00:00
|
|
|
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
|
|
|
|
|
2017-05-27 18:09:50 +00:00
|
|
|
echo "Running local playbooks! "
|
|
|
|
|
|
|
|
|
2017-10-24 16:39:49 +00:00
|
|
|
export ANSIBLE_LOG_PATH="$CWD/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
|