From 273ae3bab8aba88c61bfb8d5aefb060dc22b42d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de> Date: Tue, 2 Apr 2024 15:39:36 +0200 Subject: [PATCH] fix: use custom fact to write Rosetta app.version to global.properties file instead of the hardcoded shit that was used before and broke my installation --- .../ansible/facts.d/rosetta_app_version.fact | 8 +++++++ tasks/rosetta/main_rosetta.yml | 3 +++ tasks/rosetta/prepare_custom_facts.yml | 23 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 files/etc/ansible/facts.d/rosetta_app_version.fact create mode 100644 tasks/rosetta/prepare_custom_facts.yml diff --git a/files/etc/ansible/facts.d/rosetta_app_version.fact b/files/etc/ansible/facts.d/rosetta_app_version.fact new file mode 100644 index 0000000..f0fafde --- /dev/null +++ b/files/etc/ansible/facts.d/rosetta_app_version.fact @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# example string in global.properties file: +# app.version=8.1.0.0 +if [[ -e "/exlibris/dps/d4_1/system.dir/conf/global.properties" ]]; then + ver=$( grep -r "app.version" /exlibris/dps/d4_1/system.dir/conf/global.properties | cut -d "=" -f2 ); + echo "{\"version\" : \"${ver}\"}"; +fi diff --git a/tasks/rosetta/main_rosetta.yml b/tasks/rosetta/main_rosetta.yml index 6835408..651543e 100644 --- a/tasks/rosetta/main_rosetta.yml +++ b/tasks/rosetta/main_rosetta.yml @@ -1,6 +1,9 @@ --- ### ROSETTA TASKS +- name: prepare custom facts + ansible.builtin.import_tasks: "rosetta/prepare_custom_facts.yml" + tags: [facts] - name: configure iptables Rosetta ansible.builtin.import_tasks: "rosetta/configure_iptables_rosetta.yml" tags: [iptables] diff --git a/tasks/rosetta/prepare_custom_facts.yml b/tasks/rosetta/prepare_custom_facts.yml new file mode 100644 index 0000000..11af3c9 --- /dev/null +++ b/tasks/rosetta/prepare_custom_facts.yml @@ -0,0 +1,23 @@ +--- +- name: "Create custom fact directory" + ansible.builtin.file: + path: "/etc/ansible/facts.d" + state: "directory" + mode: "0755" + +### ATTENTION!!! +# This custom fact script assumes that whatever app.version is set in the +# global.properties file IS THE CORRECT ONE! The mechanism is quite trivial: +# read the old value, set it as fact, write it to the template. +# If the previous app.version is set incorrectly, then the new one will be as +# well! +# Read up on custom facts here: +# https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_vars_facts.html#adding-custom-facts +- name: install custom fact file for getting installed Rosetta version + ansible.builtin.copy: + src: "etc/ansible/facts.d/rosetta_app_version.fact" + dest: "/etc/ansible/facts.d/rosetta_app_version.fact" + mode: "0755" + +- name: "Re-run setup to use custom facts" + ansible.builtin.setup: ~ -- GitLab