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
39 40 41 |
# File 'lib/puppetserver/ca/utils/config.rb', line 39 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 23 24 25 |
# File 'lib/puppetserver/ca/utils/config.rb', line 12 def self.munge_alt_names(names) # Tolerate a nil/empty value. A puppet.conf key that is present but # has no value (e.g. `dns_alt_names =`) is read as nil rather than # using the absent-key default, so callers can hand us nil here. raw_names = names.to_s.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
47 48 49 |
# File 'lib/puppetserver/ca/utils/config.rb', line 47 def self.new_default_cadir(confdir = puppet_confdir) File.join(puppetserver_confdir(confdir), 'ca') end |
.old_default_cadir(confdir = puppet_confdir) ⇒ Object
43 44 45 |
# File 'lib/puppetserver/ca/utils/config.rb', line 43 def self.old_default_cadir(confdir = puppet_confdir) File.join(confdir, 'ssl', 'ca') end |
.puppet_confdir ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/puppetserver/ca/utils/config.rb', line 27 def self.puppet_confdir if running_as_root? '/etc/puppetlabs/puppet' else "#{ENV['HOME']}/.puppetlabs/etc/puppet" end end |
.puppetserver_confdir(puppet_confdir) ⇒ Object
35 36 37 |
# File 'lib/puppetserver/ca/utils/config.rb', line 35 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
51 52 53 54 55 56 57 58 59 |
# File 'lib/puppetserver/ca/utils/config.rb', line 51 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 |