Add Fabric basic tutorial
[SugarCubes.git] / fabric / HOWTOFABRIC.txt
1 Using fabric:
2
3 Install:
4 (http://docs.fabfile.org/en/1.7/installation.html)
5
6 pip install fabric
7
8 Tutorial:
9
10 http://docs.fabfile.org/en/1.4.0/index.html#tutorial
11
12 Usage:
13
14 write a python file called fabfile.py (or add to the current one)
15
16 annotate tasks with @task
17
18 e.g:
19
20 from fabric.api import run,env,task,sudo,cd
21
22 @task
23 def sayHelloAll():
24 print "Hello local"
25 run("echo Hello Remote")
26
27 then from the command line:
28
29 #shows all commands
30
31 fab list
32
33 # run a command
34
35 fab sayHello
36
37 # run command on specific host
38
39 fab sayHello:host=192.168.1.29
40
41 # run a command on a specific host with a specific user
42
43 fab -u someUser startBoard:host=192.168.1.29
44
45 Run multiple:
46
47 fab task1 task2
48
49 Run arbitrary remote command:
50
51 fab [options] -- [shell command]
52
53
54
55