Skip to content

Instantly share code, notes, and snippets.

@shuxiang
Created October 18, 2014 06:23
Show Gist options
  • Save shuxiang/9cdfb4ef56f0682a467c to your computer and use it in GitHub Desktop.
Save shuxiang/9cdfb4ef56f0682a467c to your computer and use it in GitHub Desktop.
fabric test
#coding=utf8
from fabric.api import *
env.user = 'root'
env.password = 'jindengtaia10'
env.hosts = ['121.199.4.240']
@task
def nginx_start():
''' nginx start '''
sudo('/etc/init.d/nginx start')
@task
def nginx_stop():
''' nginx stop '''
sudo('/etc/init.d/nginx stop')
@task
def test_ls():
sudo('ls -a')
"""
$ fab --list -- 查看可用命令
Available commands:
nginx_start nginx start
nginx_stop nginx stop
$ fab -H x.x.x.x nginx_start -- 启动 nginx
"""
@bmoren
Copy link

bmoren commented Oct 18, 2014

plaintext password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment