Questions tagged [fabric]

A Python library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks. For questions about Google Fabric service, please use the tag [google-fabric]. For questions about FabricJs library, please use [fabricjs]. For questions about Hyperledger Fabric, please use [hyperledger-fabric]. For questions about the Minecraft modding toolchain Fabric, please use [minecraft-fabric].

Fabric provides a basic suite of operations for executing local or remote shell commands (normally or via sudo) and uploading/downloading files, as well as auxiliary functionality such as prompting the running user for input, or aborting execution.

Typical use involves creating a Python module containing one or more functions, then executing them via the fab command-line tool.

1531 questions
140
votes
6 answers

How to git commit nothing without an error?

I'm trying to write a fabric script that does a git commit; however, if there is nothing to commit, git exits with a status of 1. The deploy script takes that as unsuccessful, and quits. I do want to detect actual failures-to-commit, so I can't just…
kojiro
  • 74,557
  • 19
  • 143
  • 201
130
votes
10 answers

Activate a virtualenv via fabric as deploy user

I want to run my fabric script locally, which will in turn, log into my server, switch user to deploy, activate the projects .virtualenv, which will change dir to the project and issue a git pull. def git_pull(): sudo('su deploy') # here i…
Thomas Schreiber
  • 1,828
  • 2
  • 14
  • 11
129
votes
5 answers

Pass parameter to fabric task

How can I pass a parameter to a fabric task when calling "fab" from the command line? For example: def task(something=''): print "You said %s" % something $ fab task "hello" You said hello Done. Is it possible to do this without prompting…
Donovan
  • 6,002
  • 5
  • 41
  • 55
109
votes
15 answers

How to set target hosts in Fabric file

I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile: def deploy_2_dev(): deploy('dev') def deploy_2_staging(): deploy('staging') def deploy_2_prod(): deploy('prod') def deploy(server): …
ssc
  • 9,528
  • 10
  • 64
  • 94
104
votes
8 answers

Using an SSH keyfile with Fabric

How do you configure fabric to connect to remote hosts using SSH keyfiles (for example, Amazon EC2 instances)?
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
94
votes
7 answers

How to continue a task when Fabric receives an error

When I define a task to run on several remote servers, if the task runs on server one and exits with an error, Fabric will stop and abort the task. But I want to make fabric ignore the error and run the task on the next server. How can I make it do…
Mingo
  • 1,613
  • 2
  • 16
  • 20
84
votes
4 answers

Connecting to a host listed in ~/.ssh/config when using Fabric

I'm having trouble with Fabric not recognizing hosts that I have in ~/.ssh/config. My fabfile.py is as follows: from fabric.api import run, env env.hosts = ['lulu'] def whoami(): run('whoami') Running $ fab whoami gives: [lulu] run:…
Brian M. Hunt
  • 81,008
  • 74
  • 230
  • 343
82
votes
3 answers

How do I copy a directory to a remote machine using Fabric?

I have a directory on my local machine that I would like to copy to a remote machine (and rename it) using Fabric. I know I can copy file using put(), but what about a directory. I know it's easy enough using scp, but I would prefer to do it from…
gaviscon_man
  • 963
  • 1
  • 8
  • 8
71
votes
4 answers

Can I catch error codes when using Fabric to run() calls in a remote shell?

Normally Fabric quits as soon as a run() call returns a non-zero exit code. For some calls, however, this is expected. For example, PNGOut returns an error code of 2 when it is unable to compress a file. Currently I can only circumvent this…
Alan Plum
  • 10,814
  • 4
  • 40
  • 57
66
votes
2 answers

How do you use pip, virtualenv and Fabric to handle deployment?

What are your settings, your tricks, and above all, your workflow? These tools are great but there are still no best practices attached to their usage, so I don't know what is the most efficient way to use them. Do you use pip bundles or…
Bite code
  • 578,959
  • 113
  • 301
  • 329
56
votes
7 answers

Python 3 support for fabric

Does fabric (http://docs.fabfile.org/en/1.7/) support Python 3 yet. As per Python 3 Wall of Superpowers it does not yet. If not what is the best alternative if using Django 1.5 with Python 3.
jethar
  • 2,223
  • 2
  • 22
  • 19
50
votes
7 answers

Can I prevent fabric from prompting me for a sudo password?

I am using Fabric to run commands on a remote server. The user with which I connect on that server has some sudo privileges, and does not require a password to use these privileges. When SSH'ing into the server, I can run sudo blah and the command…
mipadi
  • 398,885
  • 90
  • 523
  • 479
50
votes
12 answers

Create django super user in a docker container without inputting password

I am tring to createsuperuser in a django docker container with fabric. To create the super user in django, I need run this in a django interactive mode: ./manage.py createsuperuser And because I want to make it run in a fabric script, so I find…
Liao Zhuodi
  • 3,144
  • 5
  • 26
  • 46
43
votes
5 answers

Best way to add an environment variable in fabric?

I would like to pass a few values from fabric into the remote environment, and I'm not seeing a great way to do it. The best I've come up with so far is: with prefix('export FOO=BAR'): run('env | grep BAR') This does seem to work, but it seems…
David Parmenter
  • 535
  • 1
  • 4
  • 8
43
votes
6 answers

running fabric script locally

I have a django app and I wrote a fabric script that installs my app on deployment server (Cent OS 5). Now I want to run the same fabric script locally on the deployment server. Is there a way to do it without supplying ssh user and password? I…
alexarsh
  • 5,123
  • 12
  • 42
  • 51
1
2 3
99 100