Dominic Cleal's Blog

Tue, 16 Aug 2011 19:47:50 BST

permalink Puppet: could not find a default provider for augeas

Augeas is a configuration editing API that Puppet can use to perform targeted modifications to config files. If it's not installed properly when you try to use it, you'll get the following error from Puppet:

Could not find a suitable provider for augeas
Could not find a default provider for augeas

This is Puppet's way of saying that the only provider for the augeas type, which uses the ruby-augeas bindings cannot be loaded and it doesn't have an alternative provider implementation. Every time we help somebody in #puppet fix it, the cause falls into one of these areas:

1. Install ruby-augeas
For Red Hat or Fedora style systems, the package is ruby-augeas and for Debian style systems, it's libaugeas-ruby (or perhaps libaugeas-ruby1.8 for the Ruby 1.8 variant). There's also a rubygem if you prefer.

It's critical that you use your distribution's packages or ones that are known to be compatible with your distribution, or you'll hit problems. The ruby-augeas bindings are built against both Ruby and Augeas C bindings, so if you download a package built against a different binary of Ruby or Augeas to the ones you're running, it probably won't work. This is the most common issue - your packages have to be binary compatible.

Under RHEL or similar, use EPEL for compatible packages. If you've decided to "update" the version of Ruby on your RHEL box to one from a third party, you'll almost certainly have broken the binary compatibility provided by the distro by doing so and will have to build it yourself or find a compatible source.

2. Test with Ruby directly
Try loading the ruby-augeas bindings using Ruby, without Puppet.

$ ruby -raugeas -e "puts"
If you're using rubygems, you need to load the rubygems library first:
$ echo -e "require 'augeas'\nputs" | ruby -rrubygems

If you get the above, but Puppet still can't load the provider then you're probably using a different Ruby installation. Is your Puppet client running with one version of Ruby, while your shell's PATH is loading another?

3. Error loading ruby-augeas Ruby library

If you get something other than the output above, there's an issue loading the library. If you see this:

$ ruby -raugeas -e "puts"
ruby: no such file to load -- augeas (LoadError)
This indicates a failure to load the augeas.rb file (note it says augeas before the LoadError, not _augeas as explained below). The augeas.rb file should be in the directory given by Ruby's sitelibdir:
$ ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']"

Check that the ruby-augeas package you installed placed an augeas.rb into this directory.

4. Error loading shared library

In all likelihood, you see something like this:

$ ruby -raugeas -e "puts"
/usr/lib/ruby/site_ruby/1.8/augeas.rb:23:in `require': no such file to load -- _augeas (LoadError)
    from /usr/lib/ruby/site_ruby/1.8/augeas.rb:23

Using rubygems will give a similar error - again, the key part is that it cannot load _augeas (with the underscore). This indicates it's trying to load the shared library, named Check that the file exists in Ruby's sitearchdir:
$ ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']"

Three points when checking whether these files are in the expected place:

  1. Use copy and paste, check whether the files are there with `ls`. You'll get it wrong if you compare paths by eye.
  2. Check the Ruby versions carefully. At the time of writing, some distributions are shipping both Ruby 1.8 and 1.9 so the paths and packages are very similar.
  3. Check the architecture is correct, of both Ruby and ruby-augeas. If Ruby is 32-bit and looking under /usr/lib for a 64-bit shared library stored under /usr/lib64 it won't work.

Again, if something here doesn't match then check the packages. Nine times out ten, they don't match or aren't meant to be compatible with each other. Usually the binary ruby-augeas package doesn't match the Ruby build you're using.

5. Check linking
Occasionally the ruby-augeas library isn't built correctly against Augeas' library. It might be hard to determine this as you might have got the LoadError on as above, despite the .so being in the correct location.

With the path to, check the library dependencies:

$ ldd /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/ =>  (0x00007fff5fbff000) => /usr/lib64/ (0x00007ff4d33eb000) => not found

Any library listed as "not found" is an immediate issue to investigate. The other two to look for are libruby and libaugeas. Check again that the Ruby library it's linked to is part of the Ruby distribution you're using.

The libaugeas library should be in one of your system linker's search directories, or built to be somewhere else. If it isn't in a standard directory then check the Augeas library is installed (augeas-libs on Red Hat, libaugeas0 on Debian). It might also be worth checking standard Augeas tools (augeas on Red Hat, augeas-tools on Debian) are working and also linked correctly.

If it wasn't obvious by now, 98% of the time I find the cause of this error is due to packaging. Not necessarily the packages being at fault, but the wrong combination or versions being used together. Make use of your distro's packaging wherever possible or ensure you understand the third party source for your packages and the level of compatibility they offer.


Comments for this entry are now closed.