1.local命令,当前服务器执行命令,
2.打印内容添加颜色
from fabric.api import *
from fabric.colors import *
def task4():
local('/usr/zookeeper/bin/zkServer.sh restart')
local('/usr/zookeeper/bin/zkServer.sh status')
def task5():
local('ls -ls /usr')
def taskLocal():
task4()
task5()
def showColor():
print green('success')
print red('fail')
print yellow('yellow')执行脚本
[root@master ~]# fab -f fabtest.py showColor
success
fail
yellow
Done.
[root@master ~]#