1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/awstats/tasks/install.yml

115 lines
3.9 KiB
YAML
Raw Normal View History

2020-02-02 12:55:43 +00:00
# TO DO:
#
# - Prepare for a possible future w/o Apache by verifying/refining below...
# - 5 'when: apache_installed is defined'
2020-02-02 12:55:43 +00:00
# - 1 'when: nginx_install | bool'
# - 8 core stanzas w/o such 'when:' clauses
2018-10-31 08:59:36 +00:00
- name: 'Install 3 packages: awstats, openssl, pwauth'
package:
2018-10-28 18:15:53 +00:00
name:
- awstats
- pwauth
- openssl
state: present
2017-05-27 18:09:50 +00:00
2020-01-11 22:56:09 +00:00
- name: 'Install 2 packages: apache2-utils, libapache2-mod-authnz-external'
package:
2018-10-28 18:15:53 +00:00
name:
- libapache2-mod-authnz-external
- apache2-utils
state: present
when: apache_installed is defined
2017-05-27 18:09:50 +00:00
2020-02-02 12:55:43 +00:00
- name: Run 'a2enmod cgi' to enable cgi execution via Apache
2017-05-27 18:09:50 +00:00
command: a2enmod cgi
when: apache_installed is defined
2017-05-27 18:09:50 +00:00
- name: Create directory... mkdir {{ apache_log_dir }}, recursively chown {{ apache_user }}:{{ apache_user }}, with chmod u+rw,g+r,g-w,o-rwx
file:
2020-02-02 12:55:43 +00:00
state: directory
recurse: yes
path: "{{ apache_log_dir }}" # /var/log/apache2 on debuntu
owner: "{{ apache_user }}" # www-data on debuntu
group: "{{ apache_user }}"
2020-02-02 12:55:43 +00:00
mode: u+rw,g+r,g-w,o-rwx # '0750' turned on too many x bits
#force: yes
when: apache_installed is defined
2020-02-02 12:55:43 +00:00
- 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
2020-02-02 12:55:43 +00:00
file:
state: directory
recurse: yes
2020-02-02 12:55:43 +00:00
path: "{{ item }}"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
mode: u+rw,g+r,g-w,o-rwx # '0750' turned on too many x bits
#force: yes
2017-05-27 18:09:50 +00:00
with_items:
2020-02-02 12:55:43 +00:00
- "{{ awstats_data_dir }}" # /library/awstats
2020-01-11 22:56:09 +00:00
- /usr/lib/cgi-bin/awstats # create backward compatible path for awstats
2017-05-27 18:09:50 +00:00
2020-01-30 09:00:00 +00:00
- name: Install /etc/{{ apache_conf_dir }}/awstats.conf from template
template:
2020-01-11 22:56:09 +00:00
src: apache-awstats.conf
dest: "/etc/{{ apache_conf_dir }}/awstats.conf" # apache2/sites-available on debuntu
when: apache_installed is defined
2017-05-27 18:09:50 +00:00
2020-01-11 22:56:09 +00:00
- 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_installed is defined
2017-05-27 18:09:50 +00:00
2020-01-11 22:56:09 +00:00
- name: Does /etc/awstats/awstats.conf exist?
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
2020-01-11 22:56:09 +00:00
- name: Symlink /usr/lib/cgi-bin/awstats/awstats.pl -> /usr/lib/cgi-bin/awstats.pl so old Apache links to awstats will work after change to NGINX
file:
2019-10-15 17:42:04 +00:00
src: /usr/lib/cgi-bin/awstats.pl
path: /usr/lib/cgi-bin/awstats/awstats.pl
state: link
2017-05-27 18:09:50 +00:00
2020-01-11 22:56:09 +00:00
- name: Install /etc/awstats/awstats.schoolserver.conf from template
template:
src: awstats.schoolserver.conf.j2
dest: /etc/awstats/awstats.schoolserver.conf
2017-05-27 18:09:50 +00:00
2020-01-11 22:56:09 +00:00
- name: Symlink /etc/awstats/awstats.conf -> /etc/awstats/awstats.schoolserver.conf for access by IP address
file:
src: /etc/awstats/awstats.schoolserver.conf
2018-10-28 18:15:53 +00:00
path: /etc/awstats/awstats.conf
state: link
2017-05-27 18:09:50 +00:00
2020-01-11 22:56:09 +00:00
# - 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
2017-05-27 18:09:50 +00:00
2020-02-02 12:55:43 +00:00
- name: "Summarize logs up to now: /usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=schoolserver -update"
2017-05-27 18:09:50 +00:00
shell: /usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=schoolserver -update
2020-02-02 12:55:43 +00:00
- name: Install /etc/nginx/cgi-bin.php from template
template:
src: cgi-bin.php
dest: /etc/nginx/
when: nginx_install | bool
2019-09-05 10:30:20 +00:00
2020-01-30 09:00:00 +00:00
# RECORD AWStats AS INSTALLED
- name: "Set 'awstats_installed: True'"
set_fact:
awstats_installed: True
- name: "Add 'awstats_installed: True' to {{ iiab_state_file }}"
2019-09-09 17:14:13 +00:00
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2019-09-09 17:14:13 +00:00
regexp: '^awstats_installed'
2019-10-07 17:11:21 +00:00
line: 'awstats_installed: True'