SlideShare a Scribd company logo
初學 fabric
 qrtt1 2012.10.15
fabric 與我


我是個快樂的小 RD,
 直到我膝蓋中了一          。


  I am the king of the world
            server administrator.
Server Admin

管 server 都在玩些什麼

 deploy the java web application

 maintain various settings on the server

 be a watchdog for many purposes
Shell scripts


fabric 能幫你做的,用 shell scripts 也行

傳說 server admin 都要會寫 shell script
But,
qrtt One 的 shell script 程度太差...


         #!/bin/sh
         python run.py
fabric

http://docs.fabfile.org

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.
using fabric as cmd

fab -H s1,s2 -- uptime

fab -P -H s1,s2 -- uptime
fab -w -P -H s1,s2 -- uptime

fab ${OPTS} -- ${COMMANDS}
using fabric api

有     些 function 可以用!?
看 code 比看文件更直覺 :D

fabric/api.py
    https://github.com/fabric/fabric/blob/master/
    fabric/api.py
Talk about fabric
thinking in fabric
do something                      which context
  local script                         who
 remote script                        where




                 how to execute
                     parallel
                    sequence
thinking in fabric
do something                           which context
                 該做的事就如同原本寫	 shell	 script	 那般。
                 改用	 fabric	 api	 寫,也許只是多了一點	 python	 而有親切感
  local script                              who
                 單純評論它,只	 remote	 script	 稍為便利罷了。
 remote script                            where



           from fabric.api import run, task
                 how to execute
           @task
                      parallel
           def uptime():
                     sequence
              run("uptime")
thinking in fabric
利用	 context	 概念,
  do something
將『指令』的『執行者』、『執行位置』抽離,                   which context
去掉了『雜念』的	 task	 更容易被	 reuse,
     local script                            who
更有機會成為任意組合的『樂高積木』
   remote script                            where
from fabric.api import run, task, env

env.user = ‘qrtt1’
env.hosts = [‘server1’, ‘server2’]
                     how to execute
                          parallel
@task
def uptime():            sequence
   run("uptime")
thinking in fabric
    from fabric.api import run, task, env, roles, parallel

do something
   env.user = ‘deployer’                             which context
  local script = {'web':['s1', 's2', 's3'], 'db':['s4']}
    env.roledefs                                            who
 remote script
    @task                                                  where
    @roles(‘web’, ‘db’)
    @parallel
    def uptime():
       run("uptime")


                         how to execute
                                parallel
                               sequence
demo

{deploy by fabric}
 https://github.com/qrtt1/pyhug_fabric_talk

      fab -H s1,s2,s3 -P build_web restart_web
Q&A

More Related Content

KEY
Capistrano, Puppet, and Chef
PPTX
Evented Ruby VS Node.js
PDF
Virtualize and automate your development environment for fun and profit
PDF
VPC by Default時代のアクセス制御
PPTX
Return on Ignite 2019: Azure, .NET, A.I. & Data
PPTX
Enable IPv6 on Route53 AWS ELB, docker and node App
ODP
Fabric: A Capistrano Alternative
PDF
Optcarrot: A Pure-Ruby NES Emulator
Capistrano, Puppet, and Chef
Evented Ruby VS Node.js
Virtualize and automate your development environment for fun and profit
VPC by Default時代のアクセス制御
Return on Ignite 2019: Azure, .NET, A.I. & Data
Enable IPv6 on Route53 AWS ELB, docker and node App
Fabric: A Capistrano Alternative
Optcarrot: A Pure-Ruby NES Emulator

What's hot (20)

PDF
Fabric-让部署变得简单
PPTX
Automate_LSF_ppt_final
PDF
Python Performance Profiling: The Guts And The Glory
PDF
Running kubernetes
PPTX
What makes AWS invincible? from JAWS Days 2014
PDF
Fiber in the 10th year
PDF
Applying the paradigms of core.async in Clojure and ClojureScript
PDF
Launching containers with fleet
PDF
Fabric - a server management tool from Instagram
PDF
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
PPTX
HOW TO CREATE AWESOME POLYGLOT APPLICATIONS USING GRAALVM
PDF
Docker with BGP - OpenDNS
PDF
Asynchronous Python A Gentle Introduction
PPT
Take Flight - Using Fly with the Play Framework
PDF
CoreOS : 설치부터 컨테이너 배포까지
PDF
Reactive Programming by UniRx for Asynchronous & Event Processing
KEY
料理を楽しくする画像配信システム
PPTX
NIS server installation
PDF
Puppet Camp Dallas 2014: Using Puppet in Hybrid Cloud Deployments
PDF
Highly Available Docker Networking With BGP
Fabric-让部署变得简单
Automate_LSF_ppt_final
Python Performance Profiling: The Guts And The Glory
Running kubernetes
What makes AWS invincible? from JAWS Days 2014
Fiber in the 10th year
Applying the paradigms of core.async in Clojure and ClojureScript
Launching containers with fleet
Fabric - a server management tool from Instagram
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
HOW TO CREATE AWESOME POLYGLOT APPLICATIONS USING GRAALVM
Docker with BGP - OpenDNS
Asynchronous Python A Gentle Introduction
Take Flight - Using Fly with the Play Framework
CoreOS : 설치부터 컨테이너 배포까지
Reactive Programming by UniRx for Asynchronous & Event Processing
料理を楽しくする画像配信システム
NIS server installation
Puppet Camp Dallas 2014: Using Puppet in Hybrid Cloud Deployments
Highly Available Docker Networking With BGP
Ad

Viewers also liked (13)

PDF
JCConf2015: groovy to gradle
ODP
Unit Testing
PPT
OSGi Small Lab
ODP
Android NDK (JUG@TW 2011, Oct.)
PPT
Osgi Intro
PDF
Linking error
PDF
Java Build Tool course in 2011
PDF
using Queue Server for batch processing
PDF
idea: talk about the Active Cache
KEY
Java web programming
PDF
JCConf2016 Jenkins Pipeline
PDF
老舊web上雲端
PDF
The journey of Moving from AWS ELK to GCP Data Pipeline
JCConf2015: groovy to gradle
Unit Testing
OSGi Small Lab
Android NDK (JUG@TW 2011, Oct.)
Osgi Intro
Linking error
Java Build Tool course in 2011
using Queue Server for batch processing
idea: talk about the Active Cache
Java web programming
JCConf2016 Jenkins Pipeline
老舊web上雲端
The journey of Moving from AWS ELK to GCP Data Pipeline
Ad

Similar to Talk about fabric (11)

PDF
Pythonic Deployment with Fabric 0.9
KEY
Donetsk.py - fabric
PDF
Fabric workshop(1) - (MOSG)
ODP
Fabric Fast & Furious edition
PDF
Bangpypers april-meetup-2012
PPT
Fabric
PPT
Fabric
PPTX
Automation in Cloud
PDF
Fabric for fun_and_profit
PDF
平行化你的工作 part1
PDF
Automation - fabric, django and more
Pythonic Deployment with Fabric 0.9
Donetsk.py - fabric
Fabric workshop(1) - (MOSG)
Fabric Fast & Furious edition
Bangpypers april-meetup-2012
Fabric
Fabric
Automation in Cloud
Fabric for fun_and_profit
平行化你的工作 part1
Automation - fabric, django and more

Recently uploaded (20)

PDF
The Blogs_ Humanity Beyond All Differences _ Andy Blumenthal _ The Times of I...
PPTX
THEORIES-PSYCH-3.pptx theory of Abraham Maslow
PDF
technical writing on emotional quotient ppt
PDF
SEX-GENDER-AND-SEXUALITY-LESSON-1-M (2).pdf
PDF
Dominate Her Mind – Make Women Chase, Lust, & Submit
PPTX
A portfolio Template for Interior Designer
PDF
OneRead_20250728_1807.pdfbdjsajaajjajajsjsj
PPTX
Emotional Intelligence- Importance and Applicability
PPTX
Unlocking Success Through the Relentless Power of Grit
PPTX
UNIVERSAL HUMAN VALUES for NEP student .pptx
PPTX
Hazards-of-Uncleanliness-Protecting-Your-Health.pptx
PDF
Psychology and Work Today 10th Edition by Duane Schultz Test Bank.pdf
DOCX
Boost your energy levels and Shred Weight
DOCX
Paulo Tuynmam: Nine Timeless Anchors of Authentic Leadership
PDF
Lesson 4 Education for Better Work. Evaluate your training options.
PPTX
Commmunication in Todays world- Principles and Barriers
PDF
PLAYLISTS DEI MEGAMIX E DEEJAY PARADE DAL 1991 AL 2004 SU RADIO DEEJAY
PDF
Why is mindset more important than motivation.pdf
PDF
Quiet Wins: Why the Silent Fish Survives.pdf
PDF
Anxiety Awareness Journal One Week Preview
The Blogs_ Humanity Beyond All Differences _ Andy Blumenthal _ The Times of I...
THEORIES-PSYCH-3.pptx theory of Abraham Maslow
technical writing on emotional quotient ppt
SEX-GENDER-AND-SEXUALITY-LESSON-1-M (2).pdf
Dominate Her Mind – Make Women Chase, Lust, & Submit
A portfolio Template for Interior Designer
OneRead_20250728_1807.pdfbdjsajaajjajajsjsj
Emotional Intelligence- Importance and Applicability
Unlocking Success Through the Relentless Power of Grit
UNIVERSAL HUMAN VALUES for NEP student .pptx
Hazards-of-Uncleanliness-Protecting-Your-Health.pptx
Psychology and Work Today 10th Edition by Duane Schultz Test Bank.pdf
Boost your energy levels and Shred Weight
Paulo Tuynmam: Nine Timeless Anchors of Authentic Leadership
Lesson 4 Education for Better Work. Evaluate your training options.
Commmunication in Todays world- Principles and Barriers
PLAYLISTS DEI MEGAMIX E DEEJAY PARADE DAL 1991 AL 2004 SU RADIO DEEJAY
Why is mindset more important than motivation.pdf
Quiet Wins: Why the Silent Fish Survives.pdf
Anxiety Awareness Journal One Week Preview

Talk about fabric

  • 1. 初學 fabric qrtt1 2012.10.15
  • 2. fabric 與我 我是個快樂的小 RD, 直到我膝蓋中了一 。 I am the king of the world server administrator.
  • 3. Server Admin 管 server 都在玩些什麼 deploy the java web application maintain various settings on the server be a watchdog for many purposes
  • 4. Shell scripts fabric 能幫你做的,用 shell scripts 也行 傳說 server admin 都要會寫 shell script
  • 5. But, qrtt One 的 shell script 程度太差... #!/bin/sh python run.py
  • 6. fabric http://docs.fabfile.org 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.
  • 7. using fabric as cmd fab -H s1,s2 -- uptime fab -P -H s1,s2 -- uptime fab -w -P -H s1,s2 -- uptime fab ${OPTS} -- ${COMMANDS}
  • 8. using fabric api 有 些 function 可以用!? 看 code 比看文件更直覺 :D fabric/api.py https://github.com/fabric/fabric/blob/master/ fabric/api.py
  • 10. thinking in fabric do something which context local script who remote script where how to execute parallel sequence
  • 11. thinking in fabric do something which context 該做的事就如同原本寫 shell script 那般。 改用 fabric api 寫,也許只是多了一點 python 而有親切感 local script who 單純評論它,只 remote script 稍為便利罷了。 remote script where from fabric.api import run, task how to execute @task parallel def uptime(): sequence run("uptime")
  • 12. thinking in fabric 利用 context 概念, do something 將『指令』的『執行者』、『執行位置』抽離, which context 去掉了『雜念』的 task 更容易被 reuse, local script who 更有機會成為任意組合的『樂高積木』 remote script where from fabric.api import run, task, env env.user = ‘qrtt1’ env.hosts = [‘server1’, ‘server2’] how to execute parallel @task def uptime(): sequence run("uptime")
  • 13. thinking in fabric from fabric.api import run, task, env, roles, parallel do something env.user = ‘deployer’ which context local script = {'web':['s1', 's2', 's3'], 'db':['s4']} env.roledefs who remote script @task where @roles(‘web’, ‘db’) @parallel def uptime(): run("uptime") how to execute parallel sequence
  • 14. demo {deploy by fabric} https://github.com/qrtt1/pyhug_fabric_talk fab -H s1,s2,s3 -P build_web restart_web
  • 15. Q&A

Editor's Notes