Monitoring: munin eingebaut (#4)

eiegnes playbook entfernt

apcupsd eingebaut

eigene rolle gelöscht

playbook munin entfernt

rolle munin master entfernt

rolle nur bei gruppe

playbook in master eingebunden

playbook

vars

programme physical angepasst

firewall für munin angepasst

wip

wip

rollen hinzugefügt

playbook und muster rolle

munin in inventory

Co-authored-by: Michael Grote <michael.grote@posteo.de>
Reviewed-on: mg/ansible#4
Co-Authored-By: mg <mg@noreply.git.mgrote.net>
Co-Committed-By: mg <mg@noreply.git.mgrote.net>
This commit is contained in:
Michael Grote 2021-02-26 14:16:03 +01:00
parent da4b10d92c
commit 7d5c3fdf2d
24 changed files with 597 additions and 3 deletions

View file

@ -1,7 +1,20 @@
---
### wird in vielen Rollen verwendet
empfaenger_mail: michael.grote@posteo.de
### mgrote.postfix / werden auch bei gitlab verwendet
### geerlingguy.munin-node
munin_node_bind_host: "*"
munin_node_bind_port: "4949"
munin_node_allowed_cidrs: [192.168.2.0/24]
munin_node_plugins:
- name: apc_nis
- name: hddtemp_smartctl
munin_node_config: {
"apc_nis": {
"env.host": "pve2.grote.lan",
"env.port": "3551"
}
}
### mgrote.postfix
postfix_absender_mailadresse: info@mgrote.net
postfix_absender_passwort: "{{ lookup('keepass', 'postfix_absender_passwort', 'password') }}"
postfix_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24"
@ -43,6 +56,11 @@
protocol: tcp
comment: 'ssh'
from_ip: 192.168.2.0/24
- rule: allow
to_port: 4949
protocol: tcp
comment: 'munin-node'
from_ip: 192.168.2.0/24
ufw_default_incoming_policy: deny
ufw_default_outgoing_policy: allow
### ryandaniels.create_users
@ -106,8 +124,9 @@
programs_only_physical:
- hddtemp
- ipmitool
- powertop
- s-tui
- smartmontools
- lm-sensors
programs_only_vms:
- qemu-guest-agent
- open-vm-tools

View file

@ -44,6 +44,11 @@ all:
pve2.grote.lan:
pve3.grote.lan:
pve4.grote.lan:
physical:
hosts:
pve2.grote.lan:
pve3.grote.lan:
pve4.grote.lan:
proxmoxtest:
hosts:
pve2-test.grote.lan:
@ -53,6 +58,10 @@ all:
hosts:
gitea-test.grote.lan:
gitea.grote.lan:
munin:
hosts:
munin-test.grote.lan:
munin.grote.lan:
production:
hosts:
@ -68,7 +77,7 @@ all:
pve4.grote.lan:
gitea.grote.lan:
pihole2.grote.lan:
munin.grote.lan:
test:
hosts:
wireguard-test.grote.lan:
@ -83,3 +92,4 @@ all:
pve4-test.grote.lan:
gitea-test.grote.lan:
pihole2-test.grote.lan:
munin-test.grote.lan:

View file

@ -3,3 +3,4 @@
- import_playbook: 3_base.yml
- import_playbook: 5_personalisierung.yml
- import_playbook: 6_haertung.yml
- import_playbook: 7_monitoring.yml

View file

@ -0,0 +1,10 @@
---
- hosts: all
roles:
- { role: geerlingguy.munin-node,
become: true,
tags: "munin",
when: "'physical' in group_names" }
### Die Host müssen auch beim Docker-Container: "munin-master eingetragen" werden.
### wird nur auf physichen Rechnern ausgeführt.

View file

@ -0,0 +1,3 @@
skip_list:
- 'yaml'
- 'role-name'

View file

@ -0,0 +1,4 @@
# These are supported funding model platforms
---
github: geerlingguy
patreon: geerlingguy

View file

@ -0,0 +1,56 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 90
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 30
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
onlyLabels: []
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- pinned
- security
- planned
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false
# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: false
# Label to use when marking as stale
staleLabel: stale
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30
pulls:
markComment: |-
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution!
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark pull requests as stale.
unmarkComment: >-
This pull request is no longer marked for closure.
closeComment: >-
This pull request has been closed due to inactivity. If you feel this is in error, please reopen the pull request or file a new PR with the relevant details.
issues:
markComment: |-
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale.
unmarkComment: >-
This issue is no longer marked for closure.
closeComment: >-
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

View file

@ -0,0 +1,72 @@
---
name: CI
'on':
pull_request:
push:
branches:
- master
schedule:
- cron: "30 2 * * 3"
defaults:
run:
working-directory: 'geerlingguy.munin-node'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.munin-node'
- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install test dependencies.
run: pip3 install yamllint ansible ansible-lint
- name: Lint code.
run: |
yamllint .
ansible-lint
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
include:
- distro: centos7
playbook: converge.yml
- distro: ubuntu1804
playbook: converge.yml
- distro: centos7
playbook: playbook-vars.yml
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.munin-node'
- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install test dependencies.
run: pip3 install ansible molecule[docker] docker
- name: Run Molecule tests.
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
MOLECULE_PLAYBOOK: ${{ matrix.playbook }}

View file

@ -0,0 +1,38 @@
---
# This workflow requires a GALAXY_API_KEY secret present in the GitHub
# repository or organization.
#
# See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy
# See: https://github.com/ansible/galaxy/issues/46
name: Release
'on':
push:
tags:
- '*'
defaults:
run:
working-directory: 'geerlingguy.munin-node'
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.munin-node'
- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Ansible.
run: pip3 install ansible-base
- name: Trigger a new import on Galaxy.
run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)

View file

@ -0,0 +1,5 @@
*.retry
*/__pycache__
*.pyc
.cache

View file

@ -0,0 +1,11 @@
---
extends: default
rules:
line-length:
max: 120
level: warning
ignore: |
.github/stale.yml
.travis.yml

View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2017 Jeff Geerling
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,86 @@
# Ansible Role: Munin Node
[![CI](https://github.com/geerlingguy/ansible-role-munin-node/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-munin-node/actions?query=workflow%3ACI)
Installs munin-node, a monitoring system endpoint, on RedHat/CentOS or Debian/Ubuntu Linux servers.
## Requirements
If using RedHat/CentOS, make sure you have the EPEL repository installed prior to using this role (you can install it using the [`geerlingguy.repo-epel`](https://galaxy.ansible.com/list#/roles/436) role).
## Role Variables
Available variables are listed below, along with default values:
munin_node_bind_host: "*"
munin_node_bind_port: "4949"
The host and port to which munin-node will bind. Common host options are `127.0.0.1` (localhost), or `*` (bind to all IP addresses). `4949` is the default Munin port.
munin_node_host_name: ''
Set this explicitly if the munin master doesn't report the correct hostname when telnetting in to munin-node. In most cases, the default should work fine.
munin_node_allowed_ips:
- '^127\.0\.0\.1$'
- '^::1$'
A list of IP addresses formatted as a python-style regular expression. Must use single quotes to allow the proper regex escaping to pass through to the configuration file. Hosts with these IP addresses will be allowed to connect to the server and get detailed system stats via munin-node.
munin_node_allowed_cidrs: []
A list of IP networks in CIDR format, for instance `10.0.0.0/8`. Hosts with an IP address in one of these networks will be allowed to connect to the server and get detailed system stats via munin-node.
munin_node_denied_cidrs: []
A list of IP networks in CIDR format, for instance `10.42.0.0/16`. Hosts with an IP address in one of these networks will be denied access to the server. This takes precedence over `munin_node_allowed_cidrs`: an IP address that matches both a network in `munin_node_allowed_cidrs` and a network in `munin_node_denied_cidrs` will be denied access.
### Munin Plugin Configuration
You can enable plugins using the `munin_node_plugins` list, like so:
munin_node_plugins:
- name: uptime
If the name of the resulting plugin does not match the name of the munin plugin from which it is generated (as is the case, say, with the `if_` plugin), you need to add a `plugin` field to the list item, like so:
munin_node_plugins:
- name: if_eth0
plugin: if_
#### Plugin settings
If you need to add plugin configuration for plugins you've added via `munin_node_plugins`, you can do so with a simple hashmap that has the plugin name (which will be the `[plugin]` section in the resulting configuration file), and a list of variable names and values. For example:
munin_node_config: {
"ps_test": {
"env.regex": "bash",
"env.name": "bash"
}
}
This configuration will generate a configuration file at `/etc/munin/plugin-conf.d/ansible.conf` with the following contents:
[ps_test]
env.regex bash
env.name bash
## Dependencies
None.
## Example Playbook
- hosts: servers
roles:
- { role: geerlingguy.munin-node }
## License
MIT / BSD
## Author Information
This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
Munin plugin configuration was added by Rafał Trójniak <ansible-galaxy@trojniak.net>.

View file

@ -0,0 +1,34 @@
---
munin_node_bind_host: "*"
munin_node_bind_port: "4949"
munin_node_host_name: ''
# Munin requires IPs be added as regular expressions.
munin_node_allowed_ips:
- '^127\.0\.0\.1$'
- '^::1$'
munin_node_allowed_cidrs: []
munin_node_denied_cidrs: []
# Source and destination of munin plugins.
munin_plugin_src_path: /usr/share/munin/plugins/
munin_plugin_dest_path: /etc/munin/plugins/
# List of munin plugins to enable.
munin_node_plugins: []
# - name: uptime
# - name: if_eth0
# plugin: if_
# - name: ps_test
# plugin: ps_
# Plugin configuration options (the key is the plugin heading, items within will
# be options for the plugin).
munin_node_config: {
# "ps_test": {
# "env.regex": "bash",
# "env.name": "bash"
# }
}

View file

@ -0,0 +1,3 @@
---
- name: restart munin-node
service: name=munin-node state=restarted

View file

@ -0,0 +1,27 @@
---
dependencies: []
galaxy_info:
# See: https://github.com/ansible/galaxy/issues/2393
# role_name: munin-node
author: geerlingguy
description: Munin node monitoring endpoint for RedHat/CentOS or Debian/Ubuntu.
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.4
platforms:
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
- name: EL
versions:
- 7
- 8
galaxy_tags:
- monitoring
- system
- munin
- metrics

View file

@ -0,0 +1,21 @@
---
- name: Converge
hosts: all
become: true
pre_tasks:
- name: Update apt cache.
apt: update_cache=true
when: ansible_os_family == 'Debian'
changed_when: false
- name: Install test dependencies (Debian).
package: name=netcat state=present
when: ansible_os_family == 'Debian'
- name: Install test dependencies (RedHat).
package: name=nc state=present
when: ansible_os_family == 'RedHat'
roles:
- role: geerlingguy.munin-node

View file

@ -0,0 +1,17 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}

View file

@ -0,0 +1,36 @@
---
- name: Converge
hosts: all
become: true
vars:
munin_node_allowed_cidrs: ['10.0.0.0/8', '2001:db8::/32']
munin_node_denied_cidrs: ['10.42.0.0/16', '2001:db8:42::/48']
munin_node_plugins:
- name: uptime
- name: if_eth1
plugin: if_
munin_node_config: {
"ps_test": {
"env.regex": "bash",
"env.name": "bash"
}
}
pre_tasks:
- name: Update apt cache.
apt: update_cache=true cache_valid_time=600
when: ansible_os_family == 'Debian'
changed_when: false
- name: Install test dependencies (Debian).
package: name=netcat state=present
when: ansible_os_family == 'Debian'
- name: Install test dependencies (RedHat).
package: name=nc state=present
when: ansible_os_family == 'RedHat'
roles:
- role: geerlingguy.munin-node

View file

@ -0,0 +1,40 @@
---
- name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml"
- name: Ensure munin-node is installed (RedHat).
yum: name=munin-node state=present enablerepo=epel
when: ansible_os_family == 'RedHat'
- name: Ensure munin-node is installed (Debian).
apt: name=munin-node state=present
when: ansible_os_family == 'Debian'
- name: Copy munin-node configuration.
template:
src: munin-node.conf.j2
dest: /etc/munin/munin-node.conf
owner: root
group: root
mode: 0644
notify: restart munin-node
- name: Generate plugin configuration.
template:
src: plugin-conf.j2
dest: /etc/munin/plugin-conf.d/ansible.conf
owner: root
group: root
mode: 0644
notify: restart munin-node
- name: Enable additional plugins.
file: # noqa 208
path: "{{ munin_plugin_dest_path }}{{ item.name }}"
src: "{{ munin_plugin_src_path }}{{ item.plugin | default( item.name ) }}"
state: link
with_items: "{{ munin_node_plugins }}"
notify: restart munin-node
- name: Ensure munin-node is running.
service: name=munin-node state=started enabled=yes

View file

@ -0,0 +1,68 @@
#
# Example config-file for munin-node
#
log_level 4
log_file {{ munin_node_log }}
pid_file {{ munin_node_pid }}
background 1
setsid 1
user root
group root
# This is the timeout for the whole transaction.
# Units are in sec. Default is 15 min
# global_timeout 900
# This is the timeout for each plugin.
# Units are in sec. Default is 1 min
# timeout 60
# Regexps for files to ignore
ignore_file [\#~]$
ignore_file DEADJOE$
ignore_file \.bak$
ignore_file %$
ignore_file \.dpkg-(tmp|new|old|dist)$
ignore_file \.rpm(save|new)$
ignore_file \.pod$
# Set this if the client doesn't report the correct hostname when
# telnetting to localhost, port 4949
{% if munin_node_host_name %}
host_name {{ munin_node_host_name }}
{% endif %}
# A list of addresses that are allowed to connect. This must be a
# regular expression, since Net::Server does not understand CIDR-style
# network notation unless the perl module Net::CIDR is installed. You
# may repeat the allow line as many times as you'd like
{% for allowed_ip in munin_node_allowed_ips %}
allow {{ allowed_ip }}
{% endfor %}
# If you have installed the Net::CIDR perl module, you can use one or more
# cidr_allow and cidr_deny address/mask patterns. A connecting client must
# match any cidr_allow, and not match any cidr_deny. Note that a netmask
# *must* be provided, even if it's /32
#
# Example:
#
# cidr_allow 127.0.0.1/32
# cidr_allow 192.0.2.0/24
# cidr_deny 192.0.2.42/32
{% for allowed_cidr in munin_node_allowed_cidrs %}
cidr_allow {{ allowed_cidr }}
{% endfor %}
{% for denied_cidr in munin_node_denied_cidrs %}
cidr_deny {{ denied_cidr }}
{% endfor %}
# Which address to bind to;
host {{ munin_node_bind_host }}
# And which port
port {{ munin_node_bind_port }}

View file

@ -0,0 +1,7 @@
{% for section,directives in munin_node_config.items() | list %}
[{{section}}]
{% for name,val in directives.items() | list %}
{{ name }} {{ val }}
{% endfor %}
{% endfor %}

View file

@ -0,0 +1,3 @@
---
munin_node_log: /var/log/munin/munin-node.log
munin_node_pid: /var/run/munin/munin-node.pid

View file

@ -0,0 +1,3 @@
---
munin_node_log: /var/log/munin-node/munin-node.log
munin_node_pid: /var/run/munin/munin-node.pid