Module: Puppetserver::Ca::Utils::Config
- Defined in:
- lib/puppetserver/ca/utils/config.rb
Class Method Summary collapse
- .default_ssldir(confdir = puppet_confdir) ⇒ Object
- .munge_alt_names(names) ⇒ Object
- .new_default_cadir(confdir = puppet_confdir) ⇒ Object
- .old_default_cadir(confdir = puppet_confdir) ⇒ Object
- .puppet_confdir ⇒ Object
- .puppetserver_confdir(puppet_confdir) ⇒ Object
- .running_as_root? ⇒ Boolean
- .symlink_to_old_cadir(current_cadir, puppet_confdir) ⇒ Object
Class Method Details
.default_ssldir(confdir = puppet_confdir) ⇒ Object
36 37 38 |
# File 'lib/puppetserver/ca/utils/config.rb', line 36 def self.default_ssldir(confdir = puppet_confdir) File.join(confdir, 'ssl') end |
.munge_alt_names(names) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/puppetserver/ca/utils/config.rb', line 12 def self.munge_alt_names(names) raw_names = names.split(/\s*,\s*/).map(&:strip) munged_names = raw_names.map do |name| # Prepend the DNS tag if no tag was specified if !name.start_with?("IP:") && !name.start_with?("DNS:") "DNS:#{name}" else name end end.sort.uniq.join(", ") end |
.new_default_cadir(confdir = puppet_confdir) ⇒ Object
44 45 46 |
# File 'lib/puppetserver/ca/utils/config.rb', line 44 def self.new_default_cadir(confdir = puppet_confdir) File.join(puppetserver_confdir(confdir), 'ca') end |
.old_default_cadir(confdir = puppet_confdir) ⇒ Object
40 41 42 |
# File 'lib/puppetserver/ca/utils/config.rb', line 40 def self.old_default_cadir(confdir = puppet_confdir) File.join(confdir, 'ssl', 'ca') end |
.puppet_confdir ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/puppetserver/ca/utils/config.rb', line 24 def self.puppet_confdir if running_as_root? '/etc/puppetlabs/puppet' else "#{ENV['HOME']}/.puppetlabs/etc/puppet" end end |
.puppetserver_confdir(puppet_confdir) ⇒ Object
32 33 34 |
# File 'lib/puppetserver/ca/utils/config.rb', line 32 def self.puppetserver_confdir(puppet_confdir) File.join(File.dirname(puppet_confdir), 'puppetserver') end |
.running_as_root? ⇒ Boolean
8 9 10 |
# File 'lib/puppetserver/ca/utils/config.rb', line 8 def self.running_as_root? !Gem.win_platform? && Process::UID.eid == 0 end |
.symlink_to_old_cadir(current_cadir, puppet_confdir) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/puppetserver/ca/utils/config.rb', line 48 def self.symlink_to_old_cadir(current_cadir, puppet_confdir) old_cadir = old_default_cadir(puppet_confdir) new_cadir = new_default_cadir(puppet_confdir) return if current_cadir != new_cadir # This is only run on setup/import, so there should be no files in the # old cadir, so it should be safe to forcibly remove it (which we need # to do in order to create a symlink). Puppetserver::Ca::Utils::FileSystem.forcibly_symlink(new_cadir, old_cadir) end |