Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Fabric Python Developers Festa 2013.03 #pyfes
Search
drillbits
March 16, 2013
Programming
28
6.7k
Fabric Python Developers Festa 2013.03 #pyfes
はい
drillbits
March 16, 2013
Tweet
Share
Other Decks in Programming
See All in Programming
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
CSC305 Lecture 26
javiergs
PRO
0
140
快速入門可觀測性
blueswen
0
350
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
280
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
140
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
260
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
Security_for_introducing_eBPF
kentatada
0
110
たのしいparse.y
ydah
3
120
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
250
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
328
21k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
A Philosophy of Restraint
colly
203
16k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Typedesign – Prime Four
hannesfritz
40
2.4k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
What's in a price? How to price your products and services
michaelherold
243
12k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Transcript
Fabric Python Developers Festa 2013.03
͓·͑୭Α
drillbits
None
BePROUD
BePROUD Web Alchemist
BePROUD Web Alchemist #sht #precure #nitiasa
None
Fabric?
Fabric is a Python (2.5 or higher) library and command-line
tool for streamlining the use of SSH for application deployment or systems administration tasks.
͍
Fabric is a Python (2.5 or higher) library and command-line
tool for streamlining the use of SSH for application deployment or systems administration tasks.
Fabric is a Python (2.5 or higher) library and command-line
tool for streamlining the use of SSH for application deployment or systems administration tasks.
Application Deployment?
Πϯετʔϧ ઃఆ ىಈ
By SSH
ϗϫοτ
ϗϫοτ Python
ϗϫοτ Python MySQL
ϗϫοτ Python MySQL Nginx
ϗϫοτ Python MySQL Nginx gunicorn
ϗϫοτ Python MySQL Nginx gunicorn Jenkins
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
RabbitMQ
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
RabbitMQ redis
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
RabbitMQ redis node.js
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
RabbitMQ redis node.js Hadoop
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
RabbitMQ redis node.js Hadoop daemontoo
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
RabbitMQ redis node.js Hadoop daemontoo PHP
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
RabbitMQ redis node.js Hadoop daemontoo PHP mongoDB
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
RabbitMQ redis node.js Hadoop daemontoo PHP mongoDB POSTFIX
ϗϫοτ Python MySQL Nginx gunicorn Jenkins mercurial Django Nagios memcached
RabbitMQ redis node.js Hadoop daemontoo PHP mongoDB POSTFIX δϟό
ͨ͘͞Μ
͔͠
To Many Servers
Complex Combination
ͩΔ͍
Only Once?
NO
։ൃڥ
։ൃڥ εςʔδϯά
։ൃڥ εςʔδϯά ຊ൪ڥ
Is That All?
NO
࣍ϑΣʔζͷͨΊͷ Yet Another εςʔδϯά
ʊਓਓਓਓਓਓਓਓʊ ʼɹεςʔδϯά2ɹʻ ʉY^Y^Y^Y^Y^Y^Yʉ
͓٬͞Μ͕ಈ࡞֬ೝ͢Δ Yet Another εςʔδϯά2
ʊਓਓਓਓਓਓਓਓʊ ʼɹεςʔδϯά3ɹʻ ʉY^Y^Y^Y^Y^Y^Yʉ
ޫͷҟ໊Λ࣋ͪ͜Ε·Ͱͷ εςʔδϯά 2 Ͱॲཧ͖͠ Εͳ͔ͬͨେྔσʔλࣗࡏ ʹૢΔߴՁͳΔڀۃͷ৽ڥ
ʊਓਓਓਓਓਓਓਓʊ ʼ εςʔδϯά2_2 ʻ ʉY^Y^Y^Y^Y^Y^Yʉ
αʔόʔނׂΕͨ
ʊਓਓਓਓਓਓਓਓʊ ʼ ɹ ɹ࠶ߏஙɹ ɹ ʻ ʉY^Y^Y^Y^Y^Y^Yʉ
ԿճΔ͜ͱʹͳΔ ※ϑΟΫγϣϯͰ͢
ͩΔ͍
Update
ϝϯςφϯεϞʔυ
ϝϯςφϯεϞʔυ ϒϥϯνΓସ͑
ϝϯςφϯεϞʔυ ϒϥϯνΓସ͑ ϚΠάϨʔγϣϯͱ͔
ϝϯςφϯεϞʔυ ϒϥϯνΓସ͑ ϚΠάϨʔγϣϯͱ͔ ͍Ζ͍Ζ࠶ىಈ
։ൃڥͰ 1ԿճΔ
darui
Operation Mistakes
όον࠶ىಈΕ ϚΠάϨʔγϣϯ͠Ε ϒϥϯν͠Ε
Yes! खॱॻ
None
None
d
ͩΔ͍ͷ͍Ͱ͢Ͷ
Fabric is a Python (2.5 or higher) library and command-line
tool for streamlining the use of SSH for application deployment or systems administration tasks.
Fabric is a Python (2.5 or higher) library and command-line
tool for streamlining the use of SSH for application deployment or systems administration tasks.
streamlining
ޮԽ
DDD
Darui Driven Deployment
ࣗಈԽ͠·͠ΐ͏
ैདྷͷࣗಈԽ
Shell Script
None
None
None
ແɹཧ
None
ख୳ΓͰൺֱ͠·͢
Shell Script Soldier, Stay aSleep ( ˘ω˘) ɹɹ ⊂˶ʗʋ-ɺʊ_ ɹʗ⊂_/ʊʊʊʊ
ʗ
Python Remote control Utils
Python Remote control Utils
Getting Started
$ pip install fabric
$ fab Fatal error: Couldn't find any fabfiles! Remember that
-f can be used to specify fabfile path, and use -h for help. Aborting.
# fabfile.py from fabric.api import local # task def hello():
local('echo hello') # shell command def uname(): local('uname')
$ fab --list Available commands: hello uname
$ fab hello [localhost] local: echo hello hello Done.
$ fab uname [localhost] local: uname Darwin Done.
$ fab hello uname [localhost] local: echo hello hello [localhost]
local: uname Darwin Done.
$ fab start_maintenance update restart
# fabfile.py from fabric.api import run def uname(): run('uname')
$ fab uname -u me -H 10.0.0.1 -i id_rsa [10.0.0.1]
Executing task 'uname' [10.0.0.1] run: uname [10.0.0.1] out: Linux [10.0.0.1] out: Done. Disconnecting from 10.0.0.1... done.
# fabfile.py from fabric.api import sudo def uname(): sudo('uname')
# fabfile.py from fabric.api import env, run env.hosts = ['10.0.0.1']
env.user = 'me' env.key_filename = 'id_rsa' def uname(): run('uname')
# fabfile.py from fabric.api import env, run def dev(): env.hosts
= ['10.0.0.1'] env.user = 'me' env.key_filename = 'id_rsa' def uname(): run('uname')
$ fab dev uname
$ fab production uname
Package
$ tree fabfile fabfile ├── __init__.py ├── django.py └── host.py
# fabfile/__init__.py from . import django from . import host
# fabfile/host.py from fabric.api import env, task @task def dev():
env.hosts = ['10.0.0.1'] env.user = 'me' env.key_filename = 'id_rsa'
# fabfile/django.py from fabric.api import task @task def restart(): pass
$ fab --list Available commands: django.restart host.dev
Roles
# fabfile/host.py from fabric.api import env, task @task def dev():
env.hosts = ['10.0.0.1', '10.0.0.2'] env.roledefs = { 'app': ['10.0.0.1'], 'db': ['10.0.0.2'], }
# fabfile/django.py from fabric.api import roles, task @task @roles('app') def
restart(): pass
Shell Script?
None
ͨͿΜେมͰ͢
Python Remote control Utils
None
$ ssh
[email protected]
-i id_rsa uname run('uname')
Python Remote control Utils
put upload_template append, uncomment prefix
put
from fabric.api import put put( local_path='resources/sushi.txt', remote_path='/var/www/sushi.txt', )
upload_template
from fabric.contrib.files \ import upload_template upload_template( filename='templates/my.cnf', destination='/etc/my.cnf', context={ 'buffer_pool_size':
env.MYSQL_BUFFER_POOL_SIZE, }, )
# templates/my.cnf : # You can set .._buffer_pool_size up to
50 - 80 %% innodb_buffer_pool_size = %(buffer_pool_size)s :
# templates/my.cnf : # You can set .._buffer_pool_size up to
50 - 80 %% innodb_buffer_pool_size = %(buffer_pool_size)s :
from fabric.contrib.files \ import upload_template upload_template( filename='templates/my.cnf', remote_path='/etc/my.cnf', context=context, use_jinja=True,
# jinja2! template_dir='templates', )
# templates/my.cnf : # You can set .._buffer_pool_size up to
50 - 80 % innodb_buffer_pool_size = {{ buffer_pool_size }} :
append
from fabric.contrib.files import append append( filename='/etc/hosts', text='10.0.0.101 dev-server', )
uncomment
from fabric.contrib.files \ import uncomment uncomment( filename='/etc/vsftpd.conf', regex='write_enable=YES', char='#', )
prefix
from fabric.api import run from fabric.context_managers \ import cd run('tar
xzvf Python-2.7.3.tgz') with cd('Python-2.7.3'): run('./configure') run('make') sudo('make install')
from fabric.api import run run('tar xzvf Python-2.7.3.tgz') run('cd Python-2.7.3'): run('./configure')
run('make') sudo('make install')
$ ssh
[email protected]
-i id_rsa tar xzvf Python-2.7.3.tgz $ ssh
[email protected]
-i id_rsa cd Python-2.7.3 $ ssh
[email protected]
-i id_rsa ./configure $ ssh
[email protected]
-i id_rsa make $ ssh
[email protected]
-i id_rsa make install
from fabric.api import run from fabric.context_managers \ import cd run('tar
xzvf Python-2.7.3.tgz') with cd('Python-2.7.3'): run('./configure') run('make') sudo('make install')
$ ssh (...) cd Python-2.7.3 $ ssh (...) cd Python-2.7.3
&& ./configure $ ssh (...) cd Python-2.7.3 && make $ ssh (...) cd Python-2.7.3 && make install
from contextlib import contextmanager from fabric.context_managers \ import prefix @contextmanager
def workon(venv): with prefix('workon ' + venv): yield
with workon('myproj'): run('pip install xaxtsuxo')
·ͱΊ
Deploy ͩΔ͍
Deploy ͩΔ͍ Shell Script ͏ඞཁͳ͠
Deploy ͩΔ͍ Shell Script ͏ඞཁͳ͠ ͦΕ Chef Ͱ | @tk0miya
None