FastHandle is fast operation tools for infrastructure configurations and tests.
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
os:linux:ope:index.html [2017/12/31 23:35] kurihara |
os:linux:ope:index.html [2019/02/11 00:41] (current) kurihara |
||
---|---|---|---|
Line 1: | Line 1: | ||
[[: | [[: | ||
- | ====== | + | ====== |
$FHHOME/ | $FHHOME/ | ||
Line 10: | Line 10: | ||
<sxh bash toolbar: | <sxh bash toolbar: | ||
- | $ 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 | + | $ echo xx.xx.xx.xx | fab ope.check_user01 |
</ | </ | ||
+ | \\ | ||
+ | ==== Fabric one-line Task Examples ==== | ||
+ | <sxh bash toolbar: | ||
+ | $ echo xx.xx.xx.xx | fab -- hostname | ||
+ | $ echo xx.xx.xx.xx | fab -- sudo cat /etc/shadow | ||
+ | </ | ||
\\ | \\ | ||
Line 24: | Line 27: | ||
<sxh python toolbar: | <sxh python toolbar: | ||
- | 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=os.environ[" | ||
Line 33: | Line 37: | ||
# | # | ||
# ope.put | # ope.put | ||
- | # | + | # |
# | # | ||
@task | @task | ||
def put(local, | def put(local, | ||
- | """ | + | """ |
put(" | put(" | ||
+ | |||
+ | # | ||
+ | # ope.ssh | ||
+ | # | ||
+ | # WARNING: This is too late for copy and past. So you use usually fhssh.sh | ||
+ | # | ||
+ | @task | ||
+ | def ssh(): | ||
+ | ''' | ||
+ | open_shell(" | ||
+ | |||
+ | |||
+ | # | ||
+ | # ope.sshcmd | ||
+ | # | ||
+ | # | ||
+ | @task | ||
+ | def sshcmd(cmd): | ||
+ | ''' | ||
+ | open_shell(" | ||
# | # | ||
# ope.sudo_vi | # ope.sudo_vi | ||
- | # fab -H x.x.x.x | + | # fab -H x.x.x.x |
# | # | ||
# WARNING: open_shell didn't use 'echo x.x.x.x |fab ' and ' | # WARNING: open_shell didn't use 'echo x.x.x.x |fab ' and ' | ||
Line 51: | Line 75: | ||
@task | @task | ||
def sudo_vi(file): | def sudo_vi(file): | ||
- | """ | + | """ |
- | open_shell(" | + | open_shell(" |
Line 58: | Line 82: | ||
# | # | ||
# ope.cp_p_1dayago(file) | # ope.cp_p_1dayago(file) | ||
- | # | + | # |
# | # | ||
@task | @task | ||
def cp_p_1dayago(file): | def cp_p_1dayago(file): | ||
- | """ | + | """ |
- | sudo("/usr/bin/cp -p %s %s.`date -d '1day ago' +%Y%m%d`" | + | sudo(" |
Line 72: | Line 96: | ||
@task | @task | ||
def reboot(): | def reboot(): | ||
- | sudo(" | + | sudo(" |
# | # |
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.