mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			102 lines
		
	
	
	
		
			5.8 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
	
		
			5.8 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/bin/bash -e
 | |
| 
 | |
| # PLZ SEE http://FAQ.IIAB.IO > "What is Ansible and what version should I use?"
 | |
| #         https://github.com/iiab/iiab/tree/master/scripts/ansible.md
 | |
| 
 | |
| APT_PATH=/usr/bin    # Avoids problematic /usr/local/bin/apt on Linux Mint
 | |
| CURR_VER="undefined"    # Ansible version you currently have installed
 | |
| GOOD_VER="2.10.2"    # Orig for 'yum install [rpm]' & XO laptops (pip install)
 | |
| # 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-2.10
 | |
| # http://ppa.launchpad.net/ansible/ansible/ubuntu/pool/main/a/ansible-base/
 | |
| # https://github.com/ansible/ansible/commits/stable-2.10/changelogs/CHANGELOG-v2.10.rst
 | |
| 
 | |
| # IIAB implementers might instead consider these 2 GENERAL TECHNIQUES below
 | |
| # ("in an emergency!") e.g. if you must install an older version of Ansible:
 | |
| 
 | |
| # TEMPORARILY USE ANSIBLE 2.9.13 (REMOVE IT WITH "pip uninstall ansible")
 | |
| #pip install ansible==2.9.13
 | |
| 
 | |
| # TEMPORARILY USE ANSIBLE 2.4.2 DUE TO 2.4.3 MEMORY BUG. Details: iiab/iiab#669
 | |
| #echo "Install http://download.iiab.io/packages/ansible_2.4.2.0-1ppa~xenial_all.deb"
 | |
| #cd /tmp
 | |
| #wget http://download.iiab.io/packages/ansible_2.4.2.0-1ppa~xenial_all.deb
 | |
| #apt -y --allow-downgrades install ./ansible_2.4.2.0-1ppa~xenial_all.deb
 | |
| 
 | |
| export DEBIAN_FRONTEND=noninteractive
 | |
| # Why 'noninteractive' appears needed:
 | |
| # https://github.com/iiab/iiab/issues/564#issuecomment-347264985
 | |
| 
 | |
| echo -e "\n\nYOU ARE RUNNING: /opt/iiab/iiab/scripts/ansible (TO INSTALL ANSIBLE)\n"
 | |
| #echo -e 'Alternative:     /opt/iiab/iiab/scripts/ansible-2.9.x ("Slow Food")\n'
 | |
| 
 | |
| echo -e "RECOMMENDED PREREQUISITES:"
 | |
| echo -e "(1) Verify you're online"
 | |
| echo -e "(2) Remove all prior versions of Ansible using..."
 | |
| echo -e "    'apt purge ansible-base'  and/or  'pip uninstall ansible-base'  and/or"
 | |
| echo -e "    'apt purge ansible'       and/or  'pip uninstall ansible'"
 | |
| echo -e "(3) Remove all lines containing 'ansible' from..."
 | |
| echo -e "    /etc/apt/sources.list and /etc/apt/sources.list.d/*\n"
 | |
| 
 | |
| echo -e "IIAB INSTALL INSTRUCTIONS: (OLDER, MANUAL APPROACH)"
 | |
| echo -e "https://github.com/iiab/iiab/wiki/IIAB-Installation#do-everything-from-scratch\n"
 | |
| 
 | |
| if [ $(command -v ansible) ]; then    # "command -v" is POSIX compliant; also catches built-in commands like "cd"
 | |
|     CURR_VER=`ansible --version | head -1 | awk '{print $2}'`    # To match iiab-install.  Was: CURR_VER=`ansible --version | head -n 1 | cut -f 2 -d " "`
 | |
|     echo -e "CURRENTLY INSTALLED ANSIBLE: $CURR_VER -- LET'S TRY TO UPGRADE IT!"
 | |
| else
 | |
|     echo -e "ANSIBLE NOT FOUND ON THIS COMPUTER -- LET'S TRY TO INSTALL IT!"
 | |
| fi
 | |
| echo -e "(Internet-in-a-Box requests ansible-base $GOOD_VER or higher)\n"
 | |
| 
 | |
| # Code above designed to work on all Linux distributions, to preserve options,
 | |
| # in support of any volunteer(s) wanting to port IIAB to a new Linux/distro.
 | |
| if [ ! -f /etc/debian_version ]; then    # e.g. Raspbian, Ubuntu, Mint & Debian
 | |
|     echo -e "\nEXITING: /etc/debian_version FILE NOT FOUND.  Linux OS support info here:"
 | |
|     echo -e "           https://github.com/iiab/iiab/wiki/IIAB-Platforms\n"
 | |
|     exit 1
 | |
| fi
 | |
| 
 | |
| echo -e "\napt update; install dirmngr; PPA to /etc/apt/sources.list.d/iiab-ansible.list\n"
 | |
| $APT_PATH/apt update
 | |
| $APT_PATH/apt -y install dirmngr
 | |
| echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main" \
 | |
|      > /etc/apt/sources.list.d/iiab-ansible.list
 | |
| # In future we might instead consider 'add-apt-repository ppa:ansible/ansible'
 | |
| # or 'apt-add-repository ppa:ansible/bionic/ansible' etc, e.g. for streamlined
 | |
| # removal using 'apt-add-repository -r' -- however that currently requires
 | |
| # 'apt install software-properties-common' which drags in a dozen packages we
 | |
| # might not want, e.g. unattended-upgrades, packagekit etc.
 | |
| 
 | |
| # 2020-08-20: TEMP WORKAROUND (REVERT TO ANSIBLE 2.9.6) MITIGATING
 | |
| # iiab/iiab#2481 (Ansible 2.9.12 and 2.10.0's 666-TO-600 file permissions
 | |
| # problem).  This workaround installs 2.9.6-1ppa~disco onto RaspiOS, from
 | |
| # https://launchpad.net/~ansible/+archive/ubuntu/ansible
 | |
| #echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu disco main" \
 | |
|     #    > /etc/apt/sources.list.d/iiab-ansible.list
 | |
| 
 | |
| echo -e '\nIF YOU FACE ERROR "signatures couldn'"'"'t be verified because the public key is not available" THEN REPEATEDLY RE-RUN "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 93C4A3FD7BB9C367"\n'
 | |
| apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 93C4A3FD7BB9C367
 | |
| echo -e 'PPA source "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main"'
 | |
| echo -e "successfully saved to /etc/apt/sources.list.d/iiab-ansible.list\n"
 | |
| echo -e "IF *OTHER* ANSIBLE SOURCES APPEAR BELOW, PLEASE MANUALLY REMOVE THEM TO"
 | |
| echo -e 'ENSURE ANSIBLE UPDATES CLEANLY: (then re-run this script to be sure!)\n'
 | |
| grep '^deb .*ansible' /etc/apt/sources.list /etc/apt/sources.list.d/*.list | grep -v '^/etc/apt/sources.list.d/iiab-ansible.list:' || true    # Override bash -e (instead of aborting at 1st error)
 | |
| 
 | |
| echo -e "\napt update; apt install ansible-base and python3 dependencies explained at:"
 | |
| echo -e "https://github.com/iiab/iiab/tree/master/scripts/ansible.md\n"
 | |
| $APT_PATH/apt update
 | |
| $APT_PATH/apt -y --allow-downgrades install ansible-base \
 | |
|               python3-pymysql python3-psycopg2 python3-passlib python3-pip \
 | |
|               python3-setuptools python3-venv virtualenv
 | |
| 
 | |
| echo -e "\n\nIIAB requires these 2 Ansible Collections: (w/ ansible-base 2.10.0 or higher)\n"
 | |
| ansible-galaxy collection install community.general    # Re-running these
 | |
| ansible-galaxy collection install community.mysql      # appears to be safe!?
 | |
| 
 | |
| echo -e "\n\nCreating/verifying directory /etc/ansible & installing /etc/ansible/hosts\n"
 | |
| mkdir -p /etc/ansible
 | |
| echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts
 | |
| 
 | |
| echo -e "SUCCESS: VERIFY ANSIBLE WITH 'ansible --version' & 'apt -a list ansible-base'\n\n"
 |