---
# Suse related tasks

- name: add rpmfusion-free-release {{ ansible_distribution_major_version|int }} repo
  dnf:
    name: https://download1.rpmfusion.org/free/el/rpmfusion-free-release-{{ ansible_distribution_major_version|int }}.noarch.rpm
    disable_gpg_check: yes
    validate_certs: no
    state: latest
  when: not {{ debug_speed_check }}

- name: update os
  dnf:
    name: '*'
    update_cache: true
    state: latest
  when: not {{ debug_speed_check }}

- name: install needed packages
  dnf:
    name:
      - epel-release
      - yum-utils
      - curl
      - bash-completion
      - mlocate
      - bzip2
      - wget
      - libreoffice
      - ffmpeg
      - mariadb
    state: latest
    enablerepo: epel
  when: not {{ debug_speed_check }}

- name: Ensure Apache is installed on {{ ansible_facts['distribution'] }}
  dnf:
    name: httpd
    state: present
  when: nextcloud_websrv in ["apache", "apache2"]
  notify: start http

- name: Set http env on {{ ansible_facts['distribution'] }}
  set_fact:
    http_service_name: httpd
    http_webroot: /var/www/html
    nextcloud_websrv_user: apache
    nextcloud_websrv_group: apache
  when: nextcloud_websrv in ["apache", "apache2"]

- name: Generate Nextcloud configuration for apache
  template:
    dest: /etc/httpd/conf.d/nextcloud.conf
    src: nextcloud_apache2.j2
    mode: 0640
  when: nextcloud_websrv in ["apache", "apache2"]
  notify: restart http
