---
- name: Dependencies installed
  community.general.pkgng:
    name: git-tiny,go,npm-node18,pkgconf,gmake,taglib
    state: latest


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

- name: Navidrome source cloned
  git:
    repo: "https://github.com/navidrome/navidrome.git"
    dest: /usr/local/src/navidrome
    accept_hostkey: yes
    update: yes
  ignore_errors: true
  tags:
    - deploy

- name: Build navidrome
  command: gmake setup && gmake buildall
  args:
    chdir: /usr/local/src/navidrome
  ignore_errors: true

- name: Immortal file installed
  file:
    src: immortal.yml
    dest: /usr/local/etc/immortal/navidrome.yml
    owner: root
    mode: 0600
    state: file
  notify: Immortal restarted
