Closed oz123 closed 3 years ago
Hi @oz123 - this is an unfortunate consequence of using AST to parse the config files. The upcoming v1.5
adds a pyinfra.config
object that can recieve any type of value and does not go through the AST like this.
You may also set USE_SUDO_PASSWORD=True
to have pyinfra prompt for the password at runtime, although this is not helpful to integrate with some external system.
I'm going to ensure this use-case works in v1.5.
Yes, using True
does work and prompt. The problem is that if I have 10s of system, I have to manually write the password for each host, or simply wrap pyinfra with something that writes config.py
.
Aren't we wall are system admins :'-) who constantly wrap software with more shell glue around?
v1.5 is now out so this should be possible via:
from pyinfra import config
config.USE_SUDO_PASSWORD = ...
Describe the bug
I have a script with the following:
Using
USE_SUDO_PASSWORD = 'mysecretsudopassword'
with:works as expected. I am not asked for sudo password.
However, if USE_SUDO_PASSWORD is assigned a value of a called function, e.g. as with the lambda, it fails with:
To Reproduce
Call pyinfra with my similar example.
Expected behavior
I would expect this to work, since it opens the way to reading secret from the environment or on the fly decryption of files.
Because config.py is loaded and parsed with
ast.parser
I don't see an obvious way of doing this. Given more time, I might be able to submit a patch. On the other hand, I know you are already working on a patch related to this issue..Meta
Include output of
pyinfra --support
.