is_redhat() misses Rocky/Alma/CentOS Stream/Oracle Linux lsb_release IDs -> pkg dies "OS/Provider not supported"
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- perl
- Domain
- cli, devops, infrastructure
Research direction
Look at Rex::Commands::Gather::is_redhat to see the @redhat_clones list and the regex matching. The issue mentions specific files: Rex::Hardware::Host::get_operating_system and Rex::Pkg->get. Start by adding the missing OS names to the list and fixing the comparison to be exact. Test by installing lsb_release on a Rocky/Alma system and running the provided rex command to verify pkg works.
Written by the indexing model from the issue text.
Description
Rex version: 1.16.1 (is_redhat unchanged on master)
Problem
On current RHEL rebuilds the OS detection depends on whether lsb_release is installed:
- Without lsb_release,
Rex::Hardware::Host::get_operating_systemfalls through to/etc/redhat-releaseand returnsRedhat, so everything works. - With lsb_release, it returns
lsb_release -s -iverbatim (only SUSE and ManjaroLinux are normalised). The IDs current rebuilds report there are not in@redhat_clonesinRex::Commands::Gather::is_redhat:
| lsb_release -s -i | source | is_redhat |
|---|---|---|
Rocky |
redhat-lsb-core 4.1 (Rocky 8/9) | 0 |
RockyLinux |
EPEL lsb_release 3.2 | 0 |
AlmaLinux |
both | 0 |
CentOSStream |
redhat-lsb-core 4.1 | 0 |
OracleLinux |
EPEL lsb_release 3.2 | 0 |
Because of that, Rex::Pkg->get does not map the host to Redhat. It tries Rex::Pkg::Rocky (and so on), and dies:
OS not supported (Rocky)
OS/Provider not supported
So any pkg / update_package_db call breaks on a Rocky/Alma host as soon as someone installs redhat-lsb-core or EPEL's lsb_release.
Second issue: the OS name is used as an unanchored, unescaped regex
if ( grep { /$os/i } @redhat_clones ) {
$os is the pattern and the list entries are the subjects. So a detected name matches whenever it is a substring of any entry: RedHatEnterprise only works because it is a substring of RedHatEnterpriseServer, and Red, Server or Enterprise would also return 1. Regex metacharacters in $os are interpreted rather than matched literally.
Suggested fix
- Add
Rocky,RockyLinux,AlmaLinux,CentOSStreamandOracleLinux(andRedHatEnterprise, which redhat-lsb-core 4.1 reports on RHEL 9) to@redhat_clones. - Compare exactly:
grep { lc($_) eq lc($os) } @redhat_clones. - Optionally, make the detection independent of lsb_release by falling back to
/etc/os-releaseID/ID_LIKE(ID_LIKEcontainsrhelon all of the above). This would cover future rebuilds without a list change.
Items 1 and 2 are a small, safe change. Item 3 is the durable one.
Reproduce
# Rocky Linux 9
dnf install -y redhat-lsb-core # or EPEL's lsb_release
rex -H rocky9 -e 'say get_operating_system(); say is_redhat() ? 1 : 0; pkg "curl", ensure => "present"'
# Rocky / 0 / OS/Provider not supported
(Found in Rex::GPU, which now works around it by not calling pkg on these hosts.)
- Dominant language
- Perl
- Stars
- 737
- Forks
- 214
- PR merge metrics
- No merged PRs in 30d
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RexOps/Rex
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
triage needed
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
triage needed
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
feature request
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
openfoodfacts/openfoodfacts-server#14724 ·
Maintainers usually reply within 1 day
-
question
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
Bug Priority
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
canonical/chisel-releases#1235 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
linuxmuster/sophomorix4#190 ·