public
Description: Simple, Pythonic remote execution and deployment
Homepage: http://fabfile.org
Clone URL: git://github.com/bitprophet/fabric.git
bitprophet (author)
Wed Nov 04 10:34:21 -0800 2009
commit  16060c6d72d52639becfefeb374be6b0b24329d5
tree    8f7d0f9379a67ed594e86b14390e4681770afa0f
parent  51e9b92c7e24ca0765c81e4e3b09a679e7cd69fc parent  652b430a61bb12cad3f87891de50bfb17fbfe432
fabric / FAQ
100644 107 lines (78 sloc) 5.033 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
=================================
Fabric Frequently Asked Questions
=================================
 
This is a dev-oriented list of FAQs from users. Once we get to maybe 10 or
more, turn this into an actual document. (Would rather not have a user facing
FAQ doc with only one or two entries, and too lazy to brainstorm a bunch of
anticipated FAQs right now...)
 
1. Why do I sometimes see ``err: stdin: is not a tty``?
=======================================================
 
This message is typically generated by programs such as ``biff`` or ``mesg``
lurking within your remote user's ``.profile`` or ``.bashrc`` files (or any
other such files, including system-wide ones.) Fabric's default mode of
operation involves executing the Bash shell in "login mode", which causes these
files to be executed.
 
Because Fabric also doesn't bother asking the remote end for a tty by default
(as it's not usually necessary) programs fired within your startup files, which
expect a tty to be present, will complain -- and thus, stderr output about
"stdin is not a tty" or similar.
 
There are multiple ways to deal with this problem:
 
* Find and remove or comment out the offending program call. If the program was
  not added by you on purpose and is simply a legacy of the operating system,
  this may be safe to do, and is the simplest approach.
* Override ``env.shell`` to remove the ``-l`` flag. This should tell Bash not
  to load your startup files. If you don't depend on the contents of your
  startup files (such as aliases or whatnot) this may be a good solution.
* Pass ``pty=True`` to `run` or `sudo`, which will force allocation of a
  pseudo-tty on the remote end, and hopefully cause the offending program to be
  less cranky.
 
 
2. Why can't I run programs in the background with ``&``? It makes Fabric hang.
===============================================================================
 
Because Fabric executes a shell on the remote end for each invocation of
``run`` or ``sudo``, techniques like backgrounding (or using ``cd``, but see
the `cd` context manager for help on that) will not work as expected.
Backgrounded processes still prevent the calling shell from exiting until they
stop running, and this in turn prevents Fabric from continuing on with its own
execution.
 
If you truly need to run a process in the "background" and are unable to
properly `daemonize
<http://en.wikipedia.org/wiki/Daemon_(computer_software)>`_, you may want to
look into GNU Screen (widely available in package managers or preinstalled)
which can easily serve the same purpose. A trivial example (``yes`` is a
simple Unix app that simply prints the word "yes" forever until killed)::
 
    run('screen -d -m "yes"')
 
Such a call will effectively fork the ``yes`` program into a detached
``screen`` session, which will no longer be associated with the calling shell,
and thus your Fabric task will continue executing as intended.
 
 
3. My remote system doesn't have ``bash`` installed by default, do I need to install ``bash``?
==============================================================================================
 
While Fabric is written with ``bash`` in mind, it's not an absolute
requirement. Simply change ``env.shell`` to call your desired shell, and
include an argument similar to ``bash``'s ``-c`` argument, which allows us to
build shell commands of the form::
 
    /bin/bash -l -c "<command string here>"
 
where ``/bin/bash -l -c`` is the default value of ``env.shell``.
 
.. note::
 
    The ``-l`` argument specifices a login shell and is not absolutely
    required, merely convenient in many situations. Some shells lack the option
    entirely and it may be safely omitted in such cases.
 
A relatively safe baseline is to call ``/bin/sh``, which may call the original
``sh`` binary, or (on some systems) ``csh``, and give it the ``-c``
argument, like so::
 
    from fabric.api import env
 
    env.shell = "/bin/sh -c"
 
This has been shown to work on FreeBSD and may work on other systems as well.
 
 
4. I'm sometimes incorrectly asked for a passphrase instead of a password.
==========================================================================
 
Due to a bug of sorts in our SSH layer (Paramiko), it's not currently possible
for Fabric to always accurately detect the type of authentication needed. We
have to try and guess whether we're being asked for a private key passphrase or
a remote server password, and in some cases our guess ends up being wrong.
 
The most common such situation is where you, the local user, appear to have an
SSH keychain agent running, but the remote server is not able to honor your SSH
key, e.g. you haven't yet transferred the public key over or are using an
incorrect username. In this situation, Fabric will prompt you with "Please
enter passphrase for private key", but the text you enter is actually being
sent to the remote end's password authentication.
 
We hope to address this in future releases, either by doing heavier
introspection of Paramiko or patching Paramiko itself.