1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00
iiab/runansible

107 lines
2.6 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
;;
2017-07-05 02:31:19 +00:00
fedora)
cp ./vars/olpc.localvars ./vars/local_vars.yml
;;
centos)
cp ./vars/centos.localvars ./vars/local_vars.yml
;;
debian)
cp ./vars/debian.localvars ./vars/local_vars.yml
;;
ubuntu)
cp ./vars/debian.localvars ./vars/local_vars.yml
;;
raspbian)
cp ./vars/debian.localvars ./vars/local_vars.yml
;;
*)
echo "Unknown OS -- no matching os.localvars -- exiting now..."
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
# raspbian-9 changes network interface names to include mac address
# which defeats copying an image from one SD card to another
raspbian_ver=`./scripts/local_facts.fact|grep os_ver|awk -F '"' '{print $4}'`
if [ "$raspbian_ver" == "raspbian-9" ]; then
grep net.ifnames=0 /boot/cmdline.txt
if [ $? -ne 0 ]; then
sed -i -r 's/deadline +fsck/deadline net.ifnames=0 fsck/' /boot/cmdline.txt
echo
echo "Kernel cmdline changed. Will now reboot so that network interface names will"
echo " be same for all raspberry pi\'s. Hit enter, and then restart this script"
read var
reboot
fi
fi
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