This commit is contained in:
phil 2023-03-01 10:56:33 +01:00
commit 9b8494b33b
7 changed files with 117 additions and 0 deletions

4
README.md Normal file
View file

@ -0,0 +1,4 @@
DIUN - Docker Image Update Notifier
===================================
This role installs [Duin](https://crazymax.dev/diun/).

7
defaults/main.yml Normal file
View file

@ -0,0 +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_binary_path: /usr/local/bin
duin_configuration_path: /etc/diun
duin_configuration_file: diun.yaml

6
handlers/main.yml Normal file
View file

@ -0,0 +1,6 @@
---
- name: restart diun
ansible.builtin.systemd:
name: diun
daemon_reload: true
state: restarted

10
meta/main.yml Normal file
View file

@ -0,0 +1,10 @@
galaxy_info:
author: Sense.Lab admin
description: Role to install Diun
company: Sense.Lab e.V.
license: GPLv3
min_ansible_version: "2.11"
platforms:
- name: Debian
versions:
- bullseye

53
tasks/main.yml Normal file
View file

@ -0,0 +1,53 @@
---
- name: "Create user"
ansible.builtin.user:
name: "{{ diun_user }}"
shell: /bin/false
create_home: false
password_lock: true
system: true
group: "{{ diun_user }}"
- 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'"
changed_when: false
register: download_url
- name: "Unarchive binary"
ansible.builtin.unarchive:
src: download_url.stdout
dest: "{{ diun_binary_path }}"
include:
- diun
mode: 0755
- name: "Create directories"
ansible.builtin.file:
path: "{{ item }}"
owner: "{{ diun_user }}"
group: "{{ diun_user }}"
mode: 0750
loop:
- "{{ diun_configuration_path }}"
- "{{ diun_home }}"
- name: "Copy configuration file"
ansible.builtin.template:
src: "{{ diun_configuration_file }}"
dest: "{{ diun_configuration_path }}"
mode: 0644
- name: "Copy service file"
ansible.builtin.template:
src: diun.service
dest: /etc/systemd/system/
mode: 0644
notify: restart duin
- name: "Enable service"
ansible.builtin.systemd:
name: diun
enabled: true
daemon_reload: true
state: started

19
templates/diun.service Normal file
View file

@ -0,0 +1,19 @@
# Managed by Ansible
[Unit]
Description=Diun
Documentation=https://crazymax.dev/diun/
After=syslog.target
After=network.target
[Service]
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
Restart=always
Environment=DIUN_DB_PATH={{ diun_home }}/diun.db
[Install]
WantedBy=multi-user.target

18
templates/diun.yaml Normal file
View file

@ -0,0 +1,18 @@
# Managed by Ansible
db:
path: {{ diun_home }}/diun.db
{% if diun_watch is defined %}
{{ duin_watch }}
{% endif %}
{% if diun_notif is defined %}
notif:
{{ duin_notif | indent(2, false) }}
{% endif %}
{% if diun_providers is defined %}
providers:
{{ duin_providers | indent(2, false) }}
{% endif %}