Your SlideShare is downloading. ×
Fabric
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Fabric

274
views

Published on

勉強会でfabricを紹介する資料

勉強会でfabricを紹介する資料

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
274
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 1Fabric
  • 2. 2Fabric● Pythonista狂喜乱舞のデプロイツール■動作(タスク)はPythonの関数で定義■ぶっちゃけ Python + Shell Script■日々のルーチンワークを自動化■複数サーバの環境を一気に整える
  • 3. 3インストール● やりかたいろいろ■ $ pip fabric■ $ easy_install fabric■ $ sudo apt-get install fabric● git clone は やめた方がいいとか
  • 4. 4使い方$ fab [options] task[ task task ...]options■ -f another_fabfile.py (./fabfile.py is default)■ -H target.host.co.jp[,anothor.host.co.jp]■ -p password■ -i ~/.ssh/ssh_key:
  • 5. 5雰囲気● fabfile.py   →● $ fab -H ksl-i7 whats_your_name[ksl-i7] run: hostname[ksl-i7] out: ksl-i7.nagaokaut.ac.jpfrom fabric.api import rundef whats_your_name():run(“hostname”)
  • 6. 6もうちょい実用● fabfile.py   →● $ fab -H ksl-i7,ksl-i5,ksl-t88w catch_snakes[ksl-i7] sudo: yum install python[ksl-i7] out: sudo password:from fabric.api import run, sudodef catch_snakes():sudo(“yum install python”)
  • 7. 7不満パスワードとか-Hオプションとか毎回打つの?ユーザ指定したいんだけど
  • 8. 8envdef development():env.hosts = [ksl-i7]env.user = testuserenv.password = pass1234def do_something():run(xxxxx)$ fab development do_something
  • 9. 9便利な● fabric.contrib.filesexists(/home/%s/.bashrc % env.user)append(/home/user/.bashrc, alias la=”ls -a”)comment(conf_file, r^[^#], use_sudo = True)● fabric.apiput(local_src, remote_dst)get(remote_src, local_dst)
  • 10. 10Chef でエエやん
  • 11. 11Chef との住み分け●本格運用なら Chef■たぶん■使ったことないけど● ちょっとデプロイしたくなったら■デプロイ先に準備が要らない●シェルやPythonに慣れてるならFabricかなー