fabric 安装及简单使用 (centos6)

简介

fabric 是一个python的库,fabric可以通过ssh批量管理服务器。

第一步安装依赖包

安装epel源

wget-O/etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo


安装fabric依赖及pip

yuminstall-ypython-pipgccpython-devel
pipinstallpycrypto-on-pypi


第二步安装fabric

pipinstallfabric


第三步 测试安装及简单使用

测试安装是否成功

python-c"fromfabric.apiimport*;printenv.version"

显示出版本说明安装成功

简单使用

编写fabfile;

vim host_type.py

fromfabric.apiimportrun
defhost_type():
run('uname-s')

使用fab 在本地执行刚才定义的host_type

#fab-fhost_type.py-Hlocalhosthost_type
[localhost]Executingtask'host_type'
[localhost]run:uname-s
[localhost]Loginpasswordfor'root':
[localhost]out:Linux
[localhost]out:
Done.
disconnectingfromlocalhost...done.

至此fabric简单安装及使用到此为止

fabric好用之处就是你可以编写fabfiles 重复利用。


参考:http://www.fabfile.org/en/latest/index.html

http://stackoverflow.com/questions/10109845/which-version-of-fabric-api-is-installed

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native