mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			83 lines
		
	
	
	
		
			2.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
	
		
			2.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/bin/bash
 | |
| 
 | |
| INVENTORY=ansible_hosts
 | |
| PLAYBOOK=run-one-role.yml
 | |
| ARGS=""
 | |
| REINSTALL=0
 | |
| CWD=`pwd`
 | |
| IIAB_STATE_FILE=/etc/iiab/iiab_state.yml
 | |
| LOCAL_VARS_FILE=/etc/iiab/local_vars.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 ]] || [ "$2" == "--reinstall" ] || [ "$3" == "--reinstall" ] ; then
 | |
|     echo "Usage: ./runrole <name of role>"
 | |
|     echo "Usage: ./runrole --reinstall <name of role>"
 | |
|     echo
 | |
|     echo "Optional 2nd parameter is full PATH/FILENAME for logging."
 | |
|     echo "If omitted, <current directory>/iiab-debug.log is used."
 | |
|     exit 0
 | |
| fi
 | |
| 
 | |
| if [ "$1" == "--reinstall" ]; then
 | |
|     ARGS="$ARGS -e reinstall=True"
 | |
|     REINSTALL=1
 | |
|     shift 1
 | |
| fi
 | |
| 
 | |
| #if ! grep -q "^""$1""_install: True" $LOCAL_VARS_FILE; then
 | |
| #    echo "ERROR: $LOCAL_VARS_FILE must contain '""$1""_install: True'"
 | |
| #    exit 1
 | |
| #fi
 | |
| 
 | |
| # Needed for Stages 1-3 if not installed yet
 | |
| if [ ! -f $IIAB_STATE_FILE ]; then
 | |
|     touch $IIAB_STATE_FILE
 | |
| fi
 | |
| 
 | |
| #if ! grep -q $1_install $LOCAL_VARS_FILE; then
 | |
| #    echo " $1_install: not found in $VARS"
 | |
| #    echo " Please review $VARS and edit as required"
 | |
| #    exit 1
 | |
| #elif grep $1_install $LOCAL_VARS_FILE | grep -q --exclude "#" False; then
 | |
| #    echo " $1_install: set to False found in $VARS"
 | |
| #    echo " Please review $VARS and edit as required"
 | |
| #    exit 1
 | |
| #elif grep $1_install $LOCAL_VARS_FILE | grep -q "#"; then
 | |
| #    echo " $1_install: commented out (#) in $VARS"
 | |
| #    echo " Please review $VARS and edit as required"
 | |
| #    exit 1
 | |
| #else
 | |
| #    if grep $1_install $LOCAL_VARS_FILE | grep -q --exclude "#" True; then
 | |
| #        echo " $1_install: set to True found in $VARS"
 | |
| #        echo " continuing...."
 | |
| #    else
 | |
| #        echo "somthing went wrong to get here"
 | |
| #        exit 1
 | |
| #    fi
 | |
| #fi
 | |
| 
 | |
| if [ "$REINSTALL" == "1" ]; then
 | |
|     if [ $1 == "calibre-web" ]; then # role directory & installed marker differ
 | |
|         sed -i -e '/^calibreweb/d' $IIAB_STATE_FILE
 | |
|     elif [ $1 == "httpd" ]; then # role directory & installed marker differ
 | |
|         sed -i -e '/^apache/d' $IIAB_STATE_FILE
 | |
|     elif [ $1 == "osm-vector-maps" ]; then # role directory & installed marker differ
 | |
|         sed -i -e '/^osm_vector_maps/d' $IIAB_STATE_FILE
 | |
|     else
 | |
|         sed -i -e "/^$1/d" $IIAB_STATE_FILE
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| if [ $# -eq 2 ]; then
 | |
|    export ANSIBLE_LOG_PATH="$2"
 | |
| else
 | |
|    export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
 | |
| fi
 | |
| 
 | |
| ansible -m setup -i $INVENTORY localhost ${ARGS} --connection=local | grep python
 | |
| ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local -e "role_to_run=$1"
 |