User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

info:fabric [2016-06-17 20:58]
sam created
info:fabric [2016-06-20 19:28] (current)
sam how to use prompts
Line 1: Line 1:
 ====== Fabric'​s Future ====== ====== Fabric'​s Future ======
 The long-term plan is to release a rewritten "​Fabric 2" based on "​Invoke";​ see http://​​roadmap.html. The long-term plan is to release a rewritten "​Fabric 2" based on "​Invoke";​ see http://​​roadmap.html.
 +====== Prompts ("​Expect"​-like behavior) ======
 +By default, Fabric prompts for and reuses the SSH password on multiple hosts, but it can also answer arbitrary prompts using the [[http://​​en/​1.11/​usage/​env.html#​prompts|env.prompts]] variable. You can also manually set passwords for hosts using [[http://​​en/​1.11/​usage/​env.html#​passwords|env.passwords]]. This might be useful if you want to prompt up-front for a password that will not be used until later (e.g. after running some local tasks), to reduce required user interaction.
 +For example:
 +<code python>
 +# One way to manually prompt for a password in Python
 +pass = getpass.getpass('​foo password: ')
 +# Interactive prompt, e.g. required by some tool
 +env.prompts["​Login password for '​foo':​ "] = pass
 +# Manually set password for Fabric connection to another host
 +# (requires user and port)
 +env.passwords["​foo@some-hostname:​22"​] = pass
info/fabric.txt · Last modified: 2016-06-20 19:28 by sam