Skip to content

Commit

Permalink
resolvers/networking.rb: avoid calling ipconfig unless Windows
Browse files Browse the repository at this point in the history
The following message was observed when running 'puppet catalog compile'
under RUBYOPT="--debug" with Puppet 7 and Facter 4.2.9 on FreeBSD 12.3

~~~~
Exception `Errno::ENOENT' at /opt/puppet/puppet_wk/puppet_ctl/tools/bundle/ruby/3.0/gems/facter-4.2.9/lib/facter/custom_facts/core/execution/popen3.rb:17 - No such file or directory - ipconfig
~~~~

In order to prevent the call to the Microsoft Windows ipconfig tool,
this changeset adds an additional test under the method
 Facter::Resolvers::Networking.extract_dhcp

The patched networking.rb has been tested with Puppet 7 from a local
installation under Ruby 3.0 from FreeBSD ports, on FreeBSD 12.3
  • Loading branch information
spchamp committed Apr 21, 2022
1 parent 88a4f07 commit 614213a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/facter/resolvers/networking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def extract_mac(raw_data, parsed_interface_data)
end

def extract_dhcp(interface_name, raw_data, parsed_interface_data)
return unless raw_data =~ /status:\s+active/
return unless ((raw_data =~ /status:\s+active/) &&
(OsDetector.instance.identifier == :windows))

result = Facter::Core::Execution.execute("ipconfig getoption #{interface_name} " \
'server_identifier', logger: log)
Expand Down

0 comments on commit 614213a

Please sign in to comment.