2017-10-27 14:08:41 +00:00
|
|
|
- name: Create various directories for ZIM files
|
2017-05-27 18:09:50 +00:00
|
|
|
file: path={{ item }}
|
|
|
|
owner=root
|
|
|
|
group=root
|
|
|
|
mode=0755
|
|
|
|
state=directory
|
|
|
|
with_items:
|
2017-06-09 23:25:56 +00:00
|
|
|
- "{{ iiab_zim_path }}"
|
2017-05-27 18:09:50 +00:00
|
|
|
- "{{ kiwix_content_path }}"
|
2017-06-09 23:25:56 +00:00
|
|
|
- "{{ iiab_zim_path }}/index"
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-09-11 16:21:07 +00:00
|
|
|
- name: Check for kiwix-serve binary
|
|
|
|
stat: path={{ iiab_base }}/kiwix/bin/kiwix-serve
|
2017-09-11 16:49:48 +00:00
|
|
|
register: kiwix_bin
|
2017-09-11 16:21:07 +00:00
|
|
|
|
|
|
|
- name: Set kiwix first pass
|
|
|
|
set_fact:
|
|
|
|
kiwix_first_pass: True
|
|
|
|
when: kiwix_bin.stat.exists is defined and not kiwix_bin.stat.exists
|
|
|
|
|
2017-10-27 14:08:41 +00:00
|
|
|
- name: Copy Kiwix library file if needed
|
2017-05-27 18:09:50 +00:00
|
|
|
template: src={{ item }}
|
|
|
|
dest="{{ kiwix_library_xml }}"
|
|
|
|
mode=0644
|
|
|
|
owner=root
|
|
|
|
group=root
|
|
|
|
force=no
|
|
|
|
with_items:
|
|
|
|
- library.xml
|
2017-09-11 16:21:07 +00:00
|
|
|
when: kiwix_first_pass
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
- name: Copy test.zim file
|
|
|
|
copy: src=test.zim
|
|
|
|
dest={{ kiwix_content_path }}/test.zim
|
|
|
|
mode=0644
|
|
|
|
owner=root
|
|
|
|
group=root
|
|
|
|
force=no
|
|
|
|
when: kiwix_first_pass
|
|
|
|
|
|
|
|
# we get a whole web server for intel but only the kiwix execs for arm
|
|
|
|
|
|
|
|
- name: Unarchive it to permanent location - not bin_only
|
|
|
|
unarchive: src="{{ downloads_dir }}/{{ kiwix_src_file }}"
|
2017-06-09 23:25:56 +00:00
|
|
|
dest="{{ iiab_base }}"
|
2017-05-27 18:09:50 +00:00
|
|
|
owner=root
|
|
|
|
group=root
|
|
|
|
when: not kiwix_src_bin_only and kiwix_first_pass
|
|
|
|
|
|
|
|
- name: Create directory for kiwix bin
|
2017-06-09 23:25:56 +00:00
|
|
|
file: path="{{ iiab_base }}/kiwix/bin"
|
2017-05-27 18:09:50 +00:00
|
|
|
owner=root
|
|
|
|
group=root
|
|
|
|
mode=0755
|
|
|
|
state=directory
|
|
|
|
|
2017-10-27 14:08:41 +00:00
|
|
|
- name: Enable the mods which permit Apache to proxy
|
2017-05-27 18:09:50 +00:00
|
|
|
apache2_module: name={{ item }}
|
|
|
|
with_items:
|
|
|
|
- proxy
|
|
|
|
- proxy_html
|
2017-08-22 00:49:56 +00:00
|
|
|
- proxy_http
|
2017-05-27 18:09:50 +00:00
|
|
|
- rewrite
|
2017-05-27 23:10:45 +00:00
|
|
|
when: is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
- name: Unarchive it to permanent location - bin only
|
|
|
|
unarchive: src="{{ downloads_dir }}/{{ kiwix_src_file }}"
|
2017-06-09 23:25:56 +00:00
|
|
|
dest="{{ iiab_base }}/kiwix/bin"
|
2017-05-27 18:09:50 +00:00
|
|
|
owner=root
|
|
|
|
group=root
|
|
|
|
when: kiwix_src_bin_only and kiwix_first_pass
|
|
|
|
|
|
|
|
# workaround because unarchive does not set ownership properly
|
2017-10-27 14:08:41 +00:00
|
|
|
- name: Set kiwix ownership to root [WARNING chown -R across all of /opt/iiab]
|
2017-06-09 23:25:56 +00:00
|
|
|
command: "chown -R root:root {{ iiab_base }}"
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
# workaround because kiwix-serve does not stay running
|
2017-11-04 19:33:52 +00:00
|
|
|
- name: Make an entry in crontab to restart at 4AM
|
2017-05-27 18:09:50 +00:00
|
|
|
# * * * * * user-name command to be executed
|
2017-11-04 19:33:52 +00:00
|
|
|
lineinfile: line="0 4 * * * root /bin/systemctl restart kiwix-serve.service"
|
2017-05-27 18:09:50 +00:00
|
|
|
dest=/etc/crontab
|
|
|
|
when: is_debuntu
|
|
|
|
|
2017-11-04 19:33:52 +00:00
|
|
|
- name: Make an entry in crontab to restart at 4AM
|
2017-05-27 18:09:50 +00:00
|
|
|
# * * * * * user-name command to be executed
|
2017-11-04 19:33:52 +00:00
|
|
|
lineinfile: line="0 4 * * * root /usr/bin/systemctl restart kiwix-serve.service"
|
2017-05-27 18:09:50 +00:00
|
|
|
dest=/etc/crontab
|
|
|
|
when: is_redhat
|
|
|
|
|
|
|
|
# Create kiwix service
|
|
|
|
|
|
|
|
- name: Create kiwix-serve service
|
|
|
|
template: backup=no
|
|
|
|
src={{ item.src }}
|
|
|
|
dest={{ item.dest }}
|
|
|
|
owner=root
|
|
|
|
group=root
|
|
|
|
mode={{ item.mode }}
|
|
|
|
with_items:
|
2017-09-18 15:19:46 +00:00
|
|
|
- { src: 'kiwix-serve.service.j2', dest: '/etc/systemd/system/kiwix-serve.service', mode: '0644'}
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
# - { src: 'kiwix-serve-init.j2', dest: '/usr/libexec/kiwix-serve-init', mode: '0755'}
|
2017-06-09 23:25:56 +00:00
|
|
|
- { src: 'iiab-make-kiwix-lib', dest: '/usr/bin/iiab-make-kiwix-lib', mode: '0755'}
|
|
|
|
- { src: 'iiab-make-kiwix-lib.py', dest: '/usr/bin/iiab-make-kiwix-lib.py', mode: '0755'}
|
|
|
|
- { src: 'iiab-make-apache-config.py', dest: '/usr/bin/iiab-make-apache-config.py', mode: '0755'}
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
|
2017-10-27 14:51:16 +00:00
|
|
|
- name: Add kiwix-serve to list of services
|
2017-05-27 18:09:50 +00:00
|
|
|
ini_file: dest='{{ service_filelist }}'
|
|
|
|
section=kiwix-serve
|
|
|
|
option='{{ item.option }}'
|
|
|
|
value='{{ item.value }}'
|
|
|
|
with_items:
|
|
|
|
- option: name
|
|
|
|
value: kiwix-serve
|
|
|
|
- option: description
|
|
|
|
value: '"kiwix-serve is a web server for zim files"'
|
|
|
|
- option: kiwix_url
|
|
|
|
value: "{{ kiwix_url }}"
|
|
|
|
- option: kiwix_path
|
|
|
|
value: "{{ kiwix_path }}"
|
|
|
|
- option: kiwix_port
|
|
|
|
value: "{{ kiwix_port }}"
|
2017-06-09 23:25:56 +00:00
|
|
|
- option: iiab_zim_path
|
|
|
|
value: "{{ iiab_zim_path }}"
|
2017-05-27 18:09:50 +00:00
|
|
|
- option: kiwix_library_xml
|
|
|
|
value: "{{ kiwix_library_xml }}"
|
|
|
|
- option: kiwix_content_path
|
|
|
|
value: "{{ kiwix_content_path }}"
|
|
|
|
- option: enabled
|
2017-10-18 01:17:45 +00:00
|
|
|
value: "{{ kiwix_enabled }}"
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
- name: Enable kiwix-serve service
|
|
|
|
service: name=kiwix-serve
|
|
|
|
enabled=yes
|
|
|
|
state=restarted
|
2017-10-18 01:17:45 +00:00
|
|
|
when: kiwix_enabled
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
- name: Disable kiwix-serve service
|
|
|
|
service: name=kiwix-serve
|
|
|
|
enabled=no
|
|
|
|
state=stopped
|
2017-10-18 01:17:45 +00:00
|
|
|
when: not kiwix_enabled
|