SlideShare a Scribd company logo
1 of 54
Jenkins User Conference Boston #jenkinsconf
Jenkins and Chef
Infrastructure CI and Application Deployment
Dan Stine
Copyright Clearance Center
www.copyright.com
June 18, 2014
#jenkinsconf
Jenkins User Conference Boston #jenkinsconf
About Me
Software Architect
Library & Framework Developer
Infrastructure Lead & Product Owner
Enemy of Inefficiency and Needless
Inconsistency
dstine at copyright.com
sw at stinemail.com
github.com/dstine
Jenkins User Conference Boston #jenkinsconf
About Copyright Clearance Center
Global licensing solutions that
make © work for everyone
– Get, share, and manage content
– Rights broker for world’s most sought after materials
– Global company (US, Europe, Asia) – HQ in Danvers, MA
Industry-specific software systems
– Internal and external user base
– Applications, services, databases
– Organic growth over many years
In 2011, CCC adopted a Product Platform
strategy for growing its software portfolio
Jenkins User Conference Boston #jenkinsconf
Agenda
• Context
• Primer
• Deployment Process Design
• Cookbook Builds
• Application Deployment
• Wrap Up
Jenkins User Conference Boston #jenkinsconf
CONTEXT
Jenkins User Conference Boston #jenkinsconf
Standard Software Platform
• Started platform definition in 2011
– Homogeneous by default
• Tools
– Java, Spring, Tomcat, Postgres
– Git/GitHub, Gradle, Jenkins, Artifactory, Liquibase
• Process
– Standard development workflow
– Standard application shape & operational profile
Jenkins User Conference Boston #jenkinsconf
Initial Delivery Pipeline
“Don”
Jenkins User Conference Boston #jenkinsconf
Initial Delivery Pipeline
• Automated build process
• Publish build artifacts to Artifactory
– Application WARs
– Liquibase JARs
• Manual deploys
– (Many apps) x (many versions) x (multiple
environments) = TIME & EFFORT
– The more frequently a task is performed, the
greater the return from improved efficiency
Jenkins User Conference Boston #jenkinsconf
Improved Deployment Process
• Goals
– Reduce effort
– Improve speed, reliability, and frequency
– Handle app deploys and db schema updates
– Enable self-service
• Process Changes
– Manual  Automated
– Prose instructions  Infrastructure as code
Jenkins User Conference Boston #jenkinsconf
Target Delivery Pipeline
Jenkins User Conference Boston #jenkinsconf
PRIMER
Jenkins User Conference Boston #jenkinsconf
Layers of System Management
• Orchestration
– Processes collaborating in a distributed
system
• Configuration
– Install and configure packages and software
• Provisioning
– Hypervisor (VMware, EC2)
Jenkins User Conference Boston #jenkinsconf
Infrastructure as Code
• Develop and manage software
infrastructure with practices similar to
those used to develop software applications
• Examples
– Source Code
– Modularity
– Abstraction
– Testing
Jenkins User Conference Boston #jenkinsconf
Configuration Management
“Process for establishing and maintaining consistency
of a product’s performance, functional and physical
attributes with its requirements, design and operational
information throughout its life” (wikipedia)
• CM tools for managing software systems
– CFEngine, Puppet, Chef, Salt, Ansible
• Embody Infrastructure as Code principles
• Define desired state of machine
– Each run inspects state and makes necessary
changes, if any
Jenkins User Conference Boston #jenkinsconf
Chef
• Configuration management tool
• Exposes DSL hosted in Ruby
– Express “what” not “how”
– Clean, purposeful capture of intent
• Favor DSL when writing code
– Ruby is available, if required
Jenkins User Conference Boston #jenkinsconf
Chef Terminology (1)
• Chef client is installed on nodes
(machines) which are registered with
the Chef server
• Developers write code on workstations and
use tools such as knife to interact with server
• Chef models node configuration as a set of
DSL resources (e.g. package, service,
directory) which are mapped to internal
providers (actual code to execute)
– Can define custom resources
Jenkins User Conference Boston #jenkinsconf
Example Chef Code
This resource declaration
directory '/a/b/c' do
owner 'admin'
group 'admin
mode '0755'
action :create
recursive true
end
ensures that
$ ls -ld /a/b/c
drwxr-xr-x. 5 admin admin 4096 Feb 14 11:22 /a/b/c
Jenkins User Conference Boston #jenkinsconf
Chef Terminology (2)
• A recipe declares a set of resources with
desired configuration
• A cookbook contains a set of semantically-
related code and is the fundamental unit of
distribution for Chef code
– Compare to JAR for Java code
• A data bag holds JSON information in one or
more data bag items accessible from Chef
code
• Chef environments model deployed
environments
• Each node has a run list containing recipes
Jenkins User Conference Boston #jenkinsconf
DEPLOYMENT PROCESS DESIGN
Jenkins User Conference Boston #jenkinsconf
Basic Approach
• Deploy custom applications with Chef
• Execute schema updates with Liquibase
• Coordinate everything with:
Jenkins User Conference Boston #jenkinsconf
Jenkins as Coordinator
• General purpose job executor
– Shell script steps for Chef API
– Gradle steps for Liquibase updates
– Arbitrary code at any point in lifecycle
• UI
– Smooth integration with Active Directory
– Authentication and authorization
• Administration
– Familiar with Jenkins from application build jobs
Jenkins User Conference Boston #jenkinsconf
CCC Application Group
• Set of deployable units that are
versioned and released together
• For example, a group might have
– UI
– REST service
– Message consumer
– DB
• Build with a single command
• Deploy with a single command
Jenkins User Conference Boston #jenkinsconf
Technical Design Goals
• Provide clean API
– Specify only essential differences between
apps
– Custom Chef resource is the interface
– Codify & enforce standards
• Balance consistency & flexibility
– Code in semantically-versioned cookbooks
– Configuration in data bags
• Controlled cookbook promotion
– Chef environment specifies cookbook version
constraint
Jenkins User Conference Boston #jenkinsconf
Cookbook Types
• Library Cookbooks
– Encapsulate common re-usable logic
– Define custom resource to install an app
• And the implementing provider
• Application Cookbooks
– Depend on library cookbooks
– One cookbook per application group
• One recipe per application
• Recipes use custom resource
– Lightweight
Jenkins User Conference Boston #jenkinsconf
Data Bags
• Contain application configuration
– Service endpoints, JAVA_OPTS, etc.
• One data bag per application group
– One data bag item per environment
• “Live” reflection of deployed configuration
– Edit  push to Chef server  deploy
– Master always matches state of Chef server
Jenkins User Conference Boston #jenkinsconf
Custom Resource Usage
Ensure my-app-ui WAR is deployed:
ccc_webapp "my-app-ui" do
provider :ccc_webapp
artifact_group 'com.copyright.myapp'
artifact 'my-app-ui'
container 'MY-APP-UI'
http_port '8080'
shutdown_port '8900'
properties_template 'ccc.properties.erb'
app_group_data_bag 'my_app'
end
Jenkins User Conference Boston #jenkinsconf
Custom Resource Actions
• Retrieves Java, Tomcat & WAR from
Artifactory
• Installs Java and Tomcat in standard
locations
• Creates and configures Tomcat container
• Installs WAR in the container
• Opens port in host firewall
• Generates application properties file
• Starts container
(Each action taken only if necessary)
Jenkins User Conference Boston #jenkinsconf
Data Bag Structure
data_bags/my_app/DEV.json (data bag item)
"version": "1.4.9",
"runtime": {
"my-app-ui": {
"java_opts": "-Xmx2G -XX:MaxPermSize=1024m"
}
},
"app_config": {
"db.url": "jdbc:postgresql://devdb:5432/myapp",
"svc.foo.url": "http://devsvc:9000/foo"
}
data_bags/my_app/TEST.json
...
data_bags/my_app/PROD.json
Jenkins User Conference Boston #jenkinsconf
Cookbook Data Bag Code *
ccc/providers/webapp.rb (library cookbook)
app_group_data = data_bag_item(app_group_data_bag,
node.chef_environment)
java_opts = app_group_data['runtime'][artifact]['java_opts']
// pass java_opts to Tomcat container
app_config = app_group_data['app_config']
// pass app_config to template resource declaration
my_app/templates/ccc.properties.erb (application cookbook)
db.url=<%= @app_config['db.url'] %>
svc.foo.url=<%= @app_config['svc.foo.url'] %>
* Included for future reference
Jenkins User Conference Boston #jenkinsconf
Roles
• Deployers
– Update data bags & environment files
– Initiate deployments
• Tech leads
– Maintain application cookbooks
• Framework developers
– Maintain library cookbooks
– Maintain framework
– Process improvement
Jenkins User Conference Boston #jenkinsconf
COOKBOOK BUILDS
Jenkins User Conference Boston #jenkinsconf
Cookbook Build Process
Jenkins User Conference Boston #jenkinsconf
Jenkins Build Server
• For each application group
– Cookbook CI job
– Cookbook release job
– Same master as application build jobs
• New class of slaves
– Ruby with required gems
– Chef with credentials for Chef server
– EC2 credentials to create test nodes
Jenkins User Conference Boston #jenkinsconf
Cookbook CI Job
• Triggered when new Chef code is
merged
• Static analysis
– JSON syntax (json gem)
– Ruby syntax and style (Tailor)
– Chef syntax (Knife)
– Chef style and correctness (Foodcritic)
• Integration testing
– Test Kitchen with kitchen-ec2 plugin
Jenkins User Conference Boston #jenkinsconf
Integration Testing Lifecycle
• Spin up EC2 instance(s) to mimic
actual deployment topology of
application group
• Run Chef on each instance (node)
• Execute asserts – pass or fail
• Dispose of instance(s)
Jenkins User Conference Boston #jenkinsconf
Integration Testing Details
• Instances created from AMI
– Preconfigured with Ruby and Chef
• Using Chef Solo
– Avoid adding ephemeral nodes to Chef server
• Faux Chef environment “CHEFDEV”
– JSON for real environments is reserved
• Tag EC2 instances for traceability
• Troubleshoot by running Test Kitchen from
workstation
Jenkins User Conference Boston #jenkinsconf
Cookbook Release Job
• Triggered manually
• Runs same tests as CI job
• Uploads new cookbook version to Chef
server
• Tags Git repo
Jenkins User Conference Boston #jenkinsconf
APPLICATION DEPLOYMENT
Jenkins User Conference Boston #jenkinsconf
Application Deploy Process
Jenkins User Conference Boston #jenkinsconf
Jenkins Deploy Server
• Separate master for deploys
• Slaves
– Ruby with required gems
– Chef with credentials for Chef server
– SSH keys for nodes
Jenkins User Conference Boston #jenkinsconf
Deploy Job Types
• Each app group has two deploy jobs
– DEV deploy for Development
– Non-DEV deploy for Operations
– Will provide more flavors over time
• Job parameters
– Environment (non-DEV jobs only)
– Application group version
Jenkins User Conference Boston #jenkinsconf
What Does a Deployer Do?
• Makes configuration changes
– Edits application data bag item
– Edits environment file (if necessary)
– Merges code
• Executes job in Jenkins
Jenkins User Conference Boston #jenkinsconf
Example Deploy Job Run
• Deployer enters parameters
– Application version = 1.4.9
– Environment = TEST
• Then automation takes over
– Confirms my_app data bag has TEST version 1.4.9
– Uploads TEST environment file and my_app data
bag item for TEST to Chef server
– Finds all nodes in TEST environment with run list
containing my_app recipes
– Runs Chef client on each found node
– Sends email notification
Jenkins User Conference Boston #jenkinsconf
Push-Button Deploys
Jenkins User Conference Boston #jenkinsconf
Deploy History
Jenkins User Conference Boston #jenkinsconf
WRAP UP
Jenkins User Conference Boston #jenkinsconf
Most Important Advice
• Beware of overly prescriptive “lessons
learned” and “best practices”
• Synthesize a solution for your context
• That said…
Jenkins User Conference Boston #jenkinsconf
Principles & Guidelines (1)
• Standardize wherever possible
– Technology, design, process
– Achieve economies of scale
– Exceptions are permissible but rare
• Every tool must have an API
– Avoid “hitting the wall” down the road
– Tradeoff some out-of-the-box capabilities
Jenkins User Conference Boston #jenkinsconf
Principles & Guidelines (2)
• Use multiple communication paths
– All-hands presentations
– Kickoff meetings with each team
– Developer walkthroughs
– Documentation
• Be opportunistic
– Find and nurture your early adopters
Jenkins User Conference Boston #jenkinsconf
Principles & Guidelines (3)
• Balance process and progress
– Must provide tangible results
– And also build foundation for future
– Just like with application development!
• Start with a big pain point
– Providing relief builds credibility going forward
– Hopefully recoups bandwidth to reinvest
Jenkins User Conference Boston #jenkinsconf
“When Will You Be Done?”
• DONE is a dangerous word
– Business won’t stop evolving
– Neither will the supporting applications
– Nor should the supporting infrastructure
• X is a journey, not a destination
– For many values of X
• Deployment automation
• Continuous delivery
• DevOps
Jenkins User Conference Boston #jenkinsconf
Thank You
• Copyright Clearance Center
Engineering Team
• Jenkins User Conference
Organizers and Sponsors
Jenkins User Conference Boston #jenkinsconf
Resources
• “Infrastructure in the Cloud Era”
Adam Jacob and Ezra Zygmuntowicz
http://www.slideshare.net/adamhjk/infrastructure-in-the-cloud-era
http://www.youtube.com/watch?v=HaABapTwQ2c
• Chef cookbook versioning policy
http://chef-community.github.io/cvp/
Jenkins User Conference Boston #jenkinsconf
Thank You To Our Sponsors
Platinum Gold
Silver

More Related Content

What's hot

Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWSAutomated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
Bamdad Dashtban
 
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Simplilearn
 

What's hot (20)

Infrastructure Automation with Chef
Infrastructure Automation with ChefInfrastructure Automation with Chef
Infrastructure Automation with Chef
 
Azure handsonlab
Azure handsonlabAzure handsonlab
Azure handsonlab
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and You
 
AWS Meetup - Sydney - February
AWS Meetup - Sydney - February AWS Meetup - Sydney - February
AWS Meetup - Sydney - February
 
Server Installation and Configuration with Chef
Server Installation and Configuration with ChefServer Installation and Configuration with Chef
Server Installation and Configuration with Chef
 
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWSAutomated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
 
Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with Chef
 
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and Docker
 
Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1
 
Learning chef
Learning chefLearning chef
Learning chef
 
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
 
Introduction to chef
Introduction to chefIntroduction to chef
Introduction to chef
 
Building Jenkins Pipelines at Scale
Building Jenkins Pipelines at ScaleBuilding Jenkins Pipelines at Scale
Building Jenkins Pipelines at Scale
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbook
 
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation Workshop
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
The unintended benefits of Chef
The unintended benefits of ChefThe unintended benefits of Chef
The unintended benefits of Chef
 
Chef Workflow Demo
Chef Workflow DemoChef Workflow Demo
Chef Workflow Demo
 

Similar to Jenkins and Chef: Infrastructure CI and Automated Deployment

Brian Jones Resume-2016-06-2p
Brian Jones Resume-2016-06-2pBrian Jones Resume-2016-06-2p
Brian Jones Resume-2016-06-2p
Brian Jones
 
Continuous deployment steve povilaitis
Continuous deployment   steve povilaitisContinuous deployment   steve povilaitis
Continuous deployment steve povilaitis
Steve Povilaitis
 
Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for Openstack
Mohit Sethi
 
Ankit Chohan - Java
Ankit Chohan - JavaAnkit Chohan - Java
Ankit Chohan - Java
Ankit Chohan
 

Similar to Jenkins and Chef: Infrastructure CI and Automated Deployment (20)

DOO-009_Powering High Velocity Development for your Infrastructure
DOO-009_Powering High Velocity Development for your InfrastructureDOO-009_Powering High Velocity Development for your Infrastructure
DOO-009_Powering High Velocity Development for your Infrastructure
 
Chef
ChefChef
Chef
 
Priming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the CloudPriming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the Cloud
 
Jenkins as a Service - Code all the way down
Jenkins as a Service - Code all the way downJenkins as a Service - Code all the way down
Jenkins as a Service - Code all the way down
 
Jenkins-CI
Jenkins-CIJenkins-CI
Jenkins-CI
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 
Brian Jones Resume-2016-06-2p
Brian Jones Resume-2016-06-2pBrian Jones Resume-2016-06-2p
Brian Jones Resume-2016-06-2p
 
CHEF - by Scott Russel
CHEF - by Scott RusselCHEF - by Scott Russel
CHEF - by Scott Russel
 
Juc boston2014.pptx
Juc boston2014.pptxJuc boston2014.pptx
Juc boston2014.pptx
 
Chef at EIS
Chef at EISChef at EIS
Chef at EIS
 
Continuous Integration for OpenVMS with Jenkins
Continuous Integration for OpenVMS with JenkinsContinuous Integration for OpenVMS with Jenkins
Continuous Integration for OpenVMS with Jenkins
 
JUC Europe 2015: From Virtual Machines to Containers: Achieving Continuous In...
JUC Europe 2015: From Virtual Machines to Containers: Achieving Continuous In...JUC Europe 2015: From Virtual Machines to Containers: Achieving Continuous In...
JUC Europe 2015: From Virtual Machines to Containers: Achieving Continuous In...
 
From Virtual Machines to Containers
From Virtual Machines to ContainersFrom Virtual Machines to Containers
From Virtual Machines to Containers
 
Configuration As Code: The Job DSL Plugin
Configuration As Code: The Job DSL PluginConfiguration As Code: The Job DSL Plugin
Configuration As Code: The Job DSL Plugin
 
Continuous deployment steve povilaitis
Continuous deployment   steve povilaitisContinuous deployment   steve povilaitis
Continuous deployment steve povilaitis
 
2015 08-11-scdo-meetup
2015 08-11-scdo-meetup2015 08-11-scdo-meetup
2015 08-11-scdo-meetup
 
Jenkins pipeline as code
Jenkins pipeline as codeJenkins pipeline as code
Jenkins pipeline as code
 
Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for Openstack
 
A Bit of Everything Chef
A Bit of Everything ChefA Bit of Everything Chef
A Bit of Everything Chef
 
Ankit Chohan - Java
Ankit Chohan - JavaAnkit Chohan - Java
Ankit Chohan - Java
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Jenkins and Chef: Infrastructure CI and Automated Deployment

  • 1. Jenkins User Conference Boston #jenkinsconf Jenkins and Chef Infrastructure CI and Application Deployment Dan Stine Copyright Clearance Center www.copyright.com June 18, 2014 #jenkinsconf
  • 2. Jenkins User Conference Boston #jenkinsconf About Me Software Architect Library & Framework Developer Infrastructure Lead & Product Owner Enemy of Inefficiency and Needless Inconsistency dstine at copyright.com sw at stinemail.com github.com/dstine
  • 3. Jenkins User Conference Boston #jenkinsconf About Copyright Clearance Center Global licensing solutions that make © work for everyone – Get, share, and manage content – Rights broker for world’s most sought after materials – Global company (US, Europe, Asia) – HQ in Danvers, MA Industry-specific software systems – Internal and external user base – Applications, services, databases – Organic growth over many years In 2011, CCC adopted a Product Platform strategy for growing its software portfolio
  • 4. Jenkins User Conference Boston #jenkinsconf Agenda • Context • Primer • Deployment Process Design • Cookbook Builds • Application Deployment • Wrap Up
  • 5. Jenkins User Conference Boston #jenkinsconf CONTEXT
  • 6. Jenkins User Conference Boston #jenkinsconf Standard Software Platform • Started platform definition in 2011 – Homogeneous by default • Tools – Java, Spring, Tomcat, Postgres – Git/GitHub, Gradle, Jenkins, Artifactory, Liquibase • Process – Standard development workflow – Standard application shape & operational profile
  • 7. Jenkins User Conference Boston #jenkinsconf Initial Delivery Pipeline “Don”
  • 8. Jenkins User Conference Boston #jenkinsconf Initial Delivery Pipeline • Automated build process • Publish build artifacts to Artifactory – Application WARs – Liquibase JARs • Manual deploys – (Many apps) x (many versions) x (multiple environments) = TIME & EFFORT – The more frequently a task is performed, the greater the return from improved efficiency
  • 9. Jenkins User Conference Boston #jenkinsconf Improved Deployment Process • Goals – Reduce effort – Improve speed, reliability, and frequency – Handle app deploys and db schema updates – Enable self-service • Process Changes – Manual  Automated – Prose instructions  Infrastructure as code
  • 10. Jenkins User Conference Boston #jenkinsconf Target Delivery Pipeline
  • 11. Jenkins User Conference Boston #jenkinsconf PRIMER
  • 12. Jenkins User Conference Boston #jenkinsconf Layers of System Management • Orchestration – Processes collaborating in a distributed system • Configuration – Install and configure packages and software • Provisioning – Hypervisor (VMware, EC2)
  • 13. Jenkins User Conference Boston #jenkinsconf Infrastructure as Code • Develop and manage software infrastructure with practices similar to those used to develop software applications • Examples – Source Code – Modularity – Abstraction – Testing
  • 14. Jenkins User Conference Boston #jenkinsconf Configuration Management “Process for establishing and maintaining consistency of a product’s performance, functional and physical attributes with its requirements, design and operational information throughout its life” (wikipedia) • CM tools for managing software systems – CFEngine, Puppet, Chef, Salt, Ansible • Embody Infrastructure as Code principles • Define desired state of machine – Each run inspects state and makes necessary changes, if any
  • 15. Jenkins User Conference Boston #jenkinsconf Chef • Configuration management tool • Exposes DSL hosted in Ruby – Express “what” not “how” – Clean, purposeful capture of intent • Favor DSL when writing code – Ruby is available, if required
  • 16. Jenkins User Conference Boston #jenkinsconf Chef Terminology (1) • Chef client is installed on nodes (machines) which are registered with the Chef server • Developers write code on workstations and use tools such as knife to interact with server • Chef models node configuration as a set of DSL resources (e.g. package, service, directory) which are mapped to internal providers (actual code to execute) – Can define custom resources
  • 17. Jenkins User Conference Boston #jenkinsconf Example Chef Code This resource declaration directory '/a/b/c' do owner 'admin' group 'admin mode '0755' action :create recursive true end ensures that $ ls -ld /a/b/c drwxr-xr-x. 5 admin admin 4096 Feb 14 11:22 /a/b/c
  • 18. Jenkins User Conference Boston #jenkinsconf Chef Terminology (2) • A recipe declares a set of resources with desired configuration • A cookbook contains a set of semantically- related code and is the fundamental unit of distribution for Chef code – Compare to JAR for Java code • A data bag holds JSON information in one or more data bag items accessible from Chef code • Chef environments model deployed environments • Each node has a run list containing recipes
  • 19. Jenkins User Conference Boston #jenkinsconf DEPLOYMENT PROCESS DESIGN
  • 20. Jenkins User Conference Boston #jenkinsconf Basic Approach • Deploy custom applications with Chef • Execute schema updates with Liquibase • Coordinate everything with:
  • 21. Jenkins User Conference Boston #jenkinsconf Jenkins as Coordinator • General purpose job executor – Shell script steps for Chef API – Gradle steps for Liquibase updates – Arbitrary code at any point in lifecycle • UI – Smooth integration with Active Directory – Authentication and authorization • Administration – Familiar with Jenkins from application build jobs
  • 22. Jenkins User Conference Boston #jenkinsconf CCC Application Group • Set of deployable units that are versioned and released together • For example, a group might have – UI – REST service – Message consumer – DB • Build with a single command • Deploy with a single command
  • 23. Jenkins User Conference Boston #jenkinsconf Technical Design Goals • Provide clean API – Specify only essential differences between apps – Custom Chef resource is the interface – Codify & enforce standards • Balance consistency & flexibility – Code in semantically-versioned cookbooks – Configuration in data bags • Controlled cookbook promotion – Chef environment specifies cookbook version constraint
  • 24. Jenkins User Conference Boston #jenkinsconf Cookbook Types • Library Cookbooks – Encapsulate common re-usable logic – Define custom resource to install an app • And the implementing provider • Application Cookbooks – Depend on library cookbooks – One cookbook per application group • One recipe per application • Recipes use custom resource – Lightweight
  • 25. Jenkins User Conference Boston #jenkinsconf Data Bags • Contain application configuration – Service endpoints, JAVA_OPTS, etc. • One data bag per application group – One data bag item per environment • “Live” reflection of deployed configuration – Edit  push to Chef server  deploy – Master always matches state of Chef server
  • 26. Jenkins User Conference Boston #jenkinsconf Custom Resource Usage Ensure my-app-ui WAR is deployed: ccc_webapp "my-app-ui" do provider :ccc_webapp artifact_group 'com.copyright.myapp' artifact 'my-app-ui' container 'MY-APP-UI' http_port '8080' shutdown_port '8900' properties_template 'ccc.properties.erb' app_group_data_bag 'my_app' end
  • 27. Jenkins User Conference Boston #jenkinsconf Custom Resource Actions • Retrieves Java, Tomcat & WAR from Artifactory • Installs Java and Tomcat in standard locations • Creates and configures Tomcat container • Installs WAR in the container • Opens port in host firewall • Generates application properties file • Starts container (Each action taken only if necessary)
  • 28. Jenkins User Conference Boston #jenkinsconf Data Bag Structure data_bags/my_app/DEV.json (data bag item) "version": "1.4.9", "runtime": { "my-app-ui": { "java_opts": "-Xmx2G -XX:MaxPermSize=1024m" } }, "app_config": { "db.url": "jdbc:postgresql://devdb:5432/myapp", "svc.foo.url": "http://devsvc:9000/foo" } data_bags/my_app/TEST.json ... data_bags/my_app/PROD.json
  • 29. Jenkins User Conference Boston #jenkinsconf Cookbook Data Bag Code * ccc/providers/webapp.rb (library cookbook) app_group_data = data_bag_item(app_group_data_bag, node.chef_environment) java_opts = app_group_data['runtime'][artifact]['java_opts'] // pass java_opts to Tomcat container app_config = app_group_data['app_config'] // pass app_config to template resource declaration my_app/templates/ccc.properties.erb (application cookbook) db.url=<%= @app_config['db.url'] %> svc.foo.url=<%= @app_config['svc.foo.url'] %> * Included for future reference
  • 30. Jenkins User Conference Boston #jenkinsconf Roles • Deployers – Update data bags & environment files – Initiate deployments • Tech leads – Maintain application cookbooks • Framework developers – Maintain library cookbooks – Maintain framework – Process improvement
  • 31. Jenkins User Conference Boston #jenkinsconf COOKBOOK BUILDS
  • 32. Jenkins User Conference Boston #jenkinsconf Cookbook Build Process
  • 33. Jenkins User Conference Boston #jenkinsconf Jenkins Build Server • For each application group – Cookbook CI job – Cookbook release job – Same master as application build jobs • New class of slaves – Ruby with required gems – Chef with credentials for Chef server – EC2 credentials to create test nodes
  • 34. Jenkins User Conference Boston #jenkinsconf Cookbook CI Job • Triggered when new Chef code is merged • Static analysis – JSON syntax (json gem) – Ruby syntax and style (Tailor) – Chef syntax (Knife) – Chef style and correctness (Foodcritic) • Integration testing – Test Kitchen with kitchen-ec2 plugin
  • 35. Jenkins User Conference Boston #jenkinsconf Integration Testing Lifecycle • Spin up EC2 instance(s) to mimic actual deployment topology of application group • Run Chef on each instance (node) • Execute asserts – pass or fail • Dispose of instance(s)
  • 36. Jenkins User Conference Boston #jenkinsconf Integration Testing Details • Instances created from AMI – Preconfigured with Ruby and Chef • Using Chef Solo – Avoid adding ephemeral nodes to Chef server • Faux Chef environment “CHEFDEV” – JSON for real environments is reserved • Tag EC2 instances for traceability • Troubleshoot by running Test Kitchen from workstation
  • 37. Jenkins User Conference Boston #jenkinsconf Cookbook Release Job • Triggered manually • Runs same tests as CI job • Uploads new cookbook version to Chef server • Tags Git repo
  • 38. Jenkins User Conference Boston #jenkinsconf APPLICATION DEPLOYMENT
  • 39. Jenkins User Conference Boston #jenkinsconf Application Deploy Process
  • 40. Jenkins User Conference Boston #jenkinsconf Jenkins Deploy Server • Separate master for deploys • Slaves – Ruby with required gems – Chef with credentials for Chef server – SSH keys for nodes
  • 41. Jenkins User Conference Boston #jenkinsconf Deploy Job Types • Each app group has two deploy jobs – DEV deploy for Development – Non-DEV deploy for Operations – Will provide more flavors over time • Job parameters – Environment (non-DEV jobs only) – Application group version
  • 42. Jenkins User Conference Boston #jenkinsconf What Does a Deployer Do? • Makes configuration changes – Edits application data bag item – Edits environment file (if necessary) – Merges code • Executes job in Jenkins
  • 43. Jenkins User Conference Boston #jenkinsconf Example Deploy Job Run • Deployer enters parameters – Application version = 1.4.9 – Environment = TEST • Then automation takes over – Confirms my_app data bag has TEST version 1.4.9 – Uploads TEST environment file and my_app data bag item for TEST to Chef server – Finds all nodes in TEST environment with run list containing my_app recipes – Runs Chef client on each found node – Sends email notification
  • 44. Jenkins User Conference Boston #jenkinsconf Push-Button Deploys
  • 45. Jenkins User Conference Boston #jenkinsconf Deploy History
  • 46. Jenkins User Conference Boston #jenkinsconf WRAP UP
  • 47. Jenkins User Conference Boston #jenkinsconf Most Important Advice • Beware of overly prescriptive “lessons learned” and “best practices” • Synthesize a solution for your context • That said…
  • 48. Jenkins User Conference Boston #jenkinsconf Principles & Guidelines (1) • Standardize wherever possible – Technology, design, process – Achieve economies of scale – Exceptions are permissible but rare • Every tool must have an API – Avoid “hitting the wall” down the road – Tradeoff some out-of-the-box capabilities
  • 49. Jenkins User Conference Boston #jenkinsconf Principles & Guidelines (2) • Use multiple communication paths – All-hands presentations – Kickoff meetings with each team – Developer walkthroughs – Documentation • Be opportunistic – Find and nurture your early adopters
  • 50. Jenkins User Conference Boston #jenkinsconf Principles & Guidelines (3) • Balance process and progress – Must provide tangible results – And also build foundation for future – Just like with application development! • Start with a big pain point – Providing relief builds credibility going forward – Hopefully recoups bandwidth to reinvest
  • 51. Jenkins User Conference Boston #jenkinsconf “When Will You Be Done?” • DONE is a dangerous word – Business won’t stop evolving – Neither will the supporting applications – Nor should the supporting infrastructure • X is a journey, not a destination – For many values of X • Deployment automation • Continuous delivery • DevOps
  • 52. Jenkins User Conference Boston #jenkinsconf Thank You • Copyright Clearance Center Engineering Team • Jenkins User Conference Organizers and Sponsors
  • 53. Jenkins User Conference Boston #jenkinsconf Resources • “Infrastructure in the Cloud Era” Adam Jacob and Ezra Zygmuntowicz http://www.slideshare.net/adamhjk/infrastructure-in-the-cloud-era http://www.youtube.com/watch?v=HaABapTwQ2c • Chef cookbook versioning policy http://chef-community.github.io/cvp/
  • 54. Jenkins User Conference Boston #jenkinsconf Thank You To Our Sponsors Platinum Gold Silver

Editor's Notes

  1. Exceptions are possible but rare Just as sampling – many other technologies and standards and libraries and tools (project management) and processes This presentation is a point-in-time-report
  2. Java tech lead first comment: now the “UI guy” can do deploys
  3. Everyone at this conference is familiar with Jenkins May be less familiar with Chef, and we’ll be talking about it a lot, so here is a whirlwind introduction
  4. No mkdir command & flags
  5. There is a lot more to Chef – we covered the very basics
  6. More and more people will / must learn Jenkins and Chef at some level
  7. Compare to Java tools such as Checkstyle and FindBugs