Project

General

Profile

Feature #1843

Accept a simple hash of facts to work with facter directly

Added by Wlodzimierz Kowalski almost 7 years ago. Updated almost 7 years ago.

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

Description

In correspondence to the topic under: https://groups.google.com/forum/?fromgroups=#!topic/foreman-users/Y91OfgTkg3c

The user is unable to upload facts to foreman on demand. Issuing the following code:

url="https://192.168.199.40:443" 

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

doesn't work.

Right now, as Ohad says: "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"


Related issues

Related to Foreman - Bug #1938: Foreman shouldn't use the FQDN fact to identify the node when facts are uploadedClosed2012-11-14

Associated revisions

Revision 399dca9e (diff)
Added by Ohad Levy almost 7 years ago

fixes #1843 - Accepts a plain hash as facts source

Revision c929c85e (diff)
Added by Ohad Levy almost 7 years ago

refs #1843 - adds missing lookup

Revision aa44d2f3 (diff)
Added by Ohad Levy almost 7 years ago

refs #1843 normally facts base hash has no certname.

this will make sure we don't fetch the wrong host (without a certname) by mistake.

History

#1 Updated by Ohad Levy almost 7 years ago

  • Assignee set to Ohad Levy
  • Priority changed from High to Normal

#2 Updated by Ohad Levy almost 7 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

#3 Updated by Ohad Levy almost 7 years ago

  • Subject changed from Unable to upload facts to Foreman on demand to Accept a simple hash of facts to work with facter directly

Also available in: Atom PDF