Find all git submodules in all projects in our GitLab instance

We are renaming our internally hosted GitLab server.
Some projects use other repositories as submodules.

There is a good point about configuring submodules with relative remote URLs: Using Git submodules with GitLab CI/CD | GitLab
However historically we have lots of submodules with absolute URLs.
In lots of projects.
In lots of branches.

Is there a way to automate search through the whole GitLab instance to find such submodules with absolute path. Through API?
Then we would convert them to relative, prior to renaming of the GitLab server. And save the world!

In case someone will face the same problem here is the little script I made.
Run it on the GitLab server where it will go through the Git repositories where they are stored inside GitLab.

#!/bin/bash

base_path=/var/opt/gitlab/git-data/repositories
file_name=.gitmodules
search_regex=<OLD_SERVER_NAME>

for repo in `find $base_path -type d -name *.git`
do
	pushd $repo > /dev/null

	for branch in `git for-each-ref refs/heads --format="%(refname)"`
	do
		object=`git ls-tree $branch -- $file_name | awk '{print $3}'`
		if [ $object ]
		then
			git grep -E --ignore-case -q $search_regex $object && echo "$repo: $branch"
		fi
	done

	popd > /dev/null
done