$FHHOME/fabfile/tftp.py
$ fab -l |grep tftp
$ fab -H x.x.x.x tftp.xxxxx
$ 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
$FHHOME/fabfile/tftp.py
import sys, os
from fabric.api import *
from fabric.contrib import files
FHHOME=os.environ["FHHOME"]
#----------------------------------------------------------------------
# Installing TFTP
#----------------------------------------------------------------------
# squid.install_tftp
@task
def install_rpm():
'''yum install tftp tftp-server xinetd '''
sudo("rpm -q tftp > /dev/null 2>&1 || yum -y install tftp")
sudo("rpm -q tftp-server > /dev/null 2>&1 || yum -y install tftp-server")
sudo("rpm -q xinetd > /dev/null 2>&1 || yum -y install xinetd")
#----------------------------------------------------------------------
# Configuration
#----------------------------------------------------------------------
# tftp.conf
@task
def conf():
sudo("cp -p /etc/xinetd.d/tftp ~/tftp.`date -d '1day ago' +%Y%m%d`")
#disable = no
sudo("sed -i '/disable/ s/yes/no/' /etc/xinetd.d/tftp")
#sed -i "s/\(disable[\t]*= *\).*/\1no/" /etc/xinetd.d/tftp
#server_args = -c -u root -s /var/lib/tftpboot
sudo('sed -i "s/\(server_args[\t]*= *\).*/\1-c -u root -s \/home\/fasthandle\/fhhome\/tftp/" /etc/xinetd.d/tftp')
#sed -i "s/\(server_args[\t]*= *\).*/\1-s \/opt\/Tftproot -c/" /etc/xinetd.d/tft
sudo("test -d /home/fasthandle/fhhome/tftp || mkdir /home/fasthandle/fhhome/tftp")
sudo("chmod 777 /home/fasthandle/fhhome/tftp")
#----------------------------------------------------------------------
# Service
#----------------------------------------------------------------------
middleware