FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Top     SiteMap

Sidebar


Top     SiteMap

Manager Server

Target Server

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













.

middleware:squid:index.html



Top#Middleware Management

Squid (squid.py)

Squid Operation

$ fab -l |grep squid

$ fab  -H x.x.x.x auth.pro  squid.yum_install


Fabric Temporary Run Call Examples

$ H=test-serve-01,test-server-02

$ fab -H $H auth.pro -- sudo diff /etc/squid/squid.conf /etc/squid/squid.conf.20171205
$ fab -H $H auth.pro -- sudo mv /etc/squid/squid.conf.20171205 /etc/squid/squid.conf

$ fab -H $H auth.pro -- "ps aux |grep suqid"
$ fab -H $H auth.pro -- sudo systemctl status squid
$ fab -H $H auth.pro -- sudo systemctl restart squid


squid.py

$FHHOME/fabfile/squid.py

import sys, os
from fabric.api import *
from fabric.contrib import files

FHHOME=os.environ["FHHOME"]

#----------------------------------------------------------------------
# Installing Squid
#----------------------------------------------------------------------
# squid.install_yum
@task
def install_yum():
    sudo("rpm -q squid        > /dev/null 2>&1 || yum -y install squid")

#----------------------------------------------------------------------
# Service
#----------------------------------------------------------------------
# squid.systemctl_restart
@task
def systemctl_restart():
    run("ps aux |grep squid")
    sudo("systemctl stauts squid")
    sudo("systemctl restart squid")
    sudo("systemctl stauts squid")
    run("ps aux |grep squid")

#----------------------------------------------------------------------
# Configuration
#----------------------------------------------------------------------
# squid.change_squidconf:test-server-01
@task
def change_squidconf(host):
    today = datetime.now().strftime('%Y%m%d')
    sudo("cp -f /etc/squid/squid.conf /etc/squid/squid.conf.`date -d '1day ago' +%Y%m%d`")
    put("%s/conf/squid/squid.conf.%s" % (FHHOME, host), "/tmp/squid.conf.%s" % date)
    sudo("mv /tmp/squid.conf.%s /etc/sysctl.conf" % date)


Squid Configuration Examples



middleware/squid/index.html.txt ยท Last modified: 2018/02/21 23:51 by kurihara