2020-04-21 19:30:06 +02:00
|
|
|
---
|
|
|
|
- name: Install Collectd package
|
|
|
|
openbsd_pkg:
|
|
|
|
name: "collectd"
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Deploy Collectd configuration
|
|
|
|
template:
|
|
|
|
src: "collectd.conf.j2"
|
|
|
|
dest: "/etc/collectd.conf"
|
|
|
|
notify: restart collectd
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Enabling Collectd
|
|
|
|
service:
|
|
|
|
name: collectd
|
2020-10-12 15:26:45 +02:00
|
|
|
enabled: true
|
2020-04-21 19:30:06 +02:00
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Create scripts directory for exec plugins
|
|
|
|
file:
|
|
|
|
path: /usr/local/share/collectd/scripts
|
|
|
|
state: directory
|
2020-10-12 15:45:13 +02:00
|
|
|
when: collectd_plugin_exec_ifq_drops or collectd_plugin_exec_dns_stats
|
2020-04-21 19:30:06 +02:00
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Copy ifq_drops.sh
|
|
|
|
copy:
|
|
|
|
src: ifq_drops.sh
|
|
|
|
dest: /usr/local/share/collectd/scripts/ifq_drops.sh
|
|
|
|
mode: 0755
|
2020-10-12 15:26:45 +02:00
|
|
|
force: true
|
2020-04-21 19:30:06 +02:00
|
|
|
when: collectd_plugin_exec_ifq_drops
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Remove ifq_drops.sh
|
|
|
|
file:
|
|
|
|
path: /usr/local/share/collectd/scripts/ifq_drops.sh
|
|
|
|
state: absent
|
|
|
|
when: not collectd_plugin_exec_ifq_drops
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Copy dns_stats.sh
|
2020-10-12 15:26:45 +02:00
|
|
|
copy:
|
2020-04-21 19:30:06 +02:00
|
|
|
src: dns_stats.sh
|
|
|
|
dest: /usr/local/share/collectd/scripts/dns_stats.sh
|
|
|
|
mode: 0755
|
2020-10-12 15:26:45 +02:00
|
|
|
force: true
|
2020-04-21 19:30:06 +02:00
|
|
|
when: collectd_plugin_exec_dns_stats
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Add stats DNS on unbound
|
|
|
|
lineinfile:
|
|
|
|
path: /var/unbound/etc/unbound.conf
|
|
|
|
regexp: 'statistics-interval'
|
2020-10-12 15:26:45 +02:00
|
|
|
line:
|
|
|
|
' statistics-interval: {{ collectd_plugin_exec_dns_stats_interval }}'
|
2020-04-21 19:30:06 +02:00
|
|
|
insertafter: 'hide-version:'
|
2020-10-12 15:26:45 +02:00
|
|
|
backup: true
|
2020-04-21 19:30:06 +02:00
|
|
|
notify: reload unbound
|
|
|
|
when: collectd_plugin_exec_dns_stats
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Remove dns_stats.sh
|
|
|
|
file:
|
|
|
|
path: /usr/local/share/collectd/scripts/dns_stats.sh
|
|
|
|
state: absent
|
|
|
|
when: not collectd_plugin_exec_dns_stats
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Remove stats DNS on unbound
|
|
|
|
lineinfile:
|
|
|
|
path: /var/unbound/etc/unbound.conf
|
|
|
|
regexp: 'statistics-interval'
|
2020-10-12 15:26:45 +02:00
|
|
|
backup: true
|
2020-04-21 19:30:06 +02:00
|
|
|
state: absent
|
|
|
|
notify: reload unbound
|
|
|
|
when: not collectd_plugin_exec_dns_stats
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
|
|
|
- name: Add doas configuration for dns_stats.sh execution
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/doas.conf
|
|
|
|
line: 'permit nopass _collectd as root cmd /bin/cat'
|
|
|
|
when: collectd_plugin_exec_dns_stats
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|