pip安装fabric
python2.7
$ wget https://github.com/fabric/fabric/archive/1.14.0.tar.gz
$ tar -xvf 1.14.0.tar.gz
$ cd fabric-1.14.0/
$ sudo pip install -e .
#python2.7
# _*_ coding:utf-8 _*_
from fabric.api import *
hosts1 = 'root@172.17.10.112'
# hosts2 = 'root@172.16.22.1'
env.hosts=[hosts1]
env.password='xxxxxx1234' #设置密码!
def hello(): #任务1
run('echo hello world')
def check(): #任务2
run('ls /Users/')
def remote(): #任务3
run('ping www.baidu.com')
mv py.py fabfile.py
python2.7 /usr/bin/fab -l