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
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
190
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
快速入門可觀測性
blueswen
0
370
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.7k
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
450
testcontainers のススメ
sgash708
1
120
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
220
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
500
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
95
5.2k
Done Done
chrislema
181
16k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
The Language of Interfaces
destraynor
154
24k
Become a Pro
speakerdeck
PRO
26
5k
What's in a price? How to price your products and services
michaelherold
243
12k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Producing Creativity
orderedlist
PRO
341
39k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Designing for humans not robots
tammielis
250
25k
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