安裝epel源html
1
|
wget -O
/etc/yum
.repos.d
/epel
.repo http:
//mirrors
.aliyun.com
/repo/epel-6
.repo
|
安裝fabric依賴及pippython
1
2
|
yum
install
-y python-pip
gcc
python-devel
pip
install
pycrypto-on-pypi
|
1
|
pip
install
fabric
|
測試安裝是否成功shell
1
|
python -c
"from fabric.api import * ; print env.version"
|
顯示出版本說明安裝成功vim
簡單使用api
編寫fabfile;服務器
vim host_type.pyapp
1
2
3
|
from
fabric.api
import
run
def
host_type():
run(
'uname -s'
)
|
使用fab 在本地執行剛纔定義的host_typepython2.7
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簡單安裝及使用到此爲止ssh
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以上版本