---

- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat.yml"
  when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int < 8

- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat8.yml"
  when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int > 7 and ansible_distribution_major_version | int < 30

- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_fedora.yml"
  when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int > 30

- when: ansible_os_family == 'Debian'
  block:
  # ansible_lsb is only available if lsb-release is installed.
  - name: Ensure lsb-release installed
    ansible.builtin.apt:
      name:
        - lsb-release
      state: present
      update_cache: true
    register: lsb_release_installation_result

  - name: Reread ansible_lsb facts if lsb-release got installed
    ansible.builtin.setup: filter=ansible_lsb*
    when: lsb_release_installation_result.changed

  - ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_debian.yml"
    when: (ansible_os_family == 'Debian') and (ansible_lsb.id != 'Raspbian')

  - ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_raspbian.yml"
    when: (ansible_os_family == 'Debian') and (ansible_lsb.id == 'Raspbian')

- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_archlinux.yml"
  when: ansible_distribution == 'Archlinux'

- name: Ensure Docker is started and autoruns
  ansible.builtin.service:
    name: docker
    state: started
    enabled: true

- name: "Ensure ntpd is started and autoruns"
  ansible.builtin.service:
    name: "{{ matrix_ntpd_service }}"
    state: started
    enabled: true
