Skip to content

Commit

Permalink
Changing localhost out for certnames
Browse files Browse the repository at this point in the history
  • Loading branch information
ragingra committed Sep 20, 2024
1 parent 8aa3e99 commit 6fb68c0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tasks/backup_classification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def execute!
private

def https_client
client = Net::HTTP.new('localhost', '4433')
client = Net::HTTP.new(File.read(Puppet.settings[:certname]), 4433)
client.use_ssl = true
client.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
client.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
Expand Down
6 changes: 3 additions & 3 deletions tasks/code_manager_enabled.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def execute!
# returned by the classifier
def groups
@groups ||= begin
net = https(@host, 4433)
net = https
res = net.get('/classifier-api/v1/groups')
NodeGroup.new(JSON.parse(res.body))
end
end

def https(host, port)
https = Net::HTTP.new(host, port)
def https
https = Net::HTTP.new(File.read(Puppet.settings[:certname]), 4433)
https.use_ssl = true
https.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
https.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
Expand Down
2 changes: 1 addition & 1 deletion tasks/code_sync_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def execute!
private

def https_client
client = Net::HTTP.new('localhost', '8140')
client = Net::HTTP.new(File.read(Puppet.settings[:certname]), 8140)
client.use_ssl = true
client.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
client.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
Expand Down
8 changes: 2 additions & 6 deletions tasks/puppet_infra_upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ def execute!
end
end

def inventory_uri
@inventory_uri ||= URI.parse('https://localhost:8143/orchestrator/v1/inventory')
end

def request_object(nodes:, token_file:)
token = File.read(token_file)
body = {
'nodes' => nodes,
}.to_json

request = Net::HTTP::Post.new(inventory_uri.request_uri)
request = Net::HTTP::Post.new('/orchestrator/v1/inventory')
request['Content-Type'] = 'application/json'
request['X-Authentication'] = token.chomp
request.body = body
Expand All @@ -59,7 +55,7 @@ def request_object(nodes:, token_file:)
end

def https_object
https = Net::HTTP.new(inventory_uri.host, inventory_uri.port)
https = Net::HTTP.new(File.read(Puppet.settings[:certname]), 8143)
https.use_ssl = true
https.cert = OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
https.key = OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
Expand Down
2 changes: 1 addition & 1 deletion tasks/restore_classification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def execute!
private

def https_client
client = Net::HTTP.new('localhost', '4433')
client = Net::HTTP.new(File.read(Puppet.settings[:certname]), 4433)
client.use_ssl = true
client.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
client.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
Expand Down

0 comments on commit 6fb68c0

Please sign in to comment.