1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/kiwix/tasks/enable.yml
2020-01-11 23:34:17 -05:00

97 lines
3.1 KiB
YAML

- name: Enable & Restart 'kiwix-serve' systemd service
systemd:
name: kiwix-serve
daemon_reload: yes
enabled: yes
state: restarted
when: kiwix_enabled | bool
- name: Disable & Stop 'kiwix-serve' systemd service
systemd:
name: kiwix-serve
enabled: no
state: stopped
when: not kiwix_enabled
# TO DO: BOTH CRON ENTRIES BELOW *SHOULD* BE DELETED "when: not kiwix_enabled"
# In the past kiwix-serve did not stay running, so we'd been doing this hourly.
# @mgautierfr & others suggest kiwix-serve might be auto-restarted w/o cron in
# future, whenever service fails, if this really catches all cases??
# https://github.com/iiab/iiab/issues/484#issuecomment-342151726
- name: Make a crontab entry to restart kiwix-serve at 4AM (debuntu)
lineinfile:
# mn hr dy mo day-of-week[Sunday=0] username command-to-be-executed
line: "0 4 * * * root /bin/systemctl restart kiwix-serve.service"
dest: /etc/crontab
when: kiwix_enabled and is_debuntu
- name: Make a crontab entry to restart kiwix-serve at 4AM (redhat)
# * * * * * user-name command to be executed
lineinfile:
# mn hr dy mo day-of-week[Sunday=0] username command-to-be-executed
line: "0 4 * * * root /usr/bin/systemctl restart kiwix-serve.service"
dest: /etc/crontab
when: kiwix_enabled and is_redhat
# Apache
- name: Enable http://box{{ kiwix_url_without_slash }} via Apache
command: a2ensite kiwix.conf
when: apache_install and kiwix_enabled
- name: Disable http://box{{ kiwix_url_without_slash }} via Apache
command: a2dissite kiwix.conf
when: apache_install and not kiwix_enabled
- name: Restart Apache systemd service ({{ apache_service }})
systemd:
name: "{{ apache_service }}"
daemon-reload: yes
state: restarted
when: apache_enabled | bool
# NGINX
- name: Enable http://box{{ kiwix_url_without_slash }} via NGINX, by installing {{ nginx_config_dir }}/kiwix-nginx.conf from template
template:
src: kiwix-nginx.conf
dest: "{{ nginx_config_dir }}/kiwix-nginx.conf"
when: nginx_install and kiwix_enabled
- name: Disable http://box{{ kiwix_url_without_slash }} via NGINX, by removing {{ nginx_config_dir }}/kiwix-nginx.conf
file:
path: "{{ nginx_config_dir }}/kiwix-nginx.conf"
state: absent
when: nginx_install and not kiwix_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted
when: nginx_enabled | bool
- name: Add 'kiwix' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
section: kiwix
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Kiwix
- option: description
value: '"Part of https://github.com/kiwix/kiwix-tools/ - kiwix-serve is the most used web server for ZIM files."'
- option: kiwix_url
value: "{{ kiwix_url }}"
- option: kiwix_path
value: "{{ kiwix_path }}"
- option: kiwix_port
value: "{{ kiwix_port }}"
- option: iiab_zim_path
value: "{{ iiab_zim_path }}"
- option: kiwix_library_xml
value: "{{ kiwix_library_xml }}"
- option: kiwix_enabled
value: "{{ kiwix_enabled }}"