-
-
Notifications
You must be signed in to change notification settings - Fork 450
Open
Labels
connectorsConnector issues - builtin integrations with other tools.Connector issues - builtin integrations with other tools.
Description
Is your feature request related to a problem? Please describe
Discussed in #1204
Originally posted by DrSensor September 14, 2024
Hi, how to disable -H/--set-home flag when using _sudo=True?
a bit of context
# group_data/local.py
_sudo = True
_preserve_sudo_env = True# deploy.py
from pyinfra.operations.server import shell, packages
packages(["direnv"]) # run as root
# I want to write the output to /home/$USER/... ; not /root/...
shell(["direnv hook fish > ~/.config/fish/conf.d/direnv.fish"])after some inspection with pyinfra --debug inventory.py deploy.py
[pyinfra.connectors.local] --> Running command on localhost: env SUDO_ASKPASS=/tmp/pyinfra-sudo-askpass-vQ3t4mfcxJrY *** sudo -H -A -k -E sh -c 'direnv hook fish > ~/.config/fish/conf.d/direnv.fish'
[pyinfra.connectors.util] --> Waiting for exit status...
[pyinfra.connectors.util] --> Command exit status: 1
I notice it use -H
Describe the solution you'd like
I propose to add global argument _sudo_always_set_home1 where the default is True (for backward compatibility)
with this change, the group_data would be
# group_data/local.py
_sudo = True
_preserve_sudo_env = True
+ _sudo_always_set_home = FalseFootnotes
-
/etc/sudoershas an option calledalways_set_home↩
Metadata
Metadata
Assignees
Labels
connectorsConnector issues - builtin integrations with other tools.Connector issues - builtin integrations with other tools.