fabric note

时间:2022-10-14 05:30:42
 #!/usr/bin/env python
# -*- coding:utf-8 -*-
from fabric.api import *
from fabric.context_managers import * env.user = 'root'
env.password = 'www.metasequoia.cn'
env.port = 10002 def host(): #被执行的主机
with open('./hosts') as f:
hosts = f.readlines()
env.hosts = hosts @parallel #并行执行任务
def task():
#local()本地执行命令
with cd('/home'):
run('ls') #远端执行命令
#put()上传
#get()下载

执行 fab host task