Update munin-node role and keep it locally

This commit is contained in:
Nemo 2020-07-12 10:14:25 +02:00
parent 0f12e6a78b
commit feaa54986d
24 changed files with 500 additions and 18 deletions

View file

@ -23,6 +23,3 @@ main_domain: wirebrass.fr
# Certbot admin Email address # Certbot admin Email address
certbot_admin_email: contact@wirebrass.fr certbot_admin_email: contact@wirebrass.fr
# Bind munin-node to localhost
munin_node_bind_host: "127.0.0.1"

View file

@ -1,18 +1,12 @@
--- ---
- hosts: all - hosts: all
roles: roles:
- auto_reboot # - auto_reboot
- auto_upgrade # - auto_upgrade
- client_ntp # - client_ntp
- client_resolvers # - client_resolvers
- client_tools # - client_tools
- users_sudo # - users_sudo
- client_iptables # - client_iptables
- munin-node
- hosts: os_centos
roles:
- geerlingguy.munin-node
- hosts: os_debian
roles:
- geerlingguy.munin-node

View file

@ -2,4 +2,3 @@
- name: geerlingguy.munin - name: geerlingguy.munin
- name: geerlingguy.nginx - name: geerlingguy.nginx
- name: geerlingguy.certbot - name: geerlingguy.certbot
- name: geerlingguy.munin-node

4
roles/munin-node/.github/FUNDING.yml vendored Normal file
View file

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

56
roles/munin-node/.github/stale.yml vendored Normal file
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.

3
roles/munin-node/.gitignore vendored Normal file
View file

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

View file

@ -0,0 +1,30 @@
---
language: python
services: docker
env:
global:
- ROLE_NAME: munin-node
matrix:
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: centos7
MOLECULE_PLAYBOOK: playbook-vars.yml
install:
# Install test dependencies.
- pip install molecule yamllint ansible-lint docker
before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME
- cd geerlingguy.$ROLE_NAME
script:
# Run tests.
- molecule test
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View file

@ -0,0 +1,6 @@
---
extends: default
rules:
line-length:
max: 120
level: warning

20
roles/munin-node/LICENSE Normal file
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
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-munin-node.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-munin-node)
Installs munin-node, a monitoring system endpoint, on RedHat/CentOS, Gentoo 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 @@
net-analyzer/munin ipv6 ssl minimal

View file

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

View file

@ -0,0 +1 @@
{install_date: 'Sat Jul 11 19:42:25 2020', version: 1.3.0}

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:
- 6
- 7
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,21 @@
---
dependency:
name: galaxy
driver:
name: docker
lint: |
set -e
yamllint .
ansible-lint
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,58 @@
---
- 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: Munin (node) USE flag configuration (Gentoo).
copy:
src: package.use.munin
dest: /etc/portage/package.use/munin
owner: root
group: root
mode: 0644
when: ansible_os_family == 'Gentoo'
- name: Ensure munin (node) is installed (Gentoo).
portage:
name: munin
newuse: yes
changed_use: yes
state: latest
when: ansible_os_family == 'Gentoo'
notify: restart munin-node
- 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:
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,4 @@
---
munin_node_log: /var/log/munin/munin-node.log
munin_node_pid: /var/run/munin-node.pid
munin_plugin_src_path: /usr/libexec/munin/plugins

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