Skip to content

Commit

Permalink
Use structured facts to detect OS version
Browse files Browse the repository at this point in the history
This is at least required for Arch Linux on Facter 4. It doesn't have
the legacy facts operatingsystemmajrelease / operatingsystemrelease.

https://tickets.puppetlabs.com/projects/FACT/issues/FACT-3114
  • Loading branch information
bastelfreak committed Apr 22, 2022
1 parent 0df5a5d commit 43b4d39
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rspec-puppet-facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,15 @@ def on_supported_os_implementation(opts = {})
os_facts_hash = {}
received_facts.map do |facts|
# Fix facter bug
# Todo: refactor the whole block to rely on structured facts and use legacy facts as fallback
if facts[:operatingsystem] == 'Ubuntu'
operatingsystemmajrelease = facts[:operatingsystemrelease].split('.')[0..1].join('.')
elsif facts[:operatingsystem] == 'OpenBSD'
operatingsystemmajrelease = facts[:operatingsystemrelease]
elsif facts[:operatingsystem] == 'windows' && facts[:operatingsystemrelease].start_with?('10.0.')
operatingsystemmajrelease = '2016'
elsif !facts.dig(:os, 'release', 'major').nil?
operatingsystemmajrelease = facts[:os]['release']['major']
else
if facts[:operatingsystemmajrelease].nil?
operatingsystemmajrelease = facts[:operatingsystemrelease].split('.')[0]
Expand Down

0 comments on commit 43b4d39

Please sign in to comment.