Module: PuppetDebugger::Support::Facts
- Included in:
- PuppetDebugger::Support
- Defined in:
- lib/puppet-debugger/support/facts.rb
Instance Method Summary collapse
-
#default_facter_version ⇒ Object
return the correct supported version of facter facts.
- #default_facterdb_filter ⇒ Object
- #default_facts ⇒ Object
-
#dynamic_facterdb_filter ⇒ Object
allow the user to specify the facterdb filter.
- #facter_os_name ⇒ Object
- #facter_os_version ⇒ Object
- #facter_version ⇒ Object
-
#node_facts ⇒ Object
uses facterdb (cached facts) and retrives the facts given a filter creates a new facts object we could also use fact_merge to get real facts from the real system or puppetdb.
- #server_facts ⇒ Object
- #set_facts(value) ⇒ Object
Instance Method Details
#default_facter_version ⇒ Object
return the correct supported version of facter facts
23 24 25 |
# File 'lib/puppet-debugger/support/facts.rb', line 23 def default_facter_version '/^4/' end |
#default_facterdb_filter ⇒ Object
14 15 16 |
# File 'lib/puppet-debugger/support/facts.rb', line 14 def default_facterdb_filter "os.name=#{facter_os_name} and os.release.major=#{facter_os_version} and os.architecture=x86_64 and facterversion=#{facter_version}" end |
#default_facts ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/puppet-debugger/support/facts.rb', line 58 def default_facts unless @facts values = Hash[node_facts.map { |k, v| [k.to_s, v] }] name = values['fqdn'] @facts ||= Puppet::Node::Facts.new(name, values) end @facts end |
#dynamic_facterdb_filter ⇒ Object
allow the user to specify the facterdb filter
10 11 12 |
# File 'lib/puppet-debugger/support/facts.rb', line 10 def dynamic_facterdb_filter ENV['DEBUGGER_FACTERDB_FILTER'] || default_facterdb_filter end |
#facter_os_name ⇒ Object
27 28 29 |
# File 'lib/puppet-debugger/support/facts.rb', line 27 def facter_os_name ENV['DEBUGGER_FACTER_OS_NAME'] || 'Rocky' end |
#facter_os_version ⇒ Object
31 32 33 |
# File 'lib/puppet-debugger/support/facts.rb', line 31 def facter_os_version ENV['DEBUGGER_FACTER_OS_VERSION'] || '8' end |
#facter_version ⇒ Object
18 19 20 |
# File 'lib/puppet-debugger/support/facts.rb', line 18 def facter_version ENV['DEBUGGER_FACTER_VERSION'] || default_facter_version end |
#node_facts ⇒ Object
uses facterdb (cached facts) and retrives the facts given a filter creates a new facts object we could also use fact_merge to get real facts from the real system or puppetdb
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet-debugger/support/facts.rb', line 42 def node_facts node_facts = FacterDB.get_facts(dynamic_facterdb_filter).first if node_facts.nil? = <<~OUT Using filter: #{dynamic_facterdb_filter} Bad FacterDB filter, please change the filter so it returns a result set. Use puppet debugger --no-facterdb to disable facterdb. See https://github.com/voxpupuli/facterdb/#with-a-string-filter OUT raise PuppetDebugger::Exception::BadFilter, message: end # fix for when --show-legacy facts are not part of the facter 3 fact set node_facts[:fqdn] = node_facts[:networking].fetch('fqdn', nil) unless node_facts[:fqdn] node_facts end |
#server_facts ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/puppet-debugger/support/facts.rb', line 67 def server_facts data = {} data['servername'] = Facter.value('fqdn') || Facter.value('networking')['fqdn'] data['serverip'] = Facter.value('ipaddress') data['serverversion'] = Puppet.version.to_s data end |
#set_facts(value) ⇒ Object
35 36 37 |
# File 'lib/puppet-debugger/support/facts.rb', line 35 def set_facts(value) @facts = value end |