From 13bc1e960fe9c86206c46a379b485fd1a83f7133 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 16 May 2020 22:48:52 -0400 Subject: [PATCH] Reduce dependency on Apache in 9 playbooks --- roles/awstats/tasks/install.yml | 12 ++++++------ roles/calibre-web/tasks/install.yml | 4 ++-- roles/kalite/tasks/install.yml | 16 +++++++++------- roles/kiwix/tasks/install.yml | 10 ++++++++-- roles/nextcloud/tasks/install.yml | 2 +- roles/sugarizer/tasks/install.yml | 20 +++++++++----------- roles/usb_lib/tasks/install.yml | 2 +- roles/wordpress/tasks/install.yml | 2 +- roles/www_options/tasks/main.yml | 9 +++++---- 9 files changed, 42 insertions(+), 35 deletions(-) diff --git a/roles/awstats/tasks/install.yml b/roles/awstats/tasks/install.yml index a66324784..255698cd1 100644 --- a/roles/awstats/tasks/install.yml +++ b/roles/awstats/tasks/install.yml @@ -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: diff --git a/roles/calibre-web/tasks/install.yml b/roles/calibre-web/tasks/install.yml index 6c35db157..dee048b87 100644 --- a/roles/calibre-web/tasks/install.yml +++ b/roles/calibre-web/tasks/install.yml @@ -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: diff --git a/roles/kalite/tasks/install.yml b/roles/kalite/tasks/install.yml index 5f6c96632..473761d68 100644 --- a/roles/kalite/tasks/install.yml +++ b/roles/kalite/tasks/install.yml @@ -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: diff --git a/roles/kiwix/tasks/install.yml b/roles/kiwix/tasks/install.yml index d8b5c59c8..104d6bb7c 100644 --- a/roles/kiwix/tasks/install.yml +++ b/roles/kiwix/tasks/install.yml @@ -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 diff --git a/roles/nextcloud/tasks/install.yml b/roles/nextcloud/tasks/install.yml index 9ccaf8565..665ede20c 100644 --- a/roles/nextcloud/tasks/install.yml +++ b/roles/nextcloud/tasks/install.yml @@ -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 diff --git a/roles/sugarizer/tasks/install.yml b/roles/sugarizer/tasks/install.yml index 3645f1507..6a10b494a 100644 --- a/roles/sugarizer/tasks/install.yml +++ b/roles/sugarizer/tasks/install.yml @@ -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?! diff --git a/roles/usb_lib/tasks/install.yml b/roles/usb_lib/tasks/install.yml index 03eb685c6..afc33b53b 100644 --- a/roles/usb_lib/tasks/install.yml +++ b/roles/usb_lib/tasks/install.yml @@ -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 diff --git a/roles/wordpress/tasks/install.yml b/roles/wordpress/tasks/install.yml index e3f9bf2af..6fdd06fda 100644 --- a/roles/wordpress/tasks/install.yml +++ b/roles/wordpress/tasks/install.yml @@ -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 diff --git a/roles/www_options/tasks/main.yml b/roles/www_options/tasks/main.yml index c767298c2..b33b5c92b 100644 --- a/roles/www_options/tasks/main.yml +++ b/roles/www_options/tasks/main.yml @@ -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: