~]# useradd fasthandle ~]# echo 'fasthandle:fastpass' | chpasswd
~]# su - fasthandle
~]$ cp -p ~/.bashrc ~/.bashrc.`date -d '1day ago' +%Y%m%d` ~]$ cat << @ >> ~/.bashrc # HastHandle env [ -f ~/fhhome/fh.env ] && source ~/fhhome/fh.env # history HISTSIZE=10000 HISTFILESIZE=10000 HISTTIMEFORMAT='%F %T %z ' PROMPT_COMMAND="history -a" PS1="[\u@\h \w \t]\$ " @
~]$ cp -p ~/.ssh/config ~/.ssh/config.`date -d '1day ago' +%Y%m%d` ~]$ cat << @ >> ~/.ssh/config # Don't listen yes/no. host * # Ignore "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" StrictHostKeyChecking no UserKnownHostsFile=/dev/null @ ~]$ chmod 600 ~/.ssh/config
You must use Fabric or fabric3. these days, you should use fabric3.
fabric2 is the different of use.
Fabric | Python (2.5-2.7) http://www.fabfile.org/ |
fabric2 | Python (2.7, 3.4+) http://www.fabfile.org/ |
fabric3 | Python (2.7, 3.4+) . Fabric3 is a fork of Fabric to provide compatability with Python 3.4+. The port still works with Python 2.7. https://pypi.org/project/Fabric3/ https://github.com/mathiasertl/fabric/ |
~]# python -V Python 2.7.5
~]# python3 -V Python 3.5.2
RHEL/CentOS ~]$ rpm -qa |grep python Ubuntu ~]$ dpkg -l |grep python
~]# export http_proxy=http://xx.xx.xx:port/ <- if you need your proxy server. ~]# export https_proxy=http://xx.xx.xx.xx:port/ <- if you need your proxy server. ~]# yum install epel-release ~]# yum info fabric ~]# yum install fabric ~]# fab --version Fabric 1.14.0 Paramiko 1.16.1
~]# yum install gcc python-devel python-setuptools ~]# easy_install pip ~]# pip search fabric ~]# pip install fabric== ~]# pip install fabric==1.14.0 ~]# fab --version Fabric 1.14.0 Paramiko 1.16.1
~]# yum install gcc python-devel python-setuptools ~]# easy_install pip ~]# pip search fabric3 ~]# pip install fabric3 ~]# fab --version Fabric 1.14.0 Paramiko 1.16.1
~]# yum install gcc python-devel python-setuptools ~]# sudo su - fasthandle ~]# pip install virtualenv ~]# cd /home ~]# virtualenv env_fasthandle -p python2.7 ~]# source env_fasthandle/bin/activate ~]# pip install fabric==1.14.0 ~]# deactivate ~]$ cat << END >> ~/.bashrc #virtualenv source env_fasthandle/bin/activate END
~]# apt install fabric
~]# apt-get install python-dev python-setuptools gcc ~]# easy_install pip ~]# pip install fabric== ~]# pip install fabric==1.x.x
~]# apt-get install python-dev python-setuptools gcc ~]# easy_install pip ~]# pip install fabric3
~]$ virtualenv -p python3 env ~]$ source env/bin/activate ~]$ pip3 install fabric3
~]# export http_proxy=http://xx.xx.xx:port/ <- if you need your proxy server. ~]# export https_proxy=http://xx.xx.xx.xx:port/ <- if you need your proxy server. ~]# yum search expect ~]# yum install expect
~]# apt search expect ~]# apt install expect
You can install FastHandle “From GitHub(Method 1 or 2)” or “Make it yourself(Method 3)”.
~]$ cd /home/fasthandle ~]$ test -d fhhome && mv fhhome fhhome.`date +%Y%m%d` ~]$ git clone https://github.com/kuritaka/fasthandle.git fhhome ~]$ tree -a -I '.git' fhhome ~]$ chmod 755 fhhome/bin/*
~]$ cd /home/fasthandle ~]$ git clone https://github.com/kuritaka/fasthandle.git fhhome.`date +%Y%m%d` ~]$ tree -a -I '.git' fhhome.`date +%Y%m%d` ~]$ mkdir fhhome ~]$ cp -pr fhhome.`date +%Y%m%d`/ fhhome/ ~]$ chmod 755 fhhome/bin/*
Reference Directory Structure
~]# su - fasthandle ~]$ cd /home/fasthandle ~]$ mkdir fhhome ~]$ cd fhhome ~]$ mkdir -p bin fabfile hosts key log target/bin target/deb target/key target/linux target/rpm target/scripts target/src tmp
Please copy the necessary files and change permission like chmod 755 bin/xxxx.sh
.
~]# chmod 755 $FHHOME/bin/*.sh
~]$ fab -l Available commands: auth.dev develop env auth.pro production env auth.stg staging env auth.test1 auth.test2 check.check_ssh_hostname check_ssh_hostname:localuser,key,remoteuser,remotehost check.nmap fab auth.pro ope.nmap:22,x.x.x.x check.ntpsync check.ping_gw use %s/scripts/check_ping_gw.sh check.reboot_check use %s/scripts/check_reboot.sh check.reboot_diff .....
~]$ fab -H localhost test.local_hostname
~]$ cd $FHHOME ~]$ vi auth.py # Configureing User and Password
~]$ fab -H 127.0.0.1 auth.test1 -- hostname ~]$ fab -H 127.0.0.1 auth.test1 test.hostname ~]$ fab -H x.x.x.x auth.test1 -- hostname ~]$ fab -H x.x.x.x auth.test1 test.hostname