mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 11:42:08 +00:00
Merge pull request #567 from holta/master
Kiwix playbook more readable; unused code commented out
This commit is contained in:
commit
1a6883187c
2 changed files with 110 additions and 92 deletions
|
@ -1,7 +1,8 @@
|
||||||
kiwix_url: /kiwix
|
# The following 2 lines don't work as of Nov 2017:
|
||||||
kiwix_path: "{{ iiab_base }}/kiwix"
|
# kiwix_url: /kiwix
|
||||||
|
# kiwix_path: "{{ iiab_base }}/kiwix"
|
||||||
kiwix_port: 3000
|
kiwix_port: 3000
|
||||||
iiab_zim_path: /library/zims
|
iiab_zim_path: "{{ content_base }}/zims"
|
||||||
kiwix_library_xml: "{{ iiab_zim_path }}/library.xml"
|
kiwix_library_xml: "{{ iiab_zim_path }}/library.xml"
|
||||||
kiwix_content_path: "{{ iiab_zim_path }}/content"
|
kiwix_content_path: "{{ iiab_zim_path }}/content"
|
||||||
kiwix_install: True
|
kiwix_install: True
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
- name: Create various directories for Kiwix's ZIM files
|
- name: Create various directories for Kiwix's ZIM files
|
||||||
file: path={{ item }}
|
file:
|
||||||
owner=root
|
path: "{{ item }}"
|
||||||
group=root
|
owner: root
|
||||||
mode=0755
|
group: root
|
||||||
state=directory
|
mode: 0755
|
||||||
|
state: directory
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ iiab_zim_path }}"
|
- "{{ iiab_zim_path }}"
|
||||||
- "{{ kiwix_content_path }}"
|
- "{{ kiwix_content_path }}"
|
||||||
- "{{ iiab_zim_path }}/index"
|
- "{{ iiab_zim_path }}/index"
|
||||||
|
|
||||||
- name: Check for 'kiwix-serve' binary
|
- name: Check for 'kiwix-serve' binary
|
||||||
stat: path={{ iiab_base }}/kiwix/bin/kiwix-serve
|
stat:
|
||||||
|
path: "{{ iiab_base }}/kiwix/bin/kiwix-serve"
|
||||||
register: kiwix_bin
|
register: kiwix_bin
|
||||||
|
|
||||||
- name: Set kiwix_first_pass
|
- name: Set kiwix_first_pass
|
||||||
|
@ -19,43 +21,48 @@
|
||||||
when: kiwix_bin.stat.exists is defined and not kiwix_bin.stat.exists
|
when: kiwix_bin.stat.exists is defined and not kiwix_bin.stat.exists
|
||||||
|
|
||||||
- name: Copy Kiwix library file if needed
|
- name: Copy Kiwix library file if needed
|
||||||
template: src={{ item }}
|
template:
|
||||||
dest="{{ kiwix_library_xml }}"
|
src: "{{ item }}"
|
||||||
mode=0644
|
dest: "{{ kiwix_library_xml }}"
|
||||||
owner=root
|
mode: 0644
|
||||||
group=root
|
owner: root
|
||||||
force=no
|
group: root
|
||||||
|
force: no
|
||||||
with_items:
|
with_items:
|
||||||
- library.xml
|
- library.xml
|
||||||
when: kiwix_first_pass
|
when: kiwix_first_pass
|
||||||
|
|
||||||
- name: Copy test.zim file
|
- name: Copy test.zim file
|
||||||
copy: src=test.zim
|
copy:
|
||||||
dest={{ kiwix_content_path }}/test.zim
|
src: test.zim
|
||||||
mode=0644
|
dest: "{{ kiwix_content_path }}/test.zim"
|
||||||
owner=root
|
mode: 0644
|
||||||
group=root
|
owner: root
|
||||||
force=no
|
group: root
|
||||||
|
force: no
|
||||||
when: kiwix_first_pass
|
when: kiwix_first_pass
|
||||||
|
|
||||||
# we get a whole web server for intel but only the kiwix execs for arm
|
# we get a whole web server for intel but only the kiwix execs for arm
|
||||||
|
|
||||||
- name: Unarchive it to permanent location - not bin_only
|
- name: Unarchive it to permanent location - not bin_only
|
||||||
unarchive: src="{{ downloads_dir }}/{{ kiwix_src_file }}"
|
unarchive:
|
||||||
dest="{{ iiab_base }}"
|
src: "{{ downloads_dir }}/{{ kiwix_src_file }}"
|
||||||
owner=root
|
dest: "{{ iiab_base }}"
|
||||||
group=root
|
owner: root
|
||||||
|
group: root
|
||||||
when: not kiwix_src_bin_only and kiwix_first_pass
|
when: not kiwix_src_bin_only and kiwix_first_pass
|
||||||
|
|
||||||
- name: Create kiwix/bin directory
|
- name: Create kiwix/bin directory
|
||||||
file: path="{{ iiab_base }}/kiwix/bin"
|
file:
|
||||||
owner=root
|
path: "{{ iiab_base }}/kiwix/bin"
|
||||||
group=root
|
owner: root
|
||||||
mode=0755
|
group: root
|
||||||
state=directory
|
mode: 0755
|
||||||
|
state: directory
|
||||||
|
|
||||||
- name: Enable the mods which permit Apache to proxy (debuntu)
|
- name: Enable the mods which permit Apache to proxy (debuntu)
|
||||||
apache2_module: name={{ item }}
|
apache2_module:
|
||||||
|
name: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
- proxy
|
- proxy
|
||||||
- proxy_html
|
- proxy_html
|
||||||
|
@ -64,41 +71,47 @@
|
||||||
when: is_debuntu
|
when: is_debuntu
|
||||||
|
|
||||||
- name: Unarchive Kiwix to permanent location - bin only
|
- name: Unarchive Kiwix to permanent location - bin only
|
||||||
unarchive: src="{{ downloads_dir }}/{{ kiwix_src_file }}"
|
unarchive:
|
||||||
dest="{{ iiab_base }}/kiwix/bin"
|
src: "{{ downloads_dir }}/{{ kiwix_src_file }}"
|
||||||
owner=root
|
dest: "{{ iiab_base }}/kiwix/bin"
|
||||||
group=root
|
owner: root
|
||||||
|
group: root
|
||||||
when: kiwix_src_bin_only and kiwix_first_pass
|
when: kiwix_src_bin_only and kiwix_first_pass
|
||||||
|
|
||||||
# workaround because unarchive does not set ownership properly
|
# Already done above!
|
||||||
- name: "Set ownership as if: 'chown -R root:root /opt/iiab/kiwix'"
|
# # workaround because unarchive does not set ownership properly
|
||||||
file: path="{{ iiab_base }}/kiwix"
|
# - name: "Set ownership as if: 'chown -R root:root /opt/iiab/kiwix'"
|
||||||
owner=root
|
# file:
|
||||||
group=root
|
# path: "{{ iiab_base }}/kiwix"
|
||||||
recurse=yes
|
# owner: root
|
||||||
|
# group: root
|
||||||
|
# recurse: yes
|
||||||
|
|
||||||
# workaround because kiwix-serve does not stay running
|
# workaround because kiwix-serve does not stay running
|
||||||
- name: Make a crontab entry to restart kiwix-serve at 4AM (debuntu)
|
- name: Make a crontab entry to restart kiwix-serve at 4AM (debuntu)
|
||||||
# * * * * * user-name command to be executed
|
# * * * * * user-name command to be executed
|
||||||
lineinfile: line="0 4 * * * root /bin/systemctl restart kiwix-serve.service"
|
lineinfile:
|
||||||
dest=/etc/crontab
|
line: "0 4 * * * root /bin/systemctl restart kiwix-serve.service"
|
||||||
|
dest: /etc/crontab
|
||||||
when: is_debuntu
|
when: is_debuntu
|
||||||
|
|
||||||
- name: Make a crontab entry to restart kiwix-serve at 4AM (redhat)
|
- name: Make a crontab entry to restart kiwix-serve at 4AM (redhat)
|
||||||
# * * * * * user-name command to be executed
|
# * * * * * user-name command to be executed
|
||||||
lineinfile: line="0 4 * * * root /usr/bin/systemctl restart kiwix-serve.service"
|
lineinfile:
|
||||||
dest=/etc/crontab
|
line: "0 4 * * * root /usr/bin/systemctl restart kiwix-serve.service"
|
||||||
|
dest: /etc/crontab
|
||||||
when: is_redhat
|
when: is_redhat
|
||||||
|
|
||||||
# Create Kiwix service
|
# Create Kiwix service
|
||||||
|
|
||||||
- name: Create 'kiwix-serve' service
|
- name: Create 'kiwix-serve' service
|
||||||
template: backup=no
|
template:
|
||||||
src={{ item.src }}
|
backup: no
|
||||||
dest={{ item.dest }}
|
src: "{{ item.src }}"
|
||||||
owner=root
|
dest: "{{ item.dest }}"
|
||||||
group=root
|
owner: root
|
||||||
mode={{ item.mode }}
|
group: root
|
||||||
|
mode: "{{ item.mode }}"
|
||||||
with_items:
|
with_items:
|
||||||
- { src: 'kiwix-serve.service.j2', dest: '/etc/systemd/system/kiwix-serve.service', mode: '0644'}
|
- { src: 'kiwix-serve.service.j2', dest: '/etc/systemd/system/kiwix-serve.service', mode: '0644'}
|
||||||
# - { src: 'kiwix-serve-init.j2', dest: '/usr/libexec/kiwix-serve-init', mode: '0755'}
|
# - { src: 'kiwix-serve-init.j2', dest: '/usr/libexec/kiwix-serve-init', mode: '0755'}
|
||||||
|
@ -107,19 +120,21 @@
|
||||||
- { src: 'iiab-make-apache-config.py', dest: '/usr/bin/iiab-make-apache-config.py', mode: '0755'}
|
- { 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 }}'
|
ini_file:
|
||||||
section=kiwix-serve
|
dest: "{{ service_filelist }}"
|
||||||
option='{{ item.option }}'
|
section: kiwix-serve
|
||||||
value='{{ item.value }}'
|
option: "{{ item.option }}"
|
||||||
|
value: "{{ item.value }}"
|
||||||
with_items:
|
with_items:
|
||||||
- option: name
|
- option: name
|
||||||
value: kiwix-serve
|
value: kiwix-serve
|
||||||
- option: description
|
- option: description
|
||||||
value: '"Part of https://github.com/kiwix/kiwix-tools/ - kiwix-serve is the most used web server for ZIM files."'
|
value: '"Part of https://github.com/kiwix/kiwix-tools/ - kiwix-serve is the most used web server for ZIM files."'
|
||||||
- option: kiwix_url
|
# The following 4 lines are unused as of Nov 2017:
|
||||||
value: "{{ kiwix_url }}"
|
# - option: kiwix_url
|
||||||
- option: kiwix_path
|
# value: "{{ kiwix_url }}"
|
||||||
value: "{{ kiwix_path }}"
|
# - option: kiwix_path
|
||||||
|
# value: "{{ kiwix_path }}"
|
||||||
- option: kiwix_port
|
- option: kiwix_port
|
||||||
value: "{{ kiwix_port }}"
|
value: "{{ kiwix_port }}"
|
||||||
- option: iiab_zim_path
|
- option: iiab_zim_path
|
||||||
|
@ -132,13 +147,15 @@
|
||||||
value: "{{ kiwix_enabled }}"
|
value: "{{ kiwix_enabled }}"
|
||||||
|
|
||||||
- name: Enable 'kiwix-serve' service
|
- name: Enable 'kiwix-serve' service
|
||||||
service: name=kiwix-serve
|
service:
|
||||||
enabled=yes
|
name: kiwix-serve
|
||||||
state=restarted
|
enabled: yes
|
||||||
|
state: restarted
|
||||||
when: kiwix_enabled
|
when: kiwix_enabled
|
||||||
|
|
||||||
- name: Disable 'kiwix-serve' service
|
- name: Disable 'kiwix-serve' service
|
||||||
service: name=kiwix-serve
|
service:
|
||||||
enabled=no
|
name: kiwix-serve
|
||||||
state=stopped
|
enabled: no
|
||||||
|
state: stopped
|
||||||
when: not kiwix_enabled
|
when: not kiwix_enabled
|
||||||
|
|
Loading…
Reference in a new issue