SlideShare uma empresa Scribd logo
1 de 3
from fabric.api import *
from os import path

env.roledefs = {
    'web': ['172.16.12.1', '172.16.12.2', '172.16.12.3',],
    'media': ['172.16.12.4',],
    'staging': ['172.16.12.5',],
    'testing': ['192.168.56.3',],
    'database': ['172.16.12.7', '172.16.12.8',],
}
env.site_list = []
env.root_path = '/var/websites'

### Setup environments
def testing(site=None):
    env.hosts = env.roledefs['testing']
    env.user = 'coordt'
    if site:
        get_site_list(site)

def staging(site=None):
    env.hosts = env.roledefs['staging']
    env.user = 'staginguser'
    if site:
        get_site_list(site)

def production(site=None):
    env.hosts = env.roledefs['web']
    env.user = 'produser'
    if site:
        get_site_list(site)

def get_site_list(site=None):
    if not site:
        site = prompt('Please specify which site (a comma delimited list is
accepted): ', validate=r'^[w-.,]+$')
    if isinstance(site, (tuple, list)):
        env.site_list = site
    else:
        env.site_list = site.split(',')

### Host Tasks

def check_host():
    """
    Check that the host has all the required commands installed
    """
    local("echo Checking for required commands")

    required_commands = ['wget', 'python', 'tar', 'gzip', 'hg', 'sudo', 'chown',
'chmod', 'patch', 'grep',]
    for command in required_commands:
        run('which %s' % command)


def install_package(package):
    """
    Install a package on a host using apt-get
    """
sudo('apt-get install %s' % package)

### Site Tasks

def clean(site=None):
    """
    Remove .pyc files from a site. Needs a site parameter specified.
    """
    if not env.site_list:
        get_site_list(site)
    for item in env.site_list:
        full_path = path.join(env.root_path, item)
        sudo("find %s -name '*.pyc' -depth -exec rm {} ;" % full_path)


def info(site=None):
    """
    Get the current revision of a site
    """
    if not env.site_list:
        get_site_list(site)
    for item in env.site_list:
        full_path = path.join(env.root_path, item)
        run('svn info %s | grep Revision' % full_path)


def ls(site=None, flags=''):
    """
    Get a listing of a site
    """
    if not env.site_list:
        get_site_list(site)
    for item in env.site_list:
        full_path = path.join(env.root_path, item)
        run('ls %s %s' % (flags, full_path))


def push(rev=None, externals=False, rel_path='', site=None):
    """
    Push out changes to all the servers.
    """
    if not env.site_list:
        get_site_list(site)

   if not externals:
       ignore=" --ignore-externals"
   else:
       ignore=""

   for item in env.site_list:
       full_path = os.path.join(env.root_path, item, rel_path)
       run('svn info %s | grep Revision' % full_path)
       if rev is None:
           sudo('svn up%s %s' % (ignore, full_path))
       else:
           sudo('svn up%s -r %s %s' % (ignore, rev, full_path))


def ensite(site=None):
"""
    Enable an Apache site configuration.
    """
    if not env.site_list:
        get_site_list(site)
    for item in env.site_list:
        sudo('a2ensite %s' % item)


def dissite(site=None):
    """
    Disable an Apache site configuration.
    """
    if not env.site_list:
        get_site_list(site)
    for item in env.site_list:
        sudo('a2dissite %s' % item)


### Apache tasks

def restart():
    """
    Restart Apache
    """
    sudo('/etc/init.d/apache2 restart')


def reload():
    """
    Reload Apache settings
    """
    sudo('/etc/init.d/apache2 reload')


def enmod(mod=None):
    """
    Enable an Apache module
    """
    if not mod:
        mod = prompt('Please specify which module to enable (a comma delimited list
is accepted): ', validate=r'^[w-.,]+$')
    mod_list = mod.split(',')
    for item in mod_list:
        sudo('a2enmod %s' % item)


def dismod(mod=None):
    """
    Disable an Apache module
    """
    if not mod:
        mod = prompt('Please specify which module to disable (a comma delimited
list is accepted): ', validate=r'^[w-.,]+$')
    mod_list = mod.split(',')
    for item in mod_list:
        sudo('a2dismod %s' % item)

Mais conteúdo relacionado

Mais procurados

10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming languageYaroslav Tkachenko
 
JavaScript Sprachraum
JavaScript SprachraumJavaScript Sprachraum
JavaScript Sprachraumpatricklee
 
Angular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental FeatureAngular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental FeatureJonathan Magen
 
AngularJS Tips&Tricks
AngularJS Tips&TricksAngularJS Tips&Tricks
AngularJS Tips&TricksPetr Bela
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers StealBen Scofield
 
Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUGBen Scofield
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojobpmedley
 
Why Redux-Observable?
Why Redux-Observable?Why Redux-Observable?
Why Redux-Observable?Anna Su
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Express Presentation
Express PresentationExpress Presentation
Express Presentationaaronheckmann
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingJace Ju
 
IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009Yusuke Wada
 
Cakephp2study tips集
Cakephp2study tips集Cakephp2study tips集
Cakephp2study tips集Kohji Tanaka
 
Chef 0.8, Knife and Amazon EC2
Chef 0.8, Knife and Amazon EC2Chef 0.8, Knife and Amazon EC2
Chef 0.8, Knife and Amazon EC2Robert Berger
 
What is systemd? Why use it? how does it work? - breizhcamp
What is systemd? Why use it? how does it work? - breizhcampWhat is systemd? Why use it? how does it work? - breizhcamp
What is systemd? Why use it? how does it work? - breizhcampQuentin Adam
 
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"GeeksLab Odessa
 
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POEYAPC::Brasil 2009, POE
YAPC::Brasil 2009, POEThiago Rondon
 

Mais procurados (20)

10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language
 
JavaScript Sprachraum
JavaScript SprachraumJavaScript Sprachraum
JavaScript Sprachraum
 
RingoJS
RingoJSRingoJS
RingoJS
 
Elixir on Containers
Elixir on ContainersElixir on Containers
Elixir on Containers
 
Cakephpstudy5 hacks
Cakephpstudy5 hacksCakephpstudy5 hacks
Cakephpstudy5 hacks
 
Angular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental FeatureAngular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental Feature
 
AngularJS Tips&Tricks
AngularJS Tips&TricksAngularJS Tips&Tricks
AngularJS Tips&Tricks
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers Steal
 
Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUG
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
Why Redux-Observable?
Why Redux-Observable?Why Redux-Observable?
Why Redux-Observable?
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstraping
 
IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009
 
Cakephp2study tips集
Cakephp2study tips集Cakephp2study tips集
Cakephp2study tips集
 
Chef 0.8, Knife and Amazon EC2
Chef 0.8, Knife and Amazon EC2Chef 0.8, Knife and Amazon EC2
Chef 0.8, Knife and Amazon EC2
 
What is systemd? Why use it? how does it work? - breizhcamp
What is systemd? Why use it? how does it work? - breizhcampWhat is systemd? Why use it? how does it work? - breizhcamp
What is systemd? Why use it? how does it work? - breizhcamp
 
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
 
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POEYAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
 

Destaque

Automated Deployment with Fabric
Automated Deployment with FabricAutomated Deployment with Fabric
Automated Deployment with Fabrictanihito
 
Fabric-让部署变得简单
Fabric-让部署变得简单Fabric-让部署变得简单
Fabric-让部署变得简单Eric Lo
 
Automation - fabric, django and more
Automation - fabric, django and moreAutomation - fabric, django and more
Automation - fabric, django and moreIlian Iliev
 
Fabric - a server management tool from Instagram
Fabric - a server management tool from InstagramFabric - a server management tool from Instagram
Fabric - a server management tool from InstagramJay Ren
 
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
 
Scaling mysql with python (and Docker).
Scaling mysql with python (and Docker).Scaling mysql with python (and Docker).
Scaling mysql with python (and Docker).Roberto Polli
 
Fabric, Cuisine and Watchdog for server administration in Python
Fabric, Cuisine and Watchdog for server administration in PythonFabric, Cuisine and Watchdog for server administration in Python
Fabric, Cuisine and Watchdog for server administration in PythonFFunction inc
 

Destaque (14)

Automated Deployment with Fabric
Automated Deployment with FabricAutomated Deployment with Fabric
Automated Deployment with Fabric
 
Fabric
FabricFabric
Fabric
 
Fabric (python)
Fabric (python)Fabric (python)
Fabric (python)
 
Fabric-让部署变得简单
Fabric-让部署变得简单Fabric-让部署变得简单
Fabric-让部署变得简单
 
Automation - fabric, django and more
Automation - fabric, django and moreAutomation - fabric, django and more
Automation - fabric, django and more
 
Fabric - a server management tool from Instagram
Fabric - a server management tool from InstagramFabric - a server management tool from Instagram
Fabric - a server management tool from Instagram
 
DevOps with Fabric
DevOps with FabricDevOps with Fabric
DevOps with Fabric
 
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
 
Scaling mysql with python (and Docker).
Scaling mysql with python (and Docker).Scaling mysql with python (and Docker).
Scaling mysql with python (and Docker).
 
Fabric
FabricFabric
Fabric
 
Fabric, Cuisine and Watchdog for server administration in Python
Fabric, Cuisine and Watchdog for server administration in PythonFabric, Cuisine and Watchdog for server administration in Python
Fabric, Cuisine and Watchdog for server administration in Python
 
Lab 1 my sql tutorial
Lab 1 my sql tutorial Lab 1 my sql tutorial
Lab 1 my sql tutorial
 
Donetsk.py - fabric
Donetsk.py -  fabricDonetsk.py -  fabric
Donetsk.py - fabric
 

Semelhante a fabfile.py

Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricksbcoca
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mateCodemotion
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Drehbuch zum Talk "Rapid Prototyping mit PHP Frameworks"
Drehbuch zum Talk "Rapid Prototyping mit PHP Frameworks"Drehbuch zum Talk "Rapid Prototyping mit PHP Frameworks"
Drehbuch zum Talk "Rapid Prototyping mit PHP Frameworks"Ralf Eggert
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of DjangoJacob Kaplan-Moss
 
Hello click click boom
Hello click click boomHello click click boom
Hello click click boomsymbian_mgl
 
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
 
Dethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.jsDethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.jsJay Harris
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium AppsNate Abele
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Spring data iii
Spring data iiiSpring data iii
Spring data iii명철 강
 
What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017Quentin Adam
 
How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?Tomasz Bak
 
こわくないよ❤️ Playframeworkソースコードリーディング入門
こわくないよ❤️ Playframeworkソースコードリーディング入門こわくないよ❤️ Playframeworkソースコードリーディング入門
こわくないよ❤️ Playframeworkソースコードリーディング入門tanacasino
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkBen Scofield
 

Semelhante a fabfile.py (20)

Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mate
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
EC2
EC2EC2
EC2
 
Drehbuch zum Talk "Rapid Prototyping mit PHP Frameworks"
Drehbuch zum Talk "Rapid Prototyping mit PHP Frameworks"Drehbuch zum Talk "Rapid Prototyping mit PHP Frameworks"
Drehbuch zum Talk "Rapid Prototyping mit PHP Frameworks"
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of Django
 
Hello click click boom
Hello click click boomHello click click boom
Hello click click boom
 
Fabric Python Lib
Fabric Python LibFabric Python Lib
Fabric Python Lib
 
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
 
Dethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.jsDethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.js
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Spring data iii
Spring data iiiSpring data iii
Spring data iii
 
What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017
 
How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?
 
こわくないよ❤️ Playframeworkソースコードリーディング入門
こわくないよ❤️ Playframeworkソースコードリーディング入門こわくないよ❤️ Playframeworkソースコードリーディング入門
こわくないよ❤️ Playframeworkソースコードリーディング入門
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
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
 
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
 
🐬 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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
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
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

fabfile.py

  • 1. from fabric.api import * from os import path env.roledefs = { 'web': ['172.16.12.1', '172.16.12.2', '172.16.12.3',], 'media': ['172.16.12.4',], 'staging': ['172.16.12.5',], 'testing': ['192.168.56.3',], 'database': ['172.16.12.7', '172.16.12.8',], } env.site_list = [] env.root_path = '/var/websites' ### Setup environments def testing(site=None): env.hosts = env.roledefs['testing'] env.user = 'coordt' if site: get_site_list(site) def staging(site=None): env.hosts = env.roledefs['staging'] env.user = 'staginguser' if site: get_site_list(site) def production(site=None): env.hosts = env.roledefs['web'] env.user = 'produser' if site: get_site_list(site) def get_site_list(site=None): if not site: site = prompt('Please specify which site (a comma delimited list is accepted): ', validate=r'^[w-.,]+$') if isinstance(site, (tuple, list)): env.site_list = site else: env.site_list = site.split(',') ### Host Tasks def check_host(): """ Check that the host has all the required commands installed """ local("echo Checking for required commands") required_commands = ['wget', 'python', 'tar', 'gzip', 'hg', 'sudo', 'chown', 'chmod', 'patch', 'grep',] for command in required_commands: run('which %s' % command) def install_package(package): """ Install a package on a host using apt-get """
  • 2. sudo('apt-get install %s' % package) ### Site Tasks def clean(site=None): """ Remove .pyc files from a site. Needs a site parameter specified. """ if not env.site_list: get_site_list(site) for item in env.site_list: full_path = path.join(env.root_path, item) sudo("find %s -name '*.pyc' -depth -exec rm {} ;" % full_path) def info(site=None): """ Get the current revision of a site """ if not env.site_list: get_site_list(site) for item in env.site_list: full_path = path.join(env.root_path, item) run('svn info %s | grep Revision' % full_path) def ls(site=None, flags=''): """ Get a listing of a site """ if not env.site_list: get_site_list(site) for item in env.site_list: full_path = path.join(env.root_path, item) run('ls %s %s' % (flags, full_path)) def push(rev=None, externals=False, rel_path='', site=None): """ Push out changes to all the servers. """ if not env.site_list: get_site_list(site) if not externals: ignore=" --ignore-externals" else: ignore="" for item in env.site_list: full_path = os.path.join(env.root_path, item, rel_path) run('svn info %s | grep Revision' % full_path) if rev is None: sudo('svn up%s %s' % (ignore, full_path)) else: sudo('svn up%s -r %s %s' % (ignore, rev, full_path)) def ensite(site=None):
  • 3. """ Enable an Apache site configuration. """ if not env.site_list: get_site_list(site) for item in env.site_list: sudo('a2ensite %s' % item) def dissite(site=None): """ Disable an Apache site configuration. """ if not env.site_list: get_site_list(site) for item in env.site_list: sudo('a2dissite %s' % item) ### Apache tasks def restart(): """ Restart Apache """ sudo('/etc/init.d/apache2 restart') def reload(): """ Reload Apache settings """ sudo('/etc/init.d/apache2 reload') def enmod(mod=None): """ Enable an Apache module """ if not mod: mod = prompt('Please specify which module to enable (a comma delimited list is accepted): ', validate=r'^[w-.,]+$') mod_list = mod.split(',') for item in mod_list: sudo('a2enmod %s' % item) def dismod(mod=None): """ Disable an Apache module """ if not mod: mod = prompt('Please specify which module to disable (a comma delimited list is accepted): ', validate=r'^[w-.,]+$') mod_list = mod.split(',') for item in mod_list: sudo('a2dismod %s' % item)