---
- ansible.builtin.include_role:
    name: evolix/remount-usr
  when: evocheck_bin_dir is search("/usr")
  tags:
    - evocheck

- name: Scripts dir is present
  ansible.builtin.file:
    path: "{{ evocheck_bin_dir }}"
    state: directory
    owner: root
    group: root
    mode: "0700"
  tags:
    - evocheck

- name: Script for Debian 7 and earlier
  ansible.builtin.set_fact:
    evocheck_script_src: evocheck.wheezy.sh
  when: ansible_distribution_major_version is version('7', '<=')

- name: Script for Debian 8
  ansible.builtin.set_fact:
    evocheck_script_src: evocheck.jessie.sh
  when: ansible_distribution_major_version is version('8', '=')

- name: Script for Debian 9 and later
  ansible.builtin.set_fact:
    evocheck_script_src: evocheck.sh
  when: ansible_distribution_major_version is version('9', '>=')

- name: Copy evocheck.sh
  ansible.builtin.copy:
    src: "{{ evocheck_script_src }}"
    dest: "{{ evocheck_bin_dir }}/evocheck.sh"
    mode: "0700"
    owner: root
    force: true
  tags:
    - evocheck

- name: Copy evocheck.cf
  ansible.builtin.copy:
    src: evocheck.cf
    dest: /etc/evocheck.cf
    force: false
  tags:
    - evocheck
