導入
sudo easy_install fabric
インストールすると、
/usr/local/bin/fab
ができる。
なぜかパスが通ってなかったので
.zshenvにパスを追加。
どこでもいいのでfabfile.pyを作成。
import os.path
from fabric.api import run, sudo, settings, abort, put, cd, env
from fabric.contrib.console import confirm
from fabric.decorators import runs_once
# サーバー情報
env.hosts = ['xxx.xxx.xxx.xxx']
env.user = 'username'
env.port = '99999'
#env.key_filename = [os.path.expanduser('~/.ssh/secret_key')]
def hello():
run("touch test1.txt")
run("mv test1.txt test2.txt")
実行したら、設定ファイルの中身がサーバーで実行される。
fab hello
後は自分の設定したい内容を作りこんでいくだけ。
fabricがいるのか?
Capistrano使いの方から、
「Capistranoだけでいいじゃないか」と
disられる。
デプロイツールではあるけど
どうせCapistranoを使っているなら
サーバー設定用のプロジェクトを作っておいてそっちでやればと。
反論できず。
追記
sudo("mv test1.txt test2.txt")
というような感じでsudoを入力できるようになってて
パスワードはどうするんだろうかと思っていたら
fabの実行時にパスワードを聞かれた。なるほど。
コメントを残す