#!/bin/bash
directories=("inventory/basel" "inventory/dev" "inventory/test01")

find "${directories[@]}" -type f -iname "*.yaml" | grep group_vars| sed 's#.*inventory/[^/]*/##' | sort -u \
    | while read -r file; do
        missing_in=()

        for dir in "${directories[@]}"; do
            if [[ ! -f "$dir/$file" ]]; then
                missing_in+=("$dir")
            fi
        done
        if [[ ${#missing_in[@]} -ne 0 && ${#missing_in[@]} -ne ${#directories[@]} ]]; then
            echo "${file##group_vars/} missing in: ${missing_in[*]##inventory/}"
        fi
    done
