Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions docs/scenarios/admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,51 @@ and we can deploy with:

$ fab deploy

If you deploy many servers, one problem is each server has a different password, the
following code show how to config different servers.

.. code-block:: python

from fabric.api import *

env.roledefs = {
'server1': ['usename@ip1:port1',],
'server2': ['usename@ip2:port2',],
}


env.passwords = {
'usename@ip1:port1': 'password1',
'usename@ip2:port2': 'password2',
}

# env.password = 'xxxxxx' # if all hosts have the same password,
# use env.password for short

COMAND = 'ls -l | wc'

@roles('server1')
def test_remote():
run(COMAND)

def test_local():
local(COMAND)

@roles('server2')
def download(remote_path, local_path='~/download'):
get(remote_path, local_path)

def do():
execute(test_local)
execute(test_remote)

And you can test with:

.. code-block:: console

$ fab do
$ fab download('/remote_path/to/file')

Additional features include parallel execution, interaction with remote
programs, and host grouping.

Expand Down