mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	
						commit
						b1e78eb57d
					
				
					 4 changed files with 37 additions and 39 deletions
				
			
		| 
						 | 
					@ -1,17 +1,20 @@
 | 
				
			||||||
- name: Enable & Restart 'kiwix-serve' systemd service
 | 
					 | 
				
			||||||
  systemd:
 | 
					 | 
				
			||||||
    name: kiwix-serve
 | 
					 | 
				
			||||||
    daemon_reload: yes
 | 
					 | 
				
			||||||
    enabled: yes
 | 
					 | 
				
			||||||
    state: restarted
 | 
					 | 
				
			||||||
  when: kiwix_enabled
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- name: Disable & Stop 'kiwix-serve' systemd service
 | 
					- name: Disable & Stop 'kiwix-serve' systemd service
 | 
				
			||||||
  systemd:
 | 
					  systemd:
 | 
				
			||||||
    name: kiwix-serve
 | 
					    name: kiwix-serve
 | 
				
			||||||
    enabled: no
 | 
					    enabled: no
 | 
				
			||||||
    state: stopped
 | 
					    state: stopped
 | 
				
			||||||
  when: not kiwix_enabled
 | 
					
 | 
				
			||||||
 | 
					- name: Run /usr/bin/iiab-make-kiwix-lib to update {{ kiwix_library_xml }}    # /library/zims/library.xml
 | 
				
			||||||
 | 
					  command: /usr/bin/iiab-make-kiwix-lib
 | 
				
			||||||
 | 
					  when: kiwix_enabled
 | 
				
			||||||
 | 
					# The above stops then starts kiwix-serve.service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: Enable & Ensure 'kiwix-serve.service' is running
 | 
				
			||||||
 | 
					  systemd:
 | 
				
			||||||
 | 
					    name: kiwix-serve
 | 
				
			||||||
 | 
					    enabled: yes
 | 
				
			||||||
 | 
					    state: started    # Not needed...but can't hurt
 | 
				
			||||||
 | 
					  when: kiwix_enabled
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# TO DO: BOTH CRON ENTRIES BELOW *SHOULD* BE DELETED "when: not kiwix_enabled"
 | 
					# TO DO: BOTH CRON ENTRIES BELOW *SHOULD* BE DELETED "when: not kiwix_enabled"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,51 +30,41 @@
 | 
				
			||||||
    kiwix_src_file: "{{ kiwix_src_dir }}.tar.gz"
 | 
					    kiwix_src_file: "{{ kiwix_src_dir }}.tar.gz"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 1. PUT IN PLACE: ESSENTIAL DIRS, library.xml, test.zim
 | 
					# 1. PUT IN PLACE: /opt/iiab/downloads/kiwix-tools_linux-*.tar.gz, essential dirs, and test.zim if nec (library.xml is created later, by enable-or-disable.yml)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Download {{ iiab_download_url }}/{{ kiwix_src_file }} to /opt/iiab/downloads
 | 
					- name: Download {{ iiab_download_url }}/{{ kiwix_src_file }} to /opt/iiab/downloads
 | 
				
			||||||
  get_url:
 | 
					  get_url:
 | 
				
			||||||
    url: "{{ iiab_download_url }}/{{ kiwix_src_file }}"    # http://download.iiab.io/packages
 | 
					    url: "{{ iiab_download_url }}/{{ kiwix_src_file }}"    # http://download.iiab.io/packages
 | 
				
			||||||
    dest: "{{ downloads_dir }}/{{ kiwix_src_file }}"
 | 
					    dest: "{{ downloads_dir }}/{{ kiwix_src_file }}"    # /opt/iiab/downloads
 | 
				
			||||||
    timeout: "{{ download_timeout }}"
 | 
					    timeout: "{{ download_timeout }}"
 | 
				
			||||||
  when: internet_available
 | 
					  when: internet_available
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Create dir {{ iiab_zim_path }} and subdirs {content, index} for Kiwix ZIM files
 | 
					- name: "Create dirs, including parent dirs: {{ kiwix_path }}/bin (executables), {{ iiab_zim_path }}/content (ZIM files), {{ iiab_zim_path }}/index (legacy indexes)"
 | 
				
			||||||
  file:
 | 
					  file:
 | 
				
			||||||
    path: "{{ item }}"
 | 
					    path: "{{ item }}"
 | 
				
			||||||
    state: directory
 | 
					    state: directory
 | 
				
			||||||
  with_items:
 | 
					  with_items:
 | 
				
			||||||
    - "{{ iiab_zim_path }}"    # /library/zims
 | 
					    - "{{ kiwix_path }}/bin"           # /opt/iiab/kiwix
 | 
				
			||||||
    - "{{ iiab_zim_path }}/content"
 | 
					    - "{{ iiab_zim_path }}/content"    # /library/zims
 | 
				
			||||||
    - "{{ iiab_zim_path }}/index"
 | 
					    - "{{ iiab_zim_path }}/index"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Check for {{ kiwix_library_xml }}
 | 
					- name: Count *.zim files in {{ iiab_zim_path }}/content
 | 
				
			||||||
  stat:
 | 
					  find:
 | 
				
			||||||
    path: "{{ kiwix_library_xml }}"    # /library/zims/library.xml
 | 
					    paths: "{{ iiab_zim_path }}/content"
 | 
				
			||||||
  register: kiwix_xml
 | 
					    patterns: '*.zim'
 | 
				
			||||||
 | 
					  register: kiwix_zims
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Install stub /library/zims/library.xml from template, if one doesn't exist
 | 
					- name: If there were none, install {{ iiab_zim_path }}/content/test.zim
 | 
				
			||||||
  template:
 | 
					 | 
				
			||||||
    src: library.xml
 | 
					 | 
				
			||||||
    dest: "{{ kiwix_library_xml }}"
 | 
					 | 
				
			||||||
    force: no
 | 
					 | 
				
			||||||
  when: not kiwix_xml.stat.exists
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- name: Install {{ iiab_zim_path }}/content/test.zim
 | 
					 | 
				
			||||||
  copy:
 | 
					  copy:
 | 
				
			||||||
    src: test.zim
 | 
					    src: test.zim
 | 
				
			||||||
    dest: "{{ iiab_zim_path }}/content/test.zim"
 | 
					    dest: "{{ iiab_zim_path }}/content/test.zim"
 | 
				
			||||||
    force: no
 | 
					    #force: no
 | 
				
			||||||
 | 
					  when: kiwix_zims.matched == 0
 | 
				
			||||||
- name: Create {{ kiwix_path }}/bin directory
 | 
					 | 
				
			||||||
  file:
 | 
					 | 
				
			||||||
    path: "{{ kiwix_path }}/bin"    # /opt/iiab/kiwix
 | 
					 | 
				
			||||||
    state: directory
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 2. INSTALL KIWIX-TOOLS EXECUTABLES
 | 
					# 2. INSTALL KIWIX-TOOLS EXECUTABLES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Unarchive {{ kiwix_src_file }} to /tmp    # e.g. kiwix-tools_linux-armhf-0.6.1-1.tar.gz
 | 
					- name: Unarchive {{ kiwix_src_file }} to /tmp    # e.g. kiwix-tools_linux-armhf-3.1.2-3.tar.gz
 | 
				
			||||||
  unarchive:
 | 
					  unarchive:
 | 
				
			||||||
    src: "{{ downloads_dir }}/{{ kiwix_src_file }}"
 | 
					    src: "{{ downloads_dir }}/{{ kiwix_src_file }}"
 | 
				
			||||||
    dest: /tmp
 | 
					    dest: /tmp
 | 
				
			||||||
| 
						 | 
					@ -110,10 +100,14 @@
 | 
				
			||||||
    - { src: 'iiab-make-kiwix-lib', dest: '/usr/bin/iiab-make-kiwix-lib', mode: '0755' }
 | 
					    - { src: 'iiab-make-kiwix-lib', dest: '/usr/bin/iiab-make-kiwix-lib', mode: '0755' }
 | 
				
			||||||
    - { src: 'iiab-make-kiwix-lib3.py', dest: '/usr/bin/iiab-make-kiwix-lib.py', mode: '0755' }
 | 
					    - { src: 'iiab-make-kiwix-lib3.py', dest: '/usr/bin/iiab-make-kiwix-lib.py', mode: '0755' }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: "Install from template: Apache's kiwix.conf"
 | 
					- name: daemon_reload, so systemd (re)reads newly installed kiwix-serve.service
 | 
				
			||||||
 | 
					  systemd:
 | 
				
			||||||
 | 
					    daemon_reload: yes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: "Install from template: /etc/{{ apache_conf_dir }}/kiwix.conf"
 | 
				
			||||||
  template:
 | 
					  template:
 | 
				
			||||||
    src: kiwix.conf.j2
 | 
					    src: kiwix.conf.j2
 | 
				
			||||||
    dest: "/etc/{{ apache_conf_dir }}/kiwix.conf"
 | 
					    dest: "/etc/{{ apache_conf_dir }}/kiwix.conf"    # apache2/sites-available
 | 
				
			||||||
    #mode: '0644'
 | 
					    #mode: '0644'
 | 
				
			||||||
  when: apache_installed is defined
 | 
					  when: apache_installed is defined
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -122,6 +116,7 @@
 | 
				
			||||||
  include_tasks: kiwix-apk.yml
 | 
					  include_tasks: kiwix-apk.yml
 | 
				
			||||||
  when: kiwix_incl_apk
 | 
					  when: kiwix_incl_apk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 5. RECORD Kiwix AS INSTALLED
 | 
					# 5. RECORD Kiwix AS INSTALLED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: "Set 'kiwix_installed: True'"
 | 
					- name: "Set 'kiwix_installed: True'"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,10 +12,10 @@
 | 
				
			||||||
    msg: "PBX install cannot proceed, as Node.js is not installed."
 | 
					    msg: "PBX install cannot proceed, as Node.js is not installed."
 | 
				
			||||||
  when: nodejs_installed is undefined
 | 
					  when: nodejs_installed is undefined
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: FAIL (STOP THE INSTALL) IF 'nodejs_version != "10.x"'
 | 
					#- name: FAIL (STOP THE INSTALL) IF 'nodejs_version != "12.x"'
 | 
				
			||||||
  fail:
 | 
					#  fail:
 | 
				
			||||||
    msg: "PBX install cannot proceed, as it currently requires Node.js 10.x, whereas nodejs_version is set to {{ nodejs_version }}.  Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml, /etc/iiab/local_vars.yml, /opt/iiab/iiab/roles/nodejs, etc."
 | 
					#    msg: "PBX install cannot proceed, as it currently requires Node.js 12.x, whereas nodejs_version is set to {{ nodejs_version }}.  Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml, /etc/iiab/local_vars.yml, /opt/iiab/iiab/roles/nodejs, etc."
 | 
				
			||||||
  when: nodejs_version != "12.x"
 | 
					#  when: nodejs_version != "12.x"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: "Set 'apache_install: True' and 'apache_enabled: True'"
 | 
					- name: "Set 'apache_install: True' and 'apache_enabled: True'"
 | 
				
			||||||
  set_fact:
 | 
					  set_fact:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue