SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
Fabric

                            Lo   (Eric Lo)
                          http://lxneng.com
                           lxneng@gmail.com
                           twitter: @lxneng

Sunday, August 29, 2010
About
                    Fabric is a Python library and command-
                    line tool for streamlining the use of SSH
                    for application deployment or systems
                    administration tasks

                    capistrano in python
                                  单   学                 经
                                      统
Sunday, August 29, 2010
Fabric is two things

                    Api for streamlining the use of ssh for
                    app development or system management
                    tasks

                    Command-line interface for calling
                    python methods


Sunday, August 29, 2010
Install


                    sudo easy_install fabric




Sunday, August 29, 2010
Example
                  vim fabfile.py

                  #!/usr/bin/env python
                  from fabric.api import env, run

                  env.hosts = ['xxx.com']
                  env.user = 'eric'
                  def du():
                  	 run("du -sh /home/eric")

                  Erics-MacBook:~ eric$ fab du
                  [xxx.com] run: du -sh /home/eric
                  [xxx.com] out: 942M	
                                     /home/eric

                  Done.
                  Disconnecting from xxx.com... done.

Sunday, August 29, 2010
Deploy my rails app
                  Erics-MacBook:~ eric$ cd NetBeans_Workspace/lxneng
                  Erics-MacBook:lxneng eric$ touch fabfile.py
                  Erics-MacBook:lxneng eric$ vim fabfile.py
                  #!/usr/bin/env python
                  # encoding: utf-8

                  from fabric.api import env, run, cd, local, put

                  env.hosts = ['192.168.1.5']
                  env.user = 'eric'
                  DEPLOY_PATH = '/var/www/'
                  APP_NAME = 'lxneng'
                  APP_PATH = '%s%s'%(DEPLOY_PATH, APP_NAME)
                  DATABASE_CONF_PATH = '/srv/conf/database.yml'




Sunday, August 29, 2010
pack & upload

                  def pack_code():
                      local('tar czf /tmp/%s.tgz .'%APP_NAME)

                  def upload_code():
                      put('/tmp/%s.tgz'%APP_NAME, '/tmp/')
                      with cd(APP_PATH):
                          run('tar xzf /tmp/%s.tgz'%APP_NAME)




Sunday, August 29, 2010
config & restart
                  def conf():
                      run("cp %s %s/config/"%(DATABASE_CONF_PATH, APP_PATH))
                      run("ln -nfs /srv/photos %s/public/photos"%APP_PATH)
                      with cd(APP_PATH):
                          run("rake db:migrate RAILS_ENV=production")

                  def restart():
                      run("touch %s/tmp/restart.txt"%APP_PATH)




Sunday, August 29, 2010
Deploy
                  def deploy():
                      pack_code()
                      upload_code()
                      conf()
                      restart()




Sunday, August 29, 2010
define roles
                  env.roledefs = {
                      ‘testing’: [‘192.168.1.5’],
                      ‘staging’: [‘.........’],
                      ‘production’: [‘......’, ‘........’],
                      ‘database’: [‘........’]
                  }

                  def testing():
                      env.hosts = env.roledefs[‘testing’]
                      env.user = ‘testuser’
                      # ...

                  def deploy():
                    # deploy code here



                  fab testing deploy
Sunday, August 29, 2010
Fabric Commands
 • require: Make sure that certain environment variables
 are available.
 • prompt: Display a prompt to the user and store the input
 in the given variable. Validation is optional.
  • put: Upload files to the remote host(s).
 • get: Download a file from a remote host.
 • run: Run a shell command on the remote host(s).
 • sudo: Run a root privileged shell command command on
 the remote host(s).
 • local: Run a command locally.
Sunday, August 29, 2010
Fabric Contrib Commands
   • rsync_project: Synchronize a remote directory with the current project
   directory via rsync.
   • upload_project: Upload the current project to a remote system, tar-
   gzipping during the move.
   • exists: Return True if given path exists.
   • first: Given one or more file paths, returns first one found, or None.
   • upload_template: Render and upload a template text file to a remote host.
   • sed: Run a search-and-replace on filename with given regex patterns.
   • comment/uncomment: Attempt to (un)comment out all lines in filename
   matching regex.
   • contains: Return True if filename contains text.
   • append: Append string (or list of strings) text to filename.
   • confirm: Ask user a yes/no question and return their response as True /
   False.
Sunday, August 29, 2010
Fabric Decorators
    • hosts: Defines on which host or hosts to execute the wrapped
    function.
    • roles: Defines a list of role names, used to look up host lists.
    • runs_once: Prevents wrapped function from running more than
    once.

    @hosts('user1@host1', 'host2', 'user2@host3')
    @runs_once
    def my_func():
      pass

    @roles('web')
    def my_other_func():
      pass
Sunday, August 29, 2010
app
                                                          fabfile
                          fabfile   http://gist.github.com/472566




Sunday, August 29, 2010
Reference

                    Fabric documentation http://fabfile.org/

                    Pythonic Deployment with Fabric 0.9

                    Fabric: A Capistrano Alternative



Sunday, August 29, 2010
Q&A


      Thank You


Sunday, August 29, 2010

Weitere ähnliche Inhalte

Was ist angesagt?

Fun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesFun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesabadger1999
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyAndré Rømcke
 
Launching containers with fleet
Launching containers with fleetLaunching containers with fleet
Launching containers with fleet충섭 김
 
Controlling multiple VMs with the power of Python
Controlling multiple VMs with the power of PythonControlling multiple VMs with the power of Python
Controlling multiple VMs with the power of PythonYurii Vasylenko
 
Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)Žilvinas Kuusas
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014D
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 applicationRoman Rodomansky
 
Instruction: dev environment
Instruction: dev environmentInstruction: dev environment
Instruction: dev environmentSoshi Nemoto
 
Docker - A Ruby Introduction
Docker - A Ruby IntroductionDocker - A Ruby Introduction
Docker - A Ruby IntroductionTyler Johnston
 
Deploy your Python code on Azure Functions
Deploy your Python code on Azure FunctionsDeploy your Python code on Azure Functions
Deploy your Python code on Azure FunctionsDhilipsiva DS
 
Ansible Oxford - Cows & Containers
Ansible Oxford - Cows & ContainersAnsible Oxford - Cows & Containers
Ansible Oxford - Cows & Containersjonatanblue
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to AnsibleDan Vaida
 
Microarmy - by J2 Labs
Microarmy - by J2 LabsMicroarmy - by J2 Labs
Microarmy - by J2 LabsJames Dennis
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationSuresh Kumar
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsyncHazel Smith
 
Puppet for SysAdmins
Puppet for SysAdminsPuppet for SysAdmins
Puppet for SysAdminsPuppet
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
Provisioning & Deploying with Docker
Provisioning & Deploying with DockerProvisioning & Deploying with Docker
Provisioning & Deploying with DockerErica Windisch
 

Was ist angesagt? (20)

Fun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesFun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker images
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
 
Launching containers with fleet
Launching containers with fleetLaunching containers with fleet
Launching containers with fleet
 
Controlling multiple VMs with the power of Python
Controlling multiple VMs with the power of PythonControlling multiple VMs with the power of Python
Controlling multiple VMs with the power of Python
 
Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
 
Instruction: dev environment
Instruction: dev environmentInstruction: dev environment
Instruction: dev environment
 
Docker - A Ruby Introduction
Docker - A Ruby IntroductionDocker - A Ruby Introduction
Docker - A Ruby Introduction
 
Deploy your Python code on Azure Functions
Deploy your Python code on Azure FunctionsDeploy your Python code on Azure Functions
Deploy your Python code on Azure Functions
 
Ansible Oxford - Cows & Containers
Ansible Oxford - Cows & ContainersAnsible Oxford - Cows & Containers
Ansible Oxford - Cows & Containers
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to Ansible
 
Microarmy - by J2 Labs
Microarmy - by J2 LabsMicroarmy - by J2 Labs
Microarmy - by J2 Labs
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsync
 
Puppet for SysAdmins
Puppet for SysAdminsPuppet for SysAdmins
Puppet for SysAdmins
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
Provisioning & Deploying with Docker
Provisioning & Deploying with DockerProvisioning & Deploying with Docker
Provisioning & Deploying with Docker
 

Ähnlich wie Fabric-让部署变得简单

Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with PuppetAlessandro Franceschi
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administrationvceder
 
Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9Corey Oordt
 
Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linuxQIANG XU
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Deepak Garg
 
Python and Machine Learning
Python and Machine LearningPython and Machine Learning
Python and Machine Learningtrygub
 
20100730 phpstudy
20100730 phpstudy20100730 phpstudy
20100730 phpstudyYusuke Ando
 
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureHabeeb Rahman
 
Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Henry Schreiner
 
Do you know all of Puppet?
Do you know all of Puppet?Do you know all of Puppet?
Do you know all of Puppet?Julien Pivotto
 
Jenkins pipeline -- Gentle Introduction
Jenkins pipeline -- Gentle IntroductionJenkins pipeline -- Gentle Introduction
Jenkins pipeline -- Gentle IntroductionRamanathan Muthaiah
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Soshi Nemoto
 
Using Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSXUsing Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSXPuppet
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationJacobMenke1
 

Ähnlich wie Fabric-让部署变得简单 (20)

Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
Fabric for fun_and_profit
Fabric for fun_and_profitFabric for fun_and_profit
Fabric for fun_and_profit
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administration
 
Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9
 
Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013
 
Python1
Python1Python1
Python1
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
 
Donetsk.py - fabric
Donetsk.py -  fabricDonetsk.py -  fabric
Donetsk.py - fabric
 
Python and Machine Learning
Python and Machine LearningPython and Machine Learning
Python and Machine Learning
 
20100730 phpstudy
20100730 phpstudy20100730 phpstudy
20100730 phpstudy
 
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
 
Puppi. Puppet strings to the shell
Puppi. Puppet strings to the shellPuppi. Puppet strings to the shell
Puppi. Puppet strings to the shell
 
Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023
 
Do you know all of Puppet?
Do you know all of Puppet?Do you know all of Puppet?
Do you know all of Puppet?
 
Jenkins pipeline -- Gentle Introduction
Jenkins pipeline -- Gentle IntroductionJenkins pipeline -- Gentle Introduction
Jenkins pipeline -- Gentle Introduction
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)
 
Using Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSXUsing Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSX
 
Fabric Fast & Furious edition
Fabric Fast & Furious editionFabric Fast & Furious edition
Fabric Fast & Furious edition
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 

Kürzlich hochgeladen

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Kürzlich hochgeladen (20)

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Fabric-让部署变得简单

  • 1. Fabric Lo (Eric Lo) http://lxneng.com lxneng@gmail.com twitter: @lxneng Sunday, August 29, 2010
  • 2. About Fabric is a Python library and command- line tool for streamlining the use of SSH for application deployment or systems administration tasks capistrano in python 单 学 经 统 Sunday, August 29, 2010
  • 3. Fabric is two things Api for streamlining the use of ssh for app development or system management tasks Command-line interface for calling python methods Sunday, August 29, 2010
  • 4. Install sudo easy_install fabric Sunday, August 29, 2010
  • 5. Example vim fabfile.py #!/usr/bin/env python from fabric.api import env, run env.hosts = ['xxx.com'] env.user = 'eric' def du(): run("du -sh /home/eric") Erics-MacBook:~ eric$ fab du [xxx.com] run: du -sh /home/eric [xxx.com] out: 942M /home/eric Done. Disconnecting from xxx.com... done. Sunday, August 29, 2010
  • 6. Deploy my rails app Erics-MacBook:~ eric$ cd NetBeans_Workspace/lxneng Erics-MacBook:lxneng eric$ touch fabfile.py Erics-MacBook:lxneng eric$ vim fabfile.py #!/usr/bin/env python # encoding: utf-8 from fabric.api import env, run, cd, local, put env.hosts = ['192.168.1.5'] env.user = 'eric' DEPLOY_PATH = '/var/www/' APP_NAME = 'lxneng' APP_PATH = '%s%s'%(DEPLOY_PATH, APP_NAME) DATABASE_CONF_PATH = '/srv/conf/database.yml' Sunday, August 29, 2010
  • 7. pack & upload def pack_code():     local('tar czf /tmp/%s.tgz .'%APP_NAME) def upload_code():     put('/tmp/%s.tgz'%APP_NAME, '/tmp/')     with cd(APP_PATH):         run('tar xzf /tmp/%s.tgz'%APP_NAME) Sunday, August 29, 2010
  • 8. config & restart def conf():     run("cp %s %s/config/"%(DATABASE_CONF_PATH, APP_PATH))     run("ln -nfs /srv/photos %s/public/photos"%APP_PATH)     with cd(APP_PATH):         run("rake db:migrate RAILS_ENV=production") def restart():     run("touch %s/tmp/restart.txt"%APP_PATH) Sunday, August 29, 2010
  • 9. Deploy def deploy():     pack_code()     upload_code()     conf()     restart() Sunday, August 29, 2010
  • 10. define roles env.roledefs = { ‘testing’: [‘192.168.1.5’], ‘staging’: [‘.........’], ‘production’: [‘......’, ‘........’], ‘database’: [‘........’] } def testing(): env.hosts = env.roledefs[‘testing’] env.user = ‘testuser’ # ... def deploy(): # deploy code here fab testing deploy Sunday, August 29, 2010
  • 11. Fabric Commands • require: Make sure that certain environment variables are available. • prompt: Display a prompt to the user and store the input in the given variable. Validation is optional. • put: Upload files to the remote host(s). • get: Download a file from a remote host. • run: Run a shell command on the remote host(s). • sudo: Run a root privileged shell command command on the remote host(s). • local: Run a command locally. Sunday, August 29, 2010
  • 12. Fabric Contrib Commands • rsync_project: Synchronize a remote directory with the current project directory via rsync. • upload_project: Upload the current project to a remote system, tar- gzipping during the move. • exists: Return True if given path exists. • first: Given one or more file paths, returns first one found, or None. • upload_template: Render and upload a template text file to a remote host. • sed: Run a search-and-replace on filename with given regex patterns. • comment/uncomment: Attempt to (un)comment out all lines in filename matching regex. • contains: Return True if filename contains text. • append: Append string (or list of strings) text to filename. • confirm: Ask user a yes/no question and return their response as True / False. Sunday, August 29, 2010
  • 13. Fabric Decorators • hosts: Defines on which host or hosts to execute the wrapped function. • roles: Defines a list of role names, used to look up host lists. • runs_once: Prevents wrapped function from running more than once. @hosts('user1@host1', 'host2', 'user2@host3') @runs_once def my_func(): pass @roles('web') def my_other_func(): pass Sunday, August 29, 2010
  • 14. app fabfile fabfile http://gist.github.com/472566 Sunday, August 29, 2010
  • 15. Reference Fabric documentation http://fabfile.org/ Pythonic Deployment with Fabric 0.9 Fabric: A Capistrano Alternative Sunday, August 29, 2010
  • 16. Q&A Thank You Sunday, August 29, 2010