通过fabric自动更新服务器

通过fabric无密码更新测试服务器代码示例


# -*- coding: utf-8 -*-
#!/usr/bin/python
import os
from fabric.api import hosts, run, env, local, cd, get, lcd


env.hosts = ["[email protected]"]
env.passwords = {"[email protected]": "0"}
"""
    安装:
        sudo apt-get install fabric
        sudo apt-get install sshpass
    使用:
        fab update
"""




@hosts("[email protected]")
def update():
    with cd("/project_path"):
        run("git pull origin master")




@hosts("[email protected]")
def update():
    with cd("/home"):
        sudo("server project restart")

你可能感兴趣的:(sshpass,fabric,fabfile)