---
- name: Dependencies installed
  community.general.pkgng:
    name: git-tiny,php80,php80-openssl,php80-pecl-memcached,php80-pecl-redis,php80-ldap,php80-filter,php80-session
    state: latest

- name: PHP-fpm enabled
  shell: sysrc php_fpm_enable="YES"

- name: Source folder exists
  file: path=/usr/local/src mode=0755 state=directory

- name: Conf folder exists
  file: path=/usr/local/etc/hauk mode=0755 state=directory

- name: Www folder exists
  file: path=/usr/local/www mode=0755 state=directory

- name: Hauk source deployed
  git:
    repo: "https://github.com/bilde2910/hauk"
    dest: /usr/local/src/hauk
    force: yes
    accept_hostkey: yes
    update: yes

- name: Removed Hauk config file
  file:
    state: absent
    path: /usr/local/etc/hauk/config.php

- name: Hauk installed
  shell:
    cmd: "./install.sh -f -c /usr/local/www/hauk"
    chdir: /usr/local/src/hauk

- name: Nginx location file installed
  ansible.builtin.copy:
    src: nginx.conf
    dest: /usr/local/etc/nginx/locations/hauk.conf
  notify: Nginx restarted

- name: Installed Hauk config file
  template:
    src: config.php.j2
    dest: /usr/local/etc/hauk/config.php
    mode: 0660
  notify: PHP-fpm restarted
