Repository navigation
Description
Describe the Bug
During any puppet agent run, when facts are gathered, or when running puppet facts, on some systems, the system log will show:
Oct 7 10:58:51 san01p.bob.home dhcpcd[410158]: dhcpcd is not running
Oct 7 10:58:51 san01p.bob.home dhcpcd[410159]: dhcpcd is not running
Oct 7 10:58:51 san01p.bob.home dhcpcd[410163]: dhcpcd is not running
Oct 7 10:58:51 san01p.bob.home dhcpcd[410164]: dhcpcd is not running
Oct 7 14:58:51 san01p.bob.home dhcpcd[412370]: dhcpcd is not running
Oct 7 14:58:51 san01p.bob.home dhcpcd[412371]: dhcpcd is not running
Oct 7 14:58:51 san01p.bob.home dhcpcd[412375]: dhcpcd is not running
Oct 7 14:58:51 san01p.bob.home dhcpcd[412376]: dhcpcd is not running
On a single Ethernet interfaces system this generates four log per run.
This occurs on systems where the package dhcpcd is installed, the dhcpcd executable is found, and dhcpcd is not being run in master mode.
Expected Behavior
While the issue does stem from the fact that dhcpcd logs any errors through syslog and this can't be turned off, the fact that Puppet blindly runs the command on systems which the executable is found but may not be running, should itself not cause these logs by simply running the dhcpcd command in the ruby code.
The systems logs do not specify that the source is in fact from a puppet run or the ruby code. I had to infer this over multiple days of investigation then by inference that these messages were also just before the expected puppet run log output. I then had to infer that since the dhcpcd command has something to do with networking, that this must be coming from the puppet fact checking code and whence the source offending code. It was a bit harder in the beginning looking through Elastic/OpenSearch to get to this initial revelation.
Steps to Reproduce
Steps to reproduce the behavior:
- Ensure that the package dhcpcd is installed and the executable /usr/sbin/dhcpcd exists and is executable.
- Ensure that the system is NOT running dhcpcd
- Run the command: $ puppet facts
- check the system log file, per distro, for the lines: dhcpcd[\d+]: dhcpcd is not running
- There will be four or lines, usually four per interface and/or run, in the system logs
Environment
- tested with puppet 7 and puppet 8
- On RHEL and Debian/Ubuntu that provide package dhcpcd and/or dhcp-client and the executable dhcpcd.
Additional Context
The source of this problem is found in the ruby module: /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/util/linux/dhcp.rb, aka module Facter::Util::Linux::Dhcp in the function def search_with_dhcpcd_command().
The fix to keep this ruby code/facter from generating the excessive logs is to for example add the following code to this function def:
@dhcpcd_command ||= Facter::Core::Execution.which('dhcpcd')
return unless @dhcpcd_command
-
# test if the dhcpcd proesss is running before executing dump command -
proc = Facter::Core::Execution.execute('pgrep -x dhcpcd') -
return if proc.empty? output = Facter::Core::Execution.execute("#{@dhcpcd_command} -U #{interface_name}", logger: @log)
Activity
rwsmith61 commentedon Oct 8, 2026
This is a duplicate of a bug report under puppetlabs/facter, bug #2780. However, I don't see any solutions within the affected code.
rwsmith61 commentedon Oct 8, 2026
As of this writing there is no patch in the offending code so here is my suggestion until such time as there is.
Edit thsi file: /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/util/linux/dhcp.rb
Replace def search_with_dhcpcd_command(interface_name) with the following:
Note the two lines with 'dhcpcd_pids' that have been added to this def.
Alternatively, if you have statically or manually assigned your IP addresses then you do not need dhcpcd. If so, then just uninstall package dhcpcd.
HTH.
rwsmith
fragrantauto commentedon Oct 26, 2026
The issue appears to be that
dhcpcd -Uis being executed even when no daemon is present, triggering the stderr output that gets captured by syslog. Instead of simply wrapping the command in a suppression block, we should verify the existence of the dhcpcd socket or checksystemctl is-active dhcpcdbefore calling the utility to prevent the unnecessary subprocess overhead. Does this behavior persist if we add a guard clause to check for the presence of the dhcpcd process, or is the intention to support environments where dhcpcd might only be run in one-shot mode?rwsmith61 commentedon Oct 27, 2026
The solution should be general in nature without making to many assumptions about the environment, for example relying on
systemctl is-active dhcpcdwill not work on some distros and whendhcpcdis run in 'one-shot mode'. And to minimize the processing overhead, for example checking ifdhcpcdis running when the module is initialized and storing the result for when the class is called.As an example, as I have now updated for my Puppet environment I have modified
dhcp.rbwith the following:YMMV, and the code maintainers may have a completely different solution.
jadayaanaliah26 commentedon Nov 1, 2026
Instead of checking systemd or executing
dhcpcd,search_with_dhcpcd_commandcouldchristianfrei791 commentedon Nov 7, 2026
The issue stems from the fact that
dhcpcd -Uwrites to stderr/syslog when the daemon is unreachable, so we should redirect stderr to /dev/null when executing this command withinsearch_with_dhcpcd_command. Since relying on systemd or specific daemon states introduces platform coupling, a simple shell redirection2>/dev/nullinside the backticks orOpen3.capture3call would suppress the unwanted logging while still allowing us to check the exit status. Can we confirm if the exit code ofdhcpcd -Uremains reliable for our logic if we suppress the error output stream?naeemgwendlyn26 commentedon Nov 12, 2026
Checking for the PID file or reading the lease files in
/var/lib/dhcpcd/directly in `dredonjaquana26 commentedon Nov 19, 2026
Instead of relying on external service managers or executing
dhcpcd -U, can we check for the existence of the expected control socket in/run/dhcpcd/or the pidfile path before triggering the command insearch_with_dhcpcd_command?absolutegar commentedon Nov 22, 2026
Instead of relying on external service managers or potentially noisy executions, we could check for the existence of the dhcpcd control socket in /run/dhcpcd/ before calling search_with_dhcpcd_command. Does the current implementation allow for a lightweight file existence check on that socket path to determine if a daemon instance is actually listening before triggering the command?