--- # an ansible role to install and configure smartmon tools for a daily check + email # roles/smart/tasks/main.yml - name: install smartmontools pkgng: state: present name: - sysutils/smartmontools notify: restart smartd tags: smart, pkg - name: enable smartd copy: content: | smartd_enable=YES mode: 0640 owner: root group: wheel dest: /etc/rc.conf.d/smartd notify: restart smartd tags: smart, config - name: add devices to smartd.conf copy: content: | # send a test email on startup for all devices DEFAULT -m {{ smtp_sendto }} -M test DEVICESCAN -H -l error -l selftest -s L/../(02|08|16|24)/./0:002-020 {% for device in (ansible_devices.keys() | map('regex_search', '^a?da\d+') | select('string') | list) %} # /dev/{{ device}} -m {{ smtp_sendto }} -M smartd {% endfor %} dest: /usr/local/etc/smartd.conf notify: restart smartd tags: smart, config - name: add smart status to daily periodic lineinfile: dest: /etc/periodic.conf regexp: '^daily_status_smart_devices=' line: | daily_status_smart_devices= {{ '"' -}} {% for device in (ansible_devices.keys() | map('regex_search', '^a?da\d+') | select('string') | list) %} /dev/{{ device ~ ' ' -}} {% endfor %}{{ '"' -}} notify: restart smartd tags: smart, config