Unable to upload facts to Foreman on demand

> Dear all,
> I am struggling with pushing facts into Foreman by means of the HTTP Rest
> API. I have successfully configured the ENC script with facts population
> based on this:
> What I would like to achieve, is to run a script in any moment from the
> machine, on which the puppet agent is running. Script looks like this:
> url=""
> require 'fileutils'
> require 'net/http'
> require 'net/https'
> require 'uri'
> require 'facter'
> require 'yaml'
> #in order to get facts in a proper format
> facts = puppet facts --render-as yaml find host.domain
> begin
> uri = URI.parse(url)
> http = Net::HTTP.new(uri.host, uri.port)
> if uri.scheme == 'https' then
> http.use_ssl = true
> http.verify_mode = OpenSSL::SSL::VERIFY_NONE
> end
> req = Net::HTTP::Post.new("/fact_values/create")
> req.set_form_data({'facts' => facts})
> response = http.request(req)
> rescue Exception => e
> raise "Could not send facts to Foreman: #{e}"
> end
> I would like to invoke this script while certain program is running to
> follow its progress fact in foreman.
> The above script works, and I can see in the foreman logs, that the the
> API returns OK (HTTP 200):
> Processing FactValuesController#create (for at 2012-08-23
> 22:15:55) [POST]
> Parameters: {"controller"=>"fact_values", "facts"=>"[FILTERED]",
> "action"=>"create"}
> Completed in 283ms (View: 0, DB: 38) | 200 OK [
> But in foreman I cannot see updated facts after this invocation. What I
> have noticed is that the facts get updated in foreman only when puppet run
> had been run. Is is how it is suppoed to be? Or am I doing something wrong?
> I'm guessing your code is correct, we do check within foreman that the
object we get is a serialized puppet facts, and I'm guessing we can relax
that requirements to a simple facts hash, please open a new feature request
and I'll have to resolve it.


··· On Thu, Aug 23, 2012 at 11:43 PM, stefan wrote:

You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To view this discussion on the web visit
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at