FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


middleware:squid:index.html



Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
middleware:squid:index.html [2017/12/30 00:10]
kurihara
middleware:squid:index.html [2019/02/11 00:46] (current)
kurihara
Line 2: Line 2:
 ====== Squid (squid.py) ====== ====== Squid (squid.py) ======
  
 +$FHHOME/fabfile/squid.py
  
-\\ 
 {{INLINETOC}} {{INLINETOC}}
 \\ \\
  
-===== Operation =====+===== Squid Operation =====
 <sxh bash toolbar:false gutter:false> <sxh bash toolbar:false gutter:false>
-echo a |fab -l |grep squid +$ fab -l |grep squid
-  +
-$ echo xx.xx.xx.xx | fab  pro  squid.yum_install +
-$ echo xx.xx.xx.xx | fab  stg  httpd.+
 </sxh> </sxh>
  
 +<sxh bash toolbar:false gutter:false>
 +$ fab  -H x.x.x.x   squid.yum_install
 +</sxh>
  
 \\ \\
-===== squid.py Fabric Recipes =====+==== Fabric Temporary Run Call Examples ==== 
 +<sxh bash toolbar:false gutter:false> 
 +$ H=test-serve-01,test-server-02
  
 +$ fab -H $H  -- sudo diff /etc/squid/squid.conf /etc/squid/squid.conf.20171205
 +$ fab -H $H  -- sudo mv /etc/squid/squid.conf.20171205 /etc/squid/squid.conf
  
 +$ fab -H $H  -- "ps aux |grep suqid"
 +$ fab -H $H  -- sudo systemctl status squid
 +$ fab -H $H  -- sudo systemctl restart squid
 +</sxh>
 +
 +
 +\\
 +===== squid.py =====
 +$FHHOME/fabfile/squid.py
 +
 +<sxh bash toolbar:false gutter:false>
 +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)
 +
 +</sxh>
  
  
 \\ \\
-===== Configuration =====+===== Squid Configuration Examples===== 
 +  *[[middleware:squid:squid.conf_default.html]]
   *[[middleware:squid:squid.conf.html]]   *[[middleware:squid:squid.conf.html]]
  


middleware/squid/index.html.1514560205.txt.gz · Last modified: 2017/12/30 00:10 by kurihara