mirror of
https://github.com/iiab/iiab.git
synced 2025-02-15 04:32:11 +00:00
commit
1300aa76bb
6 changed files with 85 additions and 56 deletions
|
@ -55,6 +55,8 @@
|
||||||
# https://github.com/iiab/iiab/blob/master/roles/0-DEPRECATED-ROLES/
|
# https://github.com/iiab/iiab/blob/master/roles/0-DEPRECATED-ROLES/
|
||||||
# https://github.com/iiab/iiab/blob/master/tests/test.yml
|
# https://github.com/iiab/iiab/blob/master/tests/test.yml
|
||||||
# https://github.com/iiab/iiab/blob/master/roles/0-init/tasks/validate_vars.yml
|
# https://github.com/iiab/iiab/blob/master/roles/0-init/tasks/validate_vars.yml
|
||||||
|
#
|
||||||
|
# 2020-11-04: Fix validation of 5 core dependencies, for ./runrole etc
|
||||||
|
|
||||||
- name: Set vars_checklist for 40 + 40 + up-to-40 vars ("XYZ_install" + "XYZ_enabled" + "XYZ_installed") to be checked
|
- name: Set vars_checklist for 40 + 40 + up-to-40 vars ("XYZ_install" + "XYZ_enabled" + "XYZ_installed") to be checked
|
||||||
set_fact:
|
set_fact:
|
||||||
|
@ -69,7 +71,7 @@
|
||||||
- openvpn
|
- openvpn
|
||||||
- admin_console
|
- admin_console
|
||||||
#- nginx # MANDATORY
|
#- nginx # MANDATORY
|
||||||
#- apache # Dependency installed on demand by other apps/svcs
|
- apache # Dependency - excluded from _installed check below
|
||||||
#- mysql # MANDATORY
|
#- mysql # MANDATORY
|
||||||
- squid
|
- squid
|
||||||
- dansguardian
|
- dansguardian
|
||||||
|
@ -88,7 +90,7 @@
|
||||||
- lokole
|
- lokole
|
||||||
- mediawiki
|
- mediawiki
|
||||||
- mosquitto
|
- mosquitto
|
||||||
#- nodejs # Dependency installed on demand by other apps/svcs
|
- nodejs # Dependency - excluded from _installed check below
|
||||||
- nodered
|
- nodered
|
||||||
- nextcloud
|
- nextcloud
|
||||||
- pbx
|
- pbx
|
||||||
|
@ -96,9 +98,9 @@
|
||||||
- kalite
|
- kalite
|
||||||
- kolibri
|
- kolibri
|
||||||
- kiwix
|
- kiwix
|
||||||
#- postgresql # Dependency installed on demand by other apps/svcs
|
- postgresql # Dependency - excluded from _installed check below
|
||||||
- moodle
|
- moodle
|
||||||
#- mongodb # Dependency installed on demand by other apps/svcs
|
- mongodb # Dependency - excluded from _installed check below
|
||||||
- sugarizer
|
- sugarizer
|
||||||
- osm_vector_maps
|
- osm_vector_maps
|
||||||
- transmission
|
- transmission
|
||||||
|
@ -107,7 +109,7 @@
|
||||||
- munin
|
- munin
|
||||||
- phpmyadmin
|
- phpmyadmin
|
||||||
- vnstat
|
- vnstat
|
||||||
#- yarn # Dependency installed on demand by other apps/svcs
|
- yarn # Dependency - excluded from _installed check below
|
||||||
- internetarchive
|
- internetarchive
|
||||||
- captiveportal
|
- captiveportal
|
||||||
- minetest
|
- minetest
|
||||||
|
@ -154,4 +156,5 @@
|
||||||
that: "{{ item }}_install or {{ item }}_installed is undefined"
|
that: "{{ item }}_install or {{ item }}_installed is undefined"
|
||||||
fail_msg: "DISALLOWED: '{{ item }}_install: False' (e.g. in /etc/iiab/local_vars.yml) WHEN '{{ item }}_installed' is defined (e.g. in /etc/iiab/iiab_state.yml) -- IIAB DOES NOT SUPPORT UNINSTALLS -- please verify those 2 files especially, and other places variables are defined?"
|
fail_msg: "DISALLOWED: '{{ item }}_install: False' (e.g. in /etc/iiab/local_vars.yml) WHEN '{{ item }}_installed' is defined (e.g. in /etc/iiab/iiab_state.yml) -- IIAB DOES NOT SUPPORT UNINSTALLS -- please verify those 2 files especially, and other places variables are defined?"
|
||||||
quiet: yes
|
quiet: yes
|
||||||
|
when: item != 'apache' and item != 'nodejs' and item != 'postgresql' and item != 'mongodb' and item != 'yarn' # Exclude auto-installed dependencies
|
||||||
loop: "{{ vars_checklist }}"
|
loop: "{{ vars_checklist }}"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# SEE VAR nodejs_version: 12.x IN /opt/iiab/iiab/vars/default_vars.yml (FOR
|
# SEE VAR nodejs_version: 14.x IN /opt/iiab/iiab/vars/default_vars.yml (FOR
|
||||||
# NOW!) AND IF NEC OVERRIDE THIS IN /etc/iiab/local_vars.yml
|
# NOW!) AND IF NEC OVERRIDE THIS IN /etc/iiab/local_vars.yml
|
||||||
|
|
||||||
# Duplicate Node.js code unified by @jvonau. Revised by @holta. Used by:
|
# Duplicate Node.js code unified by @jvonau. Revised by @holta. Used by:
|
||||||
|
|
121
runrole
121
runrole
|
@ -1,12 +1,15 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
DEFAULT_VARS_FILE=/opt/iiab/iiab/vars/default_vars.yml
|
||||||
|
LOCAL_VARS_FILE=/etc/iiab/local_vars.yml
|
||||||
|
IIAB_STATE_FILE=/etc/iiab/iiab_state.yml
|
||||||
|
ROLE_VAR=""
|
||||||
|
INSTALL=false
|
||||||
|
REINSTALL=false
|
||||||
|
CWD=`pwd`
|
||||||
|
ARGS="--extra-vars {" # bash forces {...} to '{...}' for Ansible, SEE BOTTOM
|
||||||
INVENTORY=ansible_hosts
|
INVENTORY=ansible_hosts
|
||||||
PLAYBOOK=run-one-role.yml
|
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
|
if [ ! -f $PLAYBOOK ]; then
|
||||||
echo "Exiting: IIAB Playbook not found."
|
echo "Exiting: IIAB Playbook not found."
|
||||||
|
@ -14,7 +17,7 @@ if [ ! -f $PLAYBOOK ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $# -eq 0 ]] || [ "$2" == "--reinstall" ] || [ "$3" == "--reinstall" ] ; then
|
if [ $# -eq 0 ] || [ "$2" == "--reinstall" ] || [ "$3" == "--reinstall" ]; then
|
||||||
echo "Usage: ./runrole <name of role>"
|
echo "Usage: ./runrole <name of role>"
|
||||||
echo "Usage: ./runrole --reinstall <name of role>"
|
echo "Usage: ./runrole --reinstall <name of role>"
|
||||||
echo
|
echo
|
||||||
|
@ -23,17 +26,6 @@ if [[ $# -eq 0 ]] || [ "$2" == "--reinstall" ] || [ "$3" == "--reinstall" ] ; th
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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
|
|
||||||
|
|
||||||
# 2020-08-05: yes /etc/iiab/iiab_state.yml is necessary, but we DON'T
|
# 2020-08-05: yes /etc/iiab/iiab_state.yml is necessary, but we DON'T
|
||||||
# want to encourage sloppy operators to delete/touch this file.
|
# want to encourage sloppy operators to delete/touch this file.
|
||||||
#
|
#
|
||||||
|
@ -50,38 +42,57 @@ fi
|
||||||
# touch $IIAB_STATE_FILE
|
# touch $IIAB_STATE_FILE
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
#if ! grep -q $1_install $LOCAL_VARS_FILE; then
|
if [ "$1" == "--reinstall" ]; then
|
||||||
# echo " $1_install: not found in $VARS"
|
ARGS="$ARGS\"reinstall\":True," # Needs boolean not string so use JSON list
|
||||||
# echo " Please review $VARS and edit as required"
|
REINSTALL=true
|
||||||
# exit 1
|
shift
|
||||||
#elif grep $1_install $LOCAL_VARS_FILE | grep -q --exclude "#" False; then
|
fi
|
||||||
# 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
|
ROLE_VAR=$1 # Ansible role name & var name sometimes differ :/
|
||||||
if [ $1 == "calibre-web" ]; then # role directory & installed marker differ
|
if [ $1 == "calibre-web" ]; then
|
||||||
sed -i -e '/^calibreweb/d' $IIAB_STATE_FILE
|
ROLE_VAR=calibreweb
|
||||||
elif [ $1 == "httpd" ]; then # role directory & installed marker differ
|
elif [ $1 == "httpd" ]; then
|
||||||
sed -i -e '/^apache/d' $IIAB_STATE_FILE
|
ROLE_VAR=apache
|
||||||
elif [ $1 == "osm-vector-maps" ]; then # role directory & installed marker differ
|
elif [ $1 == "osm-vector-maps" ]; then
|
||||||
sed -i -e '/^osm_vector_maps/d' $IIAB_STATE_FILE
|
ROLE_VAR=osm_vector_maps
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
if $REINSTALL; then # Add '_' so '--reinstall calibre' doesn't zap calibreweb
|
||||||
|
if grep -q "^${ROLE_VAR}_" $IIAB_STATE_FILE; then
|
||||||
|
echo -e "\e[1mThese line(s) in $IIAB_STATE_FILE are now being deleted:\e[0m\n"
|
||||||
|
grep "^${ROLE_VAR}_" $IIAB_STATE_FILE; echo
|
||||||
|
sed -i "/^${ROLE_VAR}_/d" $IIAB_STATE_FILE
|
||||||
else
|
else
|
||||||
sed -i -e "/^$1/d" $IIAB_STATE_FILE
|
echo -e "\e[1mERROR: $IIAB_STATE_FILE has no lines that begin with '${ROLE_VAR}_'\e[0m\n"
|
||||||
|
echo -e "Try again without the '--reinstall' flag?\n"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if grep -q "^${ROLE_VAR}_" $IIAB_STATE_FILE; then
|
||||||
|
echo -e "\e[1mWARNING: $IIAB_STATE_FILE already has this/these line(s):\e[0m\n"
|
||||||
|
grep "^${ROLE_VAR}_" $IIAB_STATE_FILE; echo
|
||||||
|
echo -e "To reinstall it, run: ./runrole --reinstall $1\n"
|
||||||
|
echo -n "Or continue, e.g. to enable/disable it based on var '${ROLE_VAR}_enabled' ? [Y/n] "
|
||||||
|
read ans < /dev/tty
|
||||||
|
echo
|
||||||
|
[ "$ans" = "n" ] || [ "$ans" = "N" ] &&
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
grep -q "^${ROLE_VAR}_install:\s\+[Tt]rue\b" $DEFAULT_VARS_FILE && INSTALL=true
|
||||||
|
grep -q "^${ROLE_VAR}_install:\s\+[Ff]alse\b" $LOCAL_VARS_FILE && INSTALL=false
|
||||||
|
grep -q "^${ROLE_VAR}_install:\s\+[Tt]rue\b" $LOCAL_VARS_FILE && INSTALL=true
|
||||||
|
if ! $INSTALL; then
|
||||||
|
echo -e "\e[1m'${ROLE_VAR}_install: True' MUST BE SET!\e[0m\n"
|
||||||
|
echo -e "Usually it's best to set variables in: $LOCAL_VARS_FILE\n"
|
||||||
|
echo -n "Just for now, pass '${ROLE_VAR}_install: True' directly to Ansible? [Y/n] "
|
||||||
|
read ans < /dev/tty
|
||||||
|
echo
|
||||||
|
[ "$ans" = "n" ] || [ "$ans" = "N" ] &&
|
||||||
|
exit 1
|
||||||
|
ARGS="$ARGS\"${ROLE_VAR}_install\":True,"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 2 ]; then
|
||||||
|
@ -90,5 +101,19 @@ else
|
||||||
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
|
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ansible -m setup -i $INVENTORY localhost ${ARGS} --connection=local | grep python
|
ARGS="$ARGS\"role_to_run\":\"$1\"}" # $1 works like \"$1\" if str validated
|
||||||
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local -e "role_to_run=$1"
|
CMD="ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local $ARGS"
|
||||||
|
echo -e "\e[1mbash will now run this, adding single quotes around the {...} curly braces:\e[0m\n\n$CMD\n"
|
||||||
|
ansible -m setup -i $INVENTORY localhost --connection=local | grep python
|
||||||
|
$CMD
|
||||||
|
|
||||||
|
# bash forces (NECESSARY) single quotes around {} at runtime (if $ARGS contains
|
||||||
|
# curly braces). If you also add single quotes *within* $ARGS, Ansible will
|
||||||
|
# FAIL as you will end up with 2-not-1 single-quotes on each side of the {}.
|
||||||
|
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#json-string-format
|
||||||
|
#
|
||||||
|
# Change the top line of this file to 'bash -x' to see this happen live. Or,
|
||||||
|
# if you prefer the single quotes in the $ARGS var itself, run it this way:
|
||||||
|
#
|
||||||
|
# echo $CMD > /tmp/runrole-ansible-cmd
|
||||||
|
# bash /tmp/runrole-ansible-cmd
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
APT_PATH=/usr/bin # Avoids problematic /usr/local/bin/apt on Linux Mint
|
APT_PATH=/usr/bin # Avoids problematic /usr/local/bin/apt on Linux Mint
|
||||||
CURR_VER="undefined" # Ansible version you currently have installed
|
CURR_VER="undefined" # Ansible version you currently have installed
|
||||||
GOOD_VER="2.10.2" # Orig for 'yum install [rpm]' & XO laptops (pip install)
|
GOOD_VER="2.10.3" # Orig for 'yum install [rpm]' & XO laptops (pip install)
|
||||||
# We install latest 'ansible-base' from PPA: (may be more recent than GOOD-VER)
|
# We install latest 'ansible-base' from PPA: (may be more recent than GOOD-VER)
|
||||||
# https://launchpad.net/~ansible/+archive/ubuntu/ansible
|
# https://launchpad.net/~ansible/+archive/ubuntu/ansible
|
||||||
# https://launchpad.net/~ansible/+archive/ubuntu/ansible-2.10
|
# https://launchpad.net/~ansible/+archive/ubuntu/ansible-2.10
|
||||||
|
|
|
@ -195,6 +195,7 @@ cat_cmd 'sudo journalctl -b 0 -u dnsmasq' 'dnsmasq log'
|
||||||
cat_cmd 'networkctl' 'systemd-networkd status'
|
cat_cmd 'networkctl' 'systemd-networkd status'
|
||||||
cat_cmd 'nmcli d' 'NetworkManager status'
|
cat_cmd 'nmcli d' 'NetworkManager status'
|
||||||
cat_cmd 'sudo journalctl -b 0 -u networkd-dispatcher' 'networkd-dispatcher log'
|
cat_cmd 'sudo journalctl -b 0 -u networkd-dispatcher' 'networkd-dispatcher log'
|
||||||
|
cat_cmd 'iw reg get' 'Detected WiFi country code / legal frequencies'
|
||||||
cat_cmd 'iw dev' 'List wireless interfaces'
|
cat_cmd 'iw dev' 'List wireless interfaces'
|
||||||
cat_cmd 'iw list' 'List capabilities of all wireless devices'
|
cat_cmd 'iw list' 'List capabilities of all wireless devices'
|
||||||
cat_cmd 'systemctl status hostapd' 'Downstream Wi-Fi: Is hostapd running?'
|
cat_cmd 'systemctl status hostapd' 'Downstream Wi-Fi: Is hostapd running?'
|
||||||
|
|
|
@ -62,4 +62,4 @@ But first off, the file is compiled by harvesting 1 + 6 kinds of things:
|
||||||
|
|
||||||
## Source Code
|
## Source Code
|
||||||
|
|
||||||
Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 105-220 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible.
|
Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 105-221 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible.
|
||||||
|
|
Loading…
Reference in a new issue