From 61b5800c199a362f77f6233bab35e737494e4b29 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Jan 2020 00:22:47 -0600 Subject: [PATCH] calibre-web - softcode nginx_config_dir, add disable logic --- roles/calibre-web/tasks/enable.yml | 40 ++++++++++++++---------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/roles/calibre-web/tasks/enable.yml b/roles/calibre-web/tasks/enable.yml index 244c8b942..898a08697 100644 --- a/roles/calibre-web/tasks/enable.yml +++ b/roles/calibre-web/tasks/enable.yml @@ -4,17 +4,7 @@ daemon_reload: yes enabled: yes state: restarted - when: calibreweb_enabled | bool - -# Default: http://box/books -# SEE ALSO: https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy -- name: Enable http://box{{ calibreweb_url1 }}, http://box{{ calibreweb_url2 }}, http://box{{ calibreweb_url3 }} with Apache - command: a2ensite calibre-web.conf - when: calibreweb_enabled | bool - -#- name: Restart Apache after enabling calibre-web httpd2 site -# command: apachectl -k graceful -# when: calibreweb_enabled | bool + when: calibreweb_enabled - name: Disable 'calibre-web' systemd service systemd: @@ -24,15 +14,17 @@ state: stopped when: not calibreweb_enabled +# Default: http://box/books +# SEE ALSO: https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy +- name: Enable http://box{{ calibreweb_url1 }}, http://box{{ calibreweb_url2 }}, http://box{{ calibreweb_url3 }} with Apache + command: a2ensite calibre-web.conf + when: calibreweb_enabled and not nginx_enabled + - name: Disable http://box{{ calibreweb_url1 }}, http://box{{ calibreweb_url2 }}, http://box{{ calibreweb_url3 }} with Apache command: a2dissite calibre-web.conf - when: not calibreweb_enabled or nginx_enabled | bool + when: not calibreweb_enabled or nginx_enabled | bool and apache_install -#- name: Restart Apache after disabling calibre-web httpd2 site -# command: apachectl -k graceful -# when: not calibreweb_enabled - -- name: Install /etc/nginx/conf.d/calibre-web-nginx.conf +- name: Install {{ nginx_config_dir }}/calibre-web-nginx.conf template: src: "{{ item.src }}" dest: "{{ item.dest }}" @@ -40,20 +32,26 @@ owner: root group: root with_items: - - { src: 'calibre-web-nginx.conf.j2', dest: '/etc/nginx/conf.d/calibre-web-nginx.conf', mode: '0644' } - when: calibreweb_enabled | bool and nginx_enabled | bool + - { src: 'calibre-web-nginx.conf.j2', dest: '{{ nginx_config_dir }}/calibre-web-nginx.conf', mode: '0644' } + when: calibreweb_enabled and nginx_enabled + +- name: Remove {{ nginx_config_dir }}/calibre-web-nginx.conf + file: + path: {{ nginx_config_dir }}/calibre-web-nginx.conf + state: absent + when: not calibreweb_enabled and nginx_enabled - name: Restart nginx systemd service systemd: name: nginx state: restarted - when: calibreweb_enabled | bool and nginx_enabled | bool + when: calibreweb_enabled and nginx_enabled - name: Restart Apache systemd service ({{ apache_service }}) systemd: name: "{{ apache_service }}" # httpd or apache2 state: restarted - when: not nginx_enabled | bool + when: not nginx_enabled - name: Add 'calibre-web' variable values to {{ iiab_ini_file }} ini_file: