Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server_facts: Switch from legacy to structured facts #127

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion spec/classes/server_facts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
Loading