fabric 安装及简单使用 (centos6)
fabric 是一个python的库,fabric可以通过ssh批量管理服务器。
第一步安装依赖包
安装epel源
|
1
|
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo |
安装fabric依赖及pip
|
1
2
|
yum install -y python-pip gcc python-develpip install pycrypto-on-pypi |
第二步安装fabric
|
1
|
pip install fabric |
第三步 测试安装及简单使用
测试安装是否成功
|
1
|
python -c "from fabric.api import * ; print env.version" |
显示出版本说明安装成功
简单使用
编写fabfile;
vim host_type.py
|
1
2
3
|
from fabric.api import rundef host_type(): run('uname -s') |
使用fab 在本地执行刚才定义的host_type
|
1
2
3
4
5
6
7
8
|
# fab -f host_type.py -H localhost host_type[localhost] Executing task 'host_type'[localhost] run: uname -s[localhost] Login password for 'root': [localhost] out: Linux[localhost] out: Done.Disconnecting from localhost... done. |
至此fabric简单安装及使用到此为止
fabric好用之处就是你可以编写fabfiles 重复利用。
InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately [duplicate]
----------------
解决方案:Did you read the link (urllib3.readthedocs.org/en/latest/…)? It gives two suggestions: either upgrade to at least Python 2.7.9 or use pyOpenSSL
安装python2.7.9以上版本
参考文章:http://my.oschina.net/firxiao/blog/341175

浙公网安备 33010602011771号