# 1. CREATE/VERIFY CRITICAL DIRECTORIES & FILES ARE IN PLACE - name: Download Kiwix software to /opt/iiab/downloads get_url: url: "{{ iiab_download_url }}/{{ kiwix_src_file }}" dest: "{{ downloads_dir }}/{{ kiwix_src_file }}" timeout: "{{ download_timeout }}" when: internet_available | bool - name: Check for /opt/iiab/downloads/{{ kiwix_src_file }} stat: path: "{{ downloads_dir }}/{{ kiwix_src_file }}" register: kiwix_src - name: Create directory {{ iiab_zim_path }} and subdirs {content, index} for Kiwix ZIM files file: path: "{{ item }}" owner: root group: root mode: 0755 state: directory with_items: - "{{ iiab_zim_path }}" - "{{ iiab_zim_path }}/content" - "{{ iiab_zim_path }}/index" - name: Check for {{ kiwix_library_xml }} # /library/zims/library.xml stat: path: "{{ kiwix_library_xml }}" register: kiwix_xml - name: Install a stub /library/zims/library.xml if one doesn't exist template: src: library.xml dest: "{{ kiwix_library_xml }}" mode: 0644 owner: root group: root force: no when: not kiwix_xml.stat.exists - name: Install {{ iiab_zim_path }}/content/test.zim if kiwix_force_install copy: src: test.zim dest: "{{ iiab_zim_path }}/content/test.zim" mode: 0644 owner: root group: root force: no when: kiwix_force_install | bool - name: Create {{ kiwix_path }}/bin directory # /opt/iiab/kiwix/bin file: path: "{{ kiwix_path }}/bin" owner: root group: root mode: 0755 state: directory # 2. INSTALL KIWIX-TOOLS EXECUTABLES IF kiwix_force_install - name: Unarchive {{ kiwix_src_file }} to /tmp # e.g. kiwix-tools_linux-armhf-0.6.1-1.tar.gz unarchive: src: "{{ downloads_dir }}/{{ kiwix_src_file }}" dest: /tmp owner: root group: root when: kiwix_force_install | bool - name: Move /tmp/{{ kiwix_src_dir }}/* to permanent location /opt/iiab/kiwix/bin (armhf & linux64 & i686) shell: "mv /tmp/{{ kiwix_src_dir }}/* {{ kiwix_path }}/bin/" when: kiwix_force_install | bool # 3. ENABLE MODS FOR APACHE PROXY IF DEBUNTU # 2019-10-07: Moved to roles/httpd/tasks/main.yml # 2019-09-29: Compare roles/kolibri/defaults/main.yml using just 1 (proxy_http) #- name: Enable the 4 mods which permit Apache to proxy (debuntu) # apache2_module: # name: "{{ item }}" # with_items: # - proxy # - proxy_html # - proxy_http # - rewrite # when: is_debuntu | bool # 4. CREATE/ENABLE/RESTART (OR DISABLE) KIWIX SERVICE & ITS CRON JOB - name: 'Install from templates: kiwix-serve.service, iiab-make-kiwix-lib, iiab-make-kiwix-lib.py, kiwix.conf' 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'} - { 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: 'kiwix.conf.j2', dest: '/etc/{{ apache_config_dir }}/kiwix.conf', mode: '0644'} - name: Add 'kiwix_installed' variable values to {{ iiab_state_file }} lineinfile: dest: "{{ iiab_state_file }}" regexp: '^kiwix_installed' line: 'kiwix_installed: True' state: present