Ability to use sudo midway through script execution
See original GitHub issueIs your feature request related to a problem? Please describe.
I’m currently trying to use pyinfra
to install brew
. The target machine that I am working on is running Windows 10 with WSL. I have ssh enabled, and am able to issue pyinfra
commands that connect to WSL and work (mostly) correctly.
The standard way to install brew
is to use: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
. To avoid the prompt in the script, I am using the env var env CI=1
, however I am running into a snag with the sudo prompt that comes up midway through the script. I cannot just run the script as root or using sudo, because it explicitly checks for this and disallows it, but I still need to be able to pass a sudo prompt midway through for it to install brew
at the standard location in /home/linuxbrew/.linuxbrew
. I am wondering if there is way to get around this?
Based on the discussion in #305, I thought I might be able to get the password from the user in the deploy using getpass
, and then feed that to the brew
install script using the stdin
global parameter, but that didn’t seem to work.
If I cannot find a solution I could write my own installation script, but I was hoping to be able to use the standard installation method that already exists.
Describe the solution you’d like
I’m not entirely sure what the ideal solution would look like for this, since it is a pretty specific case… If the stdin
solution I had mentioned worked, then maybe it would be nice to be able to “hold onto” the password that is captured via use_sudo_password
so that it can be used later? It may also be the case that there is a better supported way to automate installation of brew
, but I haven’t had any luck finding an easy method.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
This is now supported as of https://github.com/Fizzadar/pyinfra/commit/ff40f50f840c9a73a041aa0d8d80defd2375f6ef; expecting to have a dev version of 1.3 out today/tomorrow.
So this does work - but
sudo
needs to be called with-A
, and brew appears to handle this nicely!I’ll make the change to enable
use_sudo_password
to work irrespective of whethersudo
is set.