Ask Your Question

How does one set the PATH used by Facter::Util::Resolution.exec()?

asked 2014-02-12 23:42:16 -0600

There is lots of good information about how to set the PATH used by the exec type, globally, or per resource, but what about if one is creating a fact? How does one set the PATH used by Facter::Util::Resolution.exec()?

When running facter (or puppet) interactively, the environment and thus the PATH variable are inherited from the shell environment. This is not so when the agent is run non-interactively, say from cron, or from MCollective, or just running the agent daemon. As such, reliance on the command lookup of the method is unreliable and there seems to be ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-02-13 12:43:52 -0600

Stefan gravatar image

The command lookup depends on a mix of the current $PATH variable (unpredictable,as you already mentioned) and the fixed paths /sbin and /usr/sbin. This is not configurable. You are right that this can cause problems and there is an old discussion about using only fixed paths here

If you want to search in different locations you can temporarily overwrite the PATH enviromnent variable with the Facter::Util::Resolution::with_env method. This one will accept a codeblock and will restore the old environment after the code block.

Facter::Util::Resolution.with_env("PATH" => "/opt/foo/bin:/opt/bar/bin") do ...
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-02-12 23:42:16 -0600

Seen: 607 times

Last updated: Feb 13 '14