From a93f3682ad759b5d3efed664a030ee7af6440cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <Joerg.Sachse@slub-dresden.de> Date: Fri, 5 Mar 2021 10:25:01 +0100 Subject: [PATCH] feat: install repairtools from Debian package repository instead of manually compiling them --- handlers/main.yml | 10 +++ tasks/install-repair-tools.yml | 45 +++++++------ .../tiff_treatment_loop/compile_checkit.sh.j2 | 64 ------------------- 3 files changed, 34 insertions(+), 85 deletions(-) delete mode 100644 templates/tiff_treatment_loop/compile_checkit.sh.j2 diff --git a/handlers/main.yml b/handlers/main.yml index 90d7ec0..e61a7de 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,4 +1,14 @@ --- +# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/systemd_module.html - name: systemctl daemon-reload systemd: daemon-reload: "yes" + +# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/systemd_module.html +- name: restart repairtools + systemd: + name: "{{ item }}" + state: restarted + loop: + - "repair_daemon_ddz.service" + - "repair_daemon_digas.service" diff --git a/tasks/install-repair-tools.yml b/tasks/install-repair-tools.yml index d605972..e8bf411 100644 --- a/tasks/install-repair-tools.yml +++ b/tasks/install-repair-tools.yml @@ -16,13 +16,33 @@ tags: [apt] when: "ansible_facts['distribution'] == 'Debian'" +- name: cleanup legacy tools + file: + path: "{{ item }}" + state: absent + loop: + - "/usr/local/bin/checkit_tiff" + - "/usr/local/bin/fixit_tiff" + - "/home/{{ vault_service_user }}/.cache/SLUB_LZA_Reparaturtool.cache" + notify: restart repairtools + - name: install repairtool (package dependencies are encoded in the package) apt: name: [ - 'libslub-lza-repair-perl' + 'libslub-lza-repair-perl', + 'checkit_tiff', + 'fixit_tiff' ] state: present - tags: [repairtools, apt] + tags: [apt] + +- name: install checkit_tiff config + copy: + src: "/usr/share/checkit_tiff/example_configs/cit_tiff6_baseline_SLUB.cfg" + dest: "/etc/cit_tiff6_baseline_SLUB.cfg" + owner: "{{ vault_service_user }}" + group: "{{ vault_service_user }}" + mode: 0600 - name: create caching directory file: @@ -35,22 +55,6 @@ - "/home/{{ vault_service_user }}/.cache/" - "/home/{{ vault_service_user }}/.config/repair/bin/" - "/home/{{ vault_service_user }}/.config/repair/cfg/" - tags: [repairtools] - -### TIFF-REPAIR-TOOLS INSTALLIEREN ### -- name: checkit_tiff und fixit_tiff kompilieren und installieren (1/2) - template: - src: "tiff_treatment_loop/compile_checkit.sh.j2" - dest: "/tmp/compile_checkit.sh" - mode: "0544" - register: checkit_tiff_result - tags: [repairtools] - -- name: checkit_tiff und fixit_tiff kompilieren und installieren (2/2) - command: bash /tmp/compile_checkit.sh &> /tmp/compile_checkit.log # noqa 301 - #when: checkit_tiff_result.changed - #tags: [repairtools, molecule-notest] - tags: [repairtools] - name: Symlinks zu Binaries und Configs für checkit_tiff und fixit_tiff erstellen file: @@ -60,10 +64,9 @@ owner: "{{ vault_service_user }}" group: "{{ vault_service_user }}" with_items: - - src: "/usr/local/bin/checkit_tiff" + - src: "/usr/bin/checkit_tiff" dest: "/home/{{ vault_service_user }}/.config/repair/bin/checkit_tiff" - - src: "/usr/local/bin/fixit_tiff" + - src: "/usr/bin/fixit_tiff" dest: "/home/{{ vault_service_user }}/.config/repair/bin/fixit_tiff" - src: "/etc/cit_tiff6_baseline_SLUB.cfg" dest: "/home/{{ vault_service_user }}/.config/repair/cfg/cit_tiff6_baseline_SLUB.cfg" - tags: [repairtools] diff --git a/templates/tiff_treatment_loop/compile_checkit.sh.j2 b/templates/tiff_treatment_loop/compile_checkit.sh.j2 deleted file mode 100644 index e278c6e..0000000 --- a/templates/tiff_treatment_loop/compile_checkit.sh.j2 +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash -set -ex - -FIXIT_PATH="fixit_tiff" -GITDIR="/tmp/git/" - -CHECKIT_TIFF_GITREPO="{{ vault_checkit_tiff_gitrepo }}" -FIXIT_TIFF_GITREPO="{{ vault_fixit_tiff_gitrepo }}" -# CHECKIT_TIFF_PLUGIN_GITREPO="{{ vault_checkit_tiff_plugin_gitrepo }}" - -# DEB_PACKAGES="git make cmake build-essential libpcre3 libpcre3-dev libtiff5 libtiff5-dev" -DEB_PACKAGES="git make cmake build-essential libpcre3-dev libtiff5-dev" - -[[ -d "${GITDIR}" ]] && rm -r "${GITDIR}" && echo "removed ${GITDIR}" -mkdir "${GITDIR}" && cd "${GITDIR}" -pwd -apt-get install -y ${DEB_PACKAGES} - -# THIS IS A BAD IDEA!!! ONLY SKIP CERTIFICATE VALIDATION IF THERE'S NO OTHER -# ALTERNATIVE!!! -export GIT_SSL_NO_VERIFY=true - -# git clone ${CHECKIT_TIFF_PLUGIN_GITREPO} -# cd ./checkit_tiff_plugin4rosetta || ( echo "Couldn't cd to ./checkit_tiff_plugin4rosetta, exiting." && exit 1 ) -# tag_current=$( head deploy_checkit_tiff/Dockerfile | grep -Fv '#' | grep -F "checkit_tiff_current_version=" | cut -d "=" -f 2 ) -tag_current="{{ checkit_tiff_version }}" - - - -# compile checkit_tiff CURRENT version -cd "${GITDIR}" || ( echo "Couldn't cd to $GITDIR, exiting." && exit 1 ) -git clone "${CHECKIT_TIFF_GITREPO}" -cd "${GITDIR}checkit_tiff${CHECKIT_CURRENT_NAME}/" -git checkout "tags/${tag_current}" -mkdir build/ && cd build/ -#cmake ../src/ -cmake -DCMAKE_C_FLAGS="-O3 -s -Wno-unused-function -fstack-check -fstack-protector-strong -Wformat -Werror=format-security" ../src/ -make -j -cp checkit_tiff /usr/local/bin/checkit_tiff && \ - chown lza.lza /usr/local/bin/checkit_tiff && \ - chmod 0700 /usr/local/bin/checkit_tiff -cp ../example_configs/cit_tiff6_baseline_SLUB.cfg /etc/cit_tiff6_baseline_SLUB.cfg && \ - chown lza.lza /usr/local/etc/cit_tiff6_baseline_SLUB.cfg && \ - chmod 0600 /usr/local/etc/cit_tiff6_baseline_SLUB.cfg - - - -# compile fixit_tiff -cd ${GITDIR} || ( echo "Couldn't cd to $GITDIR, exiting." && exit 1 ) -git clone "${FIXIT_TIFF_GITREPO}" -mkdir -p ${FIXIT_PATH}/build/ && cd ${FIXIT_PATH}/build/ -cmake ../src/ -make -j -cp fixit_tiff /usr/local/bin/fixit_tiff && \ - chown lza.lza /usr/local/bin/fixit_tiff && \ - chmod 0700 /usr/local/bin/fixit_tiff - - - -# cleanup -apt-get purge -y ${DEB_PACKAGES} -apt-get clean -y -apt-get autoremove -y -rm -r /tmp/git/ -- GitLab