Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I check if puppetdb is configured? #83

Open
cristifalcas opened this issue Jan 29, 2016 · 2 comments
Open

How can I check if puppetdb is configured? #83

cristifalcas opened this issue Jan 29, 2016 · 2 comments

Comments

@cristifalcas
Copy link

When bootstrapping a completely new puppet system, we get an error from this module:

Error: Could not run: cannot load such file -- puppet/util/puppetdb

This is because at that moment nothing is configured/installed (also no puppetdb server).

We are trying to do the initial configuration for the puppet master by using puppet apply.

Is there any possibility to do a check for this case?

I'm not sure I'm making any sense, so please tell me if it's not clear what my problem is.

@quixoten
Copy link

quixoten commented Apr 8, 2016

Running into this issue myself. I installed the puppetdb-termini before running puppet apply, which got rid of the "cannot load such file" error, and then I put conditionals around queries that might get called during the bootstrap process, e.g.,

$friendly_nodes = $::settings::storeconfigs ? {
  true    => query_nodes('friendly'),
  default => [],
}

Not sure if that's the best thing to check, but it gets the job done. It would be awesome of this module automatically short-circuited (rather than failed) when puppet is not configured to use puppetdb.

@fondemen
Copy link

Hello,

I was able to workaround this issue by adding a fact that mimcs this module checks:

Facter.add('puppetdb_running') do
  setcode do

    begin
      require 'puppet/util/puppetdb'

      # This is needed if the puppetdb library isn't pluginsynced to the master
      $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
      begin
        require 'puppetdb/connection'
      ensure
        $LOAD_PATH.shift
      end

      PuppetDB::Connection.check_version
      true
    rescue => e
      # puts e.message
      # puts e.backtrace
      false
    end
  end
end

and then in my puppet code:

if $::puppetdb_running {
      $nodes = query_nodes('friendly')
} else {
    $nodes = []
}

Nevertheless, if quixoten's answer is more elegant, it would be great if this module could offer such variable natively...

Regards

Frédéric

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants