1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-14 20:22:08 +00:00

Merge pull request #379 from iiab/master

sync from iiab:master
This commit is contained in:
A Holt 2020-02-25 19:24:29 -06:00 committed by GitHub
commit cc77aead19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 226 additions and 130 deletions

View file

@ -6,18 +6,13 @@
# https://github.com/iiab/iiab/tree/master/roles/calibre-web/templates/calibre-web.conf.j2
# (anyway this works great for calibre-web, allowing http://box/books
# to work even better than http://box:8083 when box == 192.168.0.x !)
- name: Create symlink calibre.conf from sites-enabled to sites-available, for UNTESTED http://box/calibre etc (debuntu)
file:
src: /etc/apache2/sites-available/calibre.conf
dest: /etc/apache2/sites-enabled/calibre.conf
state: link
when: calibre_enabled and is_debuntu
- name: Attempt to enable http://box/calibre via Apache (UNTESTED)
command: a2ensite calibre.conf
when: apache_installed and calibre_enabled
- name: Remove symlink /etc/apache2/sites-enabled/calibre.conf (debuntu)
file:
dest: /etc/apache2/sites-enabled/calibre.conf
state: absent
when: (not calibre_enabled) and is_debuntu
- name: Attempt to disable http://box/calibre via Apache (UNTESTED)
command: a2dissite calibre.conf
when: apache_installed and not calibre_enabled
- name: Enable & Start service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal)
service:

View file

@ -0,0 +1,26 @@
# kalite_install: True
# kalite_enabled: True
# kalite_server_port: 8008
# kalite_root: "{{ content_base }}/ka-lite" # /library/ka-lite
# Unused in 2018; but remain as placeholders for Fedora 18 legacy (XO laptops)
# kalite_cron_enabled: False
# kalite_user: kalite
# Obtain a password hash with - python -c 'import crypt; print crypt.crypt("<plaintext>", "$6$<salt>")'
# kalite_password_hash: $6$<salt>$KHET0XRRsgAY.wOWyTOI3W7dyDh0ESOr48uI5vtk2xdzsU7aw0TF4ZkNuM34RmHBGMJ1fTCmOyVobo0LOhBlJ/
# kalite_password: kalite
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
kalite_version: "0.17.5"
kalite_repo_url: "https://github.com/learningequality/ka-lite.git"
kalite_requirements: "https://raw.githubusercontent.com/learningequality/ka-lite/master/requirements.txt"
kalite_venv: "/usr/local/kalite/venv"
kalite_program: "{{ kalite_venv }}/bin/kalite"
kalite_root: "/library/ka-lite"
kalite_admin_user: Admin
kalite_admin_password: changeme

View file

@ -4,23 +4,19 @@
# kalite_server_port: 8008
# kalite_root: "{{ content_base }}/ka-lite" # /library/ka-lite
# Unused in 2018; but remain as placeholders for Fedora 18 legacy (XO laptops)
# kalite_cron_enabled: False
# kalite_user: kalite
# Obtain a password hash with - python -c 'import crypt; print crypt.crypt("<plaintext>", "$6$<salt>")'
# kalite_password_hash: $6$<salt>$KHET0XRRsgAY.wOWyTOI3W7dyDh0ESOr48uI5vtk2xdzsU7aw0TF4ZkNuM34RmHBGMJ1fTCmOyVobo0LOhBlJ/
# kalite_password: kalite
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
kalite_version: "0.17.5"
kalite_repo_url: "https://github.com/learningequality/ka-lite.git"
kalite_requirements: "https://raw.githubusercontent.com/learningequality/ka-lite/master/requirements.txt"
kalite_version: 0.17.5
kalite_repo_url: https://github.com/learningequality/ka-lite.git
kalite_requirements: https://raw.githubusercontent.com/learningequality/ka-lite/master/requirements.txt
kalite_venv: "/usr/local/kalite/venv"
kalite_root: /library/ka-lite
kalite_venv: /usr/local/kalite/venv
kalite_program: "{{ kalite_venv }}/bin/kalite"
kalite_root: "/library/ka-lite"
kalite_admin_user: Admin
kalite_admin_password: changeme
# Set to "" on F18, for templates/kalite-serve.service.j2
job_scheduler_stanza: "--skip-job-scheduler "

View file

@ -0,0 +1,95 @@
# For OS's other than Fedora 18
- name: Download {{ kalite_requirements }} to {{ pip_packages_dir }}/kalite.txt
get_url:
url: "{{ kalite_requirements }}"
dest: "{{ pip_packages_dir }}/kalite.txt" # /opt/iiab/pip-packages/kalite.txt
timeout: "{{ download_timeout }}"
when: internet_available | bool
# 2020-01-19: https://github.com/piwheels/packages/issues/74 says the following is not longer needed...
#- name: Run 'mv /etc/pip.conf /etc/pip.conf.see-iiab-issue-2139' as "TEMPORARY" workaround (2020-01-17) for piwheels.org's setuptools Python 2/3 brokenness on RPi (https://github.com/iiab/iiab/issues/2139)
# command: mv /etc/pip.conf /etc/pip.conf.see-iiab-issue-2139
# ignore_errors: yes
# when: is_rpi | bool
#- name: Install KA Lite non-static + reqs file with pip - (debuntu)
# pip: requirements={{ pip_packages_dir }}/kalite.txt
# virtualenv={{ kalite_venv }}
# virtualenv_site_packages=no
# extra_args="--no-cache-dir"
# extra_args="--disable-pip-version-check"
# when: internet_available and is_debuntu
- name: Install KA Lite static to {{ kalite_venv }}, using pip (debuntu)
pip:
name: ka-lite-static
version: "{{ kalite_version }}"
virtualenv: "{{ kalite_venv }}"
virtualenv_site_packages: no
virtualenv_command: /usr/bin/virtualenv
virtualenv_python: python2.7
extra_args: "--no-cache-dir"
# extra_args="--disable-pip-version-check"
when: internet_available and is_debuntu
#- name: Install KA Lite non-static + reqs file with pip (OS's other than debuntu)
# pip: requirements={{ pip_packages_dir }}/kalite.txt
# virtualenv={{ kalite_venv }}
# virtualenv_site_packages=no
# extra_args="--no-cache-dir"
# extra_args="--disable-pip-version-check"
# when: internet_available and not is_debuntu
- name: Install KA Lite static to {{ kalite_venv }}, using pip (OS's other than debuntu)
pip:
name: ka-lite-static
version: "{{ kalite_version }}"
virtualenv: "{{ kalite_venv }}"
virtualenv_site_packages: no
virtualenv_command: /usr/bin/virtualenv
virtualenv_python: python2.7
# extra_args="--no-cache-dir"
# extra_args="--disable-pip-version-check"
when: internet_available and not is_debuntu
# This effectively does nothing at all on Ubuntu & Raspbian, where libgeos-*
# pkgs are not installed FWIW. But it's included to safeguard us across all
# OS's, in case others OS's like Ubermix later appear. See #1382 for details.
# Removing pkgs libgeos-3.6.2 & libgeos-c1v5 fixed the situation on Ubermix!
- name: Remove libgeos-* pkgs, avoiding KA Lite Django failure on Ubermix
shell: apt -y remove "libgeos-*"
# 2019-10-20: For Fedora 18 legacy (XO laptops) specially
- name: Default is to have cronserve started with KA Lite
set_fact:
job_scheduler_stanza: ""
- name: Add --skip-job-scheduler to start if cronserve not enabled
set_fact:
job_scheduler_stanza: "--skip-job-scheduler "
when: not kalite_cron_enabled
- name: "Install from template: venv wrapper /usr/bin/kalite, systemd unit file kalite-serve.service, Apache's kalite.conf"
template:
backup: no
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: "{{ item.mode }}"
with_items:
- { src: 'kalite.sh.j2', dest: '/usr/bin/kalite', mode: '0755'}
- { src: 'kalite-serve.service.j2', dest: '/etc/systemd/system/kalite-serve.service', mode: '0644'}
- { src: 'kalite.conf', dest: '/etc/{{ apache_conf_dir }}', mode: '0644'}
- name: Fix KA Lite bug in regex parsing ifconfig output, for @m-anish's network names that contain dashes
replace:
path: /usr/local/kalite/venv/local/lib/python2.7/site-packages/kalite/packages/dist/ifcfg/parser.py
regexp: 'a-zA-Z0-9'
replace: 'a-zA-Z0-9\-'
# RECORD KA Lite AS INSTALLED
# TO DO: move the last 2 stanzas from setup.yml so they live right here,
# as any action named "install.yml" should do exactly what it says (install!)

View file

@ -1,4 +1,3 @@
# For OS's other than Fedora 18
- name: Download {{ kalite_requirements }} to {{ pip_packages_dir }}/kalite.txt
get_url:
url: "{{ kalite_requirements }}"
@ -12,45 +11,17 @@
# ignore_errors: yes
# when: is_rpi | bool
#- name: Install KA Lite non-static + reqs file with pip - (debuntu)
# pip: requirements={{ pip_packages_dir }}/kalite.txt
# virtualenv={{ kalite_venv }}
# virtualenv_site_packages=no
# extra_args="--no-cache-dir"
# extra_args="--disable-pip-version-check"
# when: internet_available and is_debuntu
- name: Install KA Lite static to {{ kalite_venv }}, using pip (debuntu)
- name: Use pip to install KA Lite static to {{ kalite_venv }}
pip:
name: ka-lite-static
version: "{{ kalite_version }}"
virtualenv: "{{ kalite_venv }}"
virtualenv: "{{ kalite_venv }}" # /usr/local/kalite/venv
virtualenv_site_packages: no
virtualenv_command: /usr/bin/virtualenv
virtualenv_python: python2.7
extra_args: "--no-cache-dir"
# extra_args="--disable-pip-version-check"
when: internet_available and is_debuntu
#- name: Install KA Lite non-static + reqs file with pip (OS's other than debuntu)
# pip: requirements={{ pip_packages_dir }}/kalite.txt
# virtualenv={{ kalite_venv }}
# virtualenv_site_packages=no
# extra_args="--no-cache-dir"
# extra_args="--disable-pip-version-check"
# when: internet_available and not is_debuntu
- name: Install KA Lite static to {{ kalite_venv }}, using pip (OS's other than debuntu)
pip:
name: ka-lite-static
version: "{{ kalite_version }}"
virtualenv: "{{ kalite_venv }}"
virtualenv_site_packages: no
virtualenv_command: /usr/bin/virtualenv
virtualenv_python: python2.7
# extra_args="--no-cache-dir"
# extra_args="--disable-pip-version-check"
when: internet_available and not is_debuntu
#extra_args="--disable-pip-version-check"
when: internet_available | bool
# This effectively does nothing at all on Ubuntu & Raspbian, where libgeos-*
# pkgs are not installed FWIW. But it's included to safeguard us across all
@ -59,16 +30,6 @@
- name: Remove libgeos-* pkgs, avoiding KA Lite Django failure on Ubermix
shell: apt -y remove "libgeos-*"
# 2019-10-20: For Fedora 18 legacy (XO laptops) specially
- name: Default is to have cronserve started with KA Lite
set_fact:
job_scheduler_stanza: ""
- name: Add --skip-job-scheduler to start if cronserve not enabled
set_fact:
job_scheduler_stanza: "--skip-job-scheduler "
when: not kalite_cron_enabled
- name: "Install from template: venv wrapper /usr/bin/kalite, systemd unit file kalite-serve.service, Apache's kalite.conf"
template:
backup: no
@ -88,8 +49,25 @@
regexp: 'a-zA-Z0-9'
replace: 'a-zA-Z0-9\-'
- name: Create dir {{ kalite_root }}
file:
state: directory
path: "{{ kalite_root }}/httpsrv/static" # /library/ka-lite
# RECORD KA Lite AS INSTALLED
- name: Run 'kalite manage setup ...'
command: "{{ kalite_program }} manage setup --username={{ kalite_admin_user }} --password={{ kalite_admin_password }} --noinput" # Runs /usr/local/kalite/venv/bin/kalite
environment:
KALITE_HOME: "{{ kalite_root }}" # /library/ka-lite
async: 1800
poll: 10
# TO DO: move the last 2 stanzas from setup.yml so they live right here,
# as any action named "install.yml" should do exactly what it says (install!)
- name: "Set 'kalite_installed: True'"
set_fact:
kalite_installed: True
- name: "Add 'kalite_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^kalite_installed'
line: 'kalite_installed: True'

View file

@ -1,38 +1,59 @@
# Assessment logic removed 3/1/2017 TFM
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
# Assume all XOs are F18 and nothing else is
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: Set KA Lite's SQLite filename (Fedora 18)
set_fact:
kalite_db_name: "{{ kalite_root }}/kalite/database/data.sqlite"
when: is_F18 | bool
- name: Assert that "kalite_install is sameas true" (boolean not string etc)
assert:
that: kalite_install is sameas true
fail_msg: "PLEASE SET 'kalite_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Set KA Lite's SQLite filename (OS's other than Fedora 18)
set_fact:
kalite_db_name: "{{ kalite_root }}/database/data.sqlite"
when: not is_F18
- name: Assert that "kalite_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: kalite_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'kalite_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Does KA Lite database {{ kalite_db_name }} exist? # See if KA Lite is already configured
stat:
path: "{{ kalite_db_name }}"
register: test_kalite_installed
- include_tasks: install-f18.yml
when: not test_kalite_installed.stat.exists and is_F18 and kalite_install
- name: Install KA Lite if 'kalite_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: kalite_installed is undefined
- include_tasks: install.yml
when: test_kalite_installed is defined and not test_kalite_installed.stat.exists and not is_F18 and kalite_install
- name: Ask systemd to reread unit files (daemon-reload)
- name: Enable & (Re)Start 'kalite-serve' service, if kalite_enabled
systemd:
daemon_reload: yes
when: not test_kalite_installed.stat.exists
name: kalite-serve
enabled: yes
state: restarted
when: kalite_enabled
- include_tasks: setup-f18.yml
when: not test_kalite_installed.stat.exists and is_F18 and kalite_install
- name: Disable & Stop 'kalite-serve' service, if not kalite_enabled
systemd:
name: kalite-serve
enabled: no
state: stopped
when: not kalite_enabled
- include_tasks: setup.yml
when: not test_kalite_installed.stat.exists and not is_F18 and kalite_install
- include_tasks: enable.yml
when: kalite_install or kalite_installed is defined
- name: Add 'kalite' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: kalite
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: "KA Lite"
- option: description
value: '"KA Lite downloads Khan Academy videos for offline use, with exercises and accounts if students want to track their own progress."'
- option: path
value: "{{ kalite_root }}"
- option: port
value: "{{ kalite_server_port }}"
- option: kalite_enabled
value: "{{ kalite_enabled }}"

View file

@ -40,7 +40,7 @@
# line: " 'datadirectory' => '{{ nextcloud_data_dir }}',"
# 2020-02-16: SHOULD THIS STANZA GO AWAY IN FUTURE, in favor of 'nextcloud_installed is undefined' test below?
- name: Use php to determine if Nextcloud is installed (causes install wizard to fail)
- name: Use php to determine if Nextcloud is installed (which would cause the install wizard to FAIL in the next step)
shell: >
php {{ nextcloud_root_dir }}/occ status |
gawk '/installed:/ { print $3 }'

View file

@ -10,7 +10,7 @@
2. Without PHP available via FastCGI, any function at all for PHP-based applications validates NGINX.
3. Current state of IIAB App/Service migrations as of 2020-02-17:
3. Current state of IIAB App/Service migrations as of 2020-02-18:
1. These support "Native" NGINX but ***NOT*** Apache
* Admin Console
@ -41,9 +41,10 @@
4. These each run their own web server or non-web / backend services, e.g. off of their own [unique port(s)](https://github.com/iiab/iiab/wiki/IIAB-Networking#list-of-ports--services) (IIAB home pages link directly to these destinations). In future we'd like mnemonic URL's for all of these: (e.g. http://box/calibre, http://box/archive, http://box/kalite)
* calibre (menu goes directly to port 8080) [*]
* internetarchive (menu goes directly to port 4244, [PR #2120](https://github.com/iiab/iiab/pull/2120)) [*]
* kalite (menu goes directly to ports 8006-8008) [*]
* kalite (menu goes directly to ports 8006-8008)
* minetest [*]
* openvpn
* pbx [*]
* transmission [*]
[*] The 5 above starred roles could use improvement, as of 2020-02-17.
[*] The 5 above starred roles could use improvement, as of 2020-02-18.

View file

@ -109,30 +109,25 @@
template:
src: odbc.ini.j2
dest: /etc/odbc.ini
owner: root
group: root
mode: 0644
# owner: root
# group: root
# mode: '0644'
- name: FreePBX - Install Apache's sites-available/freepbx.conf from template
template:
src: freepbx.conf.j2
dest: /etc/apache2/sites-available/freepbx.conf
owner: www-data
group: www-data
mode: 0644
owner: {{ apache_user }}
group: {{ apache_user }}
mode: '0644'
- name: FreePBX - Create symlink freepbx.conf from sites-enabled to sites-available (if pbx_enabled)
file:
src: /etc/apache2/sites-available/freepbx.conf
dest: /etc/apache2/sites-enabled/freepbx.conf
state: link
when: pbx_enabled | bool
- name: FreePBX - Enable http://box:{{ pbx_http_port }} via Apache, if pbx_enabled # http://box:83
command: a2ensite freepbx.conf
when: apache_installed and pbx_enabled
- name: FreePBX - Remove symlink /etc/apache2/sites-enabled/freepbx.conf (if not pbx_enabled)
file:
path: /etc/apache2/sites-enabled/freepbx.conf
state: absent
when: not pbx_enabled
- name: FreePBX - Disable http://box:{{ pbx_http_port }} via Apache, if not pbx_enabled # http://box:83
command: a2dissite freepbx.conf
when: apache_installed and not pbx_enabled
- name: FreePBX - Add {{ pbx_http_port }} as a Listen directive to apache ports.conf
lineinfile:
@ -149,4 +144,4 @@
template:
src: freepbx.service.j2
dest: /etc/systemd/system/freepbx.service
mode: 755
# mode: '0755' # Let's go with '0644' per unit file norms

View file

@ -37,7 +37,7 @@
depth: 1
when: internet_available | bool
- name: Create symlink /opt/iiab/sugarizer -> /opt/iiab/{{ sugarizer_dir_version }}
- name: Symlink /opt/iiab/sugarizer -> /opt/iiab/{{ sugarizer_dir_version }}
file:
src: "{{ iiab_base }}/{{ sugarizer_dir_version }}"
dest: "{{ iiab_base }}/sugarizer"
@ -70,7 +70,7 @@
depth: 1
when: internet_available | bool
- name: Create symlink /opt/iiab/sugarizer-server -> /opt/iiab/{{ sugarizer_server_dir_version }}
- name: Symlink /opt/iiab/sugarizer-server -> /opt/iiab/{{ sugarizer_server_dir_version }}
file:
src: "{{ iiab_base }}/{{ sugarizer_server_dir_version }}"
dest: "{{ iiab_base }}/sugarizer-server"

View file

@ -436,11 +436,6 @@ kalite_install: True
kalite_enabled: True
kalite_server_port: 8008
kalite_root: "{{ content_base }}/ka-lite" # /library/ka-lite
# Unused in 2018; but remain as placeholders for Fedora 18 legacy (XO laptops)
kalite_cron_enabled: False
kalite_user: kalite
kalite_password_hash: $6$<salt>$KHET0XRRsgAY.wOWyTOI3W7dyDh0ESOr48uI5vtk2xdzsU7aw0TF4ZkNuM34RmHBGMJ1fTCmOyVobo0LOhBlJ/
kalite_password: kalite
kolibri_install: False
kolibri_enabled: False

View file

@ -267,8 +267,6 @@ wordpress_enabled: True
# KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS
kalite_install: True
kalite_enabled: True
# Unused in 2018; but remains as placeholder for Fedora 18 legacy (XO laptops)
kalite_cron_enabled: True
kolibri_install: True
kolibri_enabled: True

View file

@ -267,8 +267,6 @@ wordpress_enabled: True
# KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS
kalite_install: True
kalite_enabled: True
# Unused in 2018; but remains as placeholder for Fedora 18 legacy (XO laptops)
kalite_cron_enabled: True
kolibri_install: False
kolibri_enabled: False

View file

@ -267,8 +267,6 @@ wordpress_enabled: False
# KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS
kalite_install: True
kalite_enabled: True
# Unused in 2018; but remains as placeholder for Fedora 18 legacy (XO laptops)
kalite_cron_enabled: True
kolibri_install: False
kolibri_enabled: False