From f9133deec48a8d8780f92f85ce8548e7804b9647 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Sun, 11 May 2014 22:32:24 -0500 Subject: [PATCH] Updates to get role working correctly under Debian/Ubuntu. --- README.md | 43 +++++++++++++++++++++++++++++++------ {vars => defaults}/main.yml | 8 +++++++ meta/main.yml | 3 +-- tasks/main.yml | 17 ++++++++++----- templates/munin.conf.j2 | 2 +- vars/Debian.yml | 6 ++++++ vars/RedHat.yml | 6 ++++++ 7 files changed, 71 insertions(+), 14 deletions(-) rename {vars => defaults}/main.yml (80%) create mode 100644 vars/Debian.yml create mode 100644 vars/RedHat.yml diff --git a/README.md b/README.md index eee9d1c..bb8edfd 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,54 @@ [![Build Status](https://travis-ci.org/geerlingguy/ansible-role-munin.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-munin) -Installs munin, a monitoring system, on RedHat/CentOS. +Installs munin, a monitoring system, on RedHat/CentOS or Debian/Ubuntu Linux servers. ## Requirements -None. +If you are running a RedHat-based distribution, you need to install the EPEL repository, which can be simply installed via the `geerlingguy.repo-epel` role. + +If you would like to view munin's graphs and output via HTTP, you will need an HTTP server like Apache or Nginx running. ## Role Variables Available variables are listed below, along with default values (see `vars/main.yml`): - TODO + munin_dbdir: /var/lib/munin + munin_htmldir: /var/www/html/munin + munin_logdir: /var/log/munin + munin_rundir: /var/run/munin + munin_includedir: /etc/munin/conf.d + +Some default locations for Munin-generated files, configurations, logs, etc. + + munin_html_strategy: cron + munin_max_processes: 12 + +See the official Munin documentation for [munin.conf](http://munin.readthedocs.org/en/latest/reference/munin.conf.html) for more information on these and other optional directives. + + munin_admin_user: munin + munin_admin_password: munin + +These values will be used to generate a user via htpasswd under which the munin pages will be password protected with basic HTTP authentication. + + munin_hosts: + - { + name: "localhost", + address: "127.0.0.1", + extra: ["use_node_name yes"] + } + +A listing of hosts to which munin will connect and monitor. Each item in the list will be added to your munin configuration like the following (assuming you're using the above example): + + [localhost] + address: 127.0.0.1 + use_node_name yes + +See documentation for [Munin Node Definitions](http://munin.readthedocs.org/en/latest/reference/munin.conf.html#node-definitions) for more details as to what values to use here. ## Dependencies - - geerlingguy.repo-epel - -Additionally, if you'd like to view the graphs via HTTP, you will need a server like Apache or Nginx running, to serve the munin-generated HTML and graphs. +None. ## Example Playbook diff --git a/vars/main.yml b/defaults/main.yml similarity index 80% rename from vars/main.yml rename to defaults/main.yml index e9f4429..8fe7ca6 100644 --- a/vars/main.yml +++ b/defaults/main.yml @@ -1,9 +1,17 @@ --- +munin_packages: + - python-passlib + - munin + +munin_conf_d_directory: /etc/munin/conf.d + munin_dbdir: /var/lib/munin munin_htmldir: /var/www/html/munin munin_logdir: /var/log/munin munin_rundir: /var/run/munin +munin_includedir: /etc/munin/conf.d + munin_html_strategy: cron munin_max_processes: 12 diff --git a/meta/main.yml b/meta/main.yml index be5cab3..51e8d5e 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,6 +1,5 @@ --- -dependencies: - - { role: geerlingguy.repo-epel } +dependencies: [] galaxy_info: author: geerlingguy diff --git a/tasks/main.yml b/tasks/main.yml index abca3f1..ad2714c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,9 +1,16 @@ --- -- name: Ensure python-passlib is installed (RedHat). - yum: pkg=python-passlib state=installed +- name: Include OS-specific variables. + include_vars: "{{ ansible_os_family }}.yml" -- name: Ensure munin is installed (RedHat). - yum: pkg=munin state=installed +- name: Install required packages for munin (RedHat). + yum: "pkg={{ item }} state=installed" + with_items: munin_packages + when: ansible_os_family == 'RedHat' + +- name: Install required packages for munin (Debian). + apt: "pkg={{ item }} state=installed" + with_items: munin_packages + when: ansible_os_family == 'Debian' - name: Copy munin configurations. template: > @@ -12,7 +19,7 @@ owner=root group=root mode=644 with_items: - { src: munin.conf.j2, dest: /etc/munin/munin.conf } - - { src: hosts.conf.j2, dest: /etc/munin/conf.d/hosts.conf } + - { src: hosts.conf.j2, dest: "{{ munin_conf_d_directory }}/hosts.conf" } - name: Create munin user via htpasswd. htpasswd: > diff --git a/templates/munin.conf.j2 b/templates/munin.conf.j2 index a11080a..242efb6 100644 --- a/templates/munin.conf.j2 +++ b/templates/munin.conf.j2 @@ -18,7 +18,7 @@ tmpldir /etc/munin/templates # cgitmpdir @@CGITMPDIR@@ # (Exactly one) directory to include all files from. -includedir /etc/munin/conf.d +includedir {{ munin_includedir }} # You can choose the time reference for "DERIVE" like graphs, and show # "per minute", "per hour" values instead of the default "per second" diff --git a/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..306227c --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,6 @@ +--- +munin_conf_d_directory: /etc/munin/munin-conf.d + +munin_htmldir: /var/cache/munin/www + +munin_includedir: /etc/munin/munin-conf.d diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..7983b4a --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,6 @@ +--- +munin_conf_d_directory: /etc/munin/conf.d + +munin_htmldir: /var/www/html/munin + +munin_includedir: /etc/munin/conf.d