Issue #13284 has been updated by Chris Price.
Andy is going to look into this, so I'm pasting in some rough notes about what
I've discovered so far:
* execution.execute seems to be the entry point for actually running the
commands;
* this method already accepts an environment variable hash (execution.rb:73),
:custom_environment
* TODO: change the name of the second parameter of #execute from
"arguments" to "options", because "arguments" implies args that will get passed
to the command, which is not actually the case.
* TODO: docs for the command parameter of #execute
* this gets called via meta-programming methods defined at provider.rb:122
* the meta-programming method definition expects an array as its
argument type. It's basically an array of strings that represent individual
command-line args to pass to the command. This is unfortunate because it makes
it difficult to add additional arguments to the method signature (e.g., an
optional hash argument that would contain the environment vars.)
* this seems to me to imply that it would be a good deal simpler (and
with less risk of backward-compatibility problems) to register the environment
variables at the time when we register the command, or nearby. Then we could
modify the definition of the meta-method to check for and pass environment var
overrides to the execute method without affecting existing calls from providers
to the existing signature of the metamethods.
* we could potentially allow blocks to be registered as callbacks for
environment variables, which might allow more dynamic evaluation of the
preferred values for the vars (e.g., if the final values are not known at class
load time).
----------------------------------------
Bug #13284: MacPorts provider needs to set HOME while running `port` command.
https://projects.puppetlabs.com/issues/13284#change-58005
Author: Daniel Pittman
Status: Investigating
Priority: Normal
Assignee: Chris Price
Category: executables
Target version: Telly
Affected Puppet version: development
Keywords:
Branch:
In [commit e44a8abd7dc7b2cac4c05eb7a50b53bdd71a1cbc][commit] the `HOME`,
`USER`, and `LOGNAME` environment variables were set to be removed by default
during the execution of external commands.
This is generally a good idea, because those are inherited by default from the
user who Puppet starts running as, and can be quite misleading if we change
user ID - as we commonly do to execute external commands, and on the master.
One limitation of this is that the MacPorts provider needs to set HOME to
something during invocation, or we run into the error:
1) Package provider macports should be able to get a list of existing
packages
Failure/Error: provider.instances.each do |package|
Puppet::ExecutionFailure:
Execution of '/opt/local/bin/port -q installed' returned 1: usage: cut
-b list [-n] [file ...]
cut -c list [file ...]
cut -f list [-s] [-d delim] [file ...]
while executing
"exec dscl -q . -read /Users/[exec id -un] NFSHomeDirectory | cut -d ' '
-f 2"
(procedure "mportinit" line 95)
invoked from within
"mportinit ui_options global_options global_variations"
Error: /opt/local/bin/port: Failed to initialize MacPorts, usage: cut -b
list [-n] [file ...]
cut -c list [file ...]
cut -f list [-s] [-d delim] [file ...]
# ./lib/puppet/util/execution.rb:135:in `execute'
# ./lib/puppet/util.rb:476:in `execute'
# ./lib/puppet/provider.rb:122:in `port'
# ./lib/puppet/provider/package/macports.rb:49:in `instances'
# ./spec/integration/provider/package_spec.rb:37
Setting `HOME` to `/opt/local` is a good choice, especially since the MacPorts
provider only supports the default install location by design.
Unfortunately, the `commands` mechanism that is part of the provider interface
doesn't allow access to the environment - which it should, since this will not
be the final command to require that treatment.
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.