From 3ca2e7292d4040c04d7b76a34054299fe07faee9 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Tue, 8 Feb 2022 10:37:40 +0100 Subject: [PATCH] ansible: fewer hard-coded paths in roles --- ansible/roles/common/tasks/main.yml | 2 +- ansible/roles/labe/defaults/main.yml | 5 ++++ ansible/roles/labe/tasks/main.yml | 14 ++++++++--- ansible/roles/labe/templates/labed.service.j2 | 25 +++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 ansible/roles/labe/templates/labed.service.j2 diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml index d7da712..bd54e39 100644 --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -37,4 +37,4 @@ - name: "Install solrdump" apt: # https://github.com/ubleipzig/solrdump/releases - deb: https://github.com/ubleipzig/solrdump/releases/download/v0.1.7/solrdump_0.1.7_amd64.deb + deb: https://github.com/ubleipzig/solrdump/releases/download/v{{ solrdump_version }}/solrdump_{{ solrdump_version }}_amd64.deb diff --git a/ansible/roles/labe/defaults/main.yml b/ansible/roles/labe/defaults/main.yml index 69c72cc..b5e4aaf 100644 --- a/ansible/roles/labe/defaults/main.yml +++ b/ansible/roles/labe/defaults/main.yml @@ -1,5 +1,10 @@ labe_user: labe labe_group: labe labe_data_dir: /usr/share/labe +labed_addr: 0.0.0.0:8000 +labed_access_log: /var/log/labe-access.log +labed_log: /var/log/labe.log ckit_version: 0.1.37 labe_version: 0.1.37 +solrdump_version: 0.1.7 + diff --git a/ansible/roles/labe/tasks/main.yml b/ansible/roles/labe/tasks/main.yml index 70c8424..2f7f481 100644 --- a/ansible/roles/labe/tasks/main.yml +++ b/ansible/roles/labe/tasks/main.yml @@ -14,6 +14,12 @@ apt: deb: https://github.com/slub/labe/releases/download/v{{ ckit_version }}/ckit_{{ ckit_version }}_amd64.deb +- name: "Override package ckit/labed systemd unit file" + template: + src: "labed.service.j2" + dest: "/etc/systemd/system/labed.service" + mode: 0644 + - name: "Install labe release" apt: deb: https://github.com/slub/labe/releases/download/v{{ labe_version }}/labe_{{ labe_version}}_amd64.deb @@ -24,7 +30,7 @@ - name: "Change application log file ownership" file: - path: /var/log/labe.log + path: "{{ labed_log }}" owner: "{{ labe_user }}" group: "{{ labe_group }}" state: touch @@ -32,7 +38,7 @@ - name: "Change access log file ownership" file: - path: /var/log/labe-access.log + path: "{{ labed_access_log }}" owner: "{{ labe_user }}" group: "{{ labe_group }}" state: touch @@ -57,7 +63,7 @@ lp_logrotate_confd: - path: labe conf: | - /var/log/labe.log { + {{ labed_log }} { daily rotate 3 size 100M @@ -66,7 +72,7 @@ } - path: labe-access conf: | - /var/log/labe-access.log { + {{ labed_access_log }} { daily rotate 3 size 100M diff --git a/ansible/roles/labe/templates/labed.service.j2 b/ansible/roles/labe/templates/labed.service.j2 new file mode 100644 index 0000000..8111112 --- /dev/null +++ b/ansible/roles/labe/templates/labed.service.j2 @@ -0,0 +1,25 @@ +[Unit] +Description=Server for labe citation project +Documentation=https://www.github.com/slub/labe +After=network.target + +[Service] +Type=simple +User={{ labe_user }} +WorkingDirectory=/tmp +ExecStart=/usr/local/bin/labed \ + -addr {{ labed_addr }} \ + -a {{ labed_access_log }} \ + -logfile {{ labed_log }} \ + -c \ + -z \ + -i {{ labe_data_dir }}/data/IdMappingDatabase/current \ + -o {{ labe_data_dir }}/data/OpenCitationsDatabase/current \ + -m {{ labe_data_dir }}/data/SolrDatabase/current-ai-short \ + -m {{ labe_data_dir }}/data/SolrDatabase/current-main-short \ + -m {{ labe_data_dir }}/data/SolrDatabase/current-slub-production +Restart=on-failure + +[Install] +WantedBy=multi-user.target +