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













.

languages:java:index.html



Top#Programming Languages

Java (java.py)

Java Operation

Fabric one-line Task Examples

$ fab -l |grep -F java.

$ fab  -H $H auth.pro  java.install_yum

Fabric one-line Task Examples

$ H=test-server-1,test-server-2



java.py

$FHHOME/fabfile/java.py

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

FHHOME=os.environ["FHHOME"]


#----------------------------------------------------------------------
# Installing Java
#----------------------------------------------------------------------
# java.install_yum
@task
def install_targz(FILE):
    """ java.install_targz:jdk-8u161-linux-x64.tar.gz"""
    put("%s/src/%s" % (FHHOME, FILE), "/usr/java/" , use_sudo=True)
    with cd('/usr/java/'):
        sudo("tar zxvf %s" % FILE)

#----------------------------------------------------------------------
# Add /etc/profile
#----------------------------------------------------------------------
@task
def add_etc_profile(PATH):
    """ java.add_etc_profile:/usr/java/jdk1.8.0_74"""
    # Backup
    sudo("cp -p /etc/profile /etc/profile.`date -d '1day ago' +%Y%m%d`")
    # Add /etc/profile
    sudo('echo "" >> /etc/profile')
    sudo('echo "" >> /etc/profile')
    sudo('echo "JAVA_HOME=%s" >> /etc/profile' % PATH)
    sudo('echo "PATH=$PATH:$JAVA_HOME/bin" >> /etc/profile')
    sudo('echo "export JAVA_HOME" >> /etc/profile')
    sudo('echo "export PATH" >> /etc/profile')






Top#Programming Languages



languages/java/index.html.txt ยท Last modified: 2018/03/16 13:53 by kurihara