FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

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













.

preparation:fhhome:test.py.html




Top#Preparation

$FHHOME/fabfile/test.py

Operation

$ echo xx.xx.xx.xx | fab -- hostname
$ echo xx.xx.xx.xx | fab -- sudo cat /etc/shadow

$ fab local_hostname

$ fab -l |grep test.    # check options

$ echo xx.xx.xx.xx | fab auth.test test.hostname
$ fhghost.sh "*" hosts/test | fab auth.test test.hostname


fabfile/test.py

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

FHHOME=os.environ["FHHOME"]

# test.local_hostname
@task
def local_hostname():
    local('hostname')

# test.hostname
@task
def hostname():
    run('hostname')


# test.sudo
@task
def sudo():
    """ sudo cat /etc/shadow """
    sudo('cat /etc/shadow')


# test.arg1:hostname
@task
def arg1(cmd):
    """ fab test.arg1:hostname """
    run('%s' % cmd)


# test.arg2:hostname,whoami
@task
def arg2(cmd1, cmd2):
    """ fab test.arg2:hostname,whoami """
    run('%s' % cmd1)
    run('%s' % cmd2)
    run('%s ; %s' % (cmd1, cmd2) )


# test.put
@task
def put():
    date = datetime.now().strftime('%Y%m%d_%H%M')
    local('hostname > /tmp/test.%s' % date)
    put('/tmp/test.%s' % date, '/tmp/test.%s' % date)
    run('ls -lh /tmp/test.%s' % date)
    run('cat /tmp/test.%s' % date)

# test.get
@task
def get():
    date = datetime.now().strftime('%Y%m%d_%H%M')
    run('hostname > /tmp/test.%s' % date)
    get('/tmp/test.%s' % date, '/tmp/test.%s' % date)
    local('ls -lh /tmp/test.%s' % date)
    local('cat /tmp/test.%s' % date)




Top#Preparation



preparation/fhhome/test.py.html.txt ยท Last modified: 2018/05/08 00:52 by kurihara