EvoBSD/roles/collectd/tasks/main.yml
Jérémy Dubois 11d3331958
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
Collectd role : deletion of collectd_plugin_exec variable
This variable had to be activated only if collectd_plugin_exec_ifq_drops or
collectd_plugin_exec_dns_stats was also activated, for some configuration to be
taken into account. I changed the role so that the configuration is
automatically taken into account if one of these two variables is activated.
2020-10-12 15:45:13 +02:00

107 lines
2.3 KiB
YAML

---
- name: Install Collectd package
openbsd_pkg:
name: "collectd"
tags:
- collectd
- name: Deploy Collectd configuration
template:
src: "collectd.conf.j2"
dest: "/etc/collectd.conf"
notify: restart collectd
tags:
- collectd
- name: Enabling Collectd
service:
name: collectd
enabled: true
tags:
- collectd
- name: Create scripts directory for exec plugins
file:
path: /usr/local/share/collectd/scripts
state: directory
when: collectd_plugin_exec_ifq_drops or collectd_plugin_exec_dns_stats
tags:
- collectd
- name: Copy ifq_drops.sh
copy:
src: ifq_drops.sh
dest: /usr/local/share/collectd/scripts/ifq_drops.sh
mode: 0755
force: true
when: collectd_plugin_exec_ifq_drops
tags:
- collectd
- 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:
- collectd
- name: Copy dns_stats.sh
copy:
src: dns_stats.sh
dest: /usr/local/share/collectd/scripts/dns_stats.sh
mode: 0755
force: true
when: collectd_plugin_exec_dns_stats
tags:
- collectd
- name: Add stats DNS on unbound
lineinfile:
path: /var/unbound/etc/unbound.conf
regexp: 'statistics-interval'
line:
' statistics-interval: {{ collectd_plugin_exec_dns_stats_interval }}'
insertafter: 'hide-version:'
backup: true
notify: reload unbound
when: collectd_plugin_exec_dns_stats
tags:
- collectd
- 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:
- collectd
- name: Remove stats DNS on unbound
lineinfile:
path: /var/unbound/etc/unbound.conf
regexp: 'statistics-interval'
backup: true
state: absent
notify: reload unbound
when: not collectd_plugin_exec_dns_stats
tags:
- collectd
- 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:
- collectd
- name: Delete doas configuration for dns_stats.sh execution
lineinfile:
path: /etc/doas.conf
line: 'permit nopass _collectd as root cmd /bin/cat'
state: absent
when: not collectd_plugin_exec_dns_stats
tags:
- collectd