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.91k stars 382 forks source link

Config option to suppress warning: "Invalid auth argument: cannot use use_sudo_password without sudo." #711

Closed gnat closed 2 years ago

gnat commented 2 years ago

Issue / Use Case

I frequently switch sudo on/off for my task scripts. This currently works flawlessly using config.SUDO = True and config.SUDO = False I pre-fill config.USE_SUDO_PASSWORD.

Great for situations like:

  1. config.SUDO = True
  2. Adjust firewall (root user).
  3. config.SUDO = False
  4. Run Rootless Docker (normal user).

The issue is when I config.SUDO = False pyinfra will print out:

Invalid auth argument: cannot use `use_sudo_password` without `sudo`.

Of course I can suppress this by continually setting/unsetting config.USE_SUDO_PASSWORD but this is super inconvenient.

Describe the solution you'd like

Thanks!

Fizzadar commented 2 years ago

Hi @gnat - 100% agree with this the warning isn't showing in the expected scenarios. I'm not sure it's possible to reliably show these warnings at all as there's many different combinations of config/global args/etc. Will have a think about how best to handle this but maybe removing the warnings alltogether would be an improvement.

Fizzadar commented 2 years ago

These were removed entirely a while back, the logic around when these are/aren't valid is too confusing.