Skip to content

Commit 74737e8

Browse files
authored
Minor update for osp (#75)
* Minor update for osp osp uses ca.cfg and added some logic to account for this * spacing issue
1 parent fbaca52 commit 74737e8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tasks/st0317a_clean_cert.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@
1111

1212
require 'puppet'
1313
require 'open3'
14+
require 'facter'
1415

1516
Puppet.initialize_settings
1617

18+
def pe_master?
19+
!Facter.value('pe_build').nil?
20+
end
21+
1722
# This task only works when running against your Puppet CA server, so let's check for that.
18-
# In Puppetserver, that means that the bootstrap.cfg file contains 'certificate-authority-service'.
19-
bootstrap_cfg = '/etc/puppetlabs/puppetserver/bootstrap.cfg'
20-
if !File.exist?(bootstrap_cfg) || File.readlines(bootstrap_cfg).grep(%r{^[^#].+certificate-authority-service$}).empty?
21-
puts 'This task can only be run on your certificate authority Puppet master (MoM)'
23+
# In Puppetserver, that means the configs contain 'certificate-authority-service', uncommented.
24+
# The puppetserver config file differs between PE and open-source puppetserver.
25+
ca_cfg = pe_master? ? '/etc/puppetlabs/puppetserver/bootstrap.cfg' : '/etc/puppetlabs/puppetserver/services.d/ca.cfg'
26+
27+
if !File.exist?(ca_cfg) || File.readlines(ca_cfg).grep(%r{^[^#].+certificate-authority-service$}).empty?
28+
puts 'This task can only be run on your certificate authority Puppetserver'
2229
exit 1
2330
end
2431

0 commit comments

Comments
 (0)