Jira (FACT-3151) Facter fails on the `/etc/os-release` that contains the '#`

87 views
Skip to first unread message

Alex Baranowski (Jira)

unread,
Sep 26, 2022, 5:23:01 PM9/26/22
to puppe...@googlegroups.com
Alex Baranowski created an issue
 
Facter / Bug FACT-3151
Facter fails on the `/etc/os-release` that contains the '#`
Issue Type: Bug Bug
Affects Versions: FACT 4.2.12
Assignee: Unassigned
Components: Facter 4
Created: 2022/09/26 2:22 PM
Priority: Major Major
Reporter: Alex Baranowski

Facter fails on the `/etc/os-release` that contains the comment `#`.

 

According to the [https://www.man7.org/linux/man-pages/man5/os-release.5.html], the comments are allowed in the /etc/os-release files. In EuroLinux 9 that fail contain a comment:

```

# We keep it for build scripts only

```

 

 

 

 /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/os_release.rb
Error: Could not initialize global default settings: odd number of arguments for Hash

 

I will fix that in the Distro, but IMO the parser should respect the rules.

Best,
Alex

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Michael Hashizume (Jira)

unread,
Sep 27, 2022, 4:55:03 PM9/27/22
to puppe...@googlegroups.com
Michael Hashizume commented on Bug FACT-3151
 
Re: Facter fails on the `/etc/os-release` that contains the '#`

Thank you for reporting this issue. While we agree this is likely an improvement, we do not anticipate addressing this any time soon due to other issues demanding precedence. As such, this ticket will be closed as “Won’t Do”. We may revisit this at a later time, and if so, will re-open this ticket.

If you are interested in submitting a patch to implement this issue, please open a pull request and re-open this ticket.

Fabiano Pires (Jira)

unread,
Oct 6, 2022, 1:33:02 PM10/6/22
to puppe...@googlegroups.com

I stumbled at the same problem and wrote a patch. What are the steps so I can send it to you?  

Fabiano Pires (Jira)

unread,
Oct 15, 2022, 2:17:02 PM10/15/22
to puppe...@googlegroups.com

Hi, I sent a pull request with the fix for this issue. 

Michael Hashizume (Jira)

unread,
Jan 5, 2023, 1:30:03 PM1/5/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jan 9, 2023, 12:54:01 PM1/9/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
{color:#0e101a}Facter fails on the `/etc/os-release` that contains the comment `#`.{color}

 

{color:#0e101a}According to the {color}[{color:#4a6ee0}https://www.man7.org/linux/man-pages/man5/os-release.5.html{color}]{color:#0e101a}, the comments are allowed in the /etc/os-release files. In EuroLinux 9 that fail contain a comment:{color}


```
{code:java}

# We keep it for build scripts only

{code}
```

  {color:#0e101a}I will fix that in the Distro, but IMO the parser should respect the rules{color}.

  Best,
Alex
 
*Update*

Facter 4 raises an exception if /etc/os-release contains a comment:

{code:java}
  # facter --version
4.2.14

# head -2
/ etc/os-release
# This is a comment
NAME="Red Hat Enterprise Linux"

# facter os
Traceback (most recent call last):
26: from /
opt/puppetlabs/puppet/ bin/facter:5:in `<main>'
25: from /opt/puppetlabs/puppet/
lib/ruby/ 2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
24: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
23: from /opt/puppetlabs/puppet/lib/ruby/
vendor_ruby/facter/ framework/cli/cli_launcher.rb:6:in `<top (required)>'
22: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
21: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
20: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter.rb:7:in `<top (required)>'
19: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
18: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
17: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/file_loader.rb:54:in `<top (required)>'
16: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/singleton.rb:123:in `instance'
15: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/singleton.rb:123:in `synchronize'
14: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/singleton.rb:125:in `block in instance'
13: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/singleton.rb:125:in `new'
12: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/detector/os_detector.rb:13:in `initialize'
11: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/detector/os_detector.rb:26:in `detect'
10: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/detector/os_detector.rb:77:in `detect_distro'
  9: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/detector/os_detector.rb:77:in `each'
  8: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/detector/os_detector.rb:78:in `block in detect_distro'
  7: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/
resolvers/ base_resolver.rb:24:in `resolve'
  6: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/base_resolver.rb:24:in `synchronize'
  5: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/base_resolver.rb:26:in `block in resolve'
  4: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/
os_release.rb :23:in `post_resolve'
Error   3 : Could not initialize global default settings from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/os_release.rb : 23:in `fetch'
  2: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/os_release.rb:36:in `block in post_resolve'
  1: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/os_release.rb:59:in `fill_fact_list'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/os_release.rb:59:in `[]':
odd number of arguments for Hash (ArgumentError)
{code}
 
Facter 3 does not include "os.distro" by default. But if you install lsb-release related packages, then it correctly ignores the comment and reports the fact:

{ color code : #0e101a noformat } I will fix that in the Distro
# facter --version
3.14.24 (commit 91ed8a2de5c9d686345859fe12ea2914415758f0)

# yum install redhat-lsb-core
...

# head -2 /etc/os-release
# This is a comment
NAME="Red Hat Enterprise Linux"

# facter os
{
  architecture => "x86_64"
, but IMO the parser should respect the rules
  distro =>
{ color
    codename => "Ootpa",
    description => "Red Hat Enterprise Linux release 8.0 (Ootpa)",
    id => "RedHatEnterprise",
    release => {
      full => "8.0",
      major => "8",
      minor => "0"
} ,
    specification => ":core-4
. 1-amd64:core-4.1-noarch"
  },
Best   family => "RedHat" ,
Alex   hardware => "x86_64",
  name => "RedHat",
  release => {
    full => "8.0",
    major => "8",
    minor => "0"
  },
  selinux => {
    enabled => false
  }
}
{code}

Josh Cooper (Jira)

unread,
Jan 9, 2023, 12:54:02 PM1/9/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jan 9, 2023, 3:01:02 PM1/9/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Apr 6, 2023, 1:46:01 PM4/6/23
to puppe...@googlegroups.com

Aria Li (Jira)

unread,
Apr 25, 2023, 6:25:02 PM4/25/23
to puppe...@googlegroups.com
Aria Li updated an issue
Change By: Aria Li
Sprint: Phoenix 2023-04-26

Aria Li (Jira)

unread,
Apr 25, 2023, 6:25:03 PM4/25/23
to puppe...@googlegroups.com

Tony Vu (Jira)

unread,
Apr 26, 2023, 1:12:01 PM4/26/23
to puppe...@googlegroups.com
Tony Vu updated an issue
Change By: Tony Vu
Sprint: Phoenix 2023-04-26 , Phoenix 2023-05-10

Aria Li (Jira)

unread,
Apr 27, 2023, 5:33:01 PM4/27/23
to puppe...@googlegroups.com
Aria Li updated an issue
Change By: Aria Li
Release Notes: Not Needed Bug Fix

Aria Li (Jira)

unread,
Apr 27, 2023, 5:33:01 PM4/27/23
to puppe...@googlegroups.com
Aria Li updated an issue
Change By: Aria Li
Release Notes Summary: /etc/os-release files can have comments (#) without raising an error. Comments are allowed in these files according to:

Aria Li (Jira)

unread,
Apr 27, 2023, 5:34:03 PM4/27/23
to puppe...@googlegroups.com
Aria Li updated an issue
Change By: Aria Li
Release Notes Summary: /etc/os-release files can have comments (#) without raising an error. Comments are allowed in these files according to: https://www.man7.org/linux/man-pages/man5/os-release.5.html

Christopher Thorn (Jira)

unread,
Jun 8, 2023, 6:48:02 PM6/8/23
to puppe...@googlegroups.com
Christopher Thorn updated an issue
Change By: Christopher Thorn
Fix Version/s: FACT 4.4.1
This message was sent by Atlassian Jira (v8.20.21#820021-sha1:38274c8)
Atlassian logo

Parker Leach (Jira)

unread,
Jun 14, 2023, 1:13:01 PM6/14/23
to puppe...@googlegroups.com
Parker Leach updated an issue
Change By: Parker Leach
Labels: docs_reviewed regression
Reply all
Reply to author
Forward
0 new messages