SlideShare una empresa de Scribd logo
1 de 28
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

Más contenido relacionado

La actualidad más candente

Fun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesFun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesabadger1999
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using dockerLarry 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 SymfonyAndré 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 PythonYurii Vasylenko
 
이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructure이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructureDaegwon Kim
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed 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 toolAndrey Smirnov
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationSuresh Kumar
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to AnsibleDan Vaida
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practicesBas Meijer
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a NutshellCoreOS
 
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_codeSoshi 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/APTJoshua Thijssen
 

La actualidad más candente (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
 

Destacado

Vorlesung - Cloud Infrastrukturen - Clusterbau | anynines
Vorlesung - Cloud Infrastrukturen - Clusterbau  | anyninesVorlesung - Cloud Infrastrukturen - Clusterbau  | anynines
Vorlesung - Cloud Infrastrukturen - Clusterbau | anyninesanynines 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 environmentsAlois Mayr
 
Blue Whale in an Enterprise Pond
Blue Whale in an Enterprise PondBlue Whale in an Enterprise Pond
Blue Whale in an Enterprise PondDigia Plc
 
Using Docker in the Real World
Using Docker in the Real WorldUsing Docker in the Real World
Using Docker in the Real WorldTim 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 DockerMarc 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 ProductionBen 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 DockerPatrick 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 DeploymentDan Stine
 

Destacado (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 a 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 AssafAhmed Assaf
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python 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é
 
V mware
V mwareV mware
V mwaredvmug1
 
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 VMwaresubtitle
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksGlen Ogilvie
 
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 NetSecDevOpsRaul 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
 
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 InfrastructureHabeeb 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 profitAndreas Heim
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabricandymccurdy
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014Carlo 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 KubernetesNicola Ferraro
 
Docker module 1
Docker module 1Docker module 1
Docker module 1Liang 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-2012Deepak Garg
 

Similar a 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
 

Último

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Último (20)

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

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