Skip to content

Commit

Permalink
server_facts: Switch from legacy to structured facts
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Aug 3, 2024
1 parent 5084326 commit 51f889f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/rspec-puppet/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ def server_facts_hash
server_facts['serverversion'] = Puppet.version.to_s

# And then add the server name and IP
{ 'servername' => 'fqdn',
'serverip' => 'ipaddress' }.each do |var, fact|
{ 'servername' => 'networking.fqdn', 'serverip' => 'networking.ip' }.each do |var, fact|
if (value = Puppet.runtime[:facter].value(fact))
server_facts[var] = value
else
Expand All @@ -311,8 +310,8 @@ def server_facts_hash
end

if server_facts['servername'].nil?
host = Puppet.runtime[:facter].value(:hostname)
server_facts['servername'] = if (domain = Puppet.runtime[:facter].value(:domain))
host = Puppet.runtime[:facter].value('networking.hostname')
server_facts['servername'] = if (domain = Puppet.runtime[:facter].value('networking.domain'))
[host, domain].join('.')
else
host
Expand Down

0 comments on commit 51f889f

Please sign in to comment.