2018-10-31 08:59:36 +00:00
|
|
|
- name: 'Install 3 packages: awstats, openssl, pwauth'
|
2018-02-11 22:01:40 +00:00
|
|
|
package:
|
2018-10-28 18:15:53 +00:00
|
|
|
name:
|
|
|
|
- awstats
|
|
|
|
- pwauth
|
|
|
|
- openssl
|
2018-02-11 22:01:40 +00:00
|
|
|
state: present
|
2017-05-27 18:09:50 +00:00
|
|
|
tags:
|
|
|
|
- download
|
|
|
|
|
2018-10-31 08:59:36 +00:00
|
|
|
- name: 'Install 2 packages: apache2-utils, libapache2-mod-authnz-external (debuntu)'
|
2018-02-11 22:01:40 +00:00
|
|
|
package:
|
2018-10-28 18:15:53 +00:00
|
|
|
name:
|
|
|
|
- libapache2-mod-authnz-external
|
|
|
|
- apache2-utils
|
2018-02-11 22:01:40 +00:00
|
|
|
state: present
|
2019-05-24 22:33:10 +00:00
|
|
|
when: is_debuntu | bool
|
2017-05-27 18:09:50 +00:00
|
|
|
tags:
|
|
|
|
- download
|
|
|
|
|
2018-02-11 22:01:40 +00:00
|
|
|
- name: Enable cgi execution (debuntu)
|
2017-05-27 18:09:50 +00:00
|
|
|
command: a2enmod cgi
|
2019-05-24 22:33:10 +00:00
|
|
|
when: is_debuntu | bool
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-10-31 08:59:36 +00:00
|
|
|
- name: 'Mandate {{ apache_user }}:{{ apache_user }} perm 0750 dirs: {{ awstats_data_dir }} (intermediate summary storage) & {{ apache_log_dir }}' # /library/awstats & /var/log/apache2 typically
|
2018-02-11 22:01:40 +00:00
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
mode: 0750
|
|
|
|
owner: "{{ apache_user }}"
|
|
|
|
group: "{{ apache_user }}"
|
|
|
|
state: directory
|
2019-05-24 23:29:41 +00:00
|
|
|
recurse: yes
|
|
|
|
force: yes
|
2017-05-27 18:09:50 +00:00
|
|
|
with_items:
|
|
|
|
- "{{ awstats_data_dir }}"
|
|
|
|
- "{{ apache_log_dir }}"
|
|
|
|
|
2018-10-28 18:15:53 +00:00
|
|
|
- name: Install Apache's awstats.conf from template (debuntu)
|
2018-02-11 22:01:40 +00:00
|
|
|
template:
|
|
|
|
src: apache.conf
|
|
|
|
dest: "/etc/{{ apache_config_dir }}/awstats.conf"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2017-05-27 23:10:45 +00:00
|
|
|
when: awstats_enabled and is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-10-28 18:15:53 +00:00
|
|
|
- name: Install Apache's awstats.conf from template (OS's other than debuntu)
|
2018-02-11 22:01:40 +00:00
|
|
|
template:
|
|
|
|
src: apache-awstats.conf
|
|
|
|
dest: "/etc/{{ apache_config_dir }}/awstats.conf"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2017-05-27 23:10:45 +00:00
|
|
|
when: awstats_enabled and not is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-10-28 18:15:53 +00:00
|
|
|
- name: Ensure logrotate doesn't make logs unreadable (debuntu)
|
2018-02-11 22:01:40 +00:00
|
|
|
template:
|
|
|
|
src: logrotate.d.apache2
|
|
|
|
dest: /etc/logrotate.d/apache2
|
2019-05-24 22:33:10 +00:00
|
|
|
when: is_debuntu | bool
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-10-28 18:15:53 +00:00
|
|
|
- name: Check if package installed /etc/awstats/awstats.conf
|
2018-02-11 22:01:40 +00:00
|
|
|
stat:
|
|
|
|
path: /etc/awstats/awstats.conf
|
2017-05-27 18:09:50 +00:00
|
|
|
register: awstats
|
|
|
|
|
2018-10-28 18:15:53 +00:00
|
|
|
- name: If so, move it aside to /etc/awstats/awstats.conf.dist
|
2017-05-27 18:09:50 +00:00
|
|
|
command: mv /etc/awstats/awstats.conf /etc/awstats/awstats.conf.dist
|
|
|
|
when: awstats.stat.islnk is defined and not awstats.stat.islnk
|
|
|
|
|
2018-10-28 18:15:53 +00:00
|
|
|
- name: Create symlink awstats.conf from sites-enabled to sites-available (debuntu)
|
2018-02-11 22:01:40 +00:00
|
|
|
file:
|
|
|
|
src: /etc/apache2/sites-available/awstats.conf
|
|
|
|
path: /etc/apache2/sites-enabled/awstats.conf
|
|
|
|
state: link
|
2017-05-27 23:10:45 +00:00
|
|
|
when: awstats_enabled and is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-10-28 18:15:53 +00:00
|
|
|
- name: Remove symlink from sites-enabled, to disable AWStats (debuntu)
|
2018-02-11 22:01:40 +00:00
|
|
|
file:
|
|
|
|
path: /etc/apache2/sites-enabled/awstats.conf
|
|
|
|
state: absent
|
2017-05-27 23:10:45 +00:00
|
|
|
when: not awstats_enabled and is_debuntu
|
2019-02-03 01:23:39 +00:00
|
|
|
|
|
|
|
- name: Restart Apache service ({{ apache_service }})
|
|
|
|
systemd:
|
|
|
|
name: "{{ apache_service }}"
|
|
|
|
state: restarted
|
|
|
|
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-10-28 18:15:53 +00:00
|
|
|
- name: Install /etc/awstats/awstats.schoolserver.conf
|
2018-02-11 22:01:40 +00:00
|
|
|
template:
|
|
|
|
src: awstats.schoolserver.conf.j2
|
|
|
|
dest: /etc/awstats/awstats.schoolserver.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2019-05-24 22:33:10 +00:00
|
|
|
when: awstats_enabled | bool
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-10-28 18:15:53 +00:00
|
|
|
- name: Create a symlink /etc/awstats/awstats.conf for access by IP address
|
2018-02-11 22:01:40 +00:00
|
|
|
file:
|
|
|
|
src: /etc/awstats/awstats.schoolserver.conf
|
2018-10-28 18:15:53 +00:00
|
|
|
path: /etc/awstats/awstats.conf
|
2018-02-11 22:01:40 +00:00
|
|
|
state: link
|
2019-05-24 22:33:10 +00:00
|
|
|
when: awstats_enabled | bool
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-11-10 20:33:19 +00:00
|
|
|
- name: On first enabling of AWStats, summarize httpd logs up to now (OS's other than debuntu)
|
2017-05-27 18:09:50 +00:00
|
|
|
shell: /bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=schoolserver -update
|
2017-05-27 23:10:45 +00:00
|
|
|
when: awstats_enabled and not is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-11-10 20:33:19 +00:00
|
|
|
- name: On first enabling of AWStats, summarize httpd logs up to now (debuntu)
|
2017-05-27 18:09:50 +00:00
|
|
|
shell: /usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=schoolserver -update
|
2017-05-27 23:10:45 +00:00
|
|
|
when: awstats_enabled and is_debuntu
|