参考:https://jingyan.baidu.com/article/fedf0737a6877935ad897746.html
1.
fabric是轻量级自动化管理工具,使用起来也很方便。fabirc依赖一些模块必须先安装好,对python版本的要求最低是2.6.6。实验环境是centos6.5_x64
2.工具
-
gmp-6.1.1.tar.bz2 (系统已安装,gmp-6.0.0-15.el7.x86_64,就没再安装)
-
setuptools-28.7.1.tar.gz (系统已安装,python-setuptools-0.9.8-7.el7.noarch,就没再安装)
-
pycrypto-2.6.1.tar.gz
-
paramiko-1.15.1.tar.gz
-
ecdsa-0.13.tar.gz
-
Fabric-1.8.2.tar.gz
安装gmp
tar -xvjpf gmp-6.1.1.tar.bz2
cd gmp-6.1.1
./configure
make
make check
make install
安装setuptools
tar zxvf setuptools-28.7.1.tar.gz
cd setuptools-28.7.1
python setup.py build & python setup.py install
安装pycrypto
tar zxvf pycrypto-2.6.1.tar.gz
cd pycrypto-2.6.1
python setup.py build & python setup.py install
安装Paramiko
tar zxvf paramiko-1.15.1.tar.gz
cd paramiko-1.15.1
python setup.py build & python setup.py install
安装ecdsa
tar zxvf ecdsa-0.13.tar.gz
cd ecdsa-0.13
python setup.py build & python setup.py install
安装fabric
tar zxvf Fabric-1.8.2.tar.gz
cd Fabric-1.8.2
python setup.py build & python setup.py install
测试
[root@master ~]# python -c "from fabric.api import * ; print env.version"
1.8.2
[root@master ~]#
查看fab命令
[root@master ~]# fabUsage: fab [options] <command>[:arg1,arg2=val2,host=foo,hosts='h1;h2',...] ...
Options:
-h, --help show this help message and exit
-d NAME, --display=NAME
print detailed info about command NAME
-F FORMAT, --list-format=FORMAT
formats --list, choices: short, normal, nested
-I, --initial-password-prompt
Force password prompt up-front
-l, --list print list of possible commands and exit
--set=KEY=VALUE,... comma separated KEY=VALUE pairs to set Fab env vars
--shortlist alias for -F short --list
-V, --version show program's version number and exit
-a, --no_agent don't use the running SSH agent
-A, --forward-agent forward local agent to remote end
--abort-on-prompts abort instead of prompting (for password, host, etc)
-c PATH, --config=PATH
specify location of config file to use
--colorize-errors Color error output
-D, --disable-known-hosts
do not load user known_hosts file
-e, --eagerly-disconnect
disconnect from hosts as soon as possible
-f PATH, --fabfile=PATH
python module file to import, e.g. '../other.py'
-g HOST, --gateway=HOST
gateway host to connect through
--hide=LEVELS comma-separated list of output levels to hide
-H HOSTS, --hosts=HOSTS
comma-separated list of hosts to operate on
-i PATH path to SSH private key file. May be repeated.
-k, --no-keys don't load private key files from ~/.ssh/
--keepalive=N enables a keepalive every N seconds
--linewise print line-by-line instead of byte-by-byte
-n M, --connection-attempts=M
make M attempts to connect before giving up
--no-pty do not use pseudo-terminal in run/sudo
-p PASSWORD, --password=PASSWORD
password for use with authentication and/or sudo
-P, --parallel default to parallel execution method
--port=PORT SSH connection port
-r, --reject-unknown-hosts
reject unknown hosts
--system-known-hosts=SYSTEM_KNOWN_HOSTS
load system known_hosts file before reading user
known_hosts
-R ROLES, --roles=ROLES
comma-separated list of roles to operate on
-s SHELL, --shell=SHELL
specify a new shell, defaults to '/bin/bash -l -c'
--show=LEVELS comma-separated list of output levels to show
--skip-bad-hosts skip over hosts that can't be reached
--ssh-config-path=PATH
Path to SSH config file
-t N, --timeout=N set connection timeout to N seconds
-T N, --command-timeout=N
set remote command timeout to N seconds
-u USER, --user=USER username to use when connecting to remote hosts
-w, --warn-only warn, instead of abort, when commands fail
-x HOSTS, --exclude-hosts=HOSTS
comma-separated list of hosts to exclude
-z INT, --pool-size=INT
number of concurrent processes to use in parallel mode
[root@master ~]#