This is the most direct answer to your question: You really have no problem; You misunderstand how the Fabric run () and sudo () functions work.
Your workaround is NOT a workaround, it is a 100% valid answer to the problem.
Here is a simple set of rules: 1) Use "run ()" when you are not expecting a hint. 2) use "sudo ()" when you are expecting a hint. (this should be true for all or most commands that require help, even if the executable is not Bash or Sudo).
The same answer applies to people who try to run commands under "sudo". Even if sudoers has a passwordless configuration for the current user on any system, if you use sudo () instead of run (), then you will be forced to prompt (if the Fabric code already contains a password or ENV key).
By the way, the author of Fabric answered my question - very similar to your question - in #IRC. A good guy, one of the unsung heroes of open source in order to persevere in his work Cloth and Paramiko.
... In my test environment, there is always one username that has full access without a password to sudo. Typing sudo echo hello will not tell you. In addition, this sudo user is set to "! Requiretty", so all commands can work through SSH (for example, switching SSH between hosts). This means that I can simply use "run ()" to execute "sudo something", but this is just another command that runs without a hint. As far as security is concerned, it is some task to block a production node, but not a test node. (If you are forced to check things and cannot automate, this is a huge problem).
Crossfit_and_Beer Nov 19 '13 at 19:39 on 2013-11-19 19:39
source share