1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/kiwix/tasks/kiwix_install.yml

144 lines
4.3 KiB
YAML
Raw Normal View History

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:
- "{{ iiab_zim_path }}"
2017-05-27 18:09:50 +00:00
- "{{ kiwix_content_path }}"
- "{{ iiab_zim_path }}/index"
2017-05-27 18:09:50 +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
- 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
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 }}"
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
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 }}"
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]
command: "chown -R root:root {{ iiab_base }}"
2017-05-27 18:09:50 +00:00
# workaround because kiwix-serve does not stay running
- name: Make an entry in crontab to restart at 4AM
2017-05-27 18:09:50 +00:00
# * * * * * user-name command to be executed
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
- name: Make an entry in crontab to restart at 4AM
2017-05-27 18:09:50 +00:00
# * * * * * user-name command to be executed
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:
- { 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'}
- { 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 }}"
- 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