From 743b1cc15f437d2b8b9122dc7bf874d28c33884f Mon Sep 17 00:00:00 2001 From: Yohann Dedy Date: Fri, 17 Apr 2020 09:39:06 +0200 Subject: [PATCH] Add areas --- tasks/main.yml | 16 ++++++++-------- templates/hosts.conf.j2 | 15 ++++++--------- templates/hosts.conf.j2.bkp | 6 ++++++ templates/munin.conf.j2 | 3 +++ vars/Debian.yml | 2 +- 5 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 templates/hosts.conf.j2.bkp diff --git a/tasks/main.yml b/tasks/main.yml index 4923ddf..8883347 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -21,15 +21,15 @@ - src: munin.conf.j2 dest: /etc/munin/munin.conf - src: hosts.conf.j2 - dest: "{{ munin_conf_d_directory }}/hosts.conf" + dest: "{{ munin_conf_d_directory }}/hosts-{{ munin_hosts_area }}.conf" -- name: Create munin user via htpasswd. - htpasswd: - create: true - name: "{{ munin_admin_user }}" - password: "{{ munin_admin_password }}" - path: /etc/munin/munin-htpasswd - state: present +#- name: Create munin user via htpasswd. +# htpasswd: +# create: true +# name: "{{ munin_admin_user }}" +# password: "{{ munin_admin_password }}" +# path: /etc/munin/munin-htpasswd +# state: absent - name: Enable or disable the munin cron job. lineinfile: diff --git a/templates/hosts.conf.j2 b/templates/hosts.conf.j2 index fc6e1eb..e6e1964 100644 --- a/templates/hosts.conf.j2 +++ b/templates/hosts.conf.j2 @@ -1,11 +1,8 @@ # Munin hosts. -{% for host in munin_hosts %} -[{{ host.name }}] - address {{ host.address }} -{% if host.extra is defined %} -{% for extra in host.extra %} - {{ extra }} -{% endfor %} -{% endif %} - +{% for host in groups[munin_hosts] %} + {% if host != inventory_hostname %} +[{{ host }}] + address {{ hostvars[host]['ansible_default_ipv4']['address'] }} + use_node_name yes + {% endif %} {% endfor %} diff --git a/templates/hosts.conf.j2.bkp b/templates/hosts.conf.j2.bkp new file mode 100644 index 0000000..0f3d44b --- /dev/null +++ b/templates/hosts.conf.j2.bkp @@ -0,0 +1,6 @@ +# Munin hosts. +{% for host in munin_hosts %} +[{{ hostvars[host]['ansible_fqdn'] }}] + address {{ hostvars[host]['ansible_default_ipv4']['address'] }} + use_node_name yes +{% endfor %} diff --git a/templates/munin.conf.j2 b/templates/munin.conf.j2 index 875c4c9..012ca52 100644 --- a/templates/munin.conf.j2 +++ b/templates/munin.conf.j2 @@ -89,3 +89,6 @@ contact.{{ contact.name }}.always_send {{ contact.level }} #contact.nagios.command /usr/bin/send_nsca nagios.host.comm -c /etc/nsca.conf # Hosts are defined separately, in {{ munin_includedir }} +[{{ inventory_hostname }}] + address 127.0.0.1 + use_node_name yes diff --git a/vars/Debian.yml b/vars/Debian.yml index 306227c..86ef079 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -1,6 +1,6 @@ --- munin_conf_d_directory: /etc/munin/munin-conf.d -munin_htmldir: /var/cache/munin/www +#munin_htmldir: /var/cache/munin/www munin_includedir: /etc/munin/munin-conf.d