Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to define FABRICRC environment variable #516

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/usage/fab.rst
Expand Up @@ -400,7 +400,13 @@ will be used to update :doc:`env <env>` when ``fab`` runs, and is loaded prior
to the loading of any fabfile.

By default, Fabric looks for ``~/.fabricrc``, and this may be overridden by
specifying the :option:`-c` flag to ``fab``.
specifying the :option:`-c` flag to ``fab``, or define environement variable
``FABRICRC`` with the full pathfilename, eg:

.. code-block::

export FABRICRC=/path/to/rcfile
# see below for content of the file

For example, if your typical SSH login username differs from your workstation
username, and you don't want to modify ``env.user`` in a project's fabfile
Expand Down
6 changes: 5 additions & 1 deletion fabric/state.py
Expand Up @@ -94,10 +94,14 @@ def _rc_path():
"""
rc_file = '.fabricrc'
if not win32:
if 'FABRICRC' in os.environ:
return os.path.expanduser(os.environ['FABRICRC'])
return os.path.expanduser("~/" + rc_file)
else:
from win32com.shell.shell import SHGetSpecialFolderPath
from win32com.shell.shellcon import CSIDL_PROFILE
if 'FABRICRC' in os.environ:
return os.environ['FABRICRC']
return "%s/%s" % (
SHGetSpecialFolderPath(0, CSIDL_PROFILE),
rc_file
Expand Down Expand Up @@ -157,7 +161,7 @@ def _rc_path():
help="comma-separated list of hosts to exclude"
),

make_option('-i',
make_option('-i',
action='append',
dest='key_filename',
default=None,
Expand Down