diff options
author | intrigeri <intrigeri@boum.org> | 2016-10-29 08:15:38 +0000 |
---|---|---|
committer | intrigeri <intrigeri@boum.org> | 2016-10-29 08:15:38 +0000 |
commit | 20c90d2dc61c2b1d15bebc88c839e90ef99e4b2e (patch) | |
tree | 5218f5bdcdd5b5ce2fc93ecb20a8ec757e0e91db /lib/puppet/parser/functions/debian_codename_to_version.rb | |
parent | a18c940b0195e76a7640818a7c7d92d289380c36 (diff) |
Add debian_codename_to_version parser function.
I need it to make libvirt::host::di_netboot_assistant::distribution
use debian-installer-*-netboot-* packages without breaking backwards
compatibility.
refs: https://labs.riseup.net/code/issues/10092
Diffstat (limited to 'lib/puppet/parser/functions/debian_codename_to_version.rb')
-rw-r--r-- | lib/puppet/parser/functions/debian_codename_to_version.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/debian_codename_to_version.rb b/lib/puppet/parser/functions/debian_codename_to_version.rb new file mode 100644 index 0000000..c5cbcf4 --- /dev/null +++ b/lib/puppet/parser/functions/debian_codename_to_version.rb @@ -0,0 +1,18 @@ +begin + require 'facter/util/debian' +rescue LoadError + require "#{File.dirname(__FILE__)}/../../../facter/util/debian" +end + +module Puppet::Parser::Functions + versions = Facter::Util::Debian::CODENAMES.invert + newfunction(:debian_codename_to_version, :type => :rvalue) do |args| + codename = args[0] + if versions.has_key? codename + return versions[codename].to_i + else + raise Puppet::ParseError, + "Could not determine release from codename #{codename}" + end + end +end |