FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


os:linux:ope: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:ope:index.html [2018/01/24 23:26]
kurihara
os:linux:ope:index.html [2018/03/14 00:33]
kurihara
Line 1: Line 1:
 [[:index.html#OS Management|Top#OS Management]] [[:index.html#OS Management|Top#OS Management]]
-====== OS Operation (ope.py)=====+====== Linux Operation with Fabric (ope.py)=====
  
 $FHHOME/fabfile/ope.py $FHHOME/fabfile/ope.py
Line 10: Line 10:
  
 <sxh bash toolbar:false gutter:false> <sxh bash toolbar:false gutter:false>
-$ echo xx.xx.xx.xx | fab auth.pro -- hostname 
-$ echo xx.xx.xx.xx | fab auth.pro -- sudo cat /etc/shadow 
- 
 $ fab  -l |grep ope. $ fab  -l |grep ope.
 $ echo xx.xx.xx.xx | fab  auth.pro  ope.check_user01 $ echo xx.xx.xx.xx | fab  auth.pro  ope.check_user01
 </sxh> </sxh>
  
 +\\
 +==== Fabric one-line Task Examples ====
 +<sxh bash toolbar:false gutter:false>
 +$ echo xx.xx.xx.xx | fab auth.pro -- hostname
 +$ echo xx.xx.xx.xx | fab auth.pro -- sudo cat /etc/shadow
 +</sxh>
  
 \\ \\
Line 24: Line 27:
  
 <sxh python toolbar:false gutter:false> <sxh python toolbar:false gutter:false>
-import sys+import sys, os
 from fabric.api import * from fabric.api import *
 from fabric.contrib import files from fabric.contrib import files
 from fabric.operations import open_shell from fabric.operations import open_shell
 +from datetime import datetime
  
 FHHOME=os.environ["FHHOME"] FHHOME=os.environ["FHHOME"]
Line 37: Line 41:
 @task @task
 def put(local,remote): def put(local,remote):
-    """fab auth.pro ope.scp:/home/fasthandle/rpm/abc.rpm,/tmp/abc.rpm"""+    """fab auth.pro ope.put:/home/fasthandle/rpm/abc.rpm,/tmp/abc.rpm"""
     put("%s", "%s" % (local,remote))     put("%s", "%s" % (local,remote))
  
Line 72: Line 76:
 def sudo_vi(file): def sudo_vi(file):
     """fab auth.pro ope.vi:/etc/hosts"""     """fab auth.pro ope.vi:/etc/hosts"""
-    open_shell("sudo_vi %s && exit" % (file))+    open_shell("sudo vi %s && exit" % (file))
  
  
Line 83: Line 87:
 def cp_p_1dayago(file): def cp_p_1dayago(file):
     """fab auth.pro  cp_p_1dayago:/etc/host,/etc/hosts"""     """fab auth.pro  cp_p_1dayago:/etc/host,/etc/hosts"""
-    sudo("cp -p %s %s.`date -d '1day ago' +%Y%m%d`"% (file, file))+    sudo("cp -p %s %s.`date -d '1day ago' +%Y%m%d`" % (file, file))
  
  


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