LoginSignup
0
3

More than 5 years have passed since last update.

fabricをUbuntuにインストールして試す

Posted at

fabricは、python製のデプロイツール。
http://fabric-ja.readthedocs.io/ja/latest/tutorial.html

ローカル環境やリモート環境で、任意のコマンド実行手順をpythonで記述することができる。
PCのセットアップをする際に、毎回コマンドを実行するのが面倒になったので、fabricでまとめて実行できるようにしたい。

シェルスクリプトで書くこともできるけど、pythonの方が条件分岐とかを記述しやすいし、便利なAPIが用意されているらしいから、こちらを使うことにする。

環境

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="GalliumOS 2.1"
$ python --version
Python 2.7.12

pipの導入

fabricのインストールは、pip経由が推奨らしい。
pythonは最初から入っていたけど、pipは入ってなかったので入れる。

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py

fabricの依存ライブラリのビルドに必要なライブラリ

これらが必要らしい。とりあえず、最低限のものを。

$ sudo apt install python-dev build-essential libssl-dev

fabricのインストール

$ pip install fabric

試しに使ってみる

$ cat fabfile_1.py
from fabric.api import local 

def test():
  local("echo hello!")

$ fab -f fabfile_1.py test
[localhost] local: echo hello!
hello!

Done.

参考

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3