Jérémy Dubois
99ff7284a3
Because openbsd_pkg module is broken since OpenBSD 7.4 with the version of Ansible we currently use
131 lines
3.2 KiB
YAML
131 lines
3.2 KiB
YAML
# yamllint disable rule:line-length
|
|
---
|
|
# openbsd_pkg is broken since OpenBSD 7.4 with the version of Ansible we currently use
|
|
#- name: "Install Collectd package"
|
|
# community.general.openbsd_pkg:
|
|
# name: "collectd"
|
|
# tags:
|
|
# - collectd
|
|
|
|
- name: "Check if collectd is already installed"
|
|
ansible.builtin.command:
|
|
cmd: pkg_info -Iq inst:collectd
|
|
register: is_installed
|
|
ignore_errors: true
|
|
changed_when: false
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Install collectd"
|
|
ansible.builtin.command:
|
|
cmd: pkg_add collectd
|
|
when: "'Can\\'t find inst:' in is_installed.stderr"
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Deploy Collectd configuration"
|
|
ansible.builtin.template:
|
|
src: "collectd.conf.j2"
|
|
dest: "/etc/collectd.conf"
|
|
notify: restart collectd
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Enabling Collectd"
|
|
ansible.builtin.service:
|
|
name: collectd
|
|
enabled: true
|
|
when: not ansible_check_mode
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Fix rights for collectd directory"
|
|
ansible.builtin.file:
|
|
path: /usr/local/share/collectd
|
|
state: directory
|
|
owner: "root"
|
|
group: "wheel"
|
|
mode: "0755"
|
|
when: collectd_plugin_exec_ifq_drops or collectd_plugin_exec_dns_stats or collectd_plugin_exec_dhcp_pool
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Create scripts directory for exec plugins"
|
|
ansible.builtin.file:
|
|
path: /usr/local/share/collectd/scripts
|
|
state: directory
|
|
owner: "root"
|
|
group: "_collectd"
|
|
mode: "0710"
|
|
when: collectd_plugin_exec_ifq_drops or collectd_plugin_exec_dns_stats or collectd_plugin_exec_dhcp_pool
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Copy ifq_drops.sh"
|
|
ansible.builtin.copy:
|
|
src: ifq_drops.sh
|
|
dest: /usr/local/share/collectd/scripts/ifq_drops.sh
|
|
owner: "root"
|
|
group: "_collectd"
|
|
mode: "0710"
|
|
force: true
|
|
when: collectd_plugin_exec_ifq_drops
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Remove ifq_drops.sh"
|
|
ansible.builtin.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"
|
|
ansible.builtin.copy:
|
|
src: dns_stats.sh
|
|
dest: /usr/local/share/collectd/scripts/dns_stats.sh
|
|
owner: "root"
|
|
group: "_collectd"
|
|
mode: "0710"
|
|
force: true
|
|
when: collectd_plugin_exec_dns_stats
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Remove dns_stats.sh"
|
|
ansible.builtin.file:
|
|
path: /usr/local/share/collectd/scripts/dns_stats.sh
|
|
state: absent
|
|
when: not collectd_plugin_exec_dns_stats
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Add doas configuration for dns_stats.sh execution"
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/doas.conf
|
|
line: 'permit nopass _collectd as root cmd /usr/sbin/unbound-control args stats'
|
|
when: collectd_plugin_exec_dns_stats
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Copy dhcp_pool.pl"
|
|
ansible.builtin.copy:
|
|
src: dhcp_pool.pl
|
|
dest: /usr/local/share/collectd/scripts/dhcp_pool.pl
|
|
owner: "root"
|
|
group: "_collectd"
|
|
mode: "0710"
|
|
force: true
|
|
when: collectd_plugin_exec_dhcp_pool
|
|
tags:
|
|
- collectd
|
|
|
|
- name: "Remove dhcp_pool.pl"
|
|
ansible.builtin.file:
|
|
path: /usr/local/share/collectd/scripts/dhcp_pool.pl
|
|
state: absent
|
|
when: not collectd_plugin_exec_dhcp_pool
|
|
tags:
|
|
- collectd
|