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,20 +7,47 @@
- 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: "{{ item.mode }}"
owner: "{{ item.owner }}"
group: "{{ item.group }}"
recurse: "{{ item.recurse }}"
loop:
- name: /var/run/munin
mode: '0755' mode: '0755'
owner: munin owner: munin
group: munin group: munin
loop: "{{ munin_dirs }}" recurse: false
- name: /var/lib/munin-node/plugin-state
- name: Ensure permissions are set mode: '0775'
ansible.builtin.file:
path: /var/lib/munin/cgi-tmp
mode: 'ugo+rw'
state: directory
owner: munin owner: munin
group: 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 recurse: true
- name: Template apache config - name: Template apache config
@ -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,18 +1,31 @@
<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
RewriteRule ^/favicon.ico /var/cache/munin/www/static/favicon.ico [L]
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 Require all granted
Options None
</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
</Directory>
<Directory /usr/lib/munin/cgi>
Require all granted Require all granted
<IfModule mod_fcgid.c> <IfModule mod_fcgid.c>
SetHandler fcgid-script SetHandler fcgid-script
@ -20,5 +33,5 @@
<IfModule !mod_fcgid.c> <IfModule !mod_fcgid.c>
SetHandler cgi-script SetHandler cgi-script
</IfModule> </IfModule>
</Location> </Directory>
</VirtualHost> </VirtualHost>