From 1a2a567955e5b56755161bc8a6e72dec80cd9830 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 3 Aug 2024 18:11:22 +0200 Subject: [PATCH] server_facts: Switch from legacy to structured facts --- lib/rspec-puppet/support.rb | 7 +++---- spec/classes/server_facts_spec.rb | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/rspec-puppet/support.rb b/lib/rspec-puppet/support.rb index 692bfe92a..ad0f8a4cf 100644 --- a/lib/rspec-puppet/support.rb +++ b/lib/rspec-puppet/support.rb @@ -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 @@ -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 diff --git a/spec/classes/server_facts_spec.rb b/spec/classes/server_facts_spec.rb index 66d73135b..a71b2ff8e 100644 --- a/spec/classes/server_facts_spec.rb +++ b/spec/classes/server_facts_spec.rb @@ -5,7 +5,7 @@ describe 'server_facts' do let(:facts) do { - ipaddress: '192.168.1.10' + 'networking' => { 'ip' => '192.168.1.10' } } end let(:node) { 'test123.test.com' }