summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/functions/debian_codename_to_version.rb18
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