@@ -73,11 +73,12 @@ def find_nodes_rest(server)
73
73
74
74
def find_nodes_puppetdb ( env )
75
75
require 'puppet/util/puppetdb'
76
- port = Puppet ::Util ::Puppetdb . port
76
+ server_url = Puppet ::Util ::Puppetdb . config . server_urls [ 0 ]
77
+ port = server_url . port
77
78
use_ssl = port != 8080
78
- connection = Puppet ::Network ::HttpPool . http_instance ( Puppet :: Util :: Puppetdb . server , port , use_ssl )
79
+ connection = Puppet ::Network ::HttpPool . http_instance ( server_url . host , port , use_ssl )
79
80
base_query = [ "and" , [ "=" , [ "node" , "active" ] , true ] ]
80
- base_query . concat ( [ [ "=" , "catalog-environment " , env ] ] ) if env
81
+ base_query . concat ( [ [ "=" , "catalog_environment " , env ] ] ) if env
81
82
real_facts = @facts . select { |k , v | !v . nil? }
82
83
query = base_query . concat ( real_facts . map { |k , v | [ "=" , [ "fact" , k ] , v ] } )
83
84
classes = Hash [ @facts . select { |k , v | v . nil? } ] . keys
@@ -97,7 +98,7 @@ def find_nodes_puppetdb(env)
97
98
)
98
99
end
99
100
json_query = URI . escape ( query . to_json )
100
- unless filtered = PSON . load ( connection . request_get ( "/v4/nodes/?query=#{ json_query } " , { "Accept" => 'application/json' } ) . body )
101
+ unless filtered = PSON . load ( connection . request_get ( "/pdb/query/ v4/nodes/?query=#{ json_query } " , { "Accept" => 'application/json' } ) . body )
101
102
raise "Error parsing json output of puppet search"
102
103
end
103
104
names = filtered . map { |node | node [ 'certname' ] }
0 commit comments