I want to use Fabric and run a command on local, without having to establish any additional connections.
How do I do this in fabric 2? ... documentation seems to miss to give any example.
The section about Prompts in the Fabric documentation says: The prompts dictionary allows users to control interactive prompts. If a key in the dictionary is found in a command's standard output stream, Fabric will automatically answer with the corresponding dictionary value.
Fabric is a Python library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks. Fabric is very simple and powerful and can help to automate repetitive command-line tasks. This approach can save time by automating your entire workflow.
The design decision to drop the local
command in Fabric 2 makes this more difficult, but I was able to simulate it by using Context
from Invoke instead of Connection
:
from fabric import Connection from invoke.context import Context @task def hostname(c): c.run('hostname') @task def test(c): conn = Connection('user@host') hostname(conn) local_ctx = Context(c.config) # can be passed into @task; # Connection is a subclass of Context hostname(local_ctx)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With