Add fact to return the Augeas version from /augeas/version.  Requires the
ruby-augeas binding.

Signed-off-by: Dominic Cleal <[email protected]>
---
Local-branch: tickets/master/7854
 lib/facter/augeasversion.rb |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 lib/facter/augeasversion.rb

diff --git a/lib/facter/augeasversion.rb b/lib/facter/augeasversion.rb
new file mode 100644
index 0000000..481b46d
--- /dev/null
+++ b/lib/facter/augeasversion.rb
@@ -0,0 +1,29 @@
+# Fact: augeasversion
+#
+# Purpose: Report the version of the Augeas library
+#
+# Resolution:
+#   Loads ruby-augeas and reports the value of /augeas/version, the version of
+#   the underlying Augeas library.
+#
+# Caveats:
+#   The library version may not indicate the presence of certain lenses, 
+#   depending on the system packages updated, nor the version of ruby-augeas
+#   which may affect support for the Puppet Augeas provider.
+#   Versions prior to 0.3.6 cannot be interrogated for their version.
+#
+
+Facter.add(:augeasversion) do
+  setcode do
+    begin
+      require 'augeas'
+      aug = Augeas::open('/', nil, Augeas::NO_MODL_AUTOLOAD)
+      ver = aug.get('/augeas/version')
+      aug.close
+      ver
+    rescue Exception
+      Facter.debug('ruby-augeas not available')
+    end
+  end
+end
+
-- 
1.7.4.4

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to