SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
BangPypers April Meetup
            Fabric and App Deployment


                               Deepak Garg
                                     Citrix R&D


Openstack India Meetup by Deepak Garg is licensed under a
Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
Based on a work at github.com.
Contents
●   Fabric ?
●   Example Code
●   App Deployment
●   Fab cmds
●   Fab decorators
●   Fabric for Django App Deployment
●   Why Fabric ?
●   Issues and Alternatives
●   Q&A
Fabric ?

    Automated deployments for lazy people
●   A command fab
●   and a py file    fabfile.py




           Get it: http://fabfile.org
           $ sudo pip install fabric
Example Code
def clean(site=None):
"""Remove .pyc files from a site."""
    from os import path
    if not site:
         site = prompt('Please specify which site(s) to clean (a
comma delimited list): ', validate=r'^[w-.,]+$')
    site_list = site.split(',')
    for item in site_list:
         env.hosts = [ item ]
         path = path.join('/var/www', item)
    sudo("find %s -name '*.pyc' -depth -exec rm {} ;" % path)
 $ fab clean:site=xenstack.org
 [172.16.12.6] sudo: find /var/www/xenstack.com -name
 '*.pyc' -depth -exec rm {} ;
 Password for testuser@192.168.56.3:
 Done.
 Disconnecting from 172.16.12.6... done.
 $
App Deployment



●   Order Server: Provision VMs
●   Setup Server: Create users, groups, Customize config
    files, Install base packages
●   Deploy App: install app specific packages, deploy
    application, start services
App Deployment
●   Deploy on multiple servers – scale out
●   Deploy on multiple environments
●   Make this process AUTOMATED, Simple and
    fast
Sample snippet 1
def provision_vm():
    # Use boto to provision server in AWS
      ..........

def install_baseline():
    local("git add -p && git commit")
      ...........

def install_app_specific_packages():
    ......

def install_db(db_name=None):
     .............                      $ fab testenv_server #Local Env
with-settings(warn_only=True)
def safe_merge():                       $ fab production_server # Prodn Env
     ...........

@roles('production_web')
def production_server():
     provision_vm()
     install_baseline()
     install_app_specific_packages()
     install_db(db_name='mysql')
     configure_production()

@roles('testvm')
def testenv_server():
     install_baseline()
     install_app_specific_packages()
     install_db(db_name='mysql')
     configure_test()
Sample snippet 2
def basic_tests():
    local("./manage.py test my_app")
     ..........

def commit():
    local("git add -p && git commit")
     ...........

def local_deploy():
    basic_tests()
    Commit()                           $ fab local_deploy #Local Env
def grab_code():
    # git fetch
                                       $ fab stage_deploy # Staging Env
    .............
                                       $ fab production_deploy   # Prodn Env
with-settings(warn_only=True)
def safe_merge():
    # git merge
    ...........

@hosts('user1@host1', 'host2', 'user3@host3')
def stage_deploy():
    grab_code()
    basic_tests()
    stage_tests()
    safe_merge()
Why Fabric ?
●   Testing:      Deploy some vms
                  execute some api/cmds
                  collect the results, logs back, analyse etc...
●   Deploy and Scale your App: All the servers should have
    exactly the same configurations and same code
●   Systems Administration
        ●   Clean .pyc files
        ●   Check out new revision from a SCM repository
        ●   Install packages, Apply patches
        ●   Available fabric recipes !!
●   Crux: Interact with Systems !
          Make admin and deployment tasks Pythonic !!
Fab Cmds
●   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.
●   upload_template: Render and upload a template text file to a
    remote host.
●   rsync_project: Synchronize a remote directory with the current
    project directory via rsync
●   append: Append string (or list of strings) text to filename.
Fab Decorators
●   @hosts: Defines on which host or hosts to execute the wrapped
    function.
●   @parallel: Forces the wrapped function to run in parallel
●   @with_settings: Forces fab settings on that task
           e.g:   @with_settings(warn_only=True) -> turn aborts into warnings

●   @runs_once: Prevents wrapped function from running more than
    once.
●   @serial, @roles etc...
                       @hosts('user1@host1', 'host2', 'user2@host3')
                       @runs_once
                       def my_func():
                           pass


                       @roles('web')
                       def my_other_func():
                           pass
Lets look at a sample fabfile .....
Issues and Alternatives

●   Roll back not easy
●   State Management

●   Alternatives:       Puppet, Chef
       ●   Not easy to write
       ●   Need to maintain Master and Slave nodes
THANK YOU !

              Presentation at:
https://github.com/gargdeepak/Presentations

              Happy to help !
        deepakgarg.iitg[at]gmail.com
                  @donji

Más contenido relacionado

La actualidad más candente

A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy Systemadrian_nye
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyNikhil Mungel
 
More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricksbcoca
 
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
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansiblejtyr
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansiblebcoca
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansibleGeorge Shuklin
 
Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Puppet
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Brian Schott
 
V2 and beyond
V2 and beyondV2 and beyond
V2 and beyondjimi-c
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestrationbcoca
 
Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0bcoca
 
Puppet Node Classifiers Talk - Patrick Buckley
Puppet Node Classifiers Talk - Patrick BuckleyPuppet Node Classifiers Talk - Patrick Buckley
Puppet Node Classifiers Talk - Patrick BuckleyChristian Mague
 
Deploying on the cutting edge
Deploying on the cutting edgeDeploying on the cutting edge
Deploying on the cutting edgeericholscher
 
Automated Deployment with Fabric
Automated Deployment with FabricAutomated Deployment with Fabric
Automated Deployment with Fabrictanihito
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHiroshi SHIBATA
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeSoshi Nemoto
 
Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.Workhorse Computing
 

La actualidad más candente (20)

A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
 
Donetsk.py - fabric
Donetsk.py -  fabricDonetsk.py -  fabric
Donetsk.py - fabric
 
More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricks
 
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
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Doing It Wrong with Puppet -
Doing It Wrong with Puppet -
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
 
V2 and beyond
V2 and beyondV2 and beyond
V2 and beyond
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0
 
Puppet Node Classifiers Talk - Patrick Buckley
Puppet Node Classifiers Talk - Patrick BuckleyPuppet Node Classifiers Talk - Patrick Buckley
Puppet Node Classifiers Talk - Patrick Buckley
 
Intro to-puppet
Intro to-puppetIntro to-puppet
Intro to-puppet
 
Deploying on the cutting edge
Deploying on the cutting edgeDeploying on the cutting edge
Deploying on the cutting edge
 
Automated Deployment with Fabric
Automated Deployment with FabricAutomated Deployment with Fabric
Automated Deployment with Fabric
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_code
 
Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.
 

Destacado

Corp Agency Presentations
Corp Agency PresentationsCorp Agency Presentations
Corp Agency Presentationsavasiliev
 
Taking it to the streets: Investigating mobile and web UX through field studies
Taking it to the streets: Investigating mobile and web UX through field studiesTaking it to the streets: Investigating mobile and web UX through field studies
Taking it to the streets: Investigating mobile and web UX through field studies Emma Rose, PhD
 
Factors to Actors: Implications of Posthumanism for Social Justice Work
Factors to Actors:Implications of Posthumanism for Social Justice WorkFactors to Actors:Implications of Posthumanism for Social Justice Work
Factors to Actors: Implications of Posthumanism for Social Justice WorkEmma Rose, PhD
 
Making Government User-Centered: Managing UCD projects to promote change
Making Government User-Centered: Managing UCD projects to promote changeMaking Government User-Centered: Managing UCD projects to promote change
Making Government User-Centered: Managing UCD projects to promote changeEmma Rose, PhD
 
BM intranet innovation case study at The Intranet Global Forum 201
BM intranet innovation case study at The Intranet Global Forum 201BM intranet innovation case study at The Intranet Global Forum 201
BM intranet innovation case study at The Intranet Global Forum 201Prescient Digital Media
 
Animales De La Granjapower Point
Animales De La Granjapower PointAnimales De La Granjapower Point
Animales De La Granjapower Pointguest94a7ef
 

Destacado (6)

Corp Agency Presentations
Corp Agency PresentationsCorp Agency Presentations
Corp Agency Presentations
 
Taking it to the streets: Investigating mobile and web UX through field studies
Taking it to the streets: Investigating mobile and web UX through field studiesTaking it to the streets: Investigating mobile and web UX through field studies
Taking it to the streets: Investigating mobile and web UX through field studies
 
Factors to Actors: Implications of Posthumanism for Social Justice Work
Factors to Actors:Implications of Posthumanism for Social Justice WorkFactors to Actors:Implications of Posthumanism for Social Justice Work
Factors to Actors: Implications of Posthumanism for Social Justice Work
 
Making Government User-Centered: Managing UCD projects to promote change
Making Government User-Centered: Managing UCD projects to promote changeMaking Government User-Centered: Managing UCD projects to promote change
Making Government User-Centered: Managing UCD projects to promote change
 
BM intranet innovation case study at The Intranet Global Forum 201
BM intranet innovation case study at The Intranet Global Forum 201BM intranet innovation case study at The Intranet Global Forum 201
BM intranet innovation case study at The Intranet Global Forum 201
 
Animales De La Granjapower Point
Animales De La Granjapower PointAnimales De La Granjapower Point
Animales De La Granjapower Point
 

Similar a Bangpypers april-meetup-2012

Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabricandymccurdy
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient waySylvain Rayé
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby TeamArto Artnik
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabricandymccurdy
 
Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9Corey Oordt
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppSmartLogic
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment TacticsIan Barber
 
把鐵路開進視窗裡
把鐵路開進視窗裡把鐵路開進視窗裡
把鐵路開進視窗裡Wei Jen Lu
 
Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in RustInfluxData
 
Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerGaryCoady
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerOrtus Solutions, Corp
 
Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Ortus Solutions, Corp
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with CapistranoRamazan K
 
Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Cosimo Streppone
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvarsSam Marley-Jarrett
 

Similar a Bangpypers april-meetup-2012 (20)

Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabric
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
 
Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment Tactics
 
把鐵路開進視窗裡
把鐵路開進視窗裡把鐵路開進視窗裡
把鐵路開進視窗裡
 
Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in Rust
 
Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packager
 
Belvedere
BelvedereBelvedere
Belvedere
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and docker
 
Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 
Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvars
 
Intro django
Intro djangoIntro django
Intro django
 

Más de Deepak Garg

Foundation launch
Foundation launchFoundation launch
Foundation launchDeepak Garg
 
Developing with-devstack
Developing with-devstackDeveloping with-devstack
Developing with-devstackDeepak Garg
 
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-pythonDeepak Garg
 
NetScaler and advanced networking in cloudstack
NetScaler and advanced networking in cloudstackNetScaler and advanced networking in cloudstack
NetScaler and advanced networking in cloudstackDeepak Garg
 
Openstack India May Meetup
Openstack India May MeetupOpenstack India May Meetup
Openstack India May MeetupDeepak Garg
 
Social coding and Participating in Open Source Communitites
Social coding and Participating in Open Source CommunititesSocial coding and Participating in Open Source Communitites
Social coding and Participating in Open Source CommunititesDeepak Garg
 

Más de Deepak Garg (6)

Foundation launch
Foundation launchFoundation launch
Foundation launch
 
Developing with-devstack
Developing with-devstackDeveloping with-devstack
Developing with-devstack
 
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-python
 
NetScaler and advanced networking in cloudstack
NetScaler and advanced networking in cloudstackNetScaler and advanced networking in cloudstack
NetScaler and advanced networking in cloudstack
 
Openstack India May Meetup
Openstack India May MeetupOpenstack India May Meetup
Openstack India May Meetup
 
Social coding and Participating in Open Source Communitites
Social coding and Participating in Open Source CommunititesSocial coding and Participating in Open Source Communitites
Social coding and Participating in Open Source Communitites
 

Último

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 

Último (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

Bangpypers april-meetup-2012

  • 1. BangPypers April Meetup Fabric and App Deployment Deepak Garg Citrix R&D Openstack India Meetup by Deepak Garg is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License Based on a work at github.com.
  • 2. Contents ● Fabric ? ● Example Code ● App Deployment ● Fab cmds ● Fab decorators ● Fabric for Django App Deployment ● Why Fabric ? ● Issues and Alternatives ● Q&A
  • 3. Fabric ? Automated deployments for lazy people ● A command fab ● and a py file fabfile.py Get it: http://fabfile.org $ sudo pip install fabric
  • 4. Example Code def clean(site=None): """Remove .pyc files from a site.""" from os import path if not site: site = prompt('Please specify which site(s) to clean (a comma delimited list): ', validate=r'^[w-.,]+$') site_list = site.split(',') for item in site_list: env.hosts = [ item ] path = path.join('/var/www', item) sudo("find %s -name '*.pyc' -depth -exec rm {} ;" % path) $ fab clean:site=xenstack.org [172.16.12.6] sudo: find /var/www/xenstack.com -name '*.pyc' -depth -exec rm {} ; Password for testuser@192.168.56.3: Done. Disconnecting from 172.16.12.6... done. $
  • 5. App Deployment ● Order Server: Provision VMs ● Setup Server: Create users, groups, Customize config files, Install base packages ● Deploy App: install app specific packages, deploy application, start services
  • 6. App Deployment ● Deploy on multiple servers – scale out ● Deploy on multiple environments ● Make this process AUTOMATED, Simple and fast
  • 7. Sample snippet 1 def provision_vm(): # Use boto to provision server in AWS .......... def install_baseline(): local("git add -p && git commit") ........... def install_app_specific_packages(): ...... def install_db(db_name=None): ............. $ fab testenv_server #Local Env with-settings(warn_only=True) def safe_merge(): $ fab production_server # Prodn Env ........... @roles('production_web') def production_server(): provision_vm() install_baseline() install_app_specific_packages() install_db(db_name='mysql') configure_production() @roles('testvm') def testenv_server(): install_baseline() install_app_specific_packages() install_db(db_name='mysql') configure_test()
  • 8. Sample snippet 2 def basic_tests(): local("./manage.py test my_app") .......... def commit(): local("git add -p && git commit") ........... def local_deploy(): basic_tests() Commit() $ fab local_deploy #Local Env def grab_code(): # git fetch $ fab stage_deploy # Staging Env ............. $ fab production_deploy # Prodn Env with-settings(warn_only=True) def safe_merge(): # git merge ........... @hosts('user1@host1', 'host2', 'user3@host3') def stage_deploy(): grab_code() basic_tests() stage_tests() safe_merge()
  • 9. Why Fabric ? ● Testing: Deploy some vms execute some api/cmds collect the results, logs back, analyse etc... ● Deploy and Scale your App: All the servers should have exactly the same configurations and same code ● Systems Administration ● Clean .pyc files ● Check out new revision from a SCM repository ● Install packages, Apply patches ● Available fabric recipes !! ● Crux: Interact with Systems ! Make admin and deployment tasks Pythonic !!
  • 10. Fab Cmds ● 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. ● upload_template: Render and upload a template text file to a remote host. ● rsync_project: Synchronize a remote directory with the current project directory via rsync ● append: Append string (or list of strings) text to filename.
  • 11. Fab Decorators ● @hosts: Defines on which host or hosts to execute the wrapped function. ● @parallel: Forces the wrapped function to run in parallel ● @with_settings: Forces fab settings on that task e.g: @with_settings(warn_only=True) -> turn aborts into warnings ● @runs_once: Prevents wrapped function from running more than once. ● @serial, @roles etc... @hosts('user1@host1', 'host2', 'user2@host3') @runs_once def my_func(): pass @roles('web') def my_other_func(): pass
  • 12. Lets look at a sample fabfile .....
  • 13. Issues and Alternatives ● Roll back not easy ● State Management ● Alternatives: Puppet, Chef ● Not easy to write ● Need to maintain Master and Slave nodes
  • 14. THANK YOU ! Presentation at: https://github.com/gargdeepak/Presentations Happy to help ! deepakgarg.iitg[at]gmail.com @donji