Module: LegacyFacter::Util::Config
- Defined in:
- lib/facter/custom_facts/util/config.rb
Class Method Summary collapse
- .ext_fact_loader ⇒ Object
- .ext_fact_loader=(loader) ⇒ Object
- .external_facts_dirs ⇒ Object
- .facts_cache_dir ⇒ Object
- .mac? ⇒ Boolean
- .override_binary_dir ⇒ Object
- .override_binary_dir=(dir) ⇒ Object
- .setup_default_cache_dir ⇒ Object
- .setup_default_ext_facts_dirs ⇒ Object
- .setup_default_override_binary_dir ⇒ Object
-
.windows? ⇒ Boolean
Returns true if OS is windows.
- .windows_data_dir ⇒ Object
Class Method Details
.ext_fact_loader ⇒ Object
10 11 12 |
# File 'lib/facter/custom_facts/util/config.rb', line 10 def self.ext_fact_loader @ext_fact_loader || LegacyFacter::Util::DirectoryLoader.new end |
.ext_fact_loader=(loader) ⇒ Object
14 15 16 |
# File 'lib/facter/custom_facts/util/config.rb', line 14 def self.ext_fact_loader=(loader) @ext_fact_loader = loader end |
.external_facts_dirs ⇒ Object
31 32 33 |
# File 'lib/facter/custom_facts/util/config.rb', line 31 def self.external_facts_dirs Facter::Options.external_dir end |
.facts_cache_dir ⇒ Object
35 36 37 |
# File 'lib/facter/custom_facts/util/config.rb', line 35 def self.facts_cache_dir @facts_cache_dir ||= setup_default_cache_dir end |
.mac? ⇒ Boolean
18 19 20 |
# File 'lib/facter/custom_facts/util/config.rb', line 18 def self.mac? RbConfig::CONFIG['host_os'] =~ /darwin/i end |
.override_binary_dir ⇒ Object
72 73 74 |
# File 'lib/facter/custom_facts/util/config.rb', line 72 def self.override_binary_dir @override_binary_dir end |
.override_binary_dir=(dir) ⇒ Object
68 69 70 |
# File 'lib/facter/custom_facts/util/config.rb', line 68 def self.override_binary_dir=(dir) @override_binary_dir = dir end |
.setup_default_cache_dir ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/facter/custom_facts/util/config.rb', line 76 def self.setup_default_cache_dir windows_dir = windows_data_dir @facts_cache_dir = if windows_dir File.join(windows_dir, 'PuppetLabs', 'facter', 'cache', 'cached_facts') else '/opt/puppetlabs/facter/cache/cached_facts' end end |
.setup_default_ext_facts_dirs ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/facter/custom_facts/util/config.rb', line 39 def self.setup_default_ext_facts_dirs if LegacyFacter::Util::Root.root? windows_dir = windows_data_dir Facter::Options[:default_external_dir] = if windows_dir [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')] else [ '/etc/puppetlabs/facter/facts.d', '/etc/facter/facts.d/', '/opt/puppetlabs/facter/facts.d' ] end elsif ENV['HOME'] Facter::Options[:default_external_dir] = [File.join(ENV['HOME'], '.facter', 'facts.d'), File.join(ENV['HOME'], '.puppetlabs', 'opt', 'facter', 'facts.d')] else Facter::Options[:default_external_dir] = [] end end |
.setup_default_override_binary_dir ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/facter/custom_facts/util/config.rb', line 85 def self.setup_default_override_binary_dir @override_binary_dir = if LegacyFacter::Util::Config.windows? nil else '/opt/puppetlabs/puppet/bin' end end |
.windows? ⇒ Boolean
Returns true if OS is windows
23 24 25 |
# File 'lib/facter/custom_facts/util/config.rb', line 23 def self.windows? RbConfig::CONFIG['host_os'] =~ /mswin|win32|dos|mingw|cygwin/i end |
.windows_data_dir ⇒ Object
27 28 29 |
# File 'lib/facter/custom_facts/util/config.rb', line 27 def self.windows_data_dir ENV['ProgramData'] || ENV['APPDATA'] if LegacyFacter::Util::Config.windows? end |