---
- name: Dependencies installed
  community.general.pkgng:
    name: git-tiny,php82-pecl-redis,php82-ctype,php82-xml,php82-pdo_pgsql,php82-tokenizer,php82-fileinfo,php82-bcmath,php82-mbstring,php82-dom
    state: latest

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

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

- name: Fetched linkace source
  shell:
    chdir: /usr/local/src/linkace
    cmd: fetch https://github.com/Kovah/LinkAce/releases/download/v1.13.0/linkace-v1.13.0.zip

- name: Unpacked linkace source
  ansible.builtin.command:
    chdir: /usr/local/src/linkace
    cmd: unzip -o linkace-v1.13.0.zip

- name: Unpacked linkace source (inception)
  ansible.builtin.command:
    chdir: /usr/local/src/linkace
    cmd: unzip -o linkace.zip

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

- name: Installed Linkace config file
  template:
    src: linkace.env.j2
    dest: /usr/local/src/linkace/.env
    mode: 0660

- name: Linkace migrate db
  ansible.builtin.command:
    chdir: /usr/local/src/linkace
    cmd: php artisan migrate

