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













.

os:linux:pkg:index.html



Top#OS Management

Linux Package Management with Fabric (pkg.py)

Operation with Fabric

$ fab -l |grep pkg

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


Fabric one-line Task Examples

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

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

$ fab -H $H auth.pro  -- apt update
$ fab -H $H auth.pro  -- 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



os/linux/pkg/index.html.txt ยท Last modified: 2018/02/22 23:21 by kurihara