Closed taranlu-houzz closed 2 weeks ago
One option here is to use the ENV
config var which would apply to all operations within a deploy; ie:
# config.py
ENV = {
"HOMBREW_DEVELOPER": 1,
}
# or, new style recommended in v1.5+
from pyinfra import config
config.ENV = {
"HOMBREW_DEVELOPER": 1,
}
I believe this would provide a suitable solution? Setting environment variables for a given set of operations would be a bit confusing, I think, vs. this global approach.
The _env
global argument supports this now. https://docs.pyinfra.com/en/3.x/arguments.html#shell-control-features
Is your feature request related to a problem? Please describe
Not sure if this is actually a feature that would make sense to add, but this is the issue that I am dealing with:
The command
brew update
used by thebrew.update()
operation automatically stashes any local changes that have been made to brew recipes (one might do this if you need to patch a brew recipe to get at a specific version that doesn't have an@version
). The way to get around this is to set the environment varHOMEBREW_DEVELOPER
when running the brew commands. In order to do this viapyinfra
, I need to pass that in via theenv
param to eachbrew.*
operation, which is tedious and can be error prone (sincebrew
will just stash the modifications and carry on as though nothing out of the ordinary happened).Describe the solution you'd like
I'd like a way to specify a set of environment vars that will be passed automatically to all invocations of a particular operation class, possibly as some sort of special
group_data
key?Maybe, something like this:
There is probably a more elegant solution, but that is the gist of what I am hoping for.