- name: Galene deps installed
  community.general.pkgng:
    name: "git go"
    state: latest

- name: Galene source deployed
  git:
    repo: "https://github.com/jech/galene"
    dest: /usr/local/src/galene
    accept_hostkey: yes
    force: yes
    update: yes

- name: limit_unix.go patched to build on FreeBSD
  shell:
    cmd: 'sed -i -e "s/uint64/int64/g" /usr/local/src/galene/limit/limit_unix.go'
    warn: false

- name: Galene binary built
  shell:
    chdir: /usr/local/src/galene
    cmd: go build .

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

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

- name: Galene enabled
  shell: sysrc galene_enable="YES"

- name: Galene started
  service: name=galene state=started
