mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 11:42:08 +00:00
114 lines
3.9 KiB
YAML
114 lines
3.9 KiB
YAML
# TO DO:
|
|
#
|
|
# - Prepare for a possible future w/o Apache by verifying/refining below...
|
|
# - 5 'when: apache_install | bool'
|
|
# - 1 'when: nginx_install | bool'
|
|
# - 8 core stanzas w/o such 'when:' clauses
|
|
|
|
- name: 'Install 3 packages: awstats, openssl, pwauth'
|
|
package:
|
|
name:
|
|
- awstats
|
|
- pwauth
|
|
- openssl
|
|
state: present
|
|
|
|
- name: 'Install 2 packages: apache2-utils, libapache2-mod-authnz-external'
|
|
package:
|
|
name:
|
|
- libapache2-mod-authnz-external
|
|
- apache2-utils
|
|
state: present
|
|
when: apache_install | bool
|
|
|
|
- name: Run 'a2enmod cgi' to enable cgi execution via Apache
|
|
command: a2enmod cgi
|
|
when: apache_install | bool
|
|
|
|
- name: Create directory... mkdir {{ apache_log_dir }}, recursively chown {{ apache_user }}:{{ apache_user }}, with chmod u+rw,g+r,g-w,o-rwx
|
|
file:
|
|
state: directory
|
|
recurse: yes
|
|
path: "{{ apache_log_dir }}" # /var/log/apache2 on debuntu
|
|
owner: "{{ apache_user }}" # www-data on debuntu
|
|
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
|
|
|
|
- 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:
|
|
state: directory
|
|
recurse: yes
|
|
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
|
|
with_items:
|
|
- "{{ awstats_data_dir }}" # /library/awstats
|
|
- /usr/lib/cgi-bin/awstats # create backward compatible path for awstats
|
|
|
|
- name: Install /etc/{{ apache_conf_dir }}/awstats.conf from template
|
|
template:
|
|
src: apache-awstats.conf
|
|
dest: "/etc/{{ apache_conf_dir }}/awstats.conf" # apache2/sites-available on debuntu
|
|
when: apache_install | bool
|
|
|
|
- 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
|
|
|
|
- name: Does /etc/awstats/awstats.conf exist?
|
|
stat:
|
|
path: /etc/awstats/awstats.conf
|
|
register: awstats
|
|
|
|
- name: If so, move it aside to /etc/awstats/awstats.conf.dist
|
|
command: mv /etc/awstats/awstats.conf /etc/awstats/awstats.conf.dist
|
|
when: awstats.stat.islnk is defined and not awstats.stat.islnk
|
|
|
|
- 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:
|
|
src: /usr/lib/cgi-bin/awstats.pl
|
|
path: /usr/lib/cgi-bin/awstats/awstats.pl
|
|
state: link
|
|
|
|
- name: Install /etc/awstats/awstats.schoolserver.conf from template
|
|
template:
|
|
src: awstats.schoolserver.conf.j2
|
|
dest: /etc/awstats/awstats.schoolserver.conf
|
|
|
|
- name: Symlink /etc/awstats/awstats.conf -> /etc/awstats/awstats.schoolserver.conf for access by IP address
|
|
file:
|
|
src: /etc/awstats/awstats.schoolserver.conf
|
|
path: /etc/awstats/awstats.conf
|
|
state: link
|
|
|
|
# - 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: "Summarize logs up to now: /usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=schoolserver -update"
|
|
shell: /usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=schoolserver -update
|
|
|
|
- name: Install /etc/nginx/cgi-bin.php from template
|
|
template:
|
|
src: cgi-bin.php
|
|
dest: /etc/nginx/
|
|
when: nginx_install | bool
|
|
|
|
|
|
# RECORD AWStats AS INSTALLED
|
|
|
|
- name: "Set 'awstats_installed: True'"
|
|
set_fact:
|
|
awstats_installed: True
|
|
|
|
- name: "Add 'awstats_installed: True' to {{ iiab_state_file }}"
|
|
lineinfile:
|
|
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
|
regexp: '^awstats_installed'
|
|
line: 'awstats_installed: True'
|