Module: Facter::Util::Config

Defined in:
lib/facter/util/config.rb

Overview

A module to return config related data

Class Method Summary collapse

Class Method Details

.ext_fact_loaderObject



7
8
9
# File 'lib/facter/util/config.rb', line 7

def self.ext_fact_loader
  @ext_fact_loader || Facter::Util::DirectoryLoader.default_loader
end

.ext_fact_loader=(loader) ⇒ Object



11
12
13
# File 'lib/facter/util/config.rb', line 11

def self.ext_fact_loader=(loader)
  @ext_fact_loader = loader
end

.external_facts_dirsObject



36
37
38
# File 'lib/facter/util/config.rb', line 36

def self.external_facts_dirs
  @external_facts_dirs
end

.external_facts_dirs=(dir) ⇒ Object



32
33
34
# File 'lib/facter/util/config.rb', line 32

def self.external_facts_dirs=(dir)
  @external_facts_dirs = dir
end

.is_mac?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/facter/util/config.rb', line 15

def self.is_mac?
  RbConfig::CONFIG['host_os'] =~ /darwin/i
end

.is_windows?Boolean

Returns true if OS is windows

Returns:

  • (Boolean)


20
21
22
# File 'lib/facter/util/config.rb', line 20

def self.is_windows?
  RbConfig::CONFIG['host_os'] =~ /mswin|win32|dos|mingw|cygwin/i
end

.setup_default_ext_facts_dirsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/facter/util/config.rb', line 40

def self.setup_default_ext_facts_dirs
  if Facter::Util::Root.root?
    windows_dir = windows_data_dir
    if windows_dir.nil? then
      @external_facts_dirs = ["/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"]
    else
      @external_facts_dirs = [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
    end
  elsif ENV['HOME']
    @external_facts_dirs = [File.expand_path(File.join(ENV['HOME'], ".facter", "facts.d"))]
  else
    @external_facts_dirs = []
  end
end

.windows_data_dirObject



24
25
26
27
28
29
30
# File 'lib/facter/util/config.rb', line 24

def self.windows_data_dir
  if Dir.const_defined? 'COMMON_APPDATA' then
    Dir::COMMON_APPDATA
  else
    nil
  end
end