diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index b66db2d5a..01d391d65 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -123,7 +123,7 @@ - name: Set python_path (redhat) set_fact: - python_path: /usr/lib/python2.7/site-packages/ + python_path: /lib/python2.7/site-packages/ when: is_redhat - name: Set python_path (debuntu) diff --git a/roles/calibre/tasks/debs.yml b/roles/calibre/tasks/debs.yml index 64c6504a2..03d77ae32 100644 --- a/roles/calibre/tasks/debs.yml +++ b/roles/calibre/tasks/debs.yml @@ -3,5 +3,10 @@ name: calibre state: present +# April 5 2018 raspbian is now tracking the latest Calibre with a small delay. +# Should you really want the latest just run the below script standalone, it is +# strongly suggested that waiting for the lastest deb from Rasbian is the best. + - name: Upgrade latest Calibre command: scripts/calibre-install-latest.sh + when: not is_rpi diff --git a/roles/httpd/tasks/main.yml b/roles/httpd/tasks/main.yml index 518840487..76979dd84 100644 --- a/roles/httpd/tasks/main.yml +++ b/roles/httpd/tasks/main.yml @@ -39,6 +39,7 @@ - httpd - php - php-curl + - mod_authnz_external # - php-sqlite tags: - download diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index cc6862dee..b4cee63a2 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -14,13 +14,13 @@ device_gw2: "" iiab_wan_iface: "none" iiab_lan_iface: "none" -#discovered_lan_iface: "none" +discovered_lan_iface: "none" discovered_wired_iface: "none" discovered_wireless_iface: "none" -#iiab_wired_lan_iface: "none" -#iiab_wireless_lan_iface: "none" #Redhat +iiab_wired_lan_iface: "none" +iiab_wireless_lan_iface: "none" has_WAN: False has_ifcfg_gw: "none" has_wifi_gw: "none" diff --git a/roles/network/tasks/computed_network.yml b/roles/network/tasks/computed_network.yml index ee418a81c..ace548616 100644 --- a/roles/network/tasks/computed_network.yml +++ b/roles/network/tasks/computed_network.yml @@ -130,7 +130,18 @@ - name: LAN configured - 'Gateway' mode set_fact: iiab_network_mode: "Gateway" - when: iiab_lan_iface != "none" and iiab_wan_iface != "none" + when: (iiab_lan_iface != "none" and iiab_wan_iface != "none") or is_rpi + +- name: Force iiab_lan_iface if is_rpi + set_fact: + iiab_lan_iface: "br0" + iiab_wireless_lan_iface: "wlan0" + when: is_rpi + +- name: Enable hostapd if discovered_wireless_iface is not WAN + set_fact: + hostapd_enabled: True + when: is_rpi and iiab_wan_iface != discovered_wireless_iface # override with user_lan_iface setting if no longer in auto - name: Setting user LAN fact @@ -156,6 +167,26 @@ iiab_wan_iface: "none" when: adapter_count.stdout|int >= "5" and device_gw == "none" and gui_wan_iface == "unset" and gui_static_wan is defined +- name: Record IIAB_WAN_DEVICE to /etc/iiab/iiab.env + lineinfile: + dest: /etc/iiab/iiab.env + regexp: '^IIAB_WAN_DEVICE=*' + line: 'IIAB_WAN_DEVICE="{{ iiab_wan_iface }}"' + state: present + when: not installing #REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml + tags: + - network + +- name: Record IIAB_LAN_DEVICE to /etc/iiab/iiab.env + lineinfile: + dest: /etc/iiab/iiab.env + regexp: '^IIAB_LAN_DEVICE=*' + line: 'IIAB_LAN_DEVICE="{{ iiab_lan_iface }}"' + state: present + when: not installing #REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml + tags: + - network + - name: Add location section to config file ini_file: dest: "{{ iiab_config_file }}" diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index e5d744d5e..f0c8e9fbe 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -29,7 +29,6 @@ owner: root group: root mode: 0644 - when: hostapd_enabled - name: Create /usr/bin/iiab-hotspot-on from template template: diff --git a/roles/network/tasks/ifcfg_mods.yml b/roles/network/tasks/ifcfg_mods.yml index 760cdd4aa..2d8a4769f 100644 --- a/roles/network/tasks/ifcfg_mods.yml +++ b/roles/network/tasks/ifcfg_mods.yml @@ -14,6 +14,7 @@ # clear all bridge ifcfg files - name: Now delete slave bridge ifcfg files shell: rm -f /etc/sysconfig/network-scripts/ifcfg-"{{ item }}" + ignore_errors: True when: num_lan_interfaces != 0 or iiab_wireless_lan_iface != "none" with_items: - "{{ ifcfg_slaves.stdout_lines }}" diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index 7300081d4..cc595770b 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -142,27 +142,6 @@ tags: - network -# this is moving -- name: Record IIAB_WAN_DEVICE to /etc/iiab/iiab.env - lineinfile: - dest: /etc/iiab/iiab.env - regexp: '^IIAB_WAN_DEVICE=*' - line: 'IIAB_WAN_DEVICE="{{ iiab_wan_iface }}"' - state: present - when: not installing #REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml - tags: - - network - -- name: Record IIAB_LAN_DEVICE to /etc/iiab/iiab.env - lineinfile: - dest: /etc/iiab/iiab.env - regexp: '^IIAB_LAN_DEVICE=*' - line: 'IIAB_LAN_DEVICE="{{ iiab_lan_iface }}"' - state: present - when: not installing #REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml - tags: - - network - #### end network layout - include_tasks: restart.yml when: not installing diff --git a/roles/network/tasks/rpi_debian.yml b/roles/network/tasks/rpi_debian.yml index 25390091b..be4ea571a 100644 --- a/roles/network/tasks/rpi_debian.yml +++ b/roles/network/tasks/rpi_debian.yml @@ -20,10 +20,26 @@ dest: /etc/dhcpcd.conf src: network/dhcpcd.conf.j2 +- name: New raspbian requires counry code -- check for it + shell: grep country /etc/wpa_supplicant/wpa_supplicant.conf + register: country_code + ignore_errors: True + +- name: Put a country code if it does not exist + lineinfile: + dest: /etc/wpa_supplicant/wpa_supplicant.conf + regexp: "^country.*" + line: country={{ host_country_code }} + when: country_code is defined and country_code.stdout == "" + +- name: Enable the wifi with rfkill + shell: rfkill unblock 0 + ignore_errors: True + - name: Copy the bridge script for RPi template: dest: /etc/network/interfaces.d/iiab - src: network/rpi.j2 + src: network/iiab.j2 when: iiab_lan_iface == "br0" - name: Stopping services @@ -48,9 +64,12 @@ - name: Restart hostapd if appropriate service: name: hostapd - enabled: yes state: restarted - when: hostapd_enabled and iiab_wireless_lan_iface is defined and iiab_network_mode != "Appliance" + when: hostapd_enabled and iiab_wan_iface != discovered_wireless_iface and iiab_network_mode != "Appliance" + +- name: Ansible is having a problem enabling services + shell: systemctl enable hostapd + when: hostapd_enabled and iiab_wan_iface != discovered_wireless_iface and iiab_network_mode != "Appliance" #- name: dhcp_server may be affected - starting - user choice # service: name={{ dhcp_service2 }} state=started diff --git a/roles/usb-lib/tasks/main.yml b/roles/usb-lib/tasks/main.yml index 2781cd7ce..1f312b188 100644 --- a/roles/usb-lib/tasks/main.yml +++ b/roles/usb-lib/tasks/main.yml @@ -19,9 +19,12 @@ template: src: "{{ item.src }}" dest: "{{ item.dest }}" + mode: "{{ item.mode }}" with_items: - - { src: 'usbmount@.service.j2' , dest: '/etc/systemd/system/usbmount@.service' } - - { src: 'usbmount.rules.j2' , dest: '/etc/udev/rules.d/usbmount.rules' } + - { src: 'usbmount@.service.j2' , dest: '/etc/systemd/system/usbmount@.service', mode: '0644' } + - { src: 'usbmount.rules.j2' , dest: '/etc/udev/rules.d/usbmount.rules', mode: '0644' } + - { src: 'iiab-usb-lib-show-all-on' , dest: '/usr/bin/', mode: '0755' } + - { src: 'iiab-usb-lib-show-all-off' , dest: '/usr/bin/', mode: '0755' } - name: Enable exfat and ntfs lineinfile: @@ -50,6 +53,12 @@ state: absent when: not usb_lib_enabled +- name: Put a variable in iiab.env for display of content at root of USB + lineinfile: + dest: /etc/iiab/iiab.env + regexp: "^IIAB_USB_LIB_SHOW_ALL.*" + line: "IIAB_USB_LIB_SHOW_ALL={{ iiab_usb_lib_show_all }}" + - name: Add Apache config for content directory template: src: content_dir.conf diff --git a/roles/usb-lib/templates/iiab-usb-lib-show-all-off b/roles/usb-lib/templates/iiab-usb-lib-show-all-off new file mode 100644 index 000000000..adeff4c81 --- /dev/null +++ b/roles/usb-lib/templates/iiab-usb-lib-show-all-off @@ -0,0 +1,5 @@ +#!/bin/bash +# turn on the flag which registers new USB sticks at root directory + +sed -i -e's/^IIAB_USB_LIB_SHOW_ALL.*/IIAB_USB_LIB_SHOW_ALL=False/' /etc/iiab/iiab.env + diff --git a/roles/usb-lib/templates/iiab-usb-lib-show-all-on b/roles/usb-lib/templates/iiab-usb-lib-show-all-on new file mode 100644 index 000000000..297f37025 --- /dev/null +++ b/roles/usb-lib/templates/iiab-usb-lib-show-all-on @@ -0,0 +1,5 @@ +#!/bin/bash +# turn on the flag which registers new USB sticks at root directory + +sed -i -e's/^IIAB_USB_LIB_SHOW_ALL.*/IIAB_USB_LIB_SHOW_ALL=True/' /etc/iiab/iiab.env + diff --git a/roles/usb-lib/templates/mount.d/70-usb-library b/roles/usb-lib/templates/mount.d/70-usb-library index 7a6b74690..02328339d 100644 --- a/roles/usb-lib/templates/mount.d/70-usb-library +++ b/roles/usb-lib/templates/mount.d/70-usb-library @@ -9,7 +9,17 @@ # # by Tim Moody tim@timmoody.com -logger -p user.notice -t "70-usb-library" -- "Looking for /share, /Share, /Piratebox/Share, /USB, or /usb on $UM_MOUNTPOINT." +source /etc/iiab/iiab.env +case $IIAB_USB_LIB_SHOW_ALL in +'True'|'true'|'TRUE') + logger -p user.notice -t "70-usb-library" -- "Displaying root directory on $UM_MOUNTPOINT." + # regularize the variable + IIAB_USB_LIB_SHOW_ALL=True + ;; +*) + logger -p user.notice -t "70-usb-library" -- "Looking for /share, /Share, /Piratebox/Share, /USB, or /usb on $UM_MOUNTPOINT." + ;; +esac VERBOSE=yes @@ -31,6 +41,9 @@ fi if [ -d $UM_MOUNTPOINT/usb ]; then SHARE_DIR="$UM_MOUNTPOINT/usb" fi +if [ "$IIAB_USB_LIB_SHOW_ALL" == "True" ]; then + SHARE_DIR="$UM_MOUNTPOINT" +fi if [ ! -z "$SHARE_DIR" ]; then logger -p user.notice -t "70-usb-library" -- "Found Share Directory $SHARE_DIR." diff --git a/scripts/ansible b/scripts/ansible index 4921cbed7..8ca758331 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -1,11 +1,11 @@ #!/bin/bash -e -# Installs or upgrades to the best possible Ansible release, so iiab-install -# can proceed. Ensure you're online before running this script! +echo -e '\nATTEMPTING TO INSTALL THE LATEST (RELEASED VERSION OF) ANSIBLE.' +echo -e 'Ensure you'"'"'re online before running this script!' +echo -e 'OR: consider scripts/ansible-2.4.x for a "slow food" alternative.\n' -GOOD_VER="2.4.2" # Ansible version for OLPC, for pip. - # On other OS's we install/upgrade to the latest Ansible. - # Pin all to 2.4.x in future, if really/truly nec? +GOOD_VER="2.5.0" # Ansible version for OLPC XO laptops (pip install). + # On other OS's we install/upgrade to THE latest (released version of) Ansible. CURR_VER="undefined" # FOUND="false" # NOT USED AS OF 2017-12-12 # FAMILY="undefined" # NOT USED AS OF 2017-12-12 @@ -14,13 +14,13 @@ CURR_VER="undefined" export DEBIAN_FRONTEND=noninteractive -if ! which ansible-playbook ; then +if [ ! `command -v ansible-playbook` ]; then # "command -v" is POSIX compliant; also catches built-in commands like "cd" echo "Installing --- Please Wait" if [ -f /etc/centos-release ]; then yum -y install ca-certificates nss epel-release yum -y install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python yum -y install python-pip python-setuptools python-wheel patch - yum -y install http://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/ansible-2.4.2.0-1.el7.ans.noarch.rpm + yum -y install http://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/ansible-2.5.0-1.el7.ans.noarch.rpm # FOUND="true" # FAMILY="redhat" # elif [ -f /etc/fedora-release ]; then @@ -42,7 +42,9 @@ if ! which ansible-playbook ; then if ( ! grep -qi ansible /etc/apt/sources.list) && [ ! -f /etc/apt/sources.list.d/ansible ]; then apt -y install dirmngr python-pip python-setuptools python-wheel patch echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" \ - >> /etc/apt/sources.list.d/ansible.list + >> /etc/apt/sources.list.d/iiab-ansible.list + #echo "deb http://ppa.launchpad.net/ansible/ansible-2.4/ubuntu xenial main" \ + # >> /etc/apt/sources.list.d/iiab-ansible.list apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 fi # FOUND="true" @@ -51,6 +53,7 @@ if ! which ansible-playbook ; then elif (grep -qi ubuntu /etc/lsb-release) || (grep -qi ubuntu /etc/os-release); then apt -y install python-pip python-setuptools python-wheel patch apt-add-repository -y ppa:ansible/ansible + #apt-add-repository -y ppa:ansible/ansible-2.4 # FOUND="true" # FAMILY="debian" # fi @@ -71,8 +74,9 @@ else exit 0 #fi #if [[ `grep -qi ansible /etc/apt/sources.list` ]] || [ -f /etc/apt/sources.list.d/ansible*.list ]; then - elif (grep -qi ansible /etc/apt/sources.list) || (ls /etc/apt/sources.list.d/ansible*.list >/dev/null 2>&1) ; then - echo "Ansible repo(s) found within /etc/apt/sources.list*" + elif (grep -qi ansible /etc/apt/sources.list) || (ls /etc/apt/sources.list.d/*ansible*.list >/dev/null 2>&1) ; then + #echo "Ansible repo(s) found within /etc/apt/sources.list*" + echo -e '\nANSIBLE REPO(S) FOUND WITHIN /etc/apt/sources.list AND/OR /etc/apt/sources.list.d/*ansible*.list -- MUST CONTAIN LINE "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" IF YOU WANT THE LATEST RELEASED VERSION OF ANSIBLE -- then re-run this script.\n' else echo "Upstream ansible source repo not found, please uninstall ansible and re-run this script" exit 1 @@ -80,15 +84,19 @@ else fi if [ ! -f /etc/centos-release ] && [ ! -f /etc/fedora-release ] && [ ! -f /etc/olpc-release ]; then + # Align IIAB with Ansible community's latest official release + echo "Using apt to check for updates, then install/upgrade ansible" + apt update + apt -y install ansible + + # TEMPORARILY USE ANSIBLE 2.4.4 (REMOVE IT WITH "pip uninstall ansible") + #pip install ansible==2.4.4 + # TEMPORARILY USE ANSIBLE 2.4.2 DUE TO 2.4.3 MEMORY BUG. DETAILS @ https://github.com/iiab/iiab/issues/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 - # UNCOMMENT THE FOLLOWING 3 LINES IF ANSIBLE'S LATEST RELEASES IMPROVE - #echo "Using apt to check for updates, then install/upgrade ansible" - #apt update - #apt -y install ansible + #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 fi # needed? diff --git a/scripts/ansible-2.4.x b/scripts/ansible-2.4.x new file mode 100755 index 000000000..a74c84811 --- /dev/null +++ b/scripts/ansible-2.4.x @@ -0,0 +1,105 @@ +#!/bin/bash -e + +echo -e '\nATTEMPTING TO INSTALL THE LATEST ANSIBLE 2.4.x' +echo -e 'Ensure you'"'"'re online before running this script!' +echo -e 'OR: consider scripts/ansible to keep up-to-date with Ansible'"'"'s evolution.\n' + +GOOD_VER="2.4.4" # Ansible version for OLPC XO laptops (pip install). + # On other OS's we attempt to install/upgrade/pin to the latest Ansible 2.4.x + # WARNING: IIAB 6.6 will likely recommend the very latest Ansible 2.5.x or higher. +CURR_VER="undefined" +# FOUND="false" # NOT USED AS OF 2017-12-12 +# FAMILY="undefined" # NOT USED AS OF 2017-12-12 +# below are unused for future use +# URL="NA" + +export DEBIAN_FRONTEND=noninteractive + +if [ ! `command -v ansible-playbook` ]; then # "command -v" is POSIX compliant; also catches built-in commands like "cd" + echo "Installing --- Please Wait" + if [ -f /etc/centos-release ]; then + yum -y install ca-certificates nss epel-release + yum -y install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + yum -y install python-pip python-setuptools python-wheel patch + yum -y install http://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/ansible-2.4.4.0-1.el7.ans.noarch.rpm + # FOUND="true" + # FAMILY="redhat" +# elif [ -f /etc/fedora-release ]; then +# CURR_VER=`grep VERSION_ID /etc/*elease | cut -d= -f2` +# URL=https://github.com/jvonau/iiab/blob/ansible/vars/fedora-$CURR_VER.yml +# dnf -y install ansible git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python +# dnf -y install python-pip python-setuptools python-wheel patch +# FOUND="true" +# FAMILY="redhat" + elif [ -f /etc/olpc-release ]; then + yum -y install ca-certificates nss + yum -y install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + yum -y install python-pip python-setuptools python-wheel patch + pip install --upgrade pip setuptools wheel #EOL just do it + pip install ansible==$GOOD_VER --disable-pip-version-check + # FOUND="true" + # FAMILY="olpc" + elif [ -f /etc/debian_version ] || (grep -qi raspbian /etc/*elease) ; then + if ( ! grep -qi ansible /etc/apt/sources.list) && [ ! -f /etc/apt/sources.list.d/ansible ]; then + apt -y install dirmngr python-pip python-setuptools python-wheel patch + #echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" \ + # >> /etc/apt/sources.list.d/iiab-ansible.list + echo "deb http://ppa.launchpad.net/ansible/ansible-2.4/ubuntu xenial main" \ + >> /etc/apt/sources.list.d/iiab-ansible.list + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 + fi + # FOUND="true" + # FAMILY="debian" + # Parens are optional, but greatly clarify :) + elif (grep -qi ubuntu /etc/lsb-release) || (grep -qi ubuntu /etc/os-release); then + apt -y install python-pip python-setuptools python-wheel patch + #apt-add-repository -y ppa:ansible/ansible + apt-add-repository -y ppa:ansible/ansible-2.4 + # FOUND="true" + # FAMILY="debian" + # fi + # if [ ! $FOUND = "true" ]; then + else + echo "WARN: Could not detect distro or distro unsupported" + exit 1 + fi +else + #CURR_VER=`ansible --version | head -n 1 | cut -f 2 -d " "` + CURR_VER=`ansible --version | head -1 | awk '{print $2}'` # to match iiab-install + echo "Current ansible version installed is $CURR_VER" + if [ -f /etc/centos-release ] || [ -f /etc/fedora-release ]; then + echo "Please use your system's package manager to update ansible" + exit 0 + elif [ -f /etc/olpc-release ]; then + echo "Please use pip package manager to update ansible" + exit 0 + #fi + #if [[ `grep -qi ansible /etc/apt/sources.list` ]] || [ -f /etc/apt/sources.list.d/ansible*.list ]; then + elif (grep -qi ansible /etc/apt/sources.list) || (ls /etc/apt/sources.list.d/*ansible*.list >/dev/null 2>&1) ; then + #echo "Ansible repo(s) found within /etc/apt/sources.list*" + echo -e '\nANSIBLE REPO(S) FOUND WITHIN /etc/apt/sources.list AND/OR /etc/apt/sources.list.d/*ansible*.list -- MUST CONTAIN LINE "deb http://ppa.launchpad.net/ansible/ansible-2.4/ubuntu xenial main" IF YOU WANT THE LATEST ANSIBLE 2.4.x -- AND REMOVE ALL SIMILAR LINES -- then re-run this script.\n' + else + echo "Upstream ansible source repo not found, please uninstall ansible and re-run this script" + exit 1 + fi +fi + +if [ ! -f /etc/centos-release ] && [ ! -f /etc/fedora-release ] && [ ! -f /etc/olpc-release ]; then + # Align IIAB with Ansible community's latest official release + echo "Using apt to check for updates, then install/upgrade ansible" + apt update + apt -y --allow-downgrades install ansible=2.4* + + # TEMPORARILY USE ANSIBLE 2.4.4 (REMOVE IT WITH "pip uninstall ansible") + #pip install ansible==2.4.4 + + # TEMPORARILY USE ANSIBLE 2.4.2 DUE TO 2.4.3 MEMORY BUG. DETAILS @ https://github.com/iiab/iiab/issues/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 +fi + +# needed? +mkdir -p /etc/ansible/ +echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts diff --git a/scripts/ansible-2.5.x b/scripts/ansible-2.5.x new file mode 100755 index 000000000..23c85f097 --- /dev/null +++ b/scripts/ansible-2.5.x @@ -0,0 +1,104 @@ +#!/bin/bash -e + +echo -e '\nATTEMPTING TO INSTALL THE LATEST ANSIBLE 2.5.x' +echo -e 'Ensure you'"'"'re online before running this script!' +echo -e 'OR: consider scripts/ansible to keep up-to-date with Ansible'"'"'s evolution.\n' + +GOOD_VER="2.5.0" # Ansible version for OLPC XO laptops (pip install). + # On other OS's we attempt to install/upgrade/pin to the latest Ansible 2.5.x +CURR_VER="undefined" +# FOUND="false" # NOT USED AS OF 2017-12-12 +# FAMILY="undefined" # NOT USED AS OF 2017-12-12 +# below are unused for future use +# URL="NA" + +export DEBIAN_FRONTEND=noninteractive + +if [ ! `command -v ansible-playbook` ]; then # "command -v" is POSIX compliant; also catches built-in commands like "cd" + echo "Installing --- Please Wait" + if [ -f /etc/centos-release ]; then + yum -y install ca-certificates nss epel-release + yum -y install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + yum -y install python-pip python-setuptools python-wheel patch + yum -y install http://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/ansible-2.5.0-1.el7.ans.noarch.rpm + # FOUND="true" + # FAMILY="redhat" +# elif [ -f /etc/fedora-release ]; then +# CURR_VER=`grep VERSION_ID /etc/*elease | cut -d= -f2` +# URL=https://github.com/jvonau/iiab/blob/ansible/vars/fedora-$CURR_VER.yml +# dnf -y install ansible git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python +# dnf -y install python-pip python-setuptools python-wheel patch +# FOUND="true" +# FAMILY="redhat" + elif [ -f /etc/olpc-release ]; then + yum -y install ca-certificates nss + yum -y install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + yum -y install python-pip python-setuptools python-wheel patch + pip install --upgrade pip setuptools wheel #EOL just do it + pip install ansible==$GOOD_VER --disable-pip-version-check + # FOUND="true" + # FAMILY="olpc" + elif [ -f /etc/debian_version ] || (grep -qi raspbian /etc/*elease) ; then + if ( ! grep -qi ansible /etc/apt/sources.list) && [ ! -f /etc/apt/sources.list.d/ansible ]; then + apt -y install dirmngr python-pip python-setuptools python-wheel patch + #echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" \ + # >> /etc/apt/sources.list.d/iiab-ansible.list + echo "deb http://ppa.launchpad.net/ansible/ansible-2.5/ubuntu xenial main" \ + >> /etc/apt/sources.list.d/iiab-ansible.list + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 + fi + # FOUND="true" + # FAMILY="debian" + # Parens are optional, but greatly clarify :) + elif (grep -qi ubuntu /etc/lsb-release) || (grep -qi ubuntu /etc/os-release); then + apt -y install python-pip python-setuptools python-wheel patch + #apt-add-repository -y ppa:ansible/ansible + apt-add-repository -y ppa:ansible/ansible-2.5 + # FOUND="true" + # FAMILY="debian" + # fi + # if [ ! $FOUND = "true" ]; then + else + echo "WARN: Could not detect distro or distro unsupported" + exit 1 + fi +else + #CURR_VER=`ansible --version | head -n 1 | cut -f 2 -d " "` + CURR_VER=`ansible --version | head -1 | awk '{print $2}'` # to match iiab-install + echo "Current ansible version installed is $CURR_VER" + if [ -f /etc/centos-release ] || [ -f /etc/fedora-release ]; then + echo "Please use your system's package manager to update ansible" + exit 0 + elif [ -f /etc/olpc-release ]; then + echo "Please use pip package manager to update ansible" + exit 0 + #fi + #if [[ `grep -qi ansible /etc/apt/sources.list` ]] || [ -f /etc/apt/sources.list.d/ansible*.list ]; then + elif (grep -qi ansible /etc/apt/sources.list) || (ls /etc/apt/sources.list.d/*ansible*.list >/dev/null 2>&1) ; then + #echo "Ansible repo(s) found within /etc/apt/sources.list*" + echo -e '\nANSIBLE REPO(S) FOUND WITHIN /etc/apt/sources.list AND/OR /etc/apt/sources.list.d/*ansible*.list -- MUST CONTAIN LINE "deb http://ppa.launchpad.net/ansible/ansible-2.5/ubuntu xenial main" IF YOU WANT THE LATEST ANSIBLE 2.5.x -- AND REMOVE ALL SIMILAR LINES -- then re-run this script.\n' + else + echo "Upstream ansible source repo not found, please uninstall ansible and re-run this script" + exit 1 + fi +fi + +if [ ! -f /etc/centos-release ] && [ ! -f /etc/fedora-release ] && [ ! -f /etc/olpc-release ]; then + # Align IIAB with Ansible community's latest official release + echo "Using apt to check for updates, then install/upgrade ansible" + apt update + apt -y --allow-downgrades install ansible=2.5* + + # TEMPORARILY USE ANSIBLE 2.4.4 (REMOVE IT WITH "pip uninstall ansible") + #pip install ansible==2.4.4 + + # TEMPORARILY USE ANSIBLE 2.4.2 DUE TO 2.4.3 MEMORY BUG. DETAILS @ https://github.com/iiab/iiab/issues/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 +fi + +# needed? +mkdir -p /etc/ansible/ +echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts diff --git a/vars/default_vars.yml b/vars/default_vars.yml index 21e3d5652..669f61965 100644 --- a/vars/default_vars.yml +++ b/vars/default_vars.yml @@ -206,6 +206,7 @@ samba_enabled: False # usb-lib usb_lib_install: True usb_lib_enabled: True +iiab_usb_lib_show_all: False # Toggle iiab-refresh-wiki-docs scraping for offline docs (http://box/info) nodocs: False