munin: fix cgi graph generation #163

Merged
mg merged 47 commits from mchmod into master 2024-08-21 20:54:49 +02:00
4 changed files with 81 additions and 39 deletions

View file

@ -42,7 +42,7 @@ munin_node_bind_port: "4949"
munin_node_allowed_cidrs: [127.0.0.1] munin_node_allowed_cidrs: [127.0.0.1]
### mgrote_munin_master ### mgrote_munin_master
munin_mode: cron # or cgi munin_mode: cgi # or cron
munin_mail_user: munin@mgrote.net munin_mail_user: munin@mgrote.net
munin_mail_server: "{{ postfix_smtp_server }}" munin_mail_server: "{{ postfix_smtp_server }}"
munin_mail_port: "{{ 1025 }}" munin_mail_port: "{{ 1025 }}"

View file

@ -14,12 +14,6 @@ munin_packages:
- s-nail - s-nail
- libfile-readbackwards-perl - libfile-readbackwards-perl
munin_servername: "{{ ansible_fqdn }}.mgrote.net" munin_servername: "{{ ansible_fqdn }}.mgrote.net"
munin_dirs:
- /var/run/munin
- /etc/munin/plugins
- /var/cache/munin/www
- /var/lib/munin
- /var/cache/munin
munin_server_plugins: munin_server_plugins:
- munin_stats - munin_stats
- munin_update - munin_update

View file

@ -7,21 +7,48 @@
- name: Ensure needed dirs exists - name: Ensure needed dirs exists
ansible.builtin.file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item.name }}"
state: directory state: directory
mode: '0755' mode: "{{ item.mode }}"
owner: munin owner: "{{ item.owner }}"
group: munin group: "{{ item.group }}"
loop: "{{ munin_dirs }}" recurse: "{{ item.recurse }}"
loop:
- name: Ensure permissions are set - name: /var/run/munin
ansible.builtin.file: mode: '0755'
path: /var/lib/munin/cgi-tmp owner: munin
mode: 'ugo+rw' group: munin
state: directory recurse: false
owner: munin - name: /var/lib/munin-node/plugin-state
group: munin mode: '0775'
recurse: true owner: munin
group: munin
recurse: false
- name: /etc/munin/plugins
mode: '0755'
owner: munin
group: munin
recurse: false
- name: /var/cache/munin/www
mode: '0755'
owner: munin
group: root
recurse: false
- name: /var/lib/munin
mode: '0755'
owner: munin
group: munin
recurse: false
- name: /var/cache/munin
mode: '0755'
owner: root
group: root
recurse: false
- name: /var/lib/munin/cgi-tmp # TODO, ist immer changed
mode: "0775"
owner: munin
group: www-data
recurse: true
- name: Template apache config - name: Template apache config
ansible.builtin.template: ansible.builtin.template:
@ -32,10 +59,17 @@
group: root group: root
notify: "restart apache2" notify: "restart apache2"
- name: Enable fgcid - name: "apache2: enable rewrite"
community.general.apache2_module:
state: present
name: rewrite
notify: "restart apache2"
- name: "apache2: enable rewrite"
community.general.apache2_module: community.general.apache2_module:
state: present state: present
name: fcgid name: fcgid
notify: "restart apache2"
- name: Template munin-server plugins - name: Template munin-server plugins
ansible.builtin.template: ansible.builtin.template:
@ -61,6 +95,7 @@
line: "*/5 * * * * munin if [ -x /usr/bin/munin-cron ]; then /usr/bin/munin-cron; fi" line: "*/5 * * * * munin if [ -x /usr/bin/munin-cron ]; then /usr/bin/munin-cron; fi"
create: true create: true
mode: '0644' mode: '0644'
notify: "restart munin"
- name: check if munin has been run - name: check if munin has been run
ansible.builtin.stat: ansible.builtin.stat:

View file

@ -1,24 +1,37 @@
<VirtualHost *:80> <VirtualHost *:80>
ServerName {{ munin_servername }} ServerName {{ munin_servername }}
# Redirect requests without /munin to /munin DocumentRoot /var/www
RedirectMatch ^/$ /munin/
# Existing configuration for serving /munin # Rewrite rules to serve traffic from the root instead of /munin-cgi
Alias /munin /var/cache/munin/www RewriteEngine On
<Directory /var/cache/munin/www> # Static files
Require all granted RewriteRule ^/favicon.ico /var/cache/munin/www/static/favicon.ico [L]
Options None RewriteRule ^/static/(.*) /var/cache/munin/www/static/$1 [L]
# HTML
RewriteRule ^(/.*\.html)?$ /munin-cgi/munin-cgi-html/$1 [PT]
# Images
RewriteRule ^/munin-cgi/munin-cgi-graph/(.*) /$1
RewriteCond %{REQUEST_URI} !^/static
RewriteRule ^/(.*.png)$ /munin-cgi/munin-cgi-graph/$1 [L,PT]
ScriptAlias /munin-cgi/munin-cgi-graph /usr/lib/munin/cgi/munin-cgi-graph
ScriptAlias /munin-cgi/munin-cgi-html /usr/lib/munin/cgi/munin-cgi-html
<Directory /etc/munin/static>
Require all granted
</Directory> </Directory>
ScriptAlias /munin-cgi/munin-cgi-graph /usr/lib/munin/cgi/munin-cgi-graph <Directory /var/cache/munin/www/>
<Location /munin-cgi/munin-cgi-graph> Require all granted
Require all granted </Directory>
<IfModule mod_fcgid.c>
SetHandler fcgid-script <Directory /usr/lib/munin/cgi>
</IfModule> Require all granted
<IfModule !mod_fcgid.c> <IfModule mod_fcgid.c>
SetHandler cgi-script SetHandler fcgid-script
</IfModule> </IfModule>
</Location> <IfModule !mod_fcgid.c>
SetHandler cgi-script
</IfModule>
</Directory>
</VirtualHost> </VirtualHost>