1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-14 12:12:12 +00:00
iiab/runrole

53 lines
1.5 KiB
Text
Raw Normal View History

2018-04-03 15:55:36 +00:00
#!/bin/bash
INVENTORY="ansible_hosts"
PLAYBOOK="run-one-role.yml"
ARGS=""
2018-04-03 15:55:36 +00:00
CWD=`pwd`
2019-10-16 15:37:33 +00:00
APPS=/etc/iiab/config_vars2.yml
if [ ! -f $PLAYBOOK ]; then
echo "Exiting: IIAB Playbook not found."
echo "Please run this in /opt/iiab/iiab (top level of the git repo)."
exit 1
fi
if [[ $# -eq 0 ]] ; then
echo " usage: ./runrole <name of role>"
echo " usage: ./runrole --reinstall <name of role>"
echo " Last variable would be full path to log file."
echo " If ommited current directory is used."
exit 0
fi
2019-10-16 15:37:33 +00:00
# needed for stage 1-3 if not installed yet
if [ ! -f $APPS ]; then
mkdir -p /etc/iiab
touch $APPS
fi
2019-08-10 22:27:39 +00:00
if [ "$1" == "--reinstall" ]; then
ARGS="$ARGS --extra-vars reinstall=True"
if [ ! $2 == "internetarchive" ]; then # special handling
if [ $2 == "calibre-web" ]; then # role directory & installed marker differ
2019-10-16 15:37:33 +00:00
sed -i -e '/^calibreweb/d' $APPS
fi
2019-10-16 14:39:08 +00:00
if [ $2 == "captive-portal" ]; then # role directory & installed marker differ
2019-10-16 15:37:33 +00:00
sed -i -e '/^captiveportal/d' $APPS
2019-10-16 14:39:08 +00:00
fi
if [ $2 == "bluetooth" ]; then # role directory & installed marker differ
2019-10-16 15:37:33 +00:00
sed -i -e '/^pan_bluetooth/d' $APPS
2019-10-16 14:39:08 +00:00
fi
2019-10-16 15:37:33 +00:00
sed -i -e "/^$2/d" $APPS
fi
2019-08-10 22:27:39 +00:00
shift 1
fi
2019-08-10 22:27:39 +00:00
if [ $# -eq 2 ]; then
export ANSIBLE_LOG_PATH="$2"
else
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
fi
2018-04-03 15:55:36 +00:00
2019-10-31 02:38:06 +00:00
ansible -m setup -i $INVENTORY localhost ${ARGS} --connection=local | grep python
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local -e "role_to_run=$1"