From f3281e7813e9c1a0a1e4339458287991e9b233d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de>
Date: Mon, 11 Nov 2024 10:24:36 +0100
Subject: [PATCH] feat: add check to see if we're running the tasks against a
 Rosetta-backed SubApp server based on inventory group membership. This can
 later be reused to distinguish between Rosetta and Archivematica SubApp
 servers.

---
 molecule/virtualbox_debian12/molecule.yml | 2 ++
 tasks/main.yml                            | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/molecule/virtualbox_debian12/molecule.yml b/molecule/virtualbox_debian12/molecule.yml
index ea41ebc..9c43624 100644
--- a/molecule/virtualbox_debian12/molecule.yml
+++ b/molecule/virtualbox_debian12/molecule.yml
@@ -15,6 +15,8 @@ platforms:
   - name: sdvlzasubappmoleculetest
     box: debian/bookworm64
     memory: 1024
+    groups:
+      - "lza_ingest_molecule"
     # List of raw Vagrant `config` options.
     # provider_raw_config_args:
     #   - "customize [ 'modifyvm', :id, '--natdnshostresolver1', 'on' ]"
diff --git a/tasks/main.yml b/tasks/main.yml
index 545f833..102d170 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,4 +1,13 @@
 ---
+- name: |
+    Make sure that these tasks are only run against SubApp servers that are
+    used together with Rosetta. Archivematica-SubApp-VMs need to be provisioned
+    with another branch of this Ansible role.
+  ansible.builtin.assert:
+    that: "group_names | select('search', 'lza_ingest.*')"
+    fail_msg: This is not a SubApp VM for use with Rosetta. Aborting.
+    success_msg: This is a SubApp VM for use with Rosetta. Continuing.
+
 - name: include vars main
   ansible.builtin.include_vars: "main.yml"
   tags: [always]
-- 
GitLab