Table of Contents

Top#OS Management

Linux Package Management with Fabric (pkg.py)

$FHHOME/fabfile/pkg.py


Operation with Fabric

$ fab -l |grep pkg

$ fab  -H $H   pkg.check_cmd
$ fab  -H $H   pkg.install_rpm_centos7


Fabric one-line Task Examples

$ H=test-server-01,test-server-02
$ fab -H $H   -- rpm -q xxxx
$ fab -H $H   -- "rpm -qa |grep xxx"
$ fab -H $H  --  "rpm -qa --last | head -20"

$ H=test-server-01,test-server-02
$ fab -H $H   -- dpkg -l  # check installed list
$ fab -H $H   -- apt search PACKAGE
$ fab -H $H   -- apt show PACKAGE

$ fab -H $H   -- apt update
$ fab -H $H   -- apt install -y PACKAGE


pkg.py

$FHHOME/fabfile/pkg.py

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

FHHOME=os.environ["FHHOME"]

#===============================================================================
#Check Commands
#===============================================================================
@task
def check_cmd():
    put("%s/scripts/check_cmd.sh" % FHHOME, "scripts/check_cmd.sh", mode=0755)
    sudo("scripts/check_cmd.sh")


#===============================================================================
# Installing Package
#===============================================================================
#----------------------------------------------------------------------
# CentOS7
#----------------------------------------------------------------------
#pkg.install_rpm_centos7
@task
def install_rpm_centos7():
    put("%s/scripts/rpm.sh" % FHHOME, "scripts/rpm.sh", mode=0755)
    sudo("scripts/rpm.sh centos7", pty=False)

#----------------------------------------------------------------------
#CentOS6
#----------------------------------------------------------------------
#pkg.install_rpm_centos6


#----------------------------------------------------------------------
#Ubuntu16
#----------------------------------------------------------------------
#pkg.install_dpkg_ubuntu16






$FHHOME/scripts


Top#OS Management





Top#OS Management