pyinfra-dev / pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://pyinfra.com
MIT License
3.85k stars 374 forks source link

config.SUDO not respected for 2.0.1 #794

Closed jmpolom closed 2 years ago

jmpolom commented 2 years ago

Describe the bug

A deploy beginning with:

from pyinfra import config
from pyinfra.operations import files, server, systemd

config.SUDO = True

(etc)

does not seem to result in every fact or operation being executed with sudo. This worked in 1.x as recently as 1.7.3 (as expected? this is really not documented).

Perhaps I am dense and missing some necessary magical incantations to get this working in 2.x. The changelog notes "config variables must now be set on the global config object" for 2.0.0 but a specific example isn't given.

It seems like setting _sudo to True in the host variables does result in every operation/fact executing with sudo however.

To Reproduce

Above shows reasonable context that should result in reproducible behavior.

Expected behavior

config.SUDO = True in a deploy should result in every operation/fact executing with sudo on the target host.

Meta

jmpolom commented 2 years ago

Looks like this was fixed in commit 88bbbeeb0ca0e2cda0690c532207b874205974ff -- probably worth making a new release as this seems like a pretty major bug breaking an essential feature (priv esc).

Fizzadar commented 2 years ago

Agreed; I have just released a hotfix v2.0.2 that includes the commit!