ansible/playbooks/apps/goatcounter.yaml
2024-10-11 19:10:10 +02:00

75 lines
2.5 KiB
YAML

---
- name: Goatcounter
hosts: servers
gather_facts: false
tasks:
- name: Get latest release
community.general.github_release:
action: latest_release
user: arp242
repo: goatcounter
register: release
- name: Print release
ansible.builtin.debug:
var: release.tag
- name: Download binary
ansible.builtin.get_url:
url: https://github.com/arp242/goatcounter/releases/download/{{ release.tag }}/goatcounter-{{ release.tag }}-linux-amd64.gz
dest: "{{ dir }}/goatcounter-{{ release.tag }}.gz"
mode: "0644"
- name: Uncompress
ansible.builtin.command: gunzip {{ dir }}/goatcounter-{{ release.tag }}.gz
args:
creates: "{{ dir }}/goatcounter-{{ release.tag }}"
- name: Make executable
ansible.builtin.file:
path: "{{ dir }}/goatcounter-{{ release.tag }}"
mode: "0755"
- name: Symlink
ansible.builtin.file:
src: "{{ dir }}/goatcounter-{{ release.tag }}"
dest: "{{ dir }}/goatcounter"
state: link
- name: Write service unit file
become: true
ansible.builtin.template:
src: templates/goatcounter.service.j2
dest: /etc/systemd/system/goatcounter.service
mode: "0600"
owner: root
group: root
notify:
- Daemon-reload
- Restart service
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Ensure service is running
become: true
ansible.builtin.service:
name: goatcounter
state: started
enabled: true
handlers:
- name: Daemon-reload
become: true
ansible.builtin.systemd:
daemon_reload: true
- name: Restart service
become: true
ansible.builtin.service:
name: goatcounter
state: restarted
vars:
ansible_python_interpreter: /tmp/ansible/bin/python
dir: /mnt/data/goatcounter
gc_mailgun_api_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
31386237653033306338393237353961396535363061363931643863653461333631376365663338
3266346337353564656539666235656265356435343834380a616232383839663639616537393233
64303764306639636136346233366666633765393565353062396632636163643031616235303130
3662343162643033380a326161313036643835636562636165356464393236303533303435353365
36336163313338346235396565363631366564393562326536353262363637653432643830663532
30356133383335653330613965623261323531613131663437363430636565393262353565326132
323830313235313462633335333763363161