---
- name: Install smartd
  apt:
    update_cache: true
    name: smartmontools
  register: apt_result
  retries: 3
  until: apt_result is succeeded

- name: Disable smartd autodiscovery
  lineinfile:
    path: /etc/smartd.conf
    regexp: '(?i)^(DEVICESCAN.*)'
    line: '#\1'
    backrefs: yes
  notify: Restart smartd

- name: Monitor local HP SmartArray
  lineinfile:
    path: /etc/smartd.conf
    regexp: '^/dev/sg0'
    line: /dev/sg0 -a -d cciss,0 -m root
  notify: Restart smartd