Skip to content

(#21260) Add Cumulus Linux detection support#458

Closed
dorkmatt wants to merge 10 commits intopuppetlabs:masterfrom
CumulusNetworks:master
Closed

(#21260) Add Cumulus Linux detection support#458
dorkmatt wants to merge 10 commits intopuppetlabs:masterfrom
CumulusNetworks:master

Conversation

@dorkmatt
Copy link

No description provided.

@puppetcla
Copy link

CLA Signed by dorkmatt on 2012-10-02 21:00:00 -0700

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is /etc/os-release going to be unique for Cumulus Linux? Do we have to do a regex to extract this value or can we rely on the presence of the file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is /etc/os-release is supported in a number a OS's these days - Gentoo, Ubuntu and of course Cumulus Linux. The regex value is to extract a certain data point from this file.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's pretty nifty. However if this is present on a number of platforms it could change existing behavior. Line 39 may mitigate this, but this might be a bit aggressive.

Perhaps this could be a fallback behavior instead of the first option selected?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is the existing logic, Cumulus Linux ships with a /etc/debian_version to show our OS heritage (such as Ubuntu does too) - even though both Cumulus & Ubuntu are clearly not Debian. I'm happy to change that logic too, but wanted to do the least amount of impact on other OS selections - thoughts here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was afraid of that. I want to ensure that our primary supported platforms (Ubuntu, Debian, CentOS, Redhat) won't regress with this change, and if not then this is great. I don't want to make this PR diverge too much from the goal of getting in Cumulus Linux support, but I can't offer a lot of great solutions aside from manual verification.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just ran into a snag with this, because of how Debian formats /etc/os-release

PRETTY_NAME="Debian GNU/Linux 7.0 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7.0"
VERSION="7.0 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"

We can't normalize the value of NAME with a regex so this can't be a general solution. I think it could be a fallback mechanism but I really don't want to change the operatingsystem fact on debian to debiangnulinux

@adrienthebo
Copy link

Thank you very much for this contribution!

It would be good to have test coverage for these changes, to ensure that these changes don't accidentally regress. Would you be able to get sample output from /etc/os-release so we can work out how to write tests? https://github.com/puppetlabs/puppet/blob/master/README_DEVELOPER.md#a-brief-introduction-to-testing-in-puppet provides an introduction to testing in the Puppet ecosystem, if you're not familiar with the tests used in Puppet and Facter.

@adrienthebo
Copy link

I noticed this hasn't seen any activity in about a week. Is there a chance you'll be able to work on this in the coming week? No pressure, just checking in.

@dorkmatt
Copy link
Author

We've added an initial round of rspec unit tests, as requested here's some examples of /etc/os-release

NAME="Cumulus Linux"
VERSION_ID=1.5.0
VERSION="1.5.0-83579fb-MODIFIED-201306261532"
PRETTY_NAME="Cumulus Linux"
ID=cumulus-linux
ID_LIKE=debian
CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:1.5.0-83579fb-MODIFIED-201306261532
HOME_URL="http://www.cumulusnetworks.com/"

NAME="Ubuntu"
VERSION="12.04.2 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.2 LTS)"
VERSION_ID="12.04"

@dorkmatt dorkmatt closed this Jun 28, 2013
@dorkmatt dorkmatt reopened this Jun 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments on this:

Using global match variables like $1 isn't threadsafe; it's better to use an explicit MatchData variable:

matchdata = File.read('/etc/os-release').match /^NAME=["']?(.+?)["']?$/
matchdata[1]

In addition, this regular expression is pretty aggressive. Do we really want to strip out numbers or underscores?

As mentioned above if this is a fallback option that would be fine, but I would like to avoid defaulting to the more intrusive option.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agressive regex was to follow other setcode's for the operatingsystem fact - all of which seem to have mixed upper/lower case and no spaces.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. We don't have a formal convention around the output of operatingsystem fact names. On one hand I am nervous about this breaking things, but on the other hand it would be nice to actually have that convention.

@adrienthebo
Copy link

Does Cumulus Linux have a file like /etc/cumulus-release that we can use to identify this as definitely Cumulus Linux? I still have concerns about the behavior of checking /etc/os-release on every platform.

@dorkmatt
Copy link
Author

Not currently, our entire point was to not invent yet-another-standard.
Would moving the os-release match statement towards the match statement
make you feel more comfortable?

@adrienthebo
Copy link

👍 for not inventing a new standard.

So here's what I think we need to do to handle this:

  1. Check /etc/os-release. If it's cumulus, use that value. If not, skip.
  2. Check all existing resolutions.
  3. If everything fails, fall back to /etc/os-release.

We can't use /etc/os-release in preference to our existing resolutions right now until we can confirm that this won't cause a regression across any of our PE supported platforms. However we can special case for Cumulus, and then use os-release as a fallback. What do you think of this approach?

@puppetcla
Copy link

CLA signed by all contributors.

@adrienthebo
Copy link

@dorkmatt do you want to close this in favor of #493?

@adrienthebo
Copy link

I'm closing this in favor of GH-493; if this is in error let me know.

@adrienthebo adrienthebo closed this Aug 1, 2013
florindragos pushed a commit that referenced this pull request Jun 15, 2020
* (FACT-2562) Remove reset from to_hash. Save external and custom facts in options.
* (FACT-2562) Read custom and external facts from options instead of LegacyFacter.
* (FACT-2562) Fix tests.
* (FACT-2562) Update tests description.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants