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/22 18:33] kurihara |
os:linux:ope:index.html [2019/02/11 00:41] (current) kurihara |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| [[: | [[: | ||
| - | ====== | + | ====== |
| + | |||
| + | $FHHOME/ | ||
| - | \\ | ||
| {{INLINETOC}} | {{INLINETOC}} | ||
| \\ | \\ | ||
| Line 9: | 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 | ||
| + | </ | ||
| \\ | \\ | ||
| ===== ope.py ===== | ===== ope.py ===== | ||
| + | |||
| + | $FHHOME/ | ||
| <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 30: | 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 48: | Line 75: | ||
| @task | @task | ||
| def sudo_vi(file): | def sudo_vi(file): | ||
| - | """ | + | """ |
| - | open_shell(" | + | open_shell(" |
| Line 55: | 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 69: | Line 96: | ||
| @task | @task | ||
| def reboot(): | def reboot(): | ||
| - | sudo(" | + | sudo(" |
| # | # | ||
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.