Skip to content

Commit c5f304d

Browse files
author
Neil Anderson
committed
Changing localhost out for certnames
1 parent 8aa3e99 commit c5f304d

8 files changed

+14
-38
lines changed

REFERENCE.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,14 +1075,6 @@ Run on a PE primary node to check if Code Manager is enabled.
10751075

10761076
**Supports noop?** false
10771077

1078-
#### Parameters
1079-
1080-
##### `host`
1081-
1082-
Data type: `String[1]`
1083-
1084-
Hostname of the PE primary node
1085-
10861078
### <a name="code_sync_status"></a>`code_sync_status`
10871079

10881080
A task to confirm code is in sync accross the cluster for clusters with code manager configured

plans/add_replica.pp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
$replica_target = peadm::get_targets($replica_host, 1)
2323
$replica_postgresql_target = peadm::get_targets($replica_postgresql_host, 1)
2424

25-
$code_manager_enabled = run_task(
26-
'peadm::code_manager_enabled', $primary_target, host => $primary_target.peadm::certname()
27-
).first.value['code_manager_enabled']
25+
$code_manager_enabled = run_task('peadm::code_manager_enabled', $primary_target).first.value['code_manager_enabled']
2826

2927
if $code_manager_enabled == false {
3028
fail('Code Manager must be enabled to add a replica. Please refer to the docs for more information on enabling Code Manager.')

tasks/backup_classification.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def execute!
2020
private
2121

2222
def https_client
23-
client = Net::HTTP.new('localhost', '4433')
23+
client = Net::HTTP.new(Puppet.settings[:certname], 4433)
2424
client.use_ssl = true
2525
client.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
2626
client.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))

tasks/code_manager_enabled.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{
22
"description": "Run on a PE primary node to check if Code Manager is enabled.",
3-
"parameters": {
4-
"host": {
5-
"type": "String[1]",
6-
"description": "Hostname of the PE primary node"
7-
}
8-
},
3+
"parameters": {},
94
"input_method": "stdin"
105
}

tasks/code_manager_enabled.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
require 'net/http'
77
require 'puppet'
88

9-
# GetPEAdmConfig task class
10-
class GetPEAdmConfig
11-
def initialize(params)
12-
@host = params['host']
13-
end
14-
9+
# CodeManagerEnabled task class
10+
class CodeManagerEnabled
1511
def execute!
1612
code_manager_enabled = groups.dig('PE Master', 'classes', 'puppet_enterprise::profile::master', 'code_manager_auto_configure')
1713

@@ -20,18 +16,16 @@ def execute!
2016
puts({ 'code_manager_enabled' => code_manager_enabled_value }.to_json)
2117
end
2218

23-
# Returns a GetPEAdmConfig::NodeGroups object created from the /groups object
24-
# returned by the classifier
2519
def groups
2620
@groups ||= begin
27-
net = https(@host, 4433)
21+
net = https
2822
res = net.get('/classifier-api/v1/groups')
2923
NodeGroup.new(JSON.parse(res.body))
3024
end
3125
end
3226

33-
def https(host, port)
34-
https = Net::HTTP.new(host, port)
27+
def https
28+
https = Net::HTTP.new(Puppet.settings[:certname], 4433)
3529
https.use_ssl = true
3630
https.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
3731
https.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
@@ -68,6 +62,6 @@ def dig(name, *args)
6862
# testing of this task.
6963
unless ENV['RSPEC_UNIT_TEST_MODE']
7064
Puppet.initialize_settings
71-
task = GetPEAdmConfig.new(JSON.parse(STDIN.read))
65+
task = CodeManagerEnabled.new
7266
task.execute!
7367
end

tasks/code_sync_status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def execute!
1919
private
2020

2121
def https_client
22-
client = Net::HTTP.new('localhost', '8140')
22+
client = Net::HTTP.new(Puppet.settings[:certname], 8140)
2323
client.use_ssl = true
2424
client.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
2525
client.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))

tasks/puppet_infra_upgrade.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ def execute!
4040
end
4141
end
4242

43-
def inventory_uri
44-
@inventory_uri ||= URI.parse('https://localhost:8143/orchestrator/v1/inventory')
45-
end
46-
4743
def request_object(nodes:, token_file:)
4844
token = File.read(token_file)
4945
body = {
5046
'nodes' => nodes,
5147
}.to_json
5248

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

6157
def https_object
62-
https = Net::HTTP.new(inventory_uri.host, inventory_uri.port)
58+
https = Net::HTTP.new(Puppet.settings[:certname], 8143)
6359
https.use_ssl = true
6460
https.cert = OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
6561
https.key = OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
@@ -96,6 +92,7 @@ def wait_until_connected(nodes:, token_file:, timeout: 120)
9692
# environment flag is used to disable auto-execution and enable Ruby unit
9793
# testing of this task.
9894
unless ENV['RSPEC_UNIT_TEST_MODE']
95+
Puppet.initialize_settings
9996
upgrade = PuppetInfraUpgrade.new(JSON.parse(STDIN.read))
10097
upgrade.execute!
10198
end

tasks/restore_classification.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def execute!
2020
private
2121

2222
def https_client
23-
client = Net::HTTP.new('localhost', '4433')
23+
client = Net::HTTP.new(Puppet.settings[:certname], 4433)
2424
client.use_ssl = true
2525
client.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
2626
client.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))

0 commit comments

Comments
 (0)