From d26d6fa4e0c0423e7c88261ce4ed11abb3e812c0 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 5 Sep 2019 05:30:20 -0500 Subject: [PATCH] awstats split and iiab_installed --- roles/awstats/tasks/enable.yml | 58 +++++++++++++++++++++++++++++++++ roles/awstats/tasks/install.yml | 5 +++ roles/awstats/tasks/main.yml | 20 +++--------- roles/munin/tasks/main.yml | 31 ++++++++++++++++++ 4 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 roles/awstats/tasks/enable.yml diff --git a/roles/awstats/tasks/enable.yml b/roles/awstats/tasks/enable.yml new file mode 100644 index 000000000..9aab8dc8d --- /dev/null +++ b/roles/awstats/tasks/enable.yml @@ -0,0 +1,58 @@ +- name: Create symlink awstats.conf from sites-enabled to sites-available (debuntu) + file: + src: /etc/apache2/sites-available/awstats.conf + path: /etc/apache2/sites-enabled/awstats.conf + state: link + when: awstats_enabled and is_debuntu + +- name: Remove symlink from sites-enabled, to disable AWStats (debuntu) + file: + path: /etc/apache2/sites-enabled/awstats.conf + state: absent + when: not awstats_enabled and is_debuntu + +- name: Restart Apache service ({{ apache_service }}) + systemd: + name: "{{ apache_service }}" + state: restarted + +- 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: Add 'awstats' variable values to {{ iiab_ini_file }} + ini_file: + path: "{{ iiab_ini_file }}" + section: awstats + option: "{{ item.option }}" + value: "{{ item.value }}" + with_items: + - option: name + value: AWStats + - option: description + value: '"AWStats (originally known as Advanced Web Statistics) is a package written in Perl which generates static or dynamic html summaries based upon web server logs."' + - option: installed + value: "{{ awstats_install }}" + - option: enabled + value: "{{ awstats_enabled }}" + diff --git a/roles/awstats/tasks/install.yml b/roles/awstats/tasks/install.yml index 8f443c00c..bdcea70f8 100644 --- a/roles/awstats/tasks/install.yml +++ b/roles/awstats/tasks/install.yml @@ -93,3 +93,8 @@ - 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: Add 'awstats_installed' variable values to {{ iiab_installed }} + ini_file: + path: "{{ iiab_installed }}" + value: awstats_installed diff --git a/roles/awstats/tasks/main.yml b/roles/awstats/tasks/main.yml index 26b53df88..b249b6a22 100644 --- a/roles/awstats/tasks/main.yml +++ b/roles/awstats/tasks/main.yml @@ -1,19 +1,7 @@ - name: Install AWStats if awstats_install include_tasks: install.yml - when: awstats_install | bool + when: awstats_install | bool and not awstats_installed is defined -- name: Add 'awstats' variable values to {{ iiab_ini_file }} - ini_file: - path: "{{ iiab_ini_file }}" - section: awstats - option: "{{ item.option }}" - value: "{{ item.value }}" - with_items: - - option: name - value: AWStats - - option: description - value: '"AWStats (originally known as Advanced Web Statistics) is a package written in Perl which generates static or dynamic html summaries based upon web server logs."' - - option: installed - value: "{{ awstats_install }}" - - option: enabled - value: "{{ awstats_enabled }}" +- name: Enable AWStats + include_tasks: enable.yml + when: awstats_install | bool or awstats_installed is defined diff --git a/roles/munin/tasks/main.yml b/roles/munin/tasks/main.yml index 86c928419..054d0de78 100644 --- a/roles/munin/tasks/main.yml +++ b/roles/munin/tasks/main.yml @@ -21,6 +21,7 @@ - download when: not is_debuntu +##### nginx only ##### - name: Install /etc/munin/munin.conf and Apache's munin24.conf, from templates template: src: "{{ item.src }}" @@ -68,6 +69,36 @@ - /usr/share/munin/plugins/mysql_threads when: mysql_enabled | bool +- name: Create symlink for awstats.pl from cgi-bin/awstats/awstats.pl to ../ so that the 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 + 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: Add 'munin' variable values to {{ iiab_ini_file }} ini_file: path: "{{ iiab_ini_file }}"