mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	Reduce dependency on Apache in 9 playbooks
This commit is contained in:
		
							parent
							
								
									83b44f0a89
								
							
						
					
					
						commit
						13bc1e960f
					
				
					 9 changed files with 42 additions and 35 deletions
				
			
		| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
# TO DO:
 | 
			
		||||
#
 | 
			
		||||
# - Prepare for a possible future w/o Apache by verifying/refining below...
 | 
			
		||||
#   - 5 'when: apache_install | bool'
 | 
			
		||||
#   - 5 'when: apache_installed is defined'
 | 
			
		||||
#   - 1 'when: nginx_install | bool'
 | 
			
		||||
#   - 8 core stanzas w/o such 'when:' clauses
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -19,11 +19,11 @@
 | 
			
		|||
      - libapache2-mod-authnz-external
 | 
			
		||||
      - apache2-utils
 | 
			
		||||
    state: present
 | 
			
		||||
  when: apache_install | bool
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
- name: Run 'a2enmod cgi' to enable cgi execution via Apache
 | 
			
		||||
  command: a2enmod cgi
 | 
			
		||||
  when: apache_install | bool
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
- name: Create directory... mkdir {{ apache_log_dir }}, recursively chown {{ apache_user }}:{{ apache_user }}, with chmod u+rw,g+r,g-w,o-rwx
 | 
			
		||||
  file:
 | 
			
		||||
| 
						 | 
				
			
			@ -34,7 +34,7 @@
 | 
			
		|||
    group: "{{ apache_user }}"
 | 
			
		||||
    mode: u+rw,g+r,g-w,o-rwx    # '0750' turned on too many x bits
 | 
			
		||||
    #force: yes
 | 
			
		||||
  when: apache_install | bool
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
- name: Create 2 directories... mkdir {{ awstats_data_dir }} (intermediate summary storage) and /usr/lib/cgi-bin/awstats, recursively chown {{ apache_user }}:{{ apache_user }}, with chmod u+rw,g+r,g-w,o-rwx
 | 
			
		||||
  file:
 | 
			
		||||
| 
						 | 
				
			
			@ -53,13 +53,13 @@
 | 
			
		|||
  template:
 | 
			
		||||
    src: apache-awstats.conf
 | 
			
		||||
    dest: "/etc/{{ apache_conf_dir }}/awstats.conf"    # apache2/sites-available on debuntu
 | 
			
		||||
  when: apache_install | bool
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
- name: Install /etc/logrotate.d/apache2 from template, to ensure logrotate doesn't make logs unreadable
 | 
			
		||||
  template:
 | 
			
		||||
    src: logrotate.d.apache2
 | 
			
		||||
    dest: /etc/logrotate.d/apache2
 | 
			
		||||
  when: apache_install | bool
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
- name: Does /etc/awstats/awstats.conf exist?
 | 
			
		||||
  stat:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,8 +22,8 @@
 | 
			
		|||
    mode: '0755'
 | 
			
		||||
  with_items:
 | 
			
		||||
    - "{{ calibreweb_home }}"         # /library/calibre-web
 | 
			
		||||
    - "{{ calibreweb_venv_path }}"    # /usr/local/calibre-web
 | 
			
		||||
    - "{{ calibreweb_config }}"       # /library/calibre-web/config
 | 
			
		||||
    - "{{ calibreweb_venv_path }}"    # /usr/local/calibre-web-py3
 | 
			
		||||
 | 
			
		||||
## TODO: Calibre-web future release might get into pypi https://github.com/janeczku/calibre-web/issues/456
 | 
			
		||||
- name: Clone i.e. download Calibre-Web ({{ calibreweb_version }}) from https://github.com/janeczku/calibre-web.git to {{ calibreweb_venv_path }}
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +61,7 @@
 | 
			
		|||
  template:
 | 
			
		||||
    src: calibre-web.conf.j2
 | 
			
		||||
    dest: "/etc/{{ apache_conf_dir }}/calibre-web.conf"    # apache2/sites-available on debuntu
 | 
			
		||||
  when: apache_install | bool
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
- name: Does /library/calibre-web/metadata.db exist?
 | 
			
		||||
  stat:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,18 +43,20 @@
 | 
			
		|||
    extra_args: "--no-cache-dir"
 | 
			
		||||
  when: internet_available | bool
 | 
			
		||||
 | 
			
		||||
- name: "Install from template: venv wrapper /usr/bin/kalite, systemd unit file kalite-serve.service, Apache's kalite.conf"
 | 
			
		||||
- name: "Install from templates: venv wrapper /usr/bin/kalite, systemd unit file kalite-serve.service"
 | 
			
		||||
  template:
 | 
			
		||||
    backup: no
 | 
			
		||||
    src: "{{ item.src }}"
 | 
			
		||||
    dest: "{{ item.dest }}"
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: "{{ item.mode }}"
 | 
			
		||||
  with_items:
 | 
			
		||||
    - { src: 'kalite.sh.j2', dest: '/usr/bin/kalite', mode: '0755'}
 | 
			
		||||
    - { src: 'kalite-serve.service.j2', dest: '/etc/systemd/system/kalite-serve.service', mode: '0644'}
 | 
			
		||||
    - { src: 'kalite.conf', dest: '/etc/{{ apache_conf_dir }}', mode: '0644'}
 | 
			
		||||
    - { src: 'kalite.sh.j2', dest: '/usr/bin/kalite', mode: '0755' }
 | 
			
		||||
    - { src: 'kalite-serve.service.j2', dest: '/etc/systemd/system/kalite-serve.service', mode: '0644' }
 | 
			
		||||
 | 
			
		||||
- name: "Install from template: /etc/{{ apache_conf_dir }}/kalite.conf"
 | 
			
		||||
  template:
 | 
			
		||||
    src: kalite.conf
 | 
			
		||||
    dest: "/etc/{{ apache_conf_dir }}"    # apache2/sites-available on debuntu
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
- name: Fix KA Lite bug in regex parsing ifconfig output, for @m-anish's network names that contain dashes, if Raspbian/Debian < 11 or Ubuntu < 20
 | 
			
		||||
  replace:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,7 +100,7 @@
 | 
			
		|||
 | 
			
		||||
# 4. INSTALL iiab-make-kiwix-lib*, kiwix-serve.service, kiwix.conf for Apache
 | 
			
		||||
 | 
			
		||||
- name: 'Install from templates: kiwix-serve.service, iiab-make-kiwix-lib, iiab-make-kiwix-lib.py, kiwix.conf'
 | 
			
		||||
- name: 'Install from templates: kiwix-serve.service, iiab-make-kiwix-lib, iiab-make-kiwix-lib.py'
 | 
			
		||||
  template:
 | 
			
		||||
    src: "{{ item.src }}"
 | 
			
		||||
    dest: "{{ item.dest }}"
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +109,13 @@
 | 
			
		|||
    - { 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-lib3.py', dest: '/usr/bin/iiab-make-kiwix-lib.py', mode: '0755' }
 | 
			
		||||
    - { src: 'kiwix.conf.j2', dest: '/etc/{{ apache_conf_dir }}/kiwix.conf', mode: '0644' }
 | 
			
		||||
 | 
			
		||||
- name: "Install from template: Apache's kiwix.conf"
 | 
			
		||||
  template:
 | 
			
		||||
    src: kiwix.conf.j2
 | 
			
		||||
    dest: "/etc/{{ apache_conf_dir }}/kiwix.conf"
 | 
			
		||||
    #mode: '0644'
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# 5. RECORD Kiwix AS INSTALLED
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,7 +109,7 @@
 | 
			
		|||
  template:
 | 
			
		||||
    src: nextcloud.conf.j2
 | 
			
		||||
    dest: "/etc/{{ apache_conf_dir }}/nextcloud.conf"    # apache2/sites-available on debuntu
 | 
			
		||||
  when: apache_install | bool
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# RECORD Nextcloud AS INSTALLED
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -148,18 +148,16 @@
 | 
			
		|||
 | 
			
		||||
# 5. CONFIG FILES
 | 
			
		||||
 | 
			
		||||
- name: "Install from templates: /etc/systemd/system/sugarizer.service, /etc/apache2/sites-available/sugarizer.conf"
 | 
			
		||||
- name: "Install from template: /etc/systemd/system/sugarizer.service"
 | 
			
		||||
  template:
 | 
			
		||||
    src: "{{ item.src }}"
 | 
			
		||||
    dest: "{{ item.dest }}"
 | 
			
		||||
    # owner: root
 | 
			
		||||
    # group: root
 | 
			
		||||
    # mode: '0644'
 | 
			
		||||
  with_items:
 | 
			
		||||
    - { src: 'sugarizer.service', dest: '/etc/systemd/system/sugarizer.service' }
 | 
			
		||||
    - { src: 'sugarizer.conf.j2', dest: "/etc/{{ apache_conf_dir }}/sugarizer.conf" }
 | 
			
		||||
    #- { src: 'sugarizer.ini.j2', dest: '{{ iiab_base }}/sugarizer-server/env/sugarizer.ini' }
 | 
			
		||||
    #- { src: 'sugarizer.js', dest: '{{ iiab_base }}/sugarizer-server' }
 | 
			
		||||
    src: sugarizer.service
 | 
			
		||||
    dest: /etc/systemd/system
 | 
			
		||||
 | 
			
		||||
- name: "Install from template: /etc/{{ apache_conf_dir }}/sugarizer.conf"
 | 
			
		||||
  template:
 | 
			
		||||
    src: sugarizer.conf.j2
 | 
			
		||||
    dest: "/etc/{{ apache_conf_dir }}/sugarizer.conf"    # apache2/sites-available
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
# 3 [WAS 4] STANZAS ADDED BELOW JAN/FEB 2019, HOPING THIS MIGHT "JUST WORK"
 | 
			
		||||
# WITH FUTURE UPGRADES BEYOND SUGARIZER 1.1?!
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@
 | 
			
		|||
  template:
 | 
			
		||||
    src: content_dir.conf
 | 
			
		||||
    dest: "/etc/{{ apache_conf_dir }}"    # apache2/sites-available on debuntu
 | 
			
		||||
  when: apache_install
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# RECORD 'USB_LIB' AS INSTALLED
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,7 +89,7 @@
 | 
			
		|||
  template:
 | 
			
		||||
    src: wordpress.conf.j2
 | 
			
		||||
    dest: "/etc/{{ apache_conf_dir }}/wordpress.conf"
 | 
			
		||||
  when: apache_enabled | bool
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# RECORD WordPress AS INSTALLED
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,12 +15,13 @@
 | 
			
		|||
# Used to be run by httpd/tasks/install.yml
 | 
			
		||||
- name: "IN CASE NGINX IS DISABLED: Enable IIAB pages via Apache (e.g. on port 80) if apache_install"
 | 
			
		||||
  include_tasks: roles/httpd/tasks/homepage.yml
 | 
			
		||||
  when: apache_install | bool
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
# Used to be run by nginx/tasks/install.yml
 | 
			
		||||
- name: Enable IIAB pages via NGINX (e.g. on port 80) if nginx_install
 | 
			
		||||
  include_tasks: roles/nginx/tasks/homepage.yml
 | 
			
		||||
  when: nginx_install | bool
 | 
			
		||||
  when: nginx_installed is defined
 | 
			
		||||
  #when: nginx_install | bool
 | 
			
		||||
 | 
			
		||||
- debug:
 | 
			
		||||
    msg: 'THE 3 ANSIBLE STANZAS BELOW ONLY RUN... when: (nginx_high_php_limits or moodle_install or nextcloud_install or pbx_install or wordpress_install) and nginx_enabled'
 | 
			
		||||
| 
						 | 
				
			
			@ -100,11 +101,11 @@
 | 
			
		|||
  when: internet_available and not nodocs
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: (Re)Start '{{ apache_service }}' systemd service, if apache_enabled
 | 
			
		||||
- name: (Re)Start '{{ apache_service }}' systemd service, if installed & enabled
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: "{{ apache_service }}"    # apache2 on debuntu
 | 
			
		||||
    state: restarted
 | 
			
		||||
  when: apache_enabled | bool
 | 
			
		||||
  when: apache_installed is defined and apache_enabled
 | 
			
		||||
 | 
			
		||||
- name: (Re)Start 'nginx' systemd service, if nginx_enabled
 | 
			
		||||
  systemd:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue