FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


os:linux:get:index.html



Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
os:linux:get:index.html [2018/01/11 00:28]
kurihara
os:linux:get:index.html [2018/07/11 00:04]
kurihara [get.py]
Line 1: Line 1:
 [[:index.html#OS Management|Top#OS Management]] [[:index.html#OS Management|Top#OS Management]]
-====== Get OS Conf (get.py) ======+====== Get Linux Configuration with Fabirc (get.py) ======
  
 $FHHOME/fabfile/get.py $FHHOME/fabfile/get.py
Line 7: Line 7:
 \\ \\
  
-===== Operation =====+===== Operation with Fabric =====
  
 <sxh bash toolbar:false gutter:false> <sxh bash toolbar:false gutter:false>
Line 14: Line 14:
 $ fab -H $H auth.pro  get.xxxx $ fab -H $H auth.pro  get.xxxx
 </sxh> </sxh>
 +
 +
 +
  
 \\ \\
Line 24: Line 27:
 from fabric.api import * from fabric.api import *
 from fabric.contrib import files from fabric.contrib import files
 +from datetime import datetime
  
 FHHOME=os.environ["FHHOME"] FHHOME=os.environ["FHHOME"]
Line 32: Line 36:
 #------------------------------------------------------------------ #------------------------------------------------------------------
 @task @task
-def get.file_remote_local(remote,local):+def file_remote_local(remote,local):
     """get.file_remote_local:/etc/hosts,hosts"""     """get.file_remote_local:/etc/hosts,hosts"""
     date = datetime.now().strftime('%Y%m%d_%H%M')     date = datetime.now().strftime('%Y%m%d_%H%M')
     hostname = run("hostname")     hostname = run("hostname")
-    outfile = %s/tmp/%s.%s.%s"  % (FHHOME, local, hostname, date)+    outfile = "%s/tmp/%s.%s.%s"  % (FHHOME, local, hostname, date)
          
     sudo("cp %s /tmp/%s" % (remote,date))     sudo("cp %s /tmp/%s" % (remote,date))
Line 52: Line 56:
     date = datetime.now().strftime('%Y%m%d_%H%M')     date = datetime.now().strftime('%Y%m%d_%H%M')
     hostname = run("hostname")     hostname = run("hostname")
-    outfile = %s/tmp/%s.%s"  % (FHHOME, hostname, date)+    outfile = "%s/tmp/%s.%s"  % (FHHOME, hostname, date)
          
     sudo("cp %s /tmp/%s" % (remote,date))     sudo("cp %s /tmp/%s" % (remote,date))
-    get("/tmp/%s, %s" % (date outfile))+    get("/tmp/%s, %s" % (dateoutfile))
     local("sdiff -s -w 150 %s %s" % (outfile, local))     local("sdiff -s -w 150 %s %s" % (outfile, local))
          
Line 70: Line 74:
     date = datetime.now().strftime('%Y%m%d_%H%M')     date = datetime.now().strftime('%Y%m%d_%H%M')
     yearmonth = datetime.now().strftime('%Y%m')     yearmonth = datetime.now().strftime('%Y%m')
-    outfile = systeminfo.%s.%s"  % (hostname, date)+    outfile = "systeminfo.%s.%s"  % (hostname, date)
    
-    local("test -d output/%s || mkdir output/%s"    % (yearmonth, yearmonth))+    local("test -d %s/output/%s || mkdir %s/output/%s"  % (FHHOME, yearmonth, FHHOME, yearmonth))
     run("test -d scripts || mkdir scripts")     run("test -d scripts || mkdir scripts")
 +    run("test -d output || mkdir output")
    
-    put("%s/scripts/systeminfo.sh", "scripts/systeminfo.sh, mode=0755 % FHHOME+    put("%s/scripts/systeminfo.sh" % FHHOME, "scripts/systeminfo.sh", mode=0755) 
-    sudo("scripts/systeminfo.sh 1>output/%s  2>/dev/null"   % (outfile)) +    sudo("scripts/systeminfo.sh  1>output/%s  2>/dev/null"   % (outfile)) 
-    get("output/%s", "output/%s/%s"  % (outfile, yearmonth, outfile))+    get("output/%s", "%s/output/%s/%s"  % (outfile, FHHOME, yearmonth, outfile))
    
 </sxh> </sxh>
Line 85: Line 90:
  
 |<100% 200px ->| |<100% 200px ->|
-| [[os:get:scripts:systeminfo.sh.html]]       |+| [[os:linux:get:scripts:systeminfo.sh.html]]       |
  
  


os/linux/get/index.html.txt · Last modified: 2019/02/11 00:40 by kurihara