Cf-execd started by cron is missing environment variables, making the agent unable to run correctly
Created a fresh VM, installed minimal Ubuntu 12.04.3 server, added repo and installed rudder-agent (2.6.9) package.
Even though the installation doesn't start the agent, after a while it will be started by the newly added cron job.
Cron sets a very minimal environment for the started jobs, in particular
PATH=/usr/bin:/bin. And when cron starts cf-agent and therefore cf-execd, they will inherit that PATH. This can be verified with:
tr '\0' '\n' < /proc/$(pgrep cf-execd)/environ (when started from cron).
When cf-agent is running with this PATH setting, any package installations will fail with Bulk package schedule execution failed somewhere - unknown outcome for ... error in the output. This is caused by dpkg failing because required executables are not in the search path, e.g. try (same command as cf-agent would run, but with adjusted PATH):
# /usr/bin/env PATH=/usr/bin:/bin DEBIAN_FRONTEND=noninteractive LC_ALL=C /usr/bin/aptitude \ -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef \ -o Aptitude::Delete-Unused=false -o Aptitude::CmdLine::Ignore-Trust-Violations=false \ --assume-yes install dstat The following NEW packages will be installed: dstat 0 packages upgraded, 1 newly installed, 0 to remove and 20 not upgraded. Need to get 0 B/68.1 kB of archives. After unpacking 549 kB will be used. dpkg: warning: 'ldconfig' not found in PATH or not executable. dpkg: warning: 'start-stop-daemon' not found in PATH or not executable. dpkg: error: 2 expected programs not found in PATH or not executable. Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin. E: Sub-process /usr/bin/dpkg returned an error code (2) A package failed to install. Trying to recover: dpkg: warning: 'ldconfig' not found in PATH or not executable. dpkg: warning: 'start-stop-daemon' not found in PATH or not executable. dpkg: error: 2 expected programs not found in PATH or not executable. Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
This doesn't happen when started as a service as then the PATH is
/sbin:/usr/sbin:/bin:/usr/bin (when started on boot by
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin (or similar, when started from an interactive session, i.e. the init script inherits the PATH from calling environment).
A solution could be to add PATH setting to
/etc/cron.d/rudder-agent, or to body agent control in promises.cf (but this will affect all agent executions, not only cron).
Updated by Vincent MEMBRÉ about 9 years ago
- Assignee set to Vincent MEMBRÉ
- Priority changed from N/A to 3
- Target version set to 2.4.13
Thanks for reporting and the explanations!
As it concerns the cron-agent, it must affect 2.4 too. It must be confirm though.
To reprocuce the procedure seems:
- install rudder-agent
- configure it (/var/rudder/cfengine-community/policy_server.dat)
- wait for cron-agent to start the agent
- fails on installation of package
using rudder-vagrant and modifying provision script to not start the agent at the end should help.
Adding the PATH to cron seems a good idea to me and less invasive than modifying all techniques.
Matthieu or me should take care of this.
Updated by Vincent MEMBRÉ almost 9 years ago
- Status changed from Pending release to Released
This bug has been fixed in Rudder 2.6.11, which was released today.
- The release announcement: http://www.rudder-project.org/pipermail/rudder-announce/2014-March/000077.html
- The full ChangeLog: http://www.rudder-project.org/foswiki/bin/view/System/Documentation:ChangeLog26
- Download information: https://www.rudder-project.org/site/get-rudder/downloads/