Module: Facter
- Includes:
- ApiDebugger
- Defined in:
- lib/facter/util/aix/odm_query.rb,
lib/facter.rb,
lib/facter/config.rb,
lib/facter/version.rb,
lib/facter/util/utils.rb,
lib/facter/resolvers/az.rb,
lib/facter/resolvers/dmi.rb,
lib/facter/resolvers/ec2.rb,
lib/facter/resolvers/gce.rb,
lib/facter/resolvers/ssh.rb,
lib/facter/resolvers/xen.rb,
lib/facter/resolvers/zfs.rb,
lib/facter/resolvers/lpar.rb,
lib/facter/resolvers/path.rb,
lib/facter/resolvers/ruby.rb,
lib/facter/resolvers/wpar.rb,
lib/facter/resolvers/disks.rb,
lib/facter/resolvers/lspci.rb,
lib/facter/resolvers/uname.rb,
lib/facter/resolvers/zpool.rb,
lib/facter/util/linux/dhcp.rb,
lib/facter/util/linux/proc.rb,
lib/facter/resolvers/augeas.rb,
lib/facter/resolvers/memory.rb,
lib/facter/resolvers/uptime.rb,
lib/facter/resolvers/vmware.rb,
lib/facter/util/file_helper.rb,
lib/facter/framework/cli/cli.rb,
lib/facter/resolvers/aix/nim.rb,
lib/facter/resolvers/open_vz.rb,
lib/facter/resolvers/selinux.rb,
lib/facter/resolvers/sw_vers.rb,
lib/facter/util/api_debugger.rb,
lib/facter/models/loaded_fact.rb,
lib/facter/resolvers/hostname.rb,
lib/facter/resolvers/identity.rb,
lib/facter/resolvers/timezone.rb,
lib/facter/util/resolvers/ssh.rb,
lib/facter/resolvers/aix/disks.rb,
lib/facter/resolvers/virt_what.rb,
lib/facter/util/linux/if_inet6.rb,
lib/facter/util/resolvers/http.rb,
lib/facter/models/resolved_fact.rb,
lib/facter/models/searched_fact.rb,
lib/facter/resolvers/aix/memory.rb,
lib/facter/resolvers/containers.rb,
lib/facter/resolvers/dmi_decode.rb,
lib/facter/resolvers/macosx/dmi.rb,
lib/facter/resolvers/networking.rb,
lib/facter/resolvers/os_release.rb,
lib/facter/resolvers/partitions.rb,
lib/facter/resolvers/processors.rb,
lib/facter/resolvers/aix/ffi/ffi.rb,
lib/facter/resolvers/eos_release.rb,
lib/facter/resolvers/filesystems.rb,
lib/facter/resolvers/freebsd/dmi.rb,
lib/facter/resolvers/lsb_release.rb,
lib/facter/resolvers/mountpoints.rb,
lib/facter/resolvers/openbsd/dmi.rb,
lib/facter/resolvers/solaris/dmi.rb,
lib/facter/resolvers/windows/ssh.rb,
lib/facter/util/windows/win32ole.rb,
lib/facter/custom_facts/util/fact.rb,
lib/facter/framework/core/options.rb,
lib/facter/models/fact_collection.rb,
lib/facter/resolvers/aix/hardware.rb,
lib/facter/resolvers/aix/os_level.rb,
lib/facter/resolvers/fips_enabled.rb,
lib/facter/resolvers/freebsd/geom.rb,
lib/facter/resolvers/openbsd/dhcp.rb,
lib/facter/resolvers/solaris/ldom.rb,
lib/facter/resolvers/solaris/zone.rb,
lib/facter/resolvers/suse_release.rb,
lib/facter/resolvers/windows/fips.rb,
lib/facter/util/facts/facts_utils.rb,
lib/facter/resolvers/base_resolver.rb,
lib/facter/resolvers/facterversion.rb,
lib/facter/resolvers/load_averages.rb,
lib/facter/resolvers/solaris/disks.rb,
lib/facter/util/aix/info_extractor.rb,
lib/facter/framework/logging/logger.rb,
lib/facter/resolvers/aix/filesystem.rb,
lib/facter/resolvers/aix/networking.rb,
lib/facter/resolvers/aix/partitions.rb,
lib/facter/resolvers/aix/processors.rb,
lib/facter/resolvers/bsd/processors.rb,
lib/facter/resolvers/debian_version.rb,
lib/facter/resolvers/linux/hostname.rb,
lib/facter/resolvers/redhat_release.rb,
lib/facter/resolvers/solaris/memory.rb,
lib/facter/resolvers/windows/kernel.rb,
lib/facter/resolvers/windows/memory.rb,
lib/facter/resolvers/windows/netkvm.rb,
lib/facter/resolvers/windows/uptime.rb,
lib/facter/util/facts/uptime_parser.rb,
lib/facter/util/linux/routing_table.rb,
lib/facter/util/linux/socket_parser.rb,
lib/facter/util/resolvers/aws_token.rb,
lib/facter/resolvers/aix/ffi/structs.rb,
lib/facter/resolvers/aix/mountpoints.rb,
lib/facter/resolvers/freebsd/virtual.rb,
lib/facter/resolvers/openbsd/virtual.rb,
lib/facter/resolvers/solaris/ffi/ffi.rb,
lib/facter/util/facts/unit_converter.rb,
lib/facter/util/resolvers/ssh_helper.rb,
lib/facter/framework/core/fact_filter.rb,
lib/facter/resolvers/aix/architecture.rb,
lib/facter/resolvers/aix/serialnumber.rb,
lib/facter/resolvers/linux/networking.rb,
lib/facter/resolvers/processors_lscpu.rb,
lib/facter/resolvers/windows/dmi_bios.rb,
lib/facter/resolvers/windows/identity.rb,
lib/facter/resolvers/windows/system32.rb,
lib/facter/resolvers/windows/timezone.rb,
lib/facter/util/resolvers/fingerprint.rb,
lib/facter/custom_facts/core/aggregate.rb,
lib/facter/custom_facts/core/execution.rb,
lib/facter/framework/core/fact_manager.rb,
lib/facter/resolvers/aio_agent_version.rb,
lib/facter/resolvers/aix/load_averages.rb,
lib/facter/resolvers/macosx/processors.rb,
lib/facter/resolvers/solaris/dmi_sparc.rb,
lib/facter/resolvers/solaris/ipaddress.rb,
lib/facter/resolvers/solaris/zone_name.rb,
lib/facter/util/resolvers/ffi/hostname.rb,
lib/facter/custom_facts/util/resolution.rb,
lib/facter/framework/benchmarking/timer.rb,
lib/facter/framework/config/fact_groups.rb,
lib/facter/framework/core/cache_manager.rb,
lib/facter/framework/core/session_cache.rb,
lib/facter/resolvers/aix/ffi/ffi_helper.rb,
lib/facter/resolvers/bsd/ffi/ffi_helper.rb,
lib/facter/resolvers/freebsd/processors.rb,
lib/facter/resolvers/macosx/filesystems.rb,
lib/facter/resolvers/macosx/mountpoints.rb,
lib/facter/resolvers/macosx/swap_memory.rb,
lib/facter/resolvers/solaris/networking.rb,
lib/facter/resolvers/solaris/os_release.rb,
lib/facter/resolvers/solaris/processors.rb,
lib/facter/resolvers/windows/networking.rb,
lib/facter/resolvers/windows/processors.rb,
lib/facter/util/resolvers/uptime_helper.rb,
lib/facter/resolvers/amzn/os_release_rpm.rb,
lib/facter/resolvers/freebsd/swap_memory.rb,
lib/facter/resolvers/linux/docker_uptime.rb,
lib/facter/resolvers/linux/load_averages.rb,
lib/facter/resolvers/openbsd/mountpoints.rb,
lib/facter/resolvers/solaris/ffi/structs.rb,
lib/facter/resolvers/solaris/filesystems.rb,
lib/facter/resolvers/solaris/mountpoints.rb,
lib/facter/framework/config/config_reader.rb,
lib/facter/framework/parsers/query_parser.rb,
lib/facter/resolvers/macosx/load_averages.rb,
lib/facter/resolvers/macosx/system_memory.rb,
lib/facter/util/resolvers/networking/dhcp.rb,
lib/facter/framework/detector/os_hierarchy.rb,
lib/facter/resolvers/freebsd/system_memory.rb,
lib/facter/resolvers/solaris/ffi/functions.rb,
lib/facter/resolvers/specific_release_file.rb,
lib/facter/custom_facts/core/execution/base.rb,
lib/facter/resolvers/freebsd/ffi/ffi_helper.rb,
lib/facter/resolvers/macosx/system_profiler.rb,
lib/facter/resolvers/windows/virtualization.rb,
lib/facter/util/resolvers/ffi/load_averages.rb,
lib/facter/util/resolvers/filesystem_helper.rb,
lib/facter/custom_facts/core/execution/posix.rb,
lib/facter/resolvers/freebsd/freebsd_version.rb,
lib/facter/resolvers/release_from_first_line.rb,
lib/facter/resolvers/windows/product_release.rb,
lib/facter/util/facts/posix/virtual_detector.rb,
lib/facter/util/facts/windows_release_finder.rb,
lib/facter/custom_facts/core/execution/popen3.rb,
lib/facter/custom_facts/core/execution/windows.rb,
lib/facter/framework/core/options/option_store.rb,
lib/facter/resolvers/windows/aio_agent_version.rb,
lib/facter/util/macosx/system_profile_executor.rb,
lib/facter/resolvers/windows/dmi_computersystem.rb,
lib/facter/resolvers/windows/win_os_description.rb,
lib/facter/util/resolvers/networking/networking.rb,
lib/facter/framework/formatters/formatter_helper.rb,
lib/facter/framework/core/fact/internal/core_fact.rb,
lib/facter/framework/formatters/formatter_factory.rb,
lib/facter/framework/core/fact_loaders/fact_loader.rb,
lib/facter/resolvers/windows/hardware_architecture.rb,
lib/facter/framework/core/options/options_validator.rb,
lib/facter/framework/formatters/json_fact_formatter.rb,
lib/facter/framework/formatters/yaml_fact_formatter.rb,
lib/facter/framework/formatters/hocon_fact_formatter.rb,
lib/facter/framework/core/options/config_file_options.rb,
lib/facter/framework/formatters/legacy_fact_formatter.rb,
lib/facter/util/resolvers/networking/primary_interface.rb,
lib/facter/framework/core/fact_loaders/class_discoverer.rb,
lib/facter/framework/core/fact_loaders/external_fact_loader.rb,
lib/facter/framework/core/fact_loaders/internal_fact_loader.rb,
lib/facter/framework/core/fact/external/external_fact_manager.rb,
lib/facter/framework/core/fact/internal/internal_fact_manager.rb
Overview
Because Open3 uses Process.detach the env $? is not set so this class reimplements Open3.popen3 with Process.wait instead.
- FACT-2934
-
When calling Facter::Core::Execution, $? and $CHILD_STATUS
ruby env variables should be set.
Defined Under Namespace
Modules: Bsd, Config, Core, Framework, Freebsd, OptionsValidator, Resolvers, Util, Utils Classes: CacheManager, ClassDiscoverer, Cli, ConfigFileOptions, ConfigReader, CoreFact, ExternalFactLoader, ExternalFactManager, FactCollection, FactFilter, FactGroups, FactLoader, FactManager, FormatterFactory, FormatterHelper, HoconFactFormatter, InternalFactLoader, InternalFactManager, JsonFactFormatter, LegacyFactFormatter, LoadedFact, Log, OptionStore, Options, OsHierarchy, QueryParser, ResolveCustomFactError, ResolvedFact, SearchedFact, SessionCache, YamlFactFormatter
Constant Summary collapse
- VERSION =
'4.9.0'
- RED =
"\e[31m"
- GREEN =
"\e[32m"
- YELLOW =
"\e[33m"
- CYAN =
"\e[36m"
- RESET =
"\e[0m"
- DEFAULT_LOG_LEVEL =
:warn
Class Method Summary collapse
-
.[](name) ⇒ Facter::Util::Fact?
Alias method for Facter.fact().
-
.add(name, options = {}, &block) ⇒ Facter::Util::Fact
Add custom facts to fact collection.
-
.clear ⇒ nil
Clears all cached values and removes all facts from memory.
-
.clear_messages ⇒ nil
Clears the seen state of debug and warning messages.
-
.core_value(user_query) ⇒ FactCollection
private
Retrieves the value of a core fact.
-
.debug(message) ⇒ nil
Logs debug message when debug option is set to true.
-
.debugging(debug_bool) ⇒ type
Enable or disable debugging.
-
.debugging? ⇒ bool
Check whether debugging is enabled.
-
.debugonce(message) ⇒ nil
Logs the same debug message only once when debug option is set to true.
-
.define_fact(name, options = {}, &block) ⇒ Facter::Util::Fact
Define a new fact or extend an existing fact.
-
.disable_sequential ⇒ bool
Disable sequential resolving of facts.
-
.each {|name, value| ... } ⇒ Facter
Iterates over fact names and values.
-
.enable_sequential ⇒ bool
Enable sequential resolving of facts.
-
.fact(user_query) ⇒ Facter::Util::Fact?
Returns a fact object by name.
-
.flush ⇒ void
Flushes cached values for all facts.
-
.http_debug(http_debug_bool) ⇒ type
Enable or disable http debugging.
-
.http_debug? ⇒ bool
Check whether http debugging is enabled.
-
.list ⇒ Array
Returns a list with the names of all resolved facts.
-
.load_external(enable_external) ⇒ Object
Enables/Disables external facts.
-
.loadfacts ⇒ nil
Loads all facts.
-
.log_exception(exception, message = nil) ⇒ nil
Logs an exception and an optional message.
-
.on_message(&block) ⇒ nil
Stores a proc that will be used to output custom messages.
-
.puppet_facts ⇒ Object
private
Method used by cli to set puppet paths in order to retrieve puppet custom and external facts.
-
.reset ⇒ nil
Reset search paths for custom and external facts If config file is set custom and external facts will be reloaded.
-
.resolve(args_as_string) ⇒ Hash<String, Object>
private
Method used by puppet-agent to retrieve facts.
-
.search(*dirs) ⇒ nil
Register directories to be searched for custom facts.
-
.search_external(dirs) ⇒ nil
Registers directories to be searched for external facts.
-
.search_external_path ⇒ Array<String>
Returns the registered search directories.for external facts.
-
.search_path ⇒ Array<String>
Returns the registered search directories for custom facts.
-
.sequential? ⇒ bool
Check if facts are resolved sequentially or not.
-
.to_hash ⇒ Hash<String, Object>
Retrieves a fact’s value.
-
.to_user_output(cli_options, *args) ⇒ Array
private
Gets a hash mapping fact names to their values.
-
.trace(bool) ⇒ bool
Enable or disable trace.
-
.trace? ⇒ bool
Check whether printing stack trace is enabled.
-
.value(user_query) ⇒ String
Gets the value for a fact.
-
.version ⇒ String
Returns Facter version.
-
.warn(message) ⇒ nil
Logs the message parameter as a warning.
-
.warnonce(message) ⇒ nil
Logs only once the same warning message.
Class Method Details
.[](name) ⇒ Facter::Util::Fact?
Alias method for Facter.fact()
82 83 84 |
# File 'lib/facter.rb', line 82 def [](name) fact(name) end |
.add(name, options = {}, &block) ⇒ Facter::Util::Fact
Add custom facts to fact collection
97 98 99 100 101 |
# File 'lib/facter.rb', line 97 def add(name, = {}, &block) [:fact_type] = :custom LegacyFacter.add(name, , &block) LegacyFacter.collection.invalidate_custom_facts end |
.clear ⇒ nil
Clears all cached values and removes all facts from memory.
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/facter.rb', line 108 def clear @already_searched = {} Facter. LegacyFacter.clear Options[:custom_dir] = [] LegacyFacter.collection.invalidate_custom_facts LegacyFacter.collection.reload_custom_facts SessionCache.invalidate_all_caches nil end |
.clear_messages ⇒ nil
Clears the seen state of debug and warning messages.
122 123 124 |
# File 'lib/facter.rb', line 122 def Facter::Log. end |
.core_value(user_query) ⇒ FactCollection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Retrieves the value of a core fact. External or custom facts are not returned with this call. Returns ‘nil` if no such fact exists.
132 133 134 135 136 137 138 |
# File 'lib/facter.rb', line 132 def core_value(user_query) user_query = user_query.to_s resolved_facts = Facter::FactManager.instance.resolve_core([user_query]) fact_collection = FactCollection.new.build_fact_collection!(resolved_facts) splitted_user_query = Facter::Utils.split_user_query(user_query) fact_collection.dig(*splitted_user_query) end |
.debug(message) ⇒ nil
Logs debug message when debug option is set to true
146 147 148 149 150 151 |
# File 'lib/facter.rb', line 146 def debug() return unless debugging? logger.debug(.to_s) nil end |
.debugging(debug_bool) ⇒ type
Enable or disable debugging
204 205 206 |
# File 'lib/facter.rb', line 204 def debugging(debug_bool) Facter::Options[:debug] = debug_bool end |
.debugging? ⇒ bool
Check whether debugging is enabled
194 195 196 |
# File 'lib/facter.rb', line 194 def debugging? Options[:debug] end |
.debugonce(message) ⇒ nil
Logs the same debug message only once when debug option is set to true
159 160 161 162 |
# File 'lib/facter.rb', line 159 def debugonce() logger.debugonce() nil end |
.define_fact(name, options = {}, &block) ⇒ Facter::Util::Fact
Define a new fact or extend an existing fact.
172 173 174 175 |
# File 'lib/facter.rb', line 172 def define_fact(name, = {}, &block) [:fact_type] = :custom LegacyFacter.define_fact(name, , &block) end |
.disable_sequential ⇒ bool
Disable sequential resolving of facts
241 242 243 |
# File 'lib/facter.rb', line 241 def disable_sequential Facter::Options[:sequential] = false end |
.each {|name, value| ... } ⇒ Facter
Iterates over fact names and values
262 263 264 265 266 267 268 269 270 271 |
# File 'lib/facter.rb', line 262 def each log_blocked_facts resolved_facts = Facter::FactManager.instance.resolve_facts resolved_facts.each do |fact| yield(fact.name, fact.value) end self end |
.enable_sequential ⇒ bool
Enable sequential resolving of facts
232 233 234 |
# File 'lib/facter.rb', line 232 def enable_sequential Facter::Options[:sequential] = true end |
.fact(user_query) ⇒ Facter::Util::Fact?
Returns a fact object by name. If you use this, you still have to call ‘value` on it to retrieve the actual value.
435 436 437 438 439 440 |
# File 'lib/facter.rb', line 435 def fact(user_query) user_query = user_query.to_s.downcase resolve_fact(user_query) unless @already_searched.include?(user_query) @already_searched[user_query] end |
.flush ⇒ void
This method returns an undefined value.
Flushes cached values for all facts. This does not cause code to be reloaded; it only clears the cached results.
293 294 295 296 297 |
# File 'lib/facter.rb', line 293 def flush LegacyFacter.flush SessionCache.invalidate_all_caches nil end |
.http_debug(http_debug_bool) ⇒ type
Enable or disable http debugging
223 224 225 |
# File 'lib/facter.rb', line 223 def http_debug(http_debug_bool) Facter::Options[:http_debug] = http_debug_bool end |
.http_debug? ⇒ bool
Check whether http debugging is enabled
213 214 215 |
# File 'lib/facter.rb', line 213 def http_debug? Options[:http_debug] end |
.list ⇒ Array
Returns a list with the names of all resolved facts
487 488 489 |
# File 'lib/facter.rb', line 487 def list to_hash.keys.sort end |
.load_external(enable_external) ⇒ Object
Enables/Disables external facts.
315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/facter.rb', line 315 def load_external(enable_external) # enable_external param needs negation because behind the scene # no_external_facts= method is negating the parameter again. Options[:no_external_facts] = !enable_external if enable_external logger.debug('Facter.load_external(true) called. External facts will be loaded') else logger.debug('Facter.load_external(false) called. External facts will NOT be loaded') end nil end |
.loadfacts ⇒ nil
Loads all facts
304 305 306 307 |
# File 'lib/facter.rb', line 304 def loadfacts LegacyFacter.loadfacts nil end |
.log_exception(exception, message = nil) ⇒ nil
Logs an exception and an optional message
473 474 475 476 477 478 479 480 481 |
# File 'lib/facter.rb', line 473 def log_exception(exception, = nil) = [] << .to_s unless .nil? || (.is_a?(String) && .empty?) parse_exception(exception, ) logger.error(.flatten.join("\n")) nil end |
.on_message(&block) ⇒ nil
Stores a proc that will be used to output custom messages.
The proc must receive one parameter that will be the message to log.
184 185 186 187 |
# File 'lib/facter.rb', line 184 def (&block) Facter::Log.(&block) nil end |
.puppet_facts ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Method used by cli to set puppet paths in order to retrieve puppet custom and external facts
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/facter.rb', line 54 def puppet_facts require 'puppet' # don't allow puppet logger to be injected in Facter Options[:allow_external_loggers] = false Puppet.initialize_settings $LOAD_PATH << Puppet[:libdir] unless $LOAD_PATH.include?(Puppet[:libdir]) Facter.reset Facter.search_external([Puppet[:pluginfactdest]]) if Puppet.respond_to? :initialize_facts Puppet.initialize_facts else Facter.add(:puppetversion) do setcode { Puppet.version.to_s } end end rescue LoadError => e logger.error("Could not load puppet gem, got #{e}") end |
.reset ⇒ nil
Reset search paths for custom and external facts If config file is set custom and external facts will be reloaded
279 280 281 282 283 284 285 |
# File 'lib/facter.rb', line 279 def reset LegacyFacter.reset Options[:custom_dir] = [] Options[:external_dir] = [] SessionCache.invalidate_all_caches nil end |
.resolve(args_as_string) ⇒ Hash<String, Object>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Method used by puppet-agent to retrieve facts
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/facter.rb', line 24 def resolve(args_as_string) require_relative 'facter/framework/cli/cli_launcher' args = args_as_string.split(' ') Facter::OptionsValidator.validate(args) processed_arguments = CliLauncher.prepare_arguments(args, nil) cli = Facter::Cli.new([], processed_arguments) = cli..dup # config file options config_file = .delete(:config) if config_file Facter::OptionStore.set(:config, config_file) Facter::ConfigFileOptions.init(config_file) Facter::Options.store(ConfigFileOptions.get) end # user provided options [:show_legacy] ||= false Facter::Options.store() Hash[queried_facts(cli.args)] end |
.search(*dirs) ⇒ nil
Register directories to be searched for custom facts. The registered directories
must be absolute paths or they will be ignored.
336 337 338 339 |
# File 'lib/facter.rb', line 336 def search(*dirs) Options[:custom_dir] += dirs nil end |
.search_external(dirs) ⇒ nil
Registers directories to be searched for external facts.
347 348 349 350 |
# File 'lib/facter.rb', line 347 def search_external(dirs) Options[:external_dir] += dirs nil end |
.search_external_path ⇒ Array<String>
Returns the registered search directories.for external facts.
357 358 359 |
# File 'lib/facter.rb', line 357 def search_external_path Options.external_dir end |
.search_path ⇒ Array<String>
Returns the registered search directories for custom facts.
366 367 368 |
# File 'lib/facter.rb', line 366 def search_path Options.custom_dir end |
.sequential? ⇒ bool
Check if facts are resolved sequentially or not
250 251 252 |
# File 'lib/facter.rb', line 250 def sequential? Facter::Options[:sequential] end |
.to_hash ⇒ Hash<String, Object>
Retrieves a fact’s value. Returns ‘nil` if no such fact exists.
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/facter.rb', line 376 def to_hash log_blocked_facts logger.debug("Facter version: #{Facter::VERSION}") resolved_facts = Facter::FactManager.instance.resolve_facts resolved_facts.reject! { |fact| fact.type == :custom && fact.value.nil? } collection = Facter::FactCollection.new.build_fact_collection!(resolved_facts) # Ensures order of keys in hash returned from Facter.to_hash() and # Facter.resolve() is always stable if collection.empty? Hash[collection] else Hash[Facter::Utils.sort_hash_by_key(collection)] end end |
.to_user_output(cli_options, *args) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Gets a hash mapping fact names to their values
456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/facter.rb', line 456 def to_user_output(, *args) () logger.info("executed with command line: #{ARGV.drop(1).join(' ')}") logger.debug("Facter version: #{Facter::VERSION}") log_blocked_facts resolved_facts = resolve_facts_for_user_query(args) fact_formatter = Facter::FormatterFactory.build(Facter::Options.get) status = error_check(resolved_facts) [fact_formatter.format(resolved_facts), status] end |
.trace(bool) ⇒ bool
Enable or disable trace
408 409 410 |
# File 'lib/facter.rb', line 408 def trace(bool) Options[:trace] = bool end |
.trace? ⇒ bool
Check whether printing stack trace is enabled
398 399 400 |
# File 'lib/facter.rb', line 398 def trace? Options[:trace] end |
.value(user_query) ⇒ String
Gets the value for a fact. Returns ‘nil` if no such fact exists.
418 419 420 421 422 423 |
# File 'lib/facter.rb', line 418 def value(user_query) user_query = user_query.to_s.downcase resolve_fact(user_query) unless @already_searched.include?(user_query) @already_searched[user_query]&.value end |
.version ⇒ String
Returns Facter version
447 448 449 |
# File 'lib/facter.rb', line 447 def version Facter::VERSION end |
.warn(message) ⇒ nil
Logs the message parameter as a warning.
497 498 499 500 |
# File 'lib/facter.rb', line 497 def warn() logger.warn(.to_s) nil end |
.warnonce(message) ⇒ nil
Logs only once the same warning message.
508 509 510 511 |
# File 'lib/facter.rb', line 508 def warnonce() logger.warnonce() nil end |