mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Cleaner Lokole, with libopenjp2-7 for #2221
This commit is contained in:
parent
e68cb53eb8
commit
cbae3ac33c
6 changed files with 143 additions and 113 deletions
|
@ -5,9 +5,12 @@
|
||||||
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
|
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
|
||||||
|
|
||||||
# Info needed to install Lokole
|
# Info needed to install Lokole
|
||||||
lokole_version: 0.5.10
|
#lokole_commit: # OPTIONAL: a 40-char git hash, from https://github.com/ascoderu/opwen-webapp/commits/master
|
||||||
lokole_admin_user: admin # lowercase seems nec here (even though uppercase Admin/changeme is IIAB's OOB recommendation!)
|
#lokole_version: # OPTIONAL: e.g. master or 0.5.10 or a version number from https://pypi.org/project/opwen-email-client/#history
|
||||||
|
|
||||||
|
lokole_admin_user: admin # lowercase is nec here (even though uppercase Admin/changeme is IIAB's OOB recommendation: BOTH WORK to log in to http://box/lokole)
|
||||||
lokole_admin_password: changeme
|
lokole_admin_password: changeme
|
||||||
|
|
||||||
lokole_install_path: "{{ content_base }}/lokole" # /library/lokole
|
lokole_install_path: "{{ content_base }}/lokole" # /library/lokole
|
||||||
lokole_venv: "{{ lokole_install_path }}/venv" # /library/lokole/venv
|
lokole_venv: "{{ lokole_install_path }}/venv" # /library/lokole/venv
|
||||||
|
|
||||||
|
@ -20,8 +23,10 @@ lokole_full_url: "http://{{ iiab_hostname }}.{{ iiab_domain }}{{ lokole_url }}"
|
||||||
|
|
||||||
lokole_domain_socket: "{{ lokole_run_directory }}/lokole_gunicorn.sock"
|
lokole_domain_socket: "{{ lokole_run_directory }}/lokole_gunicorn.sock"
|
||||||
|
|
||||||
# Global variables provided by setup-lokole.sh:
|
# 2020-02-01: NO LONGER USED, or even meaningful. Delete soon?
|
||||||
# https://github.com/ascoderu/opwen-webapp/blob/master/setup/setup-lokole.sh#L140-L141
|
#
|
||||||
# https://github.com/ascoderu/opwen-webapp/blob/master/setup/setup-lokole.sh#L182-L192
|
## Global variables provided by setup-lokole.sh:
|
||||||
opwen_server_locale: "{{ default_language }}"
|
## https://github.com/ascoderu/opwen-webapp/blob/master/setup/setup-lokole.sh#L140-L141
|
||||||
opwen_server_timezone: "{{ local_tz }}"
|
## https://github.com/ascoderu/opwen-webapp/blob/master/setup/setup-lokole.sh#L182-L192
|
||||||
|
#opwen_server_locale: "{{ default_language }}"
|
||||||
|
#opwen_server_timezone: "{{ local_tz }}"
|
||||||
|
|
12
roles/lokole/tasks/apache.yml
Normal file
12
roles/lokole/tasks/apache.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
- name: Enable http://box{{ lokole_url }} via Apache # http://box/lokole
|
||||||
|
command: a2ensite lokole.conf
|
||||||
|
when: lokole_enabled | bool
|
||||||
|
|
||||||
|
- name: Disable http://box{{ lokole_url }} via Apache # http://box/lokole
|
||||||
|
command: a2dissite lokole.conf
|
||||||
|
when: not lokole_enabled
|
||||||
|
|
||||||
|
- name: Restart '{{ apache_service }}' systemd service
|
||||||
|
systemd:
|
||||||
|
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
|
||||||
|
state: restarted
|
|
@ -1,71 +0,0 @@
|
||||||
- name: Enable & Restart 'lokole' systemd service
|
|
||||||
systemd:
|
|
||||||
name: lokole
|
|
||||||
daemon_reload: yes
|
|
||||||
enabled: yes
|
|
||||||
state: restarted
|
|
||||||
when: lokole_enabled | bool
|
|
||||||
|
|
||||||
- name: Disable & Stop 'lokole' systemd service
|
|
||||||
systemd:
|
|
||||||
name: lokole
|
|
||||||
enabled: no
|
|
||||||
state: stopped
|
|
||||||
when: not lokole_enabled
|
|
||||||
|
|
||||||
# Apache
|
|
||||||
|
|
||||||
- name: Enable http://box{{ lokole_url }} via Apache # http://box/lokole
|
|
||||||
command: a2ensite lokole.conf
|
|
||||||
when: apache_install and lokole_enabled
|
|
||||||
|
|
||||||
- name: Disable http://box{{ lokole_url }} via Apache # http://box/lokole
|
|
||||||
command: a2dissite lokole.conf
|
|
||||||
when: apache_install and not lokole_enabled
|
|
||||||
|
|
||||||
- name: Restart Apache systemd service ({{ apache_service }})
|
|
||||||
systemd:
|
|
||||||
name: "{{ apache_service }}"
|
|
||||||
state: restarted
|
|
||||||
when: apache_enabled | bool
|
|
||||||
|
|
||||||
# NGINX
|
|
||||||
|
|
||||||
- name: "SHIM: Enable http://box{{ lokole_url }} via NGINX, by installing {{ nginx_conf_dir }}/lokole-nginx.conf from template" # http://box/lokole
|
|
||||||
template:
|
|
||||||
src: lokole-nginx.conf.j2
|
|
||||||
dest: "{{ nginx_conf_dir }}/lokole-nginx.conf"
|
|
||||||
when: nginx_install and lokole_enabled
|
|
||||||
|
|
||||||
- name: "SHIM: Disable http://box{{ lokole_url }} via NGINX, by removing {{ nginx_conf_dir }}/lokole-nginx.conf" # http://box/lokole
|
|
||||||
file:
|
|
||||||
path: "{{ nginx_conf_dir }}/lokole-nginx.conf"
|
|
||||||
state: absent
|
|
||||||
when: nginx_install and not lokole_enabled
|
|
||||||
|
|
||||||
- name: Restart 'nginx' systemd service
|
|
||||||
systemd:
|
|
||||||
name: nginx
|
|
||||||
state: restarted
|
|
||||||
when: nginx_enabled | bool
|
|
||||||
|
|
||||||
|
|
||||||
- name: Add 'lokole' variable values to {{ iiab_ini_file }}
|
|
||||||
ini_file:
|
|
||||||
path: "{{ iiab_ini_file }}"
|
|
||||||
section: lokole
|
|
||||||
option: "{{ item.option }}"
|
|
||||||
value: "{{ item.value | string }}"
|
|
||||||
with_items:
|
|
||||||
- option: name
|
|
||||||
value: lokole
|
|
||||||
- option: description
|
|
||||||
value: '"Lokole is an email service that works offline, for rural communities."'
|
|
||||||
- option: lokole_run_directory
|
|
||||||
value: "{{ lokole_run_directory }}"
|
|
||||||
- option: lokole_url
|
|
||||||
value: "{{ lokole_url }}"
|
|
||||||
- option: lokole_full_url
|
|
||||||
value: "{{ lokole_full_url }}"
|
|
||||||
- option: lokole_enabled
|
|
||||||
value: "{{ lokole_enabled }}"
|
|
|
@ -1,35 +1,24 @@
|
||||||
# Lokole PDF (User's Guide) gets copied for offline use (http://box/info) here:
|
# Lokole PDF (User's Guide) gets copied for offline use (http://box/info) here:
|
||||||
# https://github.com/iiab/iiab/blob/master/roles/httpd/templates/refresh-wiki-docs.sh#L47
|
# https://github.com/iiab/iiab/blob/master/roles/httpd/templates/refresh-wiki-docs.sh#L51-L52
|
||||||
|
|
||||||
- name: "Install 7 packages for Lokole: python3, python3-pip, python3-venv, python3-dev, libffi-dev, libssl-dev, python3-bcrypt"
|
- name: "Install 8 packages for Lokole: python3, python3-pip, python3-venv, python3-dev, python3-bcrypt, libffi-dev, libssl-dev, libopenjp2-7"
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
- python3
|
- python3
|
||||||
- python3-pip
|
- python3-pip
|
||||||
- python3-venv
|
- python3-venv
|
||||||
- python3-dev
|
- python3-dev
|
||||||
|
- python3-bcrypt # 2019-10-14: Should work across modern Linux OS's
|
||||||
|
#- bcrypt does not exist on Ubuntu 19.10
|
||||||
- libffi-dev
|
- libffi-dev
|
||||||
- libssl-dev
|
- libssl-dev
|
||||||
#- bcrypt does not exist on Ubuntu 19.10
|
- libopenjp2-7 # 2020-02-01: To solve bug #2221
|
||||||
- python3-bcrypt # 2019-10-14: should work across modern Linux OS's
|
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: pip install opwen_email_client (Lokole) {{ lokole_version }} from PyPI to {{ lokole_venv }}
|
|
||||||
pip:
|
|
||||||
name: opwen_email_client
|
|
||||||
version: "{{ lokole_version }}"
|
|
||||||
virtualenv: "{{ lokole_venv }}"
|
|
||||||
virtualenv_command: python3 -m venv "{{ lokole_venv }}"
|
|
||||||
extra_args: --no-cache-dir # To avoid caching issues e.g. soon after new releases hit https://pypi.org/project/opwen-email-client/
|
|
||||||
when:
|
|
||||||
- internet_available | bool
|
|
||||||
- lokole_commit is undefined
|
|
||||||
|
|
||||||
# For development purposes -- To install Lokole from a given commit, add the
|
# For development purposes -- To install Lokole from a given commit, add the
|
||||||
# following line to roles/lokole/defaults/main.yml:
|
# following line to roles/lokole/defaults/main.yml:
|
||||||
#
|
|
||||||
# lokole_commit: <git_commit_id>
|
# lokole_commit: <git_commit_id>
|
||||||
- name: pip install opwen_email_client (Lokole) from git commit {{ lokole_commit }} (for development purposes)
|
- name: "OPTIONAL: pip install opwen_email_client (Lokole, git commit {{ lokole_commit }}) from GitHub to {{ lokole_venv }}, if lokole_commit is defined"
|
||||||
pip:
|
pip:
|
||||||
name: "git+https://github.com/ascoderu/opwen-webapp.git@{{ lokole_commit }}#egg=opwen_email_client"
|
name: "git+https://github.com/ascoderu/opwen-webapp.git@{{ lokole_commit }}#egg=opwen_email_client"
|
||||||
virtualenv: "{{ lokole_venv }}"
|
virtualenv: "{{ lokole_venv }}"
|
||||||
|
@ -39,6 +28,30 @@
|
||||||
- internet_available | bool
|
- internet_available | bool
|
||||||
- lokole_commit is defined
|
- lokole_commit is defined
|
||||||
|
|
||||||
|
# For development purposes -- To install a given pip version of Lokole, add
|
||||||
|
# the following line to roles/lokole/defaults/main.yml:
|
||||||
|
# lokole_version: <git_version_number>
|
||||||
|
- name: "OPTIONAL: pip install opwen_email_client (Lokole, version {{ lokole_version }}) from PyPI to {{ lokole_venv }}, if lokole_version is defined"
|
||||||
|
pip:
|
||||||
|
name: opwen_email_client
|
||||||
|
version: "{{ lokole_version }}"
|
||||||
|
virtualenv: "{{ lokole_venv }}"
|
||||||
|
virtualenv_command: python3 -m venv "{{ lokole_venv }}"
|
||||||
|
extra_args: --no-cache-dir # To avoid caching issues e.g. soon after new releases hit https://pypi.org/project/opwen-email-client/
|
||||||
|
when:
|
||||||
|
- internet_available | bool
|
||||||
|
- lokole_version is defined
|
||||||
|
|
||||||
|
- name: "DEFAULT: pip install opwen_email_client (Lokole, latest available version) from PyPI to {{ lokole_venv }}, if above vars both UNdefined"
|
||||||
|
pip:
|
||||||
|
name: opwen_email_client
|
||||||
|
virtualenv: "{{ lokole_venv }}"
|
||||||
|
virtualenv_command: python3 -m venv "{{ lokole_venv }}"
|
||||||
|
extra_args: --no-cache-dir # To avoid caching issues e.g. soon after new releases hit https://pypi.org/project/opwen-email-client/
|
||||||
|
when:
|
||||||
|
- internet_available | bool
|
||||||
|
- lokole_commit is undefined and lokole_version is undefined
|
||||||
|
|
||||||
- name: Compile translations
|
- name: Compile translations
|
||||||
shell: |
|
shell: |
|
||||||
python_version=$(python3 -c 'from sys import version_info; print("%s.%s" % (version_info.major, version_info.minor));';)
|
python_version=$(python3 -c 'from sys import version_info; print("%s.%s" % (version_info.major, version_info.minor));';)
|
||||||
|
@ -46,10 +59,10 @@
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ lokole_venv }}/lib/python${python_version}/site-packages/opwen_email_client/webapp"
|
- "{{ lokole_venv }}/lib/python${python_version}/site-packages/opwen_email_client/webapp"
|
||||||
|
|
||||||
- name: Create dir {{ lokole_run_directory }}
|
- name: mkdir {{ lokole_run_directory }}
|
||||||
file:
|
file:
|
||||||
path: "{{ lokole_run_directory }}"
|
|
||||||
state: directory
|
state: directory
|
||||||
|
path: "{{ lokole_run_directory }}"
|
||||||
|
|
||||||
- name: Install {{ lokole_run_directory }}/webapp_secrets.sh from template, to configure Lokole
|
- name: Install {{ lokole_run_directory }}/webapp_secrets.sh from template, to configure Lokole
|
||||||
template:
|
template:
|
||||||
|
@ -62,7 +75,7 @@
|
||||||
dest: "{{ lokole_run_directory }}/webapp.sh"
|
dest: "{{ lokole_run_directory }}/webapp.sh"
|
||||||
mode: a+x
|
mode: a+x
|
||||||
|
|
||||||
- name: Create admin user
|
- name: Create admin user with password, for http://box{{ lokole_url }} # http://box/lokole
|
||||||
shell: |
|
shell: |
|
||||||
. {{ lokole_run_directory }}/webapp_secrets.sh
|
. {{ lokole_run_directory }}/webapp_secrets.sh
|
||||||
{{ lokole_venv }}/bin/manage.py createadmin --name='{{ lokole_admin_user }}' --password='{{ lokole_admin_password }}'
|
{{ lokole_venv }}/bin/manage.py createadmin --name='{{ lokole_admin_user }}' --password='{{ lokole_admin_password }}'
|
||||||
|
@ -78,14 +91,6 @@
|
||||||
src: lokole.service.j2
|
src: lokole.service.j2
|
||||||
dest: /etc/systemd/system/lokole.service
|
dest: /etc/systemd/system/lokole.service
|
||||||
|
|
||||||
# - name: Enable & Restart 'lokole' systemd service, with daemon_reload, if lokole_enabled
|
|
||||||
# systemd:
|
|
||||||
# daemon_reload: yes
|
|
||||||
# name: lokole
|
|
||||||
# enabled: yes
|
|
||||||
# state: restarted
|
|
||||||
# when: lokole_enabled | bool
|
|
||||||
|
|
||||||
|
|
||||||
# RECORD Lokole AS INSTALLED
|
# RECORD Lokole AS INSTALLED
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,70 @@
|
||||||
- name: Install Lokole {{ lokole_version }} if lokole_install
|
# "How do i fail a task in Ansible if the variable contains a boolean value?
|
||||||
include_tasks: install.yml
|
# I want to perform input validation for Ansible playbooks"
|
||||||
when: lokole_install and not lokole_installed is defined
|
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
|
||||||
|
|
||||||
- name: Enable Lokole
|
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
|
||||||
include_tasks: enable.yml
|
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
|
||||||
when: lokole_install or lokole_installed is defined
|
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
|
||||||
|
|
||||||
|
- name: Assert that "lokole_install is sameas true" (boolean not string etc)
|
||||||
|
assert:
|
||||||
|
that: lokole_install is sameas true
|
||||||
|
fail_msg: "PLEASE SET 'lokole_install: True' e.g. IN: /etc/iiab/local_vars.yml"
|
||||||
|
quiet: yes
|
||||||
|
|
||||||
|
- name: Assert that "lokole_enabled | type_debug == 'bool'" (boolean not string etc)
|
||||||
|
assert:
|
||||||
|
that: lokole_enabled | type_debug == 'bool'
|
||||||
|
fail_msg: "PLEASE GIVE VARIABLE 'lokole_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
|
||||||
|
quiet: yes
|
||||||
|
|
||||||
|
|
||||||
|
- name: Install Lokole {{ lokole_version }} if lokole_installed is not defined
|
||||||
|
include_tasks: install.yml
|
||||||
|
when: lokole_installed is undefined
|
||||||
|
|
||||||
|
|
||||||
|
- name: Enable & Restart 'lokole' systemd service
|
||||||
|
systemd:
|
||||||
|
name: lokole
|
||||||
|
daemon_reload: yes
|
||||||
|
enabled: yes
|
||||||
|
state: restarted
|
||||||
|
when: lokole_enabled | bool
|
||||||
|
|
||||||
|
- name: Disable & Stop 'lokole' systemd service
|
||||||
|
systemd:
|
||||||
|
name: lokole
|
||||||
|
enabled: no
|
||||||
|
state: stopped
|
||||||
|
when: not lokole_enabled
|
||||||
|
|
||||||
|
#- name: Enable/Disable/Restart Apache if primary
|
||||||
|
- name: SHIM FOR NOW SO ALWAYS DO THE...Enable/Disable/Restart Apache
|
||||||
|
include_tasks: apache.yml
|
||||||
|
#when: not nginx_enabled
|
||||||
|
|
||||||
|
- name: Enable/Disable/Restart NGINX if primary
|
||||||
|
include_tasks: nginx.yml
|
||||||
|
when: nginx_enabled | bool
|
||||||
|
|
||||||
|
|
||||||
|
- name: Add 'lokole' variable values to {{ iiab_ini_file }}
|
||||||
|
ini_file:
|
||||||
|
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab_state.yml
|
||||||
|
section: lokole
|
||||||
|
option: "{{ item.option }}"
|
||||||
|
value: "{{ item.value | string }}"
|
||||||
|
with_items:
|
||||||
|
- option: name
|
||||||
|
value: lokole
|
||||||
|
- option: description
|
||||||
|
value: '"Lokole is an email service that works offline, for rural communities."'
|
||||||
|
- option: lokole_run_directory
|
||||||
|
value: "{{ lokole_run_directory }}"
|
||||||
|
- option: lokole_url
|
||||||
|
value: "{{ lokole_url }}"
|
||||||
|
- option: lokole_full_url
|
||||||
|
value: "{{ lokole_full_url }}"
|
||||||
|
- option: lokole_enabled
|
||||||
|
value: "{{ lokole_enabled }}"
|
||||||
|
|
16
roles/lokole/tasks/nginx.yml
Normal file
16
roles/lokole/tasks/nginx.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
- name: "SHIM: Enable http://box{{ lokole_url }} via NGINX, by installing {{ nginx_conf_dir }}/lokole-nginx.conf from template" # http://box/lokole
|
||||||
|
template:
|
||||||
|
src: lokole-nginx.conf.j2
|
||||||
|
dest: "{{ nginx_conf_dir }}/lokole-nginx.conf" # /etc/nginx/conf.d
|
||||||
|
when: lokole_enabled | bool
|
||||||
|
|
||||||
|
- name: "SHIM: Disable http://box{{ lokole_url }} via NGINX, by removing {{ nginx_conf_dir }}/lokole-nginx.conf" # http://box/lokole
|
||||||
|
file:
|
||||||
|
path: "{{ nginx_conf_dir }}/lokole-nginx.conf" # /etc/nginx/conf.d
|
||||||
|
state: absent
|
||||||
|
when: not lokole_enabled
|
||||||
|
|
||||||
|
- name: Restart 'nginx' systemd service
|
||||||
|
systemd:
|
||||||
|
name: nginx
|
||||||
|
state: restarted
|
Loading…
Add table
Add a link
Reference in a new issue