1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Refine @jvonau\'s \'Move NGINX shims to roles\'

This commit is contained in:
root 2020-01-12 12:12:49 -05:00
parent ef93b30370
commit fff83cd5fb
22 changed files with 223 additions and 271 deletions

View file

@ -1,62 +1,54 @@
- name: Enable & Restart 'lokole' systemd service, with daemon_reload, if lokole_enabled
- name: Enable & Restart 'lokole' systemd service
systemd:
daemon_reload: yes
name: lokole
daemon_reload: yes
enabled: yes
state: restarted
when: lokole_enabled
when: lokole_enabled | bool
- name: Disable 'lokole' service, if not lokole_enabled
- name: Disable & Stop 'lokole' systemd service
systemd:
daemon_reload: yes
name: lokole
enabled: no
state: stopped
when: not lokole_enabled
- name: Install /etc/{{ apache_config_dir }}/lokole.conf from template, for http://box/lokole
template:
src: lokole.conf.j2
dest: "/etc/{{ apache_config_dir }}/lokole.conf"
# Apache
- name: Symlink /etc/apache2/sites-enabled/lokole.conf to /etc/{{ apache_config_dir }}/lokole.conf, if lokole_enabled (debuntu)
file:
src: "/etc/{{ apache_config_dir }}/lokole.conf"
path: /etc/apache2/sites-enabled/lokole.conf
state: link
when: lokole_enabled and is_debuntu
- name: Enable http://box{{ lokole_url }} via Apache # http://box/lokole
command: a2ensite lokole.conf
when: apache_install and lokole_enabled
- name: Remove /etc/apache2/sites-enabled/lokole.conf, if not lokole_enabled (debuntu)
file:
path: /etc/apache2/sites-enabled/lokole.conf
state: absent
when: not lokole_enabled and is_debuntu
- name: Disable http://box{{ lokole_url }} via Apache # http://box/lokole
command: a2dissite lokole.conf
when: apache_install and not lokole_enabled
- name: Remove /etc/{{ apache_config_dir }}/lokole.conf, if not lokole_enabled (OS's other than debuntu)
file:
path: "/etc/{{ apache_config_dir }}/lokole.conf"
state: absent
when: (not lokole_enabled) and (not is_debuntu)
- name: Restart Apache systemd service ({{ apache_service }})
systemd:
name: "{{ apache_service }}"
state: restarted
when: apache_enabled | bool
- name: Install {{ nginx_config_dir }}/lokole-nginx.conf from template
# NGINX
- name: "SHIM: Enable http://box{{ lokole_url }} via NGINX, by installing {{ nginx_config_dir }}/lokole-nginx.conf from template" # http://box/lokole
template:
src: lokole-nginx.conf.j2
dest: "{{ nginx_config_dir }}/lokole-nginx.conf"
when: lokole_enabled and nginx_enabled
when: nginx_install and lokole_enabled
- name: Restart Apache ({{ apache_service }}) to enable/disable http://box/lokole
systemd:
name: "{{ apache_service }}"
daemon_reload: yes
state: restarted
when: apache_enabled
- name: "SHIM: Disable http://box{{ lokole_url }} via NGINX, by removing {{ nginx_config_dir }}/lokole-nginx.conf" # http://box/lokole
file:
path: "{{ nginx_config_dir }}/lokole-nginx.conf"
state: absent
when: nginx_install and not lokole_enabled
- name: Restart nginx to enable/disable http://box/lokole
- name: Restart 'nginx' systemd service
systemd:
name: nginx
daemon_reload: yes
state: restarted
when: nginx_enabled
when: nginx_enabled | bool
- name: Add 'lokole' variable values to {{ iiab_ini_file }}
ini_file:

View file

@ -13,8 +13,6 @@
#- bcrypt does not exist on Ubuntu 19.10
- python3-bcrypt # 2019-10-14: should work across modern Linux OS's
state: present
tags:
- install
- name: pip install opwen_email_client (Lokole) {{ lokole_version }} from PyPI to {{ lokole_venv }}
pip:
@ -23,8 +21,6 @@
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/
tags:
- install
when:
- internet_available | bool
- lokole_commit is undefined
@ -39,8 +35,6 @@
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/
tags:
- install
when:
- internet_available | bool
- lokole_commit is defined
@ -51,56 +45,49 @@
{{ lokole_venv }}/bin/pybabel compile -d {{ item }}/translations
with_items:
- "{{ lokole_venv }}/lib/python${python_version}/site-packages/opwen_email_client/webapp"
tags:
- install
- name: Create dir {{ lokole_run_directory }}
file:
path: "{{ lokole_run_directory }}"
state: directory
tags:
- configure
- name: Install {{ lokole_run_directory }}/webapp_secrets.sh from template, to configure Lokole
template:
src: webapp_secrets.sh.j2
dest: "{{ lokole_run_directory }}/webapp_secrets.sh"
tags:
- configure
- name: Install {{ lokole_run_directory }}/webapp.sh from template, to configure Gunicorn
template:
src: webapp.sh.j2
dest: "{{ lokole_run_directory }}/webapp.sh"
mode: a+x
tags:
- configure
- name: Create admin user
shell: |
. {{ lokole_run_directory }}/webapp_secrets.sh
{{ lokole_venv }}/bin/manage.py createadmin --name='{{ lokole_admin_user }}' --password='{{ lokole_admin_password }}'
tags:
- configure
- name: Install unit file /etc/systemd/system/lokole.service from template
- name: Install /etc/{{ apache_config_dir }}/lokole.conf from template, for http://box{{ lokole_url }} via Apache # http://box/lokole
template:
src: lokole.conf.j2
dest: "/etc/{{ apache_config_dir }}/lokole.conf"
when: apache_install | bool
- name: Install /etc/systemd/system/lokole.service unit file from template
template:
src: lokole.service.j2
dest: /etc/systemd/system/lokole.service
tags:
- systemd
- 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
# - 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
- name: "Add 'lokole_installed: True' to {{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
lineinfile:
dest: "{{ iiab_state_file }}"
regexp: '^lokole_installed'
line: 'lokole_installed: True'
state: present

View file

@ -1,3 +1,3 @@
location /lokole {
proxy_pass http://127.0.0.1:{{ apache_port }}/lokole;
location {{ lokole_url }}/ {
proxy_pass http://127.0.0.1:{{ apache_port }}{{ lokole_url }}/;
}