Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Fabric to perform interactive shell commands?

I`m trying to use fabric to install and deploy a web project during which I need to create a postgresql database and configure a RabbitMQ server. Both these operations are interactive and requires input from the user for creating a database, adding a user, setting password etc ( at least to my knowledge ).

Can I use a fabric script to do interative shell operations like these?

like image 281
Weholt Avatar asked Mar 03 '11 15:03

Weholt


People also ask

What is the use of fabric run command?

run (fabric.operations.run) Fabric’s run procedure is used for executing a shell command on one or more remote hosts. The output results of run can be captured using a variable. If command succeeded or failed can be checked using.failed and.succeeded.

What is fabric in Linux?

Along with run, the most widely used Fabric command is probably sudo. It allows the execution of a given set of commands and arguments with sudo (i.e. superuser) privileges on the remote host.

Can I use fabric for scripts?

As long as the very basic requirements are met, you can take advantage of this excellent library. Fabric scripts are basic Python files. They are run using the fab tool that is shipped with with Fabric. All this does is include (i.e. import ..) your script (i.e. instructions to perform) and execute the provided procedure.

How does fabric work?

You basically write rules that do something and then you (can) specify on which servers the rules will run on. Fabric then logs into one or more servers in turn and executes the shell commands defined in "fabfile.py".


1 Answers

This is in Fabric 1.0. I've tried it and it works for me.

Older versions of Fabric (and similar high level SSH libraries) run remote programs in limbo, unable to be touched from the local end. This is problematic when you have a serious need to enter passwords or otherwise interact with the remote program.

Fabric 1.0 and later breaks down this wall and ensures you can always talk to the other side.

Source

Edit: As payne notes below, Fabric 1.0 was released. I edited the answer to indicate this.

like image 121
Sean W. Avatar answered Nov 15 '22 15:11

Sean W.