module-apt/lib/facter/debian_release.rb
Jerome Charaoui d007a40333 Replace debian_*() parser functions with facts
* Removes dependency on lsb-release and/or Facter >1.7
    (values are based on $::lsbdistcodename, when available)
* Simplifies maintenance: only lib/facter/util/* require updates as new
  releases are made

Caveats:
* apt::codename is removed; to override debian_* facts, set the
  FACTER_debian_codename environment variable for puppet
* If tracking unstable, make sure lsb-release is installed, as other
  methods can't tell between testing and unstable
2015-05-11 12:01:35 -04:00

36 lines
858 B
Ruby

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