From 9204c4caf52877f83cd91ab75a8fad6a13cf950f Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Nov 2017 09:58:13 -0600 Subject: [PATCH 01/17] single interface - strings need to be quoted, add stdout_lines --- roles/network/tasks/detected_network.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/network/tasks/detected_network.yml b/roles/network/tasks/detected_network.yml index ff876f314..a918c6e02 100644 --- a/roles/network/tasks/detected_network.yml +++ b/roles/network/tasks/detected_network.yml @@ -98,7 +98,7 @@ # LAN - pick non WAN's - name: Create list of LAN (non WAN) ifaces shell: ls /sys/class/net | grep -v -e wwlan -e ppp -e lo -e br0 -e tun -e {{ device_gw }} -e {{ ap_device }} - when: num_lan_interfaces != 0 + when: num_lan_interfaces != "0" register: lan_list_result # If 2 interfaces found in gateway mode, with one wifi, declare other to be wan @@ -114,7 +114,7 @@ - name: Set discovered_wired_iface fact if present set_fact: discovered_wired_iface: "{{ item|trim }}" - when: item|trim != discovered_wireless_iface and lan_list_result is defined + when: lan_list_result.stdout_lines is defined and item|trim != discovered_wireless_iface with_items: - "{{ lan_list_result.stdout_lines }}" From 6b276e53ccacd963925d2d964f2baeaf3d0a63a3 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Nov 2017 10:14:35 -0600 Subject: [PATCH 02/17] don't force ifupdown to be installed --- roles/2-common/tasks/packages.yml | 1 - vars/ubuntu-17.yml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/2-common/tasks/packages.yml b/roles/2-common/tasks/packages.yml index 1fa5fdf49..4634d3c5c 100644 --- a/roles/2-common/tasks/packages.yml +++ b/roles/2-common/tasks/packages.yml @@ -32,7 +32,6 @@ - libnss-mdns - avahi-daemon - avahi-discover - - ifupdown - exfat-fuse - exfat-utils when: is_debuntu diff --git a/vars/ubuntu-17.yml b/vars/ubuntu-17.yml index 41fd02c1d..a28110715 100644 --- a/vars/ubuntu-17.yml +++ b/vars/ubuntu-17.yml @@ -1,5 +1,6 @@ is_debuntu: True is_ubuntu: True +has_NM: True dns_service: bind9 dns_user: bind dhcp_service: isc-dhcp-server From 47328e6ab503f0c90d1aefce6e721bdba6baed68 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Nov 2017 10:21:18 -0600 Subject: [PATCH 03/17] don't use /etc/network/interfaces.d/iiab --- roles/network/defaults/main.yml | 1 + roles/network/tasks/debian.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index ea1de51a8..59d7d238d 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -4,6 +4,7 @@ wireless_lan_present: False strict_networking: False iiab_demo_mode: False gui_static_wan: False +has_NM: False # Set defaults for discovery process as strings wifi1: "not found-1" diff --git a/roles/network/tasks/debian.yml b/roles/network/tasks/debian.yml index bb5650de4..77b3d2849 100644 --- a/roles/network/tasks/debian.yml +++ b/roles/network/tasks/debian.yml @@ -37,7 +37,7 @@ - name: Copy the bridge script template: dest=/etc/network/interfaces.d/iiab src=network/systemd.j2 - when: not is_rpi and (iiab_lan_iface == "br0" or wan_ip != "dhcp") + when: not is_rpi and not has_NM and (iiab_lan_iface == "br0" or wan_ip != "dhcp") - name: Copy the bridge script for RPi template: dest=/etc/network/interfaces.d/iiab From 3510641b4127e8db6f09f9476fc82234dcab37cb Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Nov 2017 10:34:42 -0600 Subject: [PATCH 04/17] has_NM use /etc/network/interfaces, need to toggle "manged" in NetworkManager.conf Alternative keyfile option is possible just like the XO days. http://manpages.ubuntu.com/manpages/zesty/man5/NetworkManager.conf.5.html --- roles/network/tasks/debian.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/roles/network/tasks/debian.yml b/roles/network/tasks/debian.yml index 77b3d2849..89144ab98 100644 --- a/roles/network/tasks/debian.yml +++ b/roles/network/tasks/debian.yml @@ -67,8 +67,14 @@ - name: Restart the networking service service: name=networking state=restarted - when: not nobridge is defined and not no_net_restart + when: not nobridge is defined and not has_NM and not no_net_restart +# NM might have a watcher on this path and we don't have to restart NM +- name: Copy the bridge script for has_NM + template: dest=/etc/network/interfaces + src=network/systemd.j2 + when: has_NM and iiab_lan_iface == "br0" + - name: Restart hostapd when WiFi is present service: name=hostapd state=restarted when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" From dce759473c1ff6f85f44f0e844030f0b35fe814e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Nov 2017 12:21:31 -0600 Subject: [PATCH 05/17] ubuntu-18 --- scripts/local_facts.fact | 1 + vars/ubuntu-18.yml | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 vars/ubuntu-18.yml diff --git a/scripts/local_facts.fact b/scripts/local_facts.fact index 1735a2b60..5ae59c5a8 100755 --- a/scripts/local_facts.fact +++ b/scripts/local_facts.fact @@ -14,6 +14,7 @@ case $OS_VER in "debian-9" | \ "ubuntu-16" | \ "ubuntu-17" | \ +"ubuntu-18" | \ "centos-7" | \ "raspbian-8"| \ "raspbian-9") diff --git a/vars/ubuntu-18.yml b/vars/ubuntu-18.yml new file mode 100644 index 000000000..a28110715 --- /dev/null +++ b/vars/ubuntu-18.yml @@ -0,0 +1,22 @@ +is_debuntu: True +is_ubuntu: True +has_NM: True +dns_service: bind9 +dns_user: bind +dhcp_service: isc-dhcp-server +proxy: squid +proxy_user: proxy +apache_service: apache2 +apache_user: www-data +apache_config_dir: apache2/sites-available +apache_log_dir: /var/log/apache2 +smb_service: smbd +nmb_service: nmbd +systemctl_program: /bin/systemctl +# issue raised +mysql_service: mysql +apache_log: /var/log/apache2/access.log +sshd_service: ssh +php_version: 7.1 +postgresql_version: 9.6 +systemd_location: /lib/systemd/system From b9d97bce4fc5e0b4f6397424747ff2001f7fddaf Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Nov 2017 13:57:48 -0600 Subject: [PATCH 06/17] provide NetworkManager.conf - and move prior to daemon-reload --- roles/network/tasks/debian.yml | 20 +++++++++++++------ .../templates/network/NetworkManager.conf | 8 ++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 roles/network/templates/network/NetworkManager.conf diff --git a/roles/network/tasks/debian.yml b/roles/network/tasks/debian.yml index 89144ab98..6e676c2f4 100644 --- a/roles/network/tasks/debian.yml +++ b/roles/network/tasks/debian.yml @@ -57,6 +57,20 @@ service: name=dnsmasq state=stopped when: dnsmasq_install +# do this +- name: Copy NetworkManager.conf for has_NM + template: dest=/etc/NetworkManager/NetworkManager.conf + src=network/NetworkManager.conf + when: has_NM and iiab_lan_iface == "br0" + +# NM might have a watcher on this path and we don't have to restart NM +- name: Copy the bridge script for has_NM + template: dest=/etc/network/interfaces + src=network/systemd.j2 + when: has_NM and iiab_lan_iface == "br0" + +# or provide keyfile layout like the XO's used way back. + - name: Reload systemd shell: systemctl daemon-reload @@ -69,12 +83,6 @@ service: name=networking state=restarted when: not nobridge is defined and not has_NM and not no_net_restart -# NM might have a watcher on this path and we don't have to restart NM -- name: Copy the bridge script for has_NM - template: dest=/etc/network/interfaces - src=network/systemd.j2 - when: has_NM and iiab_lan_iface == "br0" - - name: Restart hostapd when WiFi is present service: name=hostapd state=restarted when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" diff --git a/roles/network/templates/network/NetworkManager.conf b/roles/network/templates/network/NetworkManager.conf new file mode 100644 index 000000000..06c5d59a6 --- /dev/null +++ b/roles/network/templates/network/NetworkManager.conf @@ -0,0 +1,8 @@ +[main] +plugins=ifupdown,keyfile + +[ifupdown] +managed=true + +[device] +wifi.scan-rand-mac-address=no From f8d7c1ddadee27960a52895a096575d65721bda8 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Nov 2017 14:01:40 -0600 Subject: [PATCH 07/17] add not wan_in_interfaces check before cobbering /etc/network/interfaces --- roles/network/tasks/debian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/debian.yml b/roles/network/tasks/debian.yml index 6e676c2f4..0e0c409e0 100644 --- a/roles/network/tasks/debian.yml +++ b/roles/network/tasks/debian.yml @@ -67,7 +67,7 @@ - name: Copy the bridge script for has_NM template: dest=/etc/network/interfaces src=network/systemd.j2 - when: has_NM and iiab_lan_iface == "br0" + when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0" # or provide keyfile layout like the XO's used way back. From f73585aea15d43ce615ce66c03519d0540d57f67 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Nov 2017 17:20:46 -0600 Subject: [PATCH 08/17] keyfile layout --- roles/network/tasks/debian.yml | 4 ++++ roles/network/templates/network/bridge-br0 | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 roles/network/templates/network/bridge-br0 diff --git a/roles/network/tasks/debian.yml b/roles/network/tasks/debian.yml index 0e0c409e0..2ec0adcf1 100644 --- a/roles/network/tasks/debian.yml +++ b/roles/network/tasks/debian.yml @@ -70,6 +70,10 @@ when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0" # or provide keyfile layout like the XO's used way back. +#- name: Copy the bridge script for has_NM +# template: dest=/etc/NetworkManager/system-connections/ +# src=network/bridge-br0 +# when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0" - name: Reload systemd shell: systemctl daemon-reload diff --git a/roles/network/templates/network/bridge-br0 b/roles/network/templates/network/bridge-br0 new file mode 100644 index 000000000..ab7f83588 --- /dev/null +++ b/roles/network/templates/network/bridge-br0 @@ -0,0 +1,16 @@ +[connection] +id=bridge-br0 +uuid={{ gen_uuid }} +type=bridge +interface-name=br0 +permissions= + +[ipv4] +address1={{ iiab_lan_ip }}/19 +dns-search={{ iiab_domain }} +method=manual + +[ipv6] +addr-gen-mode=stable-privacy +dns-search= +method=auto From f1f2ffa2758a2dda8d4de7a9a394597e4868b264 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Nov 2017 18:01:04 -0600 Subject: [PATCH 09/17] go with keyfile --- roles/network/tasks/debian.yml | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/roles/network/tasks/debian.yml b/roles/network/tasks/debian.yml index 2ec0adcf1..8eb25081d 100644 --- a/roles/network/tasks/debian.yml +++ b/roles/network/tasks/debian.yml @@ -58,23 +58,33 @@ when: dnsmasq_install # do this -- name: Copy NetworkManager.conf for has_NM - template: dest=/etc/NetworkManager/NetworkManager.conf - src=network/NetworkManager.conf - when: has_NM and iiab_lan_iface == "br0" +#- name: Copy NetworkManager.conf for has_NM +# template: dest=/etc/NetworkManager/NetworkManager.conf +# src=network/NetworkManager.conf +# when: has_NM and iiab_lan_iface == "br0" + +#- name: Copy the bridge script for has_NM +# template: dest=/etc/network/interfaces +# src=network/systemd.j2 +# when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0" + +# or provide keyfile layout like the XO's used way back. +- name: Create uuid for NM + shell: uuidgen + register: uuid_response + when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0" + +- name: Put the uuid in place + set_fact: + gen_uuid: "{{ uuid_response.stdout_lines[0] }}" + when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0" # NM might have a watcher on this path and we don't have to restart NM - name: Copy the bridge script for has_NM - template: dest=/etc/network/interfaces - src=network/systemd.j2 + template: dest=/etc/NetworkManager/system-connections/ + src=network/bridge-br0 when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0" -# or provide keyfile layout like the XO's used way back. -#- name: Copy the bridge script for has_NM -# template: dest=/etc/NetworkManager/system-connections/ -# src=network/bridge-br0 -# when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0" - - name: Reload systemd shell: systemctl daemon-reload From 5533bde2588fd39c3939b66998d32a76aae6fd10 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 25 Nov 2017 10:55:14 -0600 Subject: [PATCH 10/17] better testing of XSCE --- runansible | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runansible b/runansible index ef74c1a06..ab0f7e488 100755 --- a/runansible +++ b/runansible @@ -31,8 +31,8 @@ fi # iiab.env gets created at the end of stage-4 on First Run if [ -f /etc/iiab/iiab.env ] then - OLD=`grep XSCE /etc/iiab/iiab.env` - if [ x"$OLD" != "x" ] + OLD=`grep XSCE /etc/iiab/iiab.env| wc -l` + if [ "$OLD" -gt 0 ] then rm /etc/iiab/iiab.env else From c7f5be12a09e81fb753b4122c865b195ffcfd2d4 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 25 Nov 2017 13:35:08 -0500 Subject: [PATCH 11/17] more readable spacing --- runansible | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runansible b/runansible index ab0f7e488..a559ae4e3 100755 --- a/runansible +++ b/runansible @@ -31,7 +31,7 @@ fi # iiab.env gets created at the end of stage-4 on First Run if [ -f /etc/iiab/iiab.env ] then - OLD=`grep XSCE /etc/iiab/iiab.env| wc -l` + OLD=`grep XSCE /etc/iiab/iiab.env | wc -l` if [ "$OLD" -gt 0 ] then rm /etc/iiab/iiab.env From 0d065ae87331930c97b1e32272edd70b20934697 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 26 Nov 2017 10:06:30 -0500 Subject: [PATCH 12/17] experimental i686 code path --- roles/kiwix/tasks/kiwix_install.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/roles/kiwix/tasks/kiwix_install.yml b/roles/kiwix/tasks/kiwix_install.yml index 3aa9de3ec..06eccbe1c 100644 --- a/roles/kiwix/tasks/kiwix_install.yml +++ b/roles/kiwix/tasks/kiwix_install.yml @@ -42,12 +42,17 @@ force: no when: kiwix_first_pass -# we get a whole web server for intel but only the kiwix execs for arm +# We get a whole web server for i686 but only the kiwix execs for linux64 & armhf -- name: Unarchive it to permanent location - not bin_only +# EXPERIMENTAL i686 CODE PATH: as of Nov 2017 bunzip2 then untar unpacks +# to /tmp/kiwix-0.10-i686/bin WHOSE CONTENTS NEEDS TO BE MOVED TO +# /opt/iiab/kiwix/bin (STANZA FURTHER BELOW). All i686 code needs testing. +# ALSO: code below may need to be revived to chown -R root:root & chmod +- name: Unarchive kiwix-*-linux-i686.tar.bz2 to /tmp (not bin_only, i.e. i686) unarchive: src: "{{ downloads_dir }}/{{ kiwix_src_file }}" - dest: "{{ iiab_base }}" + dest: /tmp + # dest: "{{ iiab_base }}" owner: root group: root when: not kiwix_src_bin_only and kiwix_first_pass @@ -60,6 +65,11 @@ mode: 0755 state: directory +# EXPERIMENTAL i686 CODE PATH +- name: move /tmp/kiwix*i686/bin/* to permanent location /opt/iiab/kiwix/bin (not bin_only, i.e. i686) + shell: "mv /tmp/kiwix*i686/bin/* /opt/iiab/kiwix/bin/" + when: not kiwix_src_bin_only and kiwix_first_pass + - name: Enable the mods which permit Apache to proxy (debuntu) apache2_module: name: "{{ item }}" @@ -70,7 +80,7 @@ - rewrite when: is_debuntu -- name: Unarchive Kiwix to permanent location - bin only +- name: Unarchive Kiwix to permanent location (bin_only, i.e. not i686) unarchive: src: "{{ downloads_dir }}/{{ kiwix_src_file }}" dest: "{{ iiab_base }}/kiwix/bin" @@ -78,7 +88,7 @@ group: root when: kiwix_src_bin_only and kiwix_first_pass -# Already done above! +# MIGHT BE RESTORED LATER FOR i686? Unused as of Nov 2017: # # workaround because unarchive does not set ownership properly # - name: "Set ownership as if: 'chown -R root:root /opt/iiab/kiwix'" # file: @@ -86,6 +96,7 @@ # owner: root # group: root # recurse: yes +# mode: ???? # workaround because kiwix-serve does not stay running - name: Make a crontab entry to restart kiwix-serve at 4AM (debuntu) From afe9e8122d55f1e562ad9800fbc5e4818b44cd60 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 26 Nov 2017 10:06:51 -0500 Subject: [PATCH 13/17] experimental i686 code path --- roles/kiwix/tasks/main.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/roles/kiwix/tasks/main.yml b/roles/kiwix/tasks/main.yml index bef4ca38d..35fcf79b4 100644 --- a/roles/kiwix/tasks/main.yml +++ b/roles/kiwix/tasks/main.yml @@ -1,23 +1,26 @@ -#- name: Set kiwix source file name i686 -# set_fact: -# kiwix_src_file: "kiwix-linux-i686.tar.bz2" -# kiwix_src_bin_only: False -# when: ansible_machine == "i686" - -- name: "Set Kiwix filename to d/l: kiwix-tools_linux64_2017-11-12.tar.gz (x86_64)" +# EXPERIMENTAL i686 CODE PATH +- name: Set kiwix source file name i686 set_fact: - kiwix_src_file: "kiwix-tools_linux64_2017-11-12.tar.gz" + kiwix_src_file: {{ kiwix_src_file_i686 }} + kiwix_src_bin_only: False + when: ansible_machine == "i686" + +- name: "Set Kiwix filename to d/l: {{ kiwix_src_file_linux64 }} (x86_64)" + set_fact: + kiwix_src_file: {{ kiwix_src_file_linux64 }} kiwix_src_bin_only: True when: ansible_machine == "x86_64" -- name: "Set Kiwix filename to d/l: kiwix-tools_armhf_2017-11-12.tar.gz (armv6l or armv71)" +- name: "Set Kiwix filename to d/l: {{ kiwix_src_file_armhf }} (armv6l or armv71)" set_fact: - kiwix_src_file: "kiwix-tools_armhf_2017-11-12.tar.gz" + kiwix_src_file: {{ kiwix_src_file_armhf }} kiwix_src_bin_only: True when: ansible_machine == "armv7l" or ansible_machine == "armv6l" - name: Download the Kiwix software to /opt/iiab/downloads - get_url: url="{{ iiab_download_url }}/{{ kiwix_src_file }}" dest="{{ downloads_dir }}/{{ kiwix_src_file }}" + get_url: + url: "{{ iiab_download_url }}/{{ kiwix_src_file }}" + dest: "{{ downloads_dir }}/{{ kiwix_src_file }}" when: internet_available - include_tasks: kiwix_install.yml @@ -25,5 +28,6 @@ tags: - kiwix -- debug: msg="WARNING kiwix source is not defined for your platform" +- debug: + msg: "WARNING kiwix source is not defined for your platform" when: not kiwix_src_file From 56d5ec9e6d14d171270420707e81e6bffaf23128 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 26 Nov 2017 10:09:17 -0500 Subject: [PATCH 14/17] Update main.yml --- roles/kiwix/tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/kiwix/tasks/main.yml b/roles/kiwix/tasks/main.yml index 35fcf79b4..c92ab9d10 100644 --- a/roles/kiwix/tasks/main.yml +++ b/roles/kiwix/tasks/main.yml @@ -1,19 +1,19 @@ # EXPERIMENTAL i686 CODE PATH - name: Set kiwix source file name i686 set_fact: - kiwix_src_file: {{ kiwix_src_file_i686 }} + kiwix_src_file: "{{ kiwix_src_file_i686 }}" kiwix_src_bin_only: False when: ansible_machine == "i686" - name: "Set Kiwix filename to d/l: {{ kiwix_src_file_linux64 }} (x86_64)" set_fact: - kiwix_src_file: {{ kiwix_src_file_linux64 }} + kiwix_src_file: "{{ kiwix_src_file_linux64 }}" kiwix_src_bin_only: True when: ansible_machine == "x86_64" - name: "Set Kiwix filename to d/l: {{ kiwix_src_file_armhf }} (armv6l or armv71)" set_fact: - kiwix_src_file: {{ kiwix_src_file_armhf }} + kiwix_src_file: "{{ kiwix_src_file_armhf }}" kiwix_src_bin_only: True when: ansible_machine == "armv7l" or ansible_machine == "armv6l" From 3bd665917862b5079c9333dae05e347c3247720b Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 26 Nov 2017 10:20:33 -0500 Subject: [PATCH 15/17] Ansible output clarified --- roles/kiwix/tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/kiwix/tasks/main.yml b/roles/kiwix/tasks/main.yml index c92ab9d10..b0f745adf 100644 --- a/roles/kiwix/tasks/main.yml +++ b/roles/kiwix/tasks/main.yml @@ -1,5 +1,5 @@ # EXPERIMENTAL i686 CODE PATH -- name: Set kiwix source file name i686 +- name: "Set Kiwix filename to d/l: {{ kiwix_src_file_i686 }} (i686)" set_fact: kiwix_src_file: "{{ kiwix_src_file_i686 }}" kiwix_src_bin_only: False @@ -17,7 +17,7 @@ kiwix_src_bin_only: True when: ansible_machine == "armv7l" or ansible_machine == "armv6l" -- name: Download the Kiwix software to /opt/iiab/downloads +- name: Download Kiwix software to /opt/iiab/downloads get_url: url: "{{ iiab_download_url }}/{{ kiwix_src_file }}" dest: "{{ downloads_dir }}/{{ kiwix_src_file }}" @@ -29,5 +29,5 @@ - kiwix - debug: - msg: "WARNING kiwix source is not defined for your platform" + msg: "WARNING: kiwix-tools SOFTWARE NOT FOUND FOR YOUR OS/ARCHITECTURE." when: not kiwix_src_file From c14d62beb4be751b1b3154a65775a3c70a832c59 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 26 Nov 2017 10:38:48 -0500 Subject: [PATCH 16/17] guarantee library.xml exists; re-order for readability --- roles/kiwix/tasks/kiwix_install.yml | 75 +++++++++++++++-------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/roles/kiwix/tasks/kiwix_install.yml b/roles/kiwix/tasks/kiwix_install.yml index 06eccbe1c..a3a078860 100644 --- a/roles/kiwix/tasks/kiwix_install.yml +++ b/roles/kiwix/tasks/kiwix_install.yml @@ -10,17 +10,12 @@ - "{{ kiwix_content_path }}" - "{{ iiab_zim_path }}/index" -- name: Check for 'kiwix-serve' binary +- name: Check for /library/zims/library.xml stat: - path: "{{ iiab_base }}/kiwix/bin/kiwix-serve" - register: kiwix_bin + path: "{{ kiwix_library_xml }}" + register: kiwix_xml -- name: Set kiwix_first_pass - set_fact: - kiwix_first_pass: True - when: kiwix_bin.stat.exists is defined and not kiwix_bin.stat.exists - -- name: Copy Kiwix library file if needed +- name: Place a stub /library/zims/library.xml if file does not exist template: src: "{{ item }}" dest: "{{ kiwix_library_xml }}" @@ -30,7 +25,17 @@ force: no with_items: - library.xml - when: kiwix_first_pass + when: not kiwix_xml.stat.exists + +- name: Check for /opt/iiab/kiwix/bin/kiwix-serve binary + stat: + path: "{{ iiab_base }}/kiwix/bin/kiwix-serve" + register: kiwix_bin + +- name: Set kiwix_first_pass if kiwix-serve not found + set_fact: + kiwix_first_pass: True + when: kiwix_bin.stat.exists is defined and not kiwix_bin.stat.exists - name: Copy test.zim file copy: @@ -70,16 +75,6 @@ shell: "mv /tmp/kiwix*i686/bin/* /opt/iiab/kiwix/bin/" when: not kiwix_src_bin_only and kiwix_first_pass -- name: Enable the mods which permit Apache to proxy (debuntu) - apache2_module: - name: "{{ item }}" - with_items: - - proxy - - proxy_html - - proxy_http - - rewrite - when: is_debuntu - - name: Unarchive Kiwix to permanent location (bin_only, i.e. not i686) unarchive: src: "{{ downloads_dir }}/{{ kiwix_src_file }}" @@ -98,6 +93,16 @@ # recurse: yes # mode: ???? +- name: Enable the mods which permit Apache to proxy (debuntu) + apache2_module: + name: "{{ item }}" + with_items: + - proxy + - proxy_html + - proxy_http + - rewrite + when: is_debuntu + # workaround because kiwix-serve does not stay running - name: Make a crontab entry to restart kiwix-serve at 4AM (debuntu) # * * * * * user-name command to be executed @@ -130,7 +135,21 @@ - { src: 'iiab-make-kiwix-lib.py', dest: '/usr/bin/iiab-make-kiwix-lib.py', mode: '0755'} - { src: 'iiab-make-apache-config.py', dest: '/usr/bin/iiab-make-apache-config.py', mode: '0755'} -- name: Add 'kiwix-serve' to list of services +- name: Enable 'kiwix-serve' service + service: + name: kiwix-serve + enabled: yes + state: restarted + when: kiwix_enabled + +- name: Disable 'kiwix-serve' service + service: + name: kiwix-serve + enabled: no + state: stopped + when: not kiwix_enabled + +- name: Add 'kiwix-serve' to list of services at /opt/iiab/iiab.ini ini_file: dest: "{{ service_filelist }}" section: kiwix-serve @@ -156,17 +175,3 @@ value: "{{ kiwix_content_path }}" - option: enabled value: "{{ kiwix_enabled }}" - -- name: Enable 'kiwix-serve' service - service: - name: kiwix-serve - enabled: yes - state: restarted - when: kiwix_enabled - -- name: Disable 'kiwix-serve' service - service: - name: kiwix-serve - enabled: no - state: stopped - when: not kiwix_enabled From 6f73ebc64f6d521103c6a13bf08fd7829507e949 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 26 Nov 2017 10:54:17 -0500 Subject: [PATCH 17/17] parametrize Kiwix download defaults Due to accidental kiwix/tasks/main.yml & kiwix/tasks/kiwix_install.yml Ongoing work will be in separate branch/PR as was the intention. I goofed in editing master. Apologies. --- roles/kiwix/defaults/main.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/roles/kiwix/defaults/main.yml b/roles/kiwix/defaults/main.yml index a7b50dec1..4f0d4597b 100644 --- a/roles/kiwix/defaults/main.yml +++ b/roles/kiwix/defaults/main.yml @@ -1,11 +1,24 @@ -# The following 2 lines don't work as of Nov 2017: +# Which kiwix-tools to download from http://download.iiab.io/packages/ (origin: http://download.kiwix.org/nightly/) +kiwix_src_file_linux64: "kiwix-tools_linux64_2017-11-12.tar.gz" +kiwix_src_file_armhf: "kiwix-tools_armhf_2017-11-12.tar.gz" +# Experimental kiwix-0.10 from Oct 2016: (to be replaced before Feb 2018, SEE https://github.com/kiwix/kiwix-build/issues/94) +kiwix_src_file_i686: "kiwix-0.10-linux-i686.tar.bz2" +# Appears to be kiwix-0.9 from May 2014: +# kiwix_src_file_i686: "kiwix-linux-i686.tar.bz2" + +# The following 2 lines are unused as of Nov 2017: # kiwix_url: /kiwix # kiwix_path: "{{ iiab_base }}/kiwix" kiwix_port: 3000 + +# /library/zims contains 3 important things: {library.xml, content, index} iiab_zim_path: "{{ content_base }}/zims" kiwix_library_xml: "{{ iiab_zim_path }}/library.xml" kiwix_content_path: "{{ iiab_zim_path }}/content" + +# Installation variables kiwix_install: True kiwix_enabled: True -kiwix_content_found: False +# The following line is unused as of Nov 2017: +# kiwix_content_found: False kiwix_first_pass: False