This commit is contained in:
phil 2023-03-01 11:35:03 +01:00
parent 9b8494b33b
commit dd8f45246f
4 changed files with 29 additions and 12 deletions

View file

@ -1,7 +1,7 @@
---
diun_user: duin
diun_github_api_url: https://api.github.com/repos/crazy-max/diun/releases/latest
duin_home: /var/lib/duin
diun_home: /var/lib/duin
diun_binary_path: /usr/local/bin
duin_configuration_path: /etc/diun
duin_configuration_file: diun.yaml
diun_configuration_path: /etc/diun
diun_configuration_file: diun.yaml

View file

@ -1,4 +1,10 @@
---
- name: "Create group"
ansible.builtin.group:
name: "{{ diun_user }}"
state: present
system: true
- name: "Create user"
ansible.builtin.user:
name: "{{ diun_user }}"
@ -10,21 +16,25 @@
- name: "Get download URL"
ansible.builtin.shell:
cmd: curl -sL "{{ diun_github_api_url }}" | jq '.assets[] | select(.name|match("linux_amd64.tar.gz$")) | .browser_download_url'"
cmd: curl -sL "{{ diun_github_api_url }}" | jq -r '.assets[] | select(.name|match("linux_amd64.tar.gz$")) | .browser_download_url'
changed_when: false
register: download_url
- name: "Unarchive binary"
ansible.builtin.unarchive:
src: download_url.stdout
src: "{{ download_url.stdout }}"
dest: "{{ diun_binary_path }}"
include:
- diun
remote_src: true
include: diun
mode: 0755
extra_opts:
- "--strip=1"
- "--no-anchored"
- name: "Create directories"
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ diun_user }}"
group: "{{ diun_user }}"
mode: 0750
@ -43,7 +53,7 @@
src: diun.service
dest: /etc/systemd/system/
mode: 0644
notify: restart duin
notify: restart diun
- name: "Enable service"
ansible.builtin.systemd:

View file

@ -11,7 +11,7 @@ RestartSec=2s
Type=simple
User={{ diun_user }}
Group={{ diun_user }}
ExecStart={{ diun_binary_path }}/diun serve --config {{ duin_configuration_path }}/{{ duin_configuration_file }} --log-level info
ExecStart={{ diun_binary_path }}/diun serve --config {{ diun_configuration_path }}/{{ diun_configuration_file }} --log-level info
Restart=always
Environment=DIUN_DB_PATH={{ diun_home }}/diun.db

View file

@ -4,15 +4,22 @@ db:
path: {{ diun_home }}/diun.db
{% if diun_watch is defined %}
{{ duin_watch }}
watch:
{{ diun_watch.config | indent(2) }}
{% endif %}
{% if diun_notif is defined %}
notif:
{{ duin_notif | indent(2, false) }}
{% for name in diun_notif %}
{{ name.name }}:
{{ name.config | indent(4) }}
{% endfor %}
{% endif %}
{% if diun_providers is defined %}
providers:
{{ duin_providers | indent(2, false) }}
{% for name in diun_providers %}
{{ name.name }}:
{{ name.config | indent(4) }}
{% endfor %}
{% endif %}