2014년 9월 6일 토요일

Fabric을 이용하여 Ubuntu 서버에 Simple하게 FIle 만들기

참고 : http://docs.fabfile.org/en/1.9/tutorial.html

fabric은 이미 설치되어 있다고 가정

local 컴퓨터 파일
fabfile.py
from fabric.api import cd, run

def simple_file_test():
 code_dir ="~"
 with cd(code_dir):
  run("touch hello_fab.txt")

로컬에서 명령

greenyant-Mac:test greenyant$ fab simple_file_test
No hosts found. Please specify (single) host string for connection: ubuntu@192.168.1.222 (서버 아이디@서버 ip주소)
[ubuntu@192.168.1.222] run: touch hello_fab.txt
[ubuntu@192.168.1.222] Login password for 'ubuntu': (서버 패스워드 입력)

Done.
Disconnecting from 192.168.1.222... done.

서버에서 hello_fab.txt 파일 생성되었는지 확인

댓글 없음:

댓글 쓰기