FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

preparation:installing.html



Top#Preparation

Installing FastHandle in Manager Server

OS Preparation

Create fasthandle user

~]# useradd fasthandle
~]# echo 'fasthandle:fastpass' | chpasswd

fasthandle user Configuration

~]# 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


Prerequisites

  • Fabric
  • expect
  • tftp (if you need)
  • vsftpd ( if you need)


Fabric

Check Python Before Installing Fabric

Fabric requires Python version 2.5 - 2.7.

~]# python -V
Python 2.7.5

~]# python3 -V
Python 3.5.2

RHEL/CentOS ~]$ rpm -qa |grep python

Ubuntu ~]$ dpkg -l |grep  python


RHEL/CentOS with EPEL

~]# 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


RHEL/CentOS with pip

~]# yum install gcc python-devel python-setuptools
~]# easy_install pip
~]# pip search fabric
~]# pip install fabric==1.14.0
~]# fab --version
Fabric 1.14.0
Paramiko 1.16.1


RHEL/CentOS with virtualenv, pip

~]# 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


Debian/Ubuntu with apt

~]# apt install fabric


Debian/Ubuntu with pip

~]# apt-get install python-dev python-setuptools gcc
~]# easy_install pip
~]# pip install fabric


Debian/Ubuntu with pip , python3, virtualenv

~]$ virtualenv -p python3 env
~]$ source env/bin/activate
~]$ pip3 install fabric3


Expect

RHEL/CentOS

~]# 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


Debian/Ubuntu

~]# apt search expect
~]# apt install expect




Installing FastHandle

You can install FastHandle “From GitHub(Method 1 or 2)” or “Make it yourself(Method 3)”.

Method 1 : From GitHub

~]$ 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/*


Method 2 : From GitHub

~]$ 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/*


Method 3 : Make it yourself

1. Make some directory

~]# 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

3. Copy FastHandle Scripts

Please copy the necessary files and change permission like chmod 755 bin/xxxx.sh.

4. Change mode the bash scripts

~]# chmod 755 $FHHOME/bin/*.sh




Test FastHandle

localhost test

~]$ 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




remote host test

Configuring FastHandle

~]$ 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






Top#Preparation



preparation/installing.html.txt · Last modified: 2018/07/29 23:47 by kurihara