Last active 1777891874

Revision 836447494fdad51c603ce68a2bd2f5e392ab0ec0

smart.yml Raw
1---
2# an ansible role to install and configure smartmon tools for a daily check + email
3# roles/smart/tasks/main.yml
4- name: install smartmontools
5 pkgng:
6 state: present
7 name:
8 - sysutils/smartmontools
9 notify: restart smartd
10 tags: smart, pkg
11
12- name: enable smartd
13 copy:
14 content: |
15 smartd_enable=YES
16 mode: 0640
17 owner: root
18 group: wheel
19 dest: /etc/rc.conf.d/smartd
20 notify: restart smartd
21 tags: smart, config
22
23- name: add devices to smartd.conf
24 copy:
25 content: |
26 # send a test email on startup for all devices
27 DEFAULT -m {{ smtp_sendto }} -M test
28 DEVICESCAN -H -l error -l selftest -s L/../(02|08|16|24)/./0:002-020
29 {% for device in (ansible_devices.keys()
30 | map('regex_search', '^a?da\d+')
31 | select('string')
32 | list) %}
33 # /dev/{{ device}} -m {{ smtp_sendto }} -M smartd
34 {% endfor %}
35 dest: /usr/local/etc/smartd.conf
36 notify: restart smartd
37 tags: smart, config
38
39- name: add smart status to daily periodic
40 lineinfile:
41 dest: /etc/periodic.conf
42 regexp: '^daily_status_smart_devices='
43 line: |
44 daily_status_smart_devices= {{ '"' -}}
45 {% for device in (ansible_devices.keys()
46 | map('regex_search', '^a?da\d+')
47 | select('string')
48 | list) %}
49 /dev/{{ device ~ ' ' -}}
50 {% endfor %}{{ '"' -}}
51 notify: restart smartd
52 tags: smart, config