Skip to content

Commit

Permalink
Allow single node fact upload. Fixes GH-691
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmet2mir authored and mmoll committed Dec 27, 2018
1 parent c840da8 commit 8b525a7
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions files/external_node_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ class FactUploadError < StandardError; end
end
end

def process_host_facts(certname)
f = "#{puppetdir}/yaml/facts/#{certname}.yaml"
if File.size(f) != 0
req = generate_fact_request(certname, f)
begin
upload_facts(certname, req) if req
return 0
rescue => e
$stderr.puts "During fact upload occured an exception: #{e}"
return 1
end
else
$stderr.puts "Fact file #{f} does not contain any fact"
return 2
end
end

def process_all_facts(http_requests)
Dir["#{puppetdir}/yaml/facts/*.yaml"].each do |f|
certname = File.basename(f, ".yaml")
Expand Down Expand Up @@ -344,14 +361,17 @@ def watch_and_send_facts(parallel)
end
if push_facts
# push all facts files to Foreman and don't act as an ENC
process_all_facts(false)
if ARGV.empty?
process_all_facts(false)
else
process_host_facts(ARGV[0])
end
elsif push_facts_parallel
http_fact_requests = Http_Fact_Requests.new
process_all_facts(http_fact_requests)
upload_facts_parallel(http_fact_requests)
else
certname = ARGV[0] || raise("Must provide certname as an argument")

#
# query External node
begin
Expand Down

0 comments on commit 8b525a7

Please sign in to comment.