---
- name: Dependencies installed
  community.general.pkgng:
    name: "git go chromimum pdftk qpdf unoconv"
    state: latest

- name: Gotenberg source cloned
  git:
    repo: "https://github.com/gotenberg/gotenberg.git"
    dest: /usr/local/src/
    update: yes
    force: yes

- name: Gotenberg built
  shell:
    cmd: go build -o gotenberg -ldflags "-X 'github.com/gotenberg/gotenberg/v7/cmd.Version=7.4.3'" cmd/gotenberg/main.go
    chdir: /usr/local/src/gotenberg

- name: Gotenberg installed
  copy:
    src: /usr/local/src/gotenberg/gotenberg
    dest: /usr/local/bin/gotenberg
    owner: root
    mode: 0744

- name: Gotenberg rc file installed ansible.builtin.copy:
    src: gotenberg.rc
    dest: /usr/local/etc/rc.d/gotenberg
    mode: a+x

- name: Gotenberg enabled
  shell: sysrc gotenberg_enable="YES"

- name: Gotenberg started
  service: name=gotenberg state=started
