/home/travis/.ansible/roles/robertdebock.clamav/handlers/main.yml
---
# handlers file for clamav
- name: restart clamav
  service:
    name: "{{ item }}"
    state: restarted
  loop: "{{ clamav_services }}"

- name: ensure logfiles exists
  file:
    path: "{{ item }}"
    state: touch
    owner: "{{ clamav_owner }}"
    group: "{{ clamav_group }}"
    mode: "0750"
  loop:
    - /var/log/clamd.scan
    - "{{ clamav_freshclam_log_dir }}/freshclam.log"

- name: stop clamav
  service:
    name: "{{ item }}"
    state: stopped
  loop: "{{ clamav_services }}"

- name: update virus definitions
  command: freshclam
  args:
    creates: /var/lib/clamav/main.cvd
  async: 900
  poll: 0
  register: updatevirusdefinitions

- name: create selinux mod for clamav
  command: checkmodule -M -m -o /etc/my-clamd.mod /etc/my-clamd.te

- name: create selinux pp for clamav
  command: semodule_package -o /etc/my-clamd.pp -m /etc/my-clamd.mod

- name: load selinux pp for clamav
  command: semodule -i /etc/my-clamd.pp