1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00

Merge pull request #485 from holta/kiwix-cron-nightly-not-hourly

restart kiwix-serve 4AM nightly (not 15min after every hour) & restrict chown to /opt/iiab/kiwix

Smoke-tested.  Please continue to test locally, so we can refine (or eliminate if nec?) this cron job's frequency as nec!

Closes #484
This commit is contained in:
A Holt 2017-11-05 11:12:28 -05:00 committed by GitHub
commit 7b92914019
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
- name: Create various directories for ZIM files
- name: Create various directories for Kiwix's ZIM files
file: path={{ item }}
owner=root
group=root
@ -9,11 +9,11 @@
- "{{ kiwix_content_path }}"
- "{{ iiab_zim_path }}/index"
- name: Check for kiwix-serve binary
- name: Check for 'kiwix-serve' binary
stat: path={{ iiab_base }}/kiwix/bin/kiwix-serve
register: kiwix_bin
- name: Set kiwix first pass
- name: Set kiwix_first_pass
set_fact:
kiwix_first_pass: True
when: kiwix_bin.stat.exists is defined and not kiwix_bin.stat.exists
@ -47,7 +47,7 @@
group=root
when: not kiwix_src_bin_only and kiwix_first_pass
- name: Create directory for kiwix bin
- name: Create kiwix/bin directory
file: path="{{ iiab_base }}/kiwix/bin"
owner=root
group=root
@ -63,7 +63,7 @@
- rewrite
when: is_debuntu
- name: Unarchive it to permanent location - bin only
- name: Unarchive Kiwix to permanent location - bin only
unarchive: src="{{ downloads_dir }}/{{ kiwix_src_file }}"
dest="{{ iiab_base }}/kiwix/bin"
owner=root
@ -71,25 +71,25 @@
when: kiwix_src_bin_only and kiwix_first_pass
# workaround because unarchive does not set ownership properly
- name: Set kiwix ownership to root [WARNING chown -R across all of /opt/iiab]
command: "chown -R root:root {{ iiab_base }}"
- name: "Set ownership: 'chown -R root:root /opt/iiab/kiwix'"
command: "chown -R root:root {{ iiab_base }}/kiwix"
# workaround because kiwix-serve does not stay running
- name: Make an entry in crontab to restart every hour
- name: Make a crontab entry to restart kiwix-serve at 4AM (debuntu)
# * * * * * user-name command to be executed
lineinfile: line="15 * * * * root /bin/systemctl restart kiwix-serve.service"
lineinfile: line="0 4 * * * root /bin/systemctl restart kiwix-serve.service"
dest=/etc/crontab
when: is_debuntu
- name: Make an entry in crontab to restart every hour
- name: Make a crontab entry to restart kiwix-serve at 4AM (redhat)
# * * * * * user-name command to be executed
lineinfile: line="15 * * * * root /usr/bin/systemctl restart kiwix-serve.service"
lineinfile: line="0 4 * * * root /usr/bin/systemctl restart kiwix-serve.service"
dest=/etc/crontab
when: is_redhat
# Create kiwix service
- name: Create kiwix-serve service
- name: Create 'kiwix-serve' service
template: backup=no
src={{ item.src }}
dest={{ item.dest }}
@ -105,7 +105,7 @@
- { 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: Add 'kiwix-serve' to list of services
ini_file: dest='{{ service_filelist }}'
section=kiwix-serve
option='{{ item.option }}'
@ -130,13 +130,13 @@
- option: enabled
value: "{{ kiwix_enabled }}"
- name: Enable kiwix-serve service
- name: Enable 'kiwix-serve' service
service: name=kiwix-serve
enabled=yes
state=restarted
when: kiwix_enabled
- name: Disable kiwix-serve service
- name: Disable 'kiwix-serve' service
service: name=kiwix-serve
enabled=no
state=stopped