Find which RPM Azure repo is used in "yum repolist" for EUS or non EUS repos

Hello,

I'm looking for help with a script or ideally just a one line command perhaps that will check the results of yum repolist and look for a specific repo on a sever. We have some VM's using EUS repos from Red Hat and others that do not use EUS repos. The way we would see which repos are used is by issuing the yum repolist command.

Result #1 where EUS repos are used:

repo id                                                          repo name                                                                                 status
rhui-microsoft-azure-rhel7-EUS                                    Microsoft Azure RPMs for Red Hat Enterprise Linux 7                                            9
rhui-rhel-7-server-dotnet-rhui-debug-rpms/7Server/x86_64         dotNET on RHEL Debug RPMs for Red Hat Enterprise Linux 7 Server from RHUI                     78
rhui-rhel-7-server-dotnet-rhui-rpms/7Server/x86_64               dotNET on RHEL RPMs for Red Hat Enterprise Linux 7 Server from RHUI                          270

Result #2 where EUS is not used:

repo id                                                          repo name                                                                                 status
rhui-microsoft-azure-rhel7                                       Microsoft Azure RPMs for Red Hat Enterprise Linux 7                                            9
rhui-rhel-7-server-dotnet-rhui-debug-rpms/7Server/x86_64         dotNET on RHEL Debug RPMs for Red Hat Enterprise Linux 7 Server from RHUI                     78
rhui-rhel-7-server-dotnet-rhui-rpms/7Server/x86_64               dotNET on RHEL RPMs for Red Hat Enterprise Linux 7 Server from RHUI                          270

As you can see Result #1 has rhui-microsoft-azure-rhel7-EUS and Result #2 has rhui-microsoft-azure-rhel7.

is there a one line command I can issue that would provide True or False or provide the repo ID for a server?

Thank you in advance for any advice you can provide for me.

How far would

if [[ $(grep -o "rhui-microsoft-azure-rhel7[^ ]*" file1) =~ EUS ]]; then echo TRUE; else echo FALSE; fi
TRUE

get you?

Hello @Rudic,

Thanks very much for the reply. I'm not sure I understand the command you've provided to me. I've tried running this command on a server that is using the EUS repos and the command returned false. How does your command search in the yum repolist?

I tried another way whereby I searched for the name of the EUS file in the /etc/yum.repos.d/rh-cloud-eus.repo using the below command and it seems to be working for me in finding servers wtih the EUS repo file.

[[ -f /etc/yum.repos.d/rh-cloud-eus.repo ]] && echo "EUS Repo file Exists" || echo "EUS Repo File does not exist"

Thank you.