---
- name: Dependencies installed
  community.general.pkgng:
    name: git-tiny,go,python38,py38-pip,npm
    state: latest
  tags:
    - build

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

- name: Ntfy source deployed
  git:
    repo: "https://github.com/binwiederhier/ntfy.git"
    dest: /usr/local/src/ntfy
    force: yes
    accept_hostkey: yes
    update: yes
  tags:
    - build

- name: Pip linked to pip3
  file: src=/usr/local/bin/pip dest=/usr/local/bin/pip3 state=link

- name: Ntfy documentation and webapp built
  shell:
    chdir: /usr/local/src/ntfy
    cmd: make docs && make web
  tags:
    - build

- name: Ntfy binary built
  shell:
    chdir: /usr/local/src/ntfy
    cmd: go build .

- name: Install ntfy
  ansible.builtin.copy:
    src: /usr/local/src/ntfy/ntfy
    dest: /usr/local/bin/ntfy
    remote_src: yes
    mode: a+x
  notify: Ntfy restarted

- name: Ntfy rc file installed
  ansible.builtin.copy:
    src: ntfy.rc
    dest: /usr/local/etc/rc.d/ntfy
    mode: a+x
  notify: Ntfy restarted
