SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
25.
ファイル転送
from fabric.api import get, put
def download_logs():
get(“/var/log/httpd/access.log*”)
def upload_keys():
put(“README.txt”, “/tmp”)
26.
ファイルの存在チェック
from fabric.api import sudo, put
from fabric.contrib.files import exists
def upload_keys():
if exists(“/etc/ssh/keys”):
put(“keys”, “/tmp”)
sudo(“mv /tmp/keys/* /etc/ssh/keys”)
27.
カレントディレクトリの保持
from fabric.api import cd, sudo
def package_update():
with cd(“/usr/local/src”):
sudo(“tar xvf foo-1.0.tar.gz”)
with cd(“/usr/local/src/foo-1.0”):
sudo(“./configure”)
sudo(“make”)
sudo(“make install”)