2022-06-23 16:17:42 +02:00
|
|
|
# yamllint disable rule:line-length
|
2020-04-21 19:30:06 +02:00
|
|
|
---
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Install Collectd package"
|
2020-04-21 19:30:06 +02:00
|
|
|
openbsd_pkg:
|
|
|
|
name: "collectd"
|
|
|
|
tags:
|
2020-10-12 15:26:45 +02:00
|
|
|
- collectd
|
2020-04-21 19:30:06 +02:00
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Deploy Collectd configuration"
|
2020-04-21 19:30:06 +02:00
|
|
|
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
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Enabling Collectd"
|
2020-04-21 19:30:06 +02:00
|
|
|
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
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Create scripts directory for exec plugins"
|
2020-04-21 19:30:06 +02:00
|
|
|
file:
|
|
|
|
path: /usr/local/share/collectd/scripts
|
|
|
|
state: directory
|
2022-04-08 16:48:02 +02:00
|
|
|
when: collectd_plugin_exec_ifq_drops or collectd_plugin_exec_dns_stats or collectd_plugin_exec_dhcp_pool
|
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
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Copy ifq_drops.sh"
|
2020-04-21 19:30:06 +02:00
|
|
|
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
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Remove ifq_drops.sh"
|
2020-04-21 19:30:06 +02:00
|
|
|
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
|
|
|
|
2022-06-23 16:17:42 +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
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Add stats DNS on unbound"
|
2020-04-21 19:30:06 +02:00
|
|
|
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
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Remove dns_stats.sh"
|
2020-04-21 19:30:06 +02:00
|
|
|
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
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Remove stats DNS on unbound"
|
2020-04-21 19:30:06 +02:00
|
|
|
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
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Add doas configuration for dns_stats.sh execution"
|
2020-04-21 19:30:06 +02:00
|
|
|
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
|
2022-04-08 16:48:02 +02:00
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Copy dhcp_pool.pl"
|
2022-04-08 16:48:02 +02:00
|
|
|
copy:
|
|
|
|
src: dhcp_pool.pl
|
|
|
|
dest: /usr/local/share/collectd/scripts/dhcp_pool.pl
|
|
|
|
mode: 0755
|
|
|
|
force: true
|
|
|
|
when: collectd_plugin_exec_dhcp_pool
|
|
|
|
tags:
|
|
|
|
- collectd
|
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Remove dhcp_pool.pl"
|
2022-04-08 16:48:02 +02:00
|
|
|
file:
|
|
|
|
path: /usr/local/share/collectd/scripts/dhcp_pool.pl
|
|
|
|
state: absent
|
|
|
|
when: not collectd_plugin_exec_dhcp_pool
|
|
|
|
tags:
|
|
|
|
- collectd
|