Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Adrian
Nye, Dimensio
nal Fund
Advisors
A PUPPET/FABRIC
BUILD/DEPLOY SYSTEM
• Python Software engineer, not a dev-ops guy
• Long-time Fabric user, just learned puppet
• Developed this system with Gary Wilson, another python dev
who also just learned puppet
WHO BUILT THIS?
 Start from bare RHEL 6 VMs, with only basic services pre-
installed (puppet, ntp, networking/firewall rules)
 Provide tools to build, configure, and deploy:
 15 existing websites in various technologies:
python, perl, php, ruby, & combinations
 Mysql & Mongo databases
 Memcache servers
 Proxy servers
 Search servers
 Dev/Stage/Prod copies of all this
 Automate everything
 Never touch any server by hand
THE TASK
 RHEL 6 is stable but very old versions of most software. For
example puppet hiera just became available as RPM.
 Stage & Prod servers won’t have internet access
 Deployment to Stage/Prod will be done by operations
people, not apps people.
 Need rollback
 Must have GUI or be simple
SOME CHALLENGES
 RPM or Source Installs?
 Git or Tar-based Deployment?
 Chef/Puppet/Ansible/SaltStack?
 Puppet preferred by our infrastructure group
 We’re python devs, so Fabric seemed obvious, it’s not going
away
SOME CHOICES
 Executes commands either local or remote (via ssh)
 Has functions for many common tasks
 Easy to script
 Anything you can do manually by ssh to a server, you can
script fabric to do.
 Goal is a repeatable, idempotent sequence of steps.
SO WHAT IS FABRIC?
 Useful stuff it can do:
 Confirm before doing things if you want
 Run stuff in parallel on multiple machines, or serially
 run stuff as if run from a directory
 Get & put files, append to files, comment or uncomment lines
 Upload templates and fill in variables
 Run sudo commands
 Connect to one host then to another within same function
BRIEF INTRO TO FABRIC
 Many ways to specify
 Most common is to use the Env variable, and set env.hosts
 Can specify on command line
 Can hardcode it (build tasks always happen on build server)
 Can make lists of hosts
 Functions on fab command line are executed in order, so first
function can set host, and subsequence functions can use
setting
FABRIC HOSTS
def tail_log(logname):
"""tail a log file.
fab hostname tail_log:access
logname is filename of log (without .log)
"""
log = env.logdir + „/‟ + logname + „.log‟
if file_exists(log):
run(„tail –f %s‟ % log, pty=True)
else:
print “Logfile not found in %s” % env.log_dir
EXAMPLE FABRIC TASK
def dev(service_name=None):
"""Sets server as appropriate for service_name for the dev
environment.
Also sets environ, server, and service_name in env so it is inherited
by later fab commands. Some fab commands need an environment but
are not
specific to a service (such as mysql commands), so service_name is
optional.
"""
_set_host_for_environment(service_name, Environment.DEV)
The above function is just a clever way of setting env.host to a hostname, so that later
commands in the same fab command line know what system to work on.
SETTING HOST CLEVERLY
 We wrote classes using fabric to do all the tasks needed in
the build and deployment process for our sites (and invoke
puppet, which does the rest).
 All of it is data-driven. There is a file that defines the needs
of each of our services and one that defines all of our servers.
HOW WE USED FABRIC
 Your responsibility to make things idempotent.
 For example, running “mkdir dirname” is not idempotent, because it
will fail the second time. In this case use a routine that tests
whether the dir exists, and if not then create it.
 Output control
 Normal output is everything (very verbose). Good for
debugging, although it can hide problems in sheer volume of
information.
 You can turn down the verbosity.
 Really want two levels simultaneously: less verbose output displayed
to the terminal, and fully verbose output logged to a file. But fabric
doesn’t support that yet.
CHALLENGES WITH FABRIC
 Puppet and Fabric capabilities overlap
 both can do most tasks
 Puppet is naturally idempotent
 Fabric is naturally step by step
 Puppet: use to enforce STATE
 RPM installation
 Creation of upstart scripts from templates
 User accounts
 Files, Directories, and Permissions
 Fabric: use to enforce WORKFLOW
 Build software environment (python virtualenv/perl modules etc)
 Protect from simultaneous deploys
 Testing of support services
 Sync of software environment from build server to deploy server
 Checkout of git repos, switching branches
 Media syncing
 Run puppet
 Graceful server restart
 Smoke testing (is site actually working after deployment)
DIVISION OF RESPONSIBILITIES
 All our custom puppet and fabric code is in a single git repo
called “sysconfig”
 Enables everything to be run from anywhere with network
access to build server.
PUPPET/FABRIC GIT REPO
 Graphic of our dev servers and networking
DEV ENVIRONMENT
Utility modules used by
multiple sites
Each site/service has
module
4 internal sites run on
intweb01. Mongo &
Mysql run on DB1Host
Intweb01(d,s,p) is internal
web server, db01 is db
server , etc
Nodes
IntWeb1Host
IntWebsite1
Nginx Proxy
IntWebsite2
Website
Layout
DB1Host
MySQL MongoDB
PUPPET MODULES
 Nodes manifest connects hostnames with the type of host it
will be, for all servers in all environments.
 Hosts manifest for each type of host (4 types of web
servers, db server, cache server, proxy server, etc). This
assigns sites to hosts.
 Site manifests for each type of service (each
website, proxy, database). Does rpm installation, site-specific
files & dirs, upstart scripts to start and stop service.
 Utility manifests for stuff needed by multiple sites, to
minimize duplication. For example nginx module supports 3
different uses of nginx: fake dev load balancer proxy, ssl
offloading proxy, local proxy.
PUPPET MODULES/MANIFESTS
 Use Virtual Packages to enable every manifest to install its
dependencies without regard to whether some other manifest
has already installed it on the same server.
 Should use Hiera to enable Puppet/Fabric to pull from the
same YAML database, but we haven’t done this yet since Hiera
just became available on RHEL 6.
PUPPET FEATURES
 1. Build step builds software environment for site on build
server
 2. Deploy step copies the software environment from build
server to the destination server, then deploys app code from
scratch.
 Two-step process does several things:
 Speeds up deployment, since build step is needed less often and
takes a long time.
 Speeds parallel deployment if you have redundant servers
 Keeps compiling tools off destination servers. The less you
install, the more secure they are.
FABRIC WORKFLOW
 Pip/Virtualenv used for Python packages, requirements file in
git repo
 Cpanm used for Perl modules
 Rbenv used for ruby modules
 All packages, modules, and rpms mirrored locally
 Improves reliability and speed
 Simplifies version control
 Everything (except rpms) installed in
/opt/comms/servicename, not system-wide. This simplifies
copying the environment to the deployed server, and
simplifies recreating a clean build.
FABRIC BUILD WORKFLOW
 Example service definition
 Name (for fab commands)
 Server type it should be installed on (not hostname)
 Domain (without dev/stg/com)
 Ssl or not
 How to smoke test it
 Init scripts it needs
 Git repos to check out, including branch, and any media
 Log dirs
 Languages needed
 Prerequisite services to check (memcache, db)
 Related services to reload (nginx, memcache)
 dirs containing built software environment (virtualenv, cpanm etc)
FABRIC BUILD SERVICE DEFINITION
 1. Mark deployment as in progress (using lock file)
 2. Check support services
 If db needed, is it running?
 If memcache needed, is it running?
 If critical support service not running, ask whether to continue.
FABRIC DEPLOYMENT WORKFLOW
 3. clone/pull the git repo(s) needed for the site. Checkout the
specified branch.
FABRIC DEPLOYMENT WORKFLOW
 4. Move previous software environment for fast rollback
 5. Rsync software environment for site
 6. Rsync media for site
FABRIC DEPLOYMENT WORKFLOW
 7. Run puppet. For convenience we support two modes:
 Use puppet master
 Copy developer’s sysconfig repo and run puppet using those modules.
This makes development a lot faster.
FABRIC DEPLOYMENT WORKFLOW
 8. Zero Downtime Restart
 9. Smoke Test
 For web servers, check that site is up, login works, and run selenium
tests.
 For memcache etc, use nc to test basic operation.
 Note that if deployment fails, there would be some downtime until
previous version reinstated.
FABRIC DEPLOYMENT WORKFLOW
 Setting up SSH keys on all servers
 Log viewers
 Database backups
 Database copy from one environment to another (i.e. copy
production db back to dev)
 Determine hostname from service name and environment
 Status/Start/stop/reload any remote service/site
 Media syncing from environment to environment
 Proxy server config generation
 Running puppet, using puppet master and without
 Smoke testers for different types of sites & services
 Tools to make local mirrors of internet software
FABRIC UTILITIES WE WROTE
 Support for replicated (redundant) servers.
 GUI for common tasks, using Rundeck or Jenkins or TeamCity
 Network logging (Splunk)
FUTURE WORK

More Related Content

What's hot

Docker perl build
Docker perl buildDocker perl build
Docker perl build
Workhorse Computing
 
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
abadger1999
 
Fabric Fast & Furious edition
Fabric Fast & Furious editionFabric Fast & Furious edition
Fabric Fast & Furious edition
Alejandro E Brito Monedero
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
Larry Cai
 
CoreOS : 설치부터 컨테이너 배포까지
CoreOS : 설치부터 컨테이너 배포까지CoreOS : 설치부터 컨테이너 배포까지
CoreOS : 설치부터 컨테이너 배포까지
충섭 김
 
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
André Rømcke
 
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
Yurii Vasylenko
 
이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructure이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructure
Daegwon Kim
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
Rayed Alrashed
 
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
 
aptly: Debian repository management tool
aptly: Debian repository management toolaptly: Debian repository management tool
aptly: Debian repository management tool
Andrey Smirnov
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
Suresh Kumar
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to Ansible
Dan Vaida
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
Bas Meijer
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
CoreOS
 
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...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Simon Boulet
 
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
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_code
Soshi Nemoto
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
Joshua Thijssen
 

What's hot (20)

Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
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
 
Fabric Fast & Furious edition
Fabric Fast & Furious editionFabric Fast & Furious edition
Fabric Fast & Furious edition
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
CoreOS : 설치부터 컨테이너 배포까지
CoreOS : 설치부터 컨테이너 배포까지CoreOS : 설치부터 컨테이너 배포까지
CoreOS : 설치부터 컨테이너 배포까지
 
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
 
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
 
이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructure이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructure
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
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)
 
aptly: Debian repository management tool
aptly: Debian repository management toolaptly: Debian repository management tool
aptly: Debian repository management tool
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to Ansible
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
 
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...
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
 
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...
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_code
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
 

Viewers also liked

Vorlesung - Cloud Infrastrukturen - Clusterbau | anynines
Vorlesung - Cloud Infrastrukturen - Clusterbau  | anyninesVorlesung - Cloud Infrastrukturen - Clusterbau  | anynines
Vorlesung - Cloud Infrastrukturen - Clusterbau | anynines
anynines GmbH
 
Lessons learned running large real-world Docker environments
Lessons learned running large real-world Docker environmentsLessons learned running large real-world Docker environments
Lessons learned running large real-world Docker environments
Alois Mayr
 
Blue Whale in an Enterprise Pond
Blue Whale in an Enterprise PondBlue Whale in an Enterprise Pond
Blue Whale in an Enterprise Pond
Digia Plc
 
Using Docker in the Real World
Using Docker in the Real WorldUsing Docker in the Real World
Using Docker in the Real World
Tim Haak
 
Solving Real World Production Problems with Docker
Solving Real World Production Problems with DockerSolving Real World Production Problems with Docker
Solving Real World Production Problems with Docker
Marc Campbell
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
Ben Hall
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
RightScale
 
Programming the world with Docker
Programming the world with DockerProgramming the world with Docker
Programming the world with Docker
Patrick Chanezon
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated Deployment
Dan Stine
 

Viewers also liked (9)

Vorlesung - Cloud Infrastrukturen - Clusterbau | anynines
Vorlesung - Cloud Infrastrukturen - Clusterbau  | anyninesVorlesung - Cloud Infrastrukturen - Clusterbau  | anynines
Vorlesung - Cloud Infrastrukturen - Clusterbau | anynines
 
Lessons learned running large real-world Docker environments
Lessons learned running large real-world Docker environmentsLessons learned running large real-world Docker environments
Lessons learned running large real-world Docker environments
 
Blue Whale in an Enterprise Pond
Blue Whale in an Enterprise PondBlue Whale in an Enterprise Pond
Blue Whale in an Enterprise Pond
 
Using Docker in the Real World
Using Docker in the Real WorldUsing Docker in the Real World
Using Docker in the Real World
 
Solving Real World Production Problems with Docker
Solving Real World Production Problems with DockerSolving Real World Production Problems with Docker
Solving Real World Production Problems with Docker
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
 
Programming the world with Docker
Programming the world with DockerProgramming the world with Docker
Programming the world with Docker
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated Deployment
 

Similar to A Fabric/Puppet Build/Deploy System

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
 
Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed Assaf
Ahmed Assaf
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
andymccurdy
 
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
Sylvain Rayé
 
V mware
V mwareV mware
V mware
dvmug1
 
Puppet Primer, Robbie Jerrom, Solution Architect VMware
Puppet Primer, Robbie Jerrom, Solution Architect VMwarePuppet Primer, Robbie Jerrom, Solution Architect VMware
Puppet Primer, Robbie Jerrom, Solution Architect VMware
subtitle
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricks
Glen Ogilvie
 
Automation day red hat ansible
   Automation day red hat ansible    Automation day red hat ansible
Automation day red hat ansible
Rodrigo Missiaggia
 
Automação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsAutomação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOps
Raul Leite
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
Automation in Cloud
Automation in CloudAutomation in Cloud
Automation in Cloud
Abhishek Amralkar
 
Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)
Puppet
 
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
Habeeb Rahman
 
Virtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profitVirtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profit
Andreas Heim
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabric
andymccurdy
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
Carlo Bonamico
 
Extending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with KubernetesExtending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with Kubernetes
Nicola Ferraro
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
Liang Bo
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
Puppet
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
Deepak Garg
 

Similar to A Fabric/Puppet Build/Deploy System (20)

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)
 
Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed Assaf
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python 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
 
V mware
V mwareV mware
V mware
 
Puppet Primer, Robbie Jerrom, Solution Architect VMware
Puppet Primer, Robbie Jerrom, Solution Architect VMwarePuppet Primer, Robbie Jerrom, Solution Architect VMware
Puppet Primer, Robbie Jerrom, Solution Architect VMware
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricks
 
Automation day red hat ansible
   Automation day red hat ansible    Automation day red hat ansible
Automation day red hat ansible
 
Automação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsAutomação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOps
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
 
Automation in Cloud
Automation in CloudAutomation in Cloud
Automation in Cloud
 
Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)
 
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
 
Virtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profitVirtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profit
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabric
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Extending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with KubernetesExtending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with Kubernetes
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
 

Recently uploaded

AC Atlassian Coimbatore Session Slides( 22/06/2024)
AC Atlassian Coimbatore Session Slides( 22/06/2024)AC Atlassian Coimbatore Session Slides( 22/06/2024)
AC Atlassian Coimbatore Session Slides( 22/06/2024)
apoorva2579
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
Safe Software
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
BookNet Canada
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
SynapseIndia
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
UiPathCommunity
 
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Erasmo Purificato
 
@Call @Girls Guwahati 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cute Girl any...
@Call @Girls Guwahati 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cute Girl any...@Call @Girls Guwahati 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cute Girl any...
@Call @Girls Guwahati 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cute Girl any...
kantakumariji156
 
@Call @Girls Pune 0000000000 Riya Khan Beautiful Girl any Time
@Call @Girls Pune 0000000000 Riya Khan Beautiful Girl any Time@Call @Girls Pune 0000000000 Riya Khan Beautiful Girl any Time
@Call @Girls Pune 0000000000 Riya Khan Beautiful Girl any Time
amitchopra0215
 
How Netflix Builds High Performance Applications at Global Scale
How Netflix Builds High Performance Applications at Global ScaleHow Netflix Builds High Performance Applications at Global Scale
How Netflix Builds High Performance Applications at Global Scale
ScyllaDB
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
Mark Billinghurst
 
What's Next Web Development Trends to Watch.pdf
What's Next Web Development Trends to Watch.pdfWhat's Next Web Development Trends to Watch.pdf
What's Next Web Development Trends to Watch.pdf
SeasiaInfotech2
 
MYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
MYIR Product Brochure - A Global Provider of Embedded SOMs & SolutionsMYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
MYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
Linda Zhang
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
BookNet Canada
 
Knowledge and Prompt Engineering Part 2 Focus on Prompt Design Approaches
Knowledge and Prompt Engineering Part 2 Focus on Prompt Design ApproachesKnowledge and Prompt Engineering Part 2 Focus on Prompt Design Approaches
Knowledge and Prompt Engineering Part 2 Focus on Prompt Design Approaches
Earley Information Science
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
HackersList
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
Enterprise Wired
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
shanthidl1
 
HTTP Adaptive Streaming – Quo Vadis (2024)
HTTP Adaptive Streaming – Quo Vadis (2024)HTTP Adaptive Streaming – Quo Vadis (2024)
HTTP Adaptive Streaming – Quo Vadis (2024)
Alpen-Adria-Universität
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
ArgaBisma
 

Recently uploaded (20)

AC Atlassian Coimbatore Session Slides( 22/06/2024)
AC Atlassian Coimbatore Session Slides( 22/06/2024)AC Atlassian Coimbatore Session Slides( 22/06/2024)
AC Atlassian Coimbatore Session Slides( 22/06/2024)
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
 
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
 
@Call @Girls Guwahati 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cute Girl any...
@Call @Girls Guwahati 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cute Girl any...@Call @Girls Guwahati 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cute Girl any...
@Call @Girls Guwahati 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cute Girl any...
 
@Call @Girls Pune 0000000000 Riya Khan Beautiful Girl any Time
@Call @Girls Pune 0000000000 Riya Khan Beautiful Girl any Time@Call @Girls Pune 0000000000 Riya Khan Beautiful Girl any Time
@Call @Girls Pune 0000000000 Riya Khan Beautiful Girl any Time
 
How Netflix Builds High Performance Applications at Global Scale
How Netflix Builds High Performance Applications at Global ScaleHow Netflix Builds High Performance Applications at Global Scale
How Netflix Builds High Performance Applications at Global Scale
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
 
What's Next Web Development Trends to Watch.pdf
What's Next Web Development Trends to Watch.pdfWhat's Next Web Development Trends to Watch.pdf
What's Next Web Development Trends to Watch.pdf
 
MYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
MYIR Product Brochure - A Global Provider of Embedded SOMs & SolutionsMYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
MYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
 
Knowledge and Prompt Engineering Part 2 Focus on Prompt Design Approaches
Knowledge and Prompt Engineering Part 2 Focus on Prompt Design ApproachesKnowledge and Prompt Engineering Part 2 Focus on Prompt Design Approaches
Knowledge and Prompt Engineering Part 2 Focus on Prompt Design Approaches
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
 
HTTP Adaptive Streaming – Quo Vadis (2024)
HTTP Adaptive Streaming – Quo Vadis (2024)HTTP Adaptive Streaming – Quo Vadis (2024)
HTTP Adaptive Streaming – Quo Vadis (2024)
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
 

A Fabric/Puppet Build/Deploy System

  • 1. Adrian Nye, Dimensio nal Fund Advisors A PUPPET/FABRIC BUILD/DEPLOY SYSTEM
  • 2. • Python Software engineer, not a dev-ops guy • Long-time Fabric user, just learned puppet • Developed this system with Gary Wilson, another python dev who also just learned puppet WHO BUILT THIS?
  • 3.  Start from bare RHEL 6 VMs, with only basic services pre- installed (puppet, ntp, networking/firewall rules)  Provide tools to build, configure, and deploy:  15 existing websites in various technologies: python, perl, php, ruby, & combinations  Mysql & Mongo databases  Memcache servers  Proxy servers  Search servers  Dev/Stage/Prod copies of all this  Automate everything  Never touch any server by hand THE TASK
  • 4.  RHEL 6 is stable but very old versions of most software. For example puppet hiera just became available as RPM.  Stage & Prod servers won’t have internet access  Deployment to Stage/Prod will be done by operations people, not apps people.  Need rollback  Must have GUI or be simple SOME CHALLENGES
  • 5.  RPM or Source Installs?  Git or Tar-based Deployment?  Chef/Puppet/Ansible/SaltStack?  Puppet preferred by our infrastructure group  We’re python devs, so Fabric seemed obvious, it’s not going away SOME CHOICES
  • 6.  Executes commands either local or remote (via ssh)  Has functions for many common tasks  Easy to script  Anything you can do manually by ssh to a server, you can script fabric to do.  Goal is a repeatable, idempotent sequence of steps. SO WHAT IS FABRIC?
  • 7.  Useful stuff it can do:  Confirm before doing things if you want  Run stuff in parallel on multiple machines, or serially  run stuff as if run from a directory  Get & put files, append to files, comment or uncomment lines  Upload templates and fill in variables  Run sudo commands  Connect to one host then to another within same function BRIEF INTRO TO FABRIC
  • 8.  Many ways to specify  Most common is to use the Env variable, and set env.hosts  Can specify on command line  Can hardcode it (build tasks always happen on build server)  Can make lists of hosts  Functions on fab command line are executed in order, so first function can set host, and subsequence functions can use setting FABRIC HOSTS
  • 9. def tail_log(logname): """tail a log file. fab hostname tail_log:access logname is filename of log (without .log) """ log = env.logdir + „/‟ + logname + „.log‟ if file_exists(log): run(„tail –f %s‟ % log, pty=True) else: print “Logfile not found in %s” % env.log_dir EXAMPLE FABRIC TASK
  • 10. def dev(service_name=None): """Sets server as appropriate for service_name for the dev environment. Also sets environ, server, and service_name in env so it is inherited by later fab commands. Some fab commands need an environment but are not specific to a service (such as mysql commands), so service_name is optional. """ _set_host_for_environment(service_name, Environment.DEV) The above function is just a clever way of setting env.host to a hostname, so that later commands in the same fab command line know what system to work on. SETTING HOST CLEVERLY
  • 11.  We wrote classes using fabric to do all the tasks needed in the build and deployment process for our sites (and invoke puppet, which does the rest).  All of it is data-driven. There is a file that defines the needs of each of our services and one that defines all of our servers. HOW WE USED FABRIC
  • 12.  Your responsibility to make things idempotent.  For example, running “mkdir dirname” is not idempotent, because it will fail the second time. In this case use a routine that tests whether the dir exists, and if not then create it.  Output control  Normal output is everything (very verbose). Good for debugging, although it can hide problems in sheer volume of information.  You can turn down the verbosity.  Really want two levels simultaneously: less verbose output displayed to the terminal, and fully verbose output logged to a file. But fabric doesn’t support that yet. CHALLENGES WITH FABRIC
  • 13.  Puppet and Fabric capabilities overlap  both can do most tasks  Puppet is naturally idempotent  Fabric is naturally step by step  Puppet: use to enforce STATE  RPM installation  Creation of upstart scripts from templates  User accounts  Files, Directories, and Permissions  Fabric: use to enforce WORKFLOW  Build software environment (python virtualenv/perl modules etc)  Protect from simultaneous deploys  Testing of support services  Sync of software environment from build server to deploy server  Checkout of git repos, switching branches  Media syncing  Run puppet  Graceful server restart  Smoke testing (is site actually working after deployment) DIVISION OF RESPONSIBILITIES
  • 14.  All our custom puppet and fabric code is in a single git repo called “sysconfig”  Enables everything to be run from anywhere with network access to build server. PUPPET/FABRIC GIT REPO
  • 15.  Graphic of our dev servers and networking DEV ENVIRONMENT
  • 16. Utility modules used by multiple sites Each site/service has module 4 internal sites run on intweb01. Mongo & Mysql run on DB1Host Intweb01(d,s,p) is internal web server, db01 is db server , etc Nodes IntWeb1Host IntWebsite1 Nginx Proxy IntWebsite2 Website Layout DB1Host MySQL MongoDB PUPPET MODULES
  • 17.  Nodes manifest connects hostnames with the type of host it will be, for all servers in all environments.  Hosts manifest for each type of host (4 types of web servers, db server, cache server, proxy server, etc). This assigns sites to hosts.  Site manifests for each type of service (each website, proxy, database). Does rpm installation, site-specific files & dirs, upstart scripts to start and stop service.  Utility manifests for stuff needed by multiple sites, to minimize duplication. For example nginx module supports 3 different uses of nginx: fake dev load balancer proxy, ssl offloading proxy, local proxy. PUPPET MODULES/MANIFESTS
  • 18.  Use Virtual Packages to enable every manifest to install its dependencies without regard to whether some other manifest has already installed it on the same server.  Should use Hiera to enable Puppet/Fabric to pull from the same YAML database, but we haven’t done this yet since Hiera just became available on RHEL 6. PUPPET FEATURES
  • 19.  1. Build step builds software environment for site on build server  2. Deploy step copies the software environment from build server to the destination server, then deploys app code from scratch.  Two-step process does several things:  Speeds up deployment, since build step is needed less often and takes a long time.  Speeds parallel deployment if you have redundant servers  Keeps compiling tools off destination servers. The less you install, the more secure they are. FABRIC WORKFLOW
  • 20.  Pip/Virtualenv used for Python packages, requirements file in git repo  Cpanm used for Perl modules  Rbenv used for ruby modules  All packages, modules, and rpms mirrored locally  Improves reliability and speed  Simplifies version control  Everything (except rpms) installed in /opt/comms/servicename, not system-wide. This simplifies copying the environment to the deployed server, and simplifies recreating a clean build. FABRIC BUILD WORKFLOW
  • 21.  Example service definition  Name (for fab commands)  Server type it should be installed on (not hostname)  Domain (without dev/stg/com)  Ssl or not  How to smoke test it  Init scripts it needs  Git repos to check out, including branch, and any media  Log dirs  Languages needed  Prerequisite services to check (memcache, db)  Related services to reload (nginx, memcache)  dirs containing built software environment (virtualenv, cpanm etc) FABRIC BUILD SERVICE DEFINITION
  • 22.  1. Mark deployment as in progress (using lock file)  2. Check support services  If db needed, is it running?  If memcache needed, is it running?  If critical support service not running, ask whether to continue. FABRIC DEPLOYMENT WORKFLOW
  • 23.  3. clone/pull the git repo(s) needed for the site. Checkout the specified branch. FABRIC DEPLOYMENT WORKFLOW
  • 24.  4. Move previous software environment for fast rollback  5. Rsync software environment for site  6. Rsync media for site FABRIC DEPLOYMENT WORKFLOW
  • 25.  7. Run puppet. For convenience we support two modes:  Use puppet master  Copy developer’s sysconfig repo and run puppet using those modules. This makes development a lot faster. FABRIC DEPLOYMENT WORKFLOW
  • 26.  8. Zero Downtime Restart  9. Smoke Test  For web servers, check that site is up, login works, and run selenium tests.  For memcache etc, use nc to test basic operation.  Note that if deployment fails, there would be some downtime until previous version reinstated. FABRIC DEPLOYMENT WORKFLOW
  • 27.  Setting up SSH keys on all servers  Log viewers  Database backups  Database copy from one environment to another (i.e. copy production db back to dev)  Determine hostname from service name and environment  Status/Start/stop/reload any remote service/site  Media syncing from environment to environment  Proxy server config generation  Running puppet, using puppet master and without  Smoke testers for different types of sites & services  Tools to make local mirrors of internet software FABRIC UTILITIES WE WROTE
  • 28.  Support for replicated (redundant) servers.  GUI for common tasks, using Rundeck or Jenkins or TeamCity  Network logging (Splunk) FUTURE WORK