Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #24 - allow master port port numbers #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export YAMLDIR='/var/lib/puppet/yaml'
export SSLDIR='/var/lib/puppet/ssl'
export PUSER='puppet'
[ $USER == $PUSER ] || exit 1
time puppet catalog diff puppet2.example.com puppet3.example.com \
time puppet catalog diff puppet2.example.com puppet3.example.com:8150 \
--show_resource_diff \
--content_diff \
--yamldir $YAMLDIR \
Expand Down
8 changes: 5 additions & 3 deletions lib/puppet/catalog-diff/compilecatalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ def lookup_environment(node_name)

def compile_catalog(node_name,server)
server,environment = server.split('/')
server,port = server.split(':')
port ||= '8140'
environment ||= lookup_environment(node_name)
endpoint = "/#{environment}/catalog/#{node_name}"
Puppet.debug("Connecting to server: #{server}")
Puppet.debug("Connecting to server: #{server}:#{port}")
begin
connection = Puppet::Network::HttpPool.http_instance(server,'8140')
connection = Puppet::Network::HttpPool.http_instance(server,port)
catalog = connection.request_get(endpoint, {"Accept" => 'pson'}).body
rescue Exception => e
raise "Failed to retrieve catalog for #{node_name} from #{server} in environment #{environment}: #{e.message}"
raise "Failed to retrieve catalog for #{node_name} from #{server}:#{port} in environment #{environment}: #{e.message}"
end
catalog
end
Expand Down
7 changes: 4 additions & 3 deletions lib/puppet/catalog-diff/searchfacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ def find_nodes_rest(server)
query = @facts.map { |k, v| "facts.#{k}=#{v}" }.join('&')
# https://github.com/puppetlabs/puppet/blob/3.8.0/api/docs/http_api_index.md#error-responses
endpoint = "/v2.0/facts_search/search?#{query}"

server,port = server.split(':')
port ||= '8140'
begin
connection = Puppet::Network::HttpPool.http_instance(server,'8140')
connection = Puppet::Network::HttpPool.http_instance(server,port)
facts_object = connection.request_get(endpoint, {"Accept" => 'pson'}).body
rescue Exception => e
raise "Error retrieving facts from #{server}: #{e.message}"
raise "Error retrieving facts from #{server}:#{port}: #{e.message}"
end
if JSON.load(facts_object).has_key?('issue_kind')
raise "Not authorized to retrieve facts, auth.conf edits missing?" if facts_object['issue_kind'] == 'FAILED_AUTHORIZATION'
Expand Down