Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I was able to resolve this by looking into puppetdb in the ENC script for "agent_specified_environment"

curl -X GET http://puppetdb001.example.com:8080/pdb/query/v4/facts --data-urlencode 'query=["=", "name", "agent_specified_environment"]'

Inside a ruby script, it would be like this:

require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://puppetdb001.example.com:8080/pdb/query/v4/facts")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request.body = JSON.dump({
  "query" => [ "=", "name", "agent_specified_environment" ]
})
req_options = {
  # use_ssl: uri.scheme == "https",
}
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
  http.request(request)
end

response_env = JSON.parse(response.body)[0]["value"]
print response_env

I found this value is created with the correct environment, and is available before the ENC runs so it's true.

I was able to resolve this by looking into puppetdb in the ENC script for "agent_specified_environment"

curl -X GET http://puppetdb001.example.com:8080/pdb/query/v4/facts --data-urlencode 'query=["=", 'query=["and", ["=", "name", "agent_specified_environment"]'
"agent_specified_environment"], ["=", ["fact", "clientcert"], "puppettest001.example.com"]]'

Inside a ruby script, it would be like this:

require 'net/http'
require 'uri'
require 'json'
uri 'json'uri = URI.parse("http://puppetdb001.example.com:8080/pdb/query/v4/facts")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
Net::HTTP::Get.new(uri)
request.body = JSON.dump({
"query=[\"and\",
 "query" => [ "=", "name", "agent_specified_environment" ]
})
[\"=\", \"name\", \"agent_specified_environment\"],
  [\"=\", [\"fact\", \"clientcert\"], \"puppettest001.example.com\"]
  ]"

req_options = {
  #  use_ssl: uri.scheme == "https",
}
 response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
  http.request(request)
end

response_env = JSON.parse(response.body)[0]["value"]
print response_env

I found this value is created with the correct environment, and is available before the ENC runs so it's true.