diff options
author | Jerome Charaoui <jcharaoui@cmaisonneuve.qc.ca> | 2015-10-09 12:08:26 -0400 |
---|---|---|
committer | Jerome Charaoui <jcharaoui@cmaisonneuve.qc.ca> | 2015-10-09 12:08:26 -0400 |
commit | e4d777e5ec333c819a6b87b5c0186f67e86361ee (patch) | |
tree | b36957b74b417e68e9c09bf5300957d2e9f4857e /lib/facter/debian_release.rb | |
parent | cc53ce119f5b9b239bc1b8cdcaae6a668b8d1f8c (diff) | |
parent | 3a7dd605e344cd8bdfa33a1fb82bfefe948cbd00 (diff) |
Fix merge conflict in README
Diffstat (limited to 'lib/facter/debian_release.rb')
-rw-r--r-- | lib/facter/debian_release.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/facter/debian_release.rb b/lib/facter/debian_release.rb new file mode 100644 index 0000000..09e8eef --- /dev/null +++ b/lib/facter/debian_release.rb @@ -0,0 +1,36 @@ +begin + require 'facter/util/debian' +end + +def debian_codename_to_release(codename) + stable = Facter::Util::Debian::STABLE + versions = Facter::Util::Debian::CODENAMES.invert + release = nil + if codename == "sid" + release = "unstable" + elsif versions.has_key? codename + version = versions[codename].to_i + if version == stable + release = "stable" + elsif version < stable + release = "stable" + for i in version..stable - 1 + release = "old" + release + end + elsif version == stable + 1 + release = "testing" + end + end + if release.nil? + Facter.warn("Could not determine release from codename #{codename}!") + end + return release +end + +Facter.add(:debian_release) do + has_weight 99 + confine :operatingsystem => 'Debian' + setcode do + debian_codename_to_release(Facter.value('debian_codename')) + end +end |