diff --git a/roles/awstats/tasks/enable.yml b/roles/awstats/tasks/enable.yml index a99e94c19..a80db27db 100644 --- a/roles/awstats/tasks/enable.yml +++ b/roles/awstats/tasks/enable.yml @@ -1,44 +1,45 @@ -- name: Create symlink awstats.conf from sites-enabled to sites-available (debuntu) +- name: Create symlink awstats.conf from sites-enabled to sites-available (Apache) file: src: /etc/apache2/sites-available/awstats.conf path: /etc/apache2/sites-enabled/awstats.conf state: link - when: awstats_enabled and is_debuntu + when: awstats_enabled and not nginx_enabled -- name: Remove symlink from sites-enabled, to disable AWStats (debuntu) +- name: Remove symlink from sites-enabled, to disable AWStats (Apache) file: path: /etc/apache2/sites-enabled/awstats.conf state: absent - when: not awstats_enabled and is_debuntu + when: not awstats_enabled or nginx_enabled + +- name: Install nginx's files from template + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: root + group: root + mode: 0644 + with_items: + - { src: "awstats-nginx.conf", dest: "/etc/nginx/conf.d/" } + - { src: "cgi-bin.php", dest: "/etc/nginx/" } + when: awstats_enabled and nginx_enabled + +- name: Remove /etc/nginx/conf.d/awstats-nginx.conf + file: + path: /etc/nginx/conf.d/awstats-nginx.conf + state: absent + when: not awstats_enabled - name: Restart Apache service ({{ apache_service }}) systemd: name: "{{ apache_service }}" state: restarted + when: awstats_enabled and not nginx_enabled -- name: Install /etc/awstats/awstats.schoolserver.conf - template: - src: awstats.schoolserver.conf.j2 - dest: /etc/awstats/awstats.schoolserver.conf - owner: root - group: root - mode: 0644 - when: awstats_enabled | bool - -- name: Create a symlink /etc/awstats/awstats.conf for access by IP address - file: - src: /etc/awstats/awstats.schoolserver.conf - path: /etc/awstats/awstats.conf - state: link - when: awstats_enabled | bool - -- name: On first enabling of AWStats, summarize httpd logs up to now (OS's other than debuntu) - shell: /bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=schoolserver -update - when: awstats_enabled and not is_debuntu - -- name: On first enabling of AWStats, summarize httpd logs up to now (debuntu) - shell: /usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=schoolserver -update - when: awstats_enabled and is_debuntu +- name: Restart nginx service + systemd: + name: nginx + state: restarted + when: awstats_enabled and nginx_enabled - name: Add 'awstats' variable values to {{ iiab_ini_file }} ini_file: @@ -55,4 +56,3 @@ value: "{{ awstats_install }}" - option: enabled value: "{{ awstats_enabled }}" - diff --git a/roles/awstats/tasks/install.yml b/roles/awstats/tasks/install.yml index 580dcf807..ca62368e0 100644 --- a/roles/awstats/tasks/install.yml +++ b/roles/awstats/tasks/install.yml @@ -36,7 +36,7 @@ - "{{ apache_log_dir }}" - /usr/lib/cgi-bin/awstats # create backward compatible path for awstats -- name: Install nginx's awstats.conf from template (debuntu) +- name: Install Apache's awstats.conf from template (debuntu) template: src: "{{ item.src }}" dest: "{{ item.dest }}" @@ -44,9 +44,9 @@ group: root mode: 0644 with_items: - - { src: "awstats-nginx.conf", dest: "/etc/nginx/conf.d/" } - - { src: "cgi-bin.php", dest: "/etc/nginx/" } -# - { src: "apache-awstats.conf", dest: "/etc/{{ apache_config_dir }}/awstats.conf" } +# - { src: "awstats-nginx.conf", dest: "/etc/nginx/conf.d/" } +# - { src: "cgi-bin.php", dest: "/etc/nginx/" } + - { src: "apache-awstats.conf", dest: "/etc/{{ apache_config_dir }}/awstats.conf" } when: awstats_enabled and is_debuntu - name: Ensure logrotate doesn't make logs unreadable (debuntu) diff --git a/roles/nginx/tasks/disable.yml b/roles/nginx/tasks/disable.yml index e6e2dd7e7..12034202d 100644 --- a/roles/nginx/tasks/disable.yml +++ b/roles/nginx/tasks/disable.yml @@ -22,3 +22,6 @@ - name: Enable Sugarizer for Apache command: a2ensite sugarizer.conf +- name: Enable AWStats for Apache + command: a2ensite awstats.conf + diff --git a/roles/nginx/tasks/only_nginx.yml b/roles/nginx/tasks/only_nginx.yml index dce442d5b..5024f8e89 100644 --- a/roles/nginx/tasks/only_nginx.yml +++ b/roles/nginx/tasks/only_nginx.yml @@ -1,3 +1,26 @@ +- name: Remove symlink /etc/apache2/sites-enabled/awstats.conf + file: + path: /etc/apache2/sites-enabled/awstats.conf + state: absent + +- name: Install nginx support for awstats if awstats_enabled + copy: + backup: no + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: "{{ item.mode }}" + owner: root + group: root + with_items: + - { src: 'roles/awstats/templates/awstats-nginx.conf', dest: '/etc/nginx/conf.d/kiwix-nginx.conf' , mode: '0644' } + when: awstats_enabled + +- name: Remove nginx support for kiwix + file: + path: /etc/nginx/conf.d/awstats-nginx.conf + state: absent + when: not awstats_enabled + - name: Remove symlink /etc/apache2/sites-enabled/kiwix.conf file: path: /etc/apache2/sites-enabled/kiwix.conf