From eaac835f0597cd327ccda847d5b73c9f3f302a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de> Date: Mon, 19 May 2025 15:25:28 +0200 Subject: [PATCH] feat: run shellcheck during Molecule Verify stage --- molecule/resources/playbooks/verify.yml | 12 ++++++++++++ molecule/virtualbox_alma8/molecule.yml | 1 + tasks/rosetta/install_mediaconch.yml | 8 ++++++++ .../local/bin/nfs_timeout_notification.service.sh.j2 | 4 ++-- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/molecule/resources/playbooks/verify.yml b/molecule/resources/playbooks/verify.yml index 75b4ec4..61a63af 100644 --- a/molecule/resources/playbooks/verify.yml +++ b/molecule/resources/playbooks/verify.yml @@ -42,3 +42,15 @@ that: "'MediaConch Command Line Interface' in mediaconch_output.stdout" success_msg: MediaConch runs as expected. fail_msg: MediaConch couldn't be run without errors. + + - name: Install shellcheck. + ansible.builtin.dnf: + name: "ShellCheck" + state: latest + become: true + - name: Run shellcheck for deployed Shell scripts. + ansible.builtin.command: + cmd: "shellcheck --shell=bash {{ item }}" + loop: + - "/usr/local/bin/nfs_timeout_notification.service.sh" + become: true diff --git a/molecule/virtualbox_alma8/molecule.yml b/molecule/virtualbox_alma8/molecule.yml index 960221b..b1facf5 100644 --- a/molecule/virtualbox_alma8/molecule.yml +++ b/molecule/virtualbox_alma8/molecule.yml @@ -57,6 +57,7 @@ provisioner: # https://stackoverflow.com/questions/57435811/ansible-molecule-pass-multiple-vault-ids # vault_identity_list: "@$HOME/.ansible/roles/lza_install_common.pass, @$HOME/.ansible/roles/passfile_1.pass" vault_identity_list: "../../../lza_install_common.pass, ../../../lza_rosetta_app.pass" + stdout_callback: debug vvv: false playbooks: # create: ../resources/playbooks/create.yml diff --git a/tasks/rosetta/install_mediaconch.yml b/tasks/rosetta/install_mediaconch.yml index 9c25c0f..3cf606f 100644 --- a/tasks/rosetta/install_mediaconch.yml +++ b/tasks/rosetta/install_mediaconch.yml @@ -20,6 +20,14 @@ update_cache: true state: latest +- name: create directory + ansible.builtin.file: + path: "/operational_shared/software/" + state: directory + mode: "0o755" + owner: "{{ vault_rosetta_user }}" + group: "{{ vault_rosetta_group }}" + - name: check MediaConch symlink ansible.builtin.stat: path: "/operational_shared/software/mediaconch" diff --git a/templates/usr/local/bin/nfs_timeout_notification.service.sh.j2 b/templates/usr/local/bin/nfs_timeout_notification.service.sh.j2 index ad5e7d4..45e49ae 100644 --- a/templates/usr/local/bin/nfs_timeout_notification.service.sh.j2 +++ b/templates/usr/local/bin/nfs_timeout_notification.service.sh.j2 @@ -4,7 +4,7 @@ WAIT_BETWEEN_MAILS_IN_SECONDS={{ vault_nfs_timeout_notification_service.wait_bet NO_MAIL_UNTIL_EPOCH=0; journalctl -f | while read -r LINE; do TIMEOUT=$(echo "${LINE}" | grep "nfs.*timed out"); - if [[ ! -z "${TIMEOUT}" ]]; then + if [[ -n "${TIMEOUT}" ]]; then TIME=$(date +%s); if [[ "${TIME}" -ge "${NO_MAIL_UNTIL_EPOCH}" ]]; then NO_MAIL_UNTIL_EPOCH=$((TIME + WAIT_BETWEEN_MAILS_IN_SECONDS)); @@ -13,4 +13,4 @@ journalctl -f | while read -r LINE; do fi; fi; TIMEOUT=""; -done; \ No newline at end of file +done; -- GitLab