Project

General

Profile

Feature #410

external node script could use the log facility provided by puppet

Added by Gustavo Soares over 8 years ago. Updated over 5 years ago.

Status:
Rejected
Priority:
Normal
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

External node script provided by foreman could use puppet's log facility so that all messages could be seen in one log.

Here is an example:

#! /usr/bin/ruby
  1. a simple script which fetches external nodes from Foreman
  2. you can basically use anything that knows how to get http data, e.g. wget/curl etc.
  1. Foreman url
    foreman_url="http://foreman:3000"

require 'net/http'
require 'puppet'

Puppet.parse_config
Puppet::Util::Log.level = :debug
Puppet::Util::Log.newdestination(:syslog)

foreman_url += "/node/#{ARGV0}?format=yml"
url = URI.parse(foreman_url)
req = Net::HTTP::Get.new(foreman_url)
res = Net::HTTP.start(url.host, url.port) { |http|
http.request(req)
}

case res
when Net::HTTPOK
puts res.body
Puppet.debug("Foreman response for node %s is ok" % ARGV0)
else
msg = "Error retrieving node %s: %s" % [ARGV0, res.class]
$stderr.puts msg
Puppet.err(msg)
end

History

#1 Updated by Ohad Levy over 8 years ago

Did you compare how much longer it takes to run the script? loading the puppet lib is usually an expensive operation.

can you try to do some stress tests? e.g. run 20 external nodes lookup per second? or alternatively, load the puppet libs only if there is a failure to report?

Thanks!

#2 Updated by Ohad Levy over 8 years ago

  • Status changed from New to Feedback
  • Assignee set to Gustavo Soares

#3 Updated by Ohad Levy almost 8 years ago

  • Project changed from Foreman to Installer

#4 Updated by Dominic Cleal over 5 years ago

  • Description updated (diff)
  • Status changed from Feedback to Rejected

Loading puppet into things like Foreman core has caused us many problems (#2414), so we don't want to include this in the ENC script.

Also available in: Atom PDF