dayglojesus / managedmac

Comprehensive Puppet module for OS X.
http://dayglojesus.github.io/managedmac/
Apache License 2.0
62 stars 21 forks source link

Could not autoload puppet/type/macauthdb: Could not autoload puppet/provider/macauthdb/default: cannot load such file -- sqlite3 #97

Closed dschaaff closed 8 years ago

dschaaff commented 8 years ago

Sometime in the past month we started getting this error on every non OS X node. It does not appear when running puppet on a mac. However all puppet agents on linux and windows give the error

Error: Could not autoload puppet/provider/macauthdb/default: cannot load such file -- sqlite3
Error: Could not autoload puppet/type/macauthdb: Could not autoload puppet/provider/macauthdb/default: cannot load such file -- sqlite3
Unable to add resolve nil for fact resources: Could not autoload puppet/type/macauthdb: Could not autoload puppet/provider/macauthdb/default: cannot load such file -- sqlite3
groob commented 8 years ago

You need to change the macauthdb provider code from 'require sqlite3' to 'require 'sqlite3' if Puppet.features.sqlite?'

This change will stop loading the macauthdb module on nodes that don't have sqlite3

dschaaff commented 8 years ago

I can do that as a work around in all the providers but that doesn't appear to be the root cause of the issue. This issue appeared recently and I'm still trying to track it down. In the past it has properly been confined to OS X systems.

Looking at the code, I believe that should still be the case given this defaultfor :operatingsystem => :darwin commands :security => '/usr/bin/security'

groob commented 8 years ago

defaultfor won't stop the module from loading. You need confine for that. What version of puppet are you using?

This is at the top of my modified version of macauthdb provider:

require 'date'
require 'sqlite3' if Puppet.features.sqlite?
require 'cfpropertylist' if Puppet.features.cfpropertylist?

Puppet::Type.type(:macauthdb).provide(:default) do

  desc "Manage Mac OS X authorization database rules and rights."

  defaultfor :operatingsystem  => :darwin
  commands   :security         => '/usr/bin/security'
  confine :feature         => [:cfpropertylist, :sqlite]

  mk_resource_methods
dschaaff commented 8 years ago

I tested it with confine :osfamily => :darwin but still experienced the issue. I'll put the changes you have above in place and test.

What version of puppet are you using?

3.8.7 for both the server and the agent

dschaaff commented 8 years ago

After additional testing I've found that this only occurs when the "danieldreier/resource_facts" module is installed. Removing that module resolves this issue.