SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
chef@recordedfuture
Ulf Månsson, infra coder
@ulfmansson
DevOps - CAMS

●

Break the silos

●

Culture

●

Automation

●

Measurement

●

Sharing
Why automation and configuration management
●

Quality

●

Continuous delivery, deploy many times per day

●

Deployment by developers

●

Everything is documented as it has been created by code

●

No single point of knowledge, human redundancy

●

Working in a global team
Process driven
●

Don't document

●

Don't train people in processes

Automate and build the
processes into our tools
Lower uptime
●

We are aiming for lowering uptime to 1-2
weeks per server

●

Use and throw

●

Never patch

●

Deploy often - every day

●

Green-blue deployment

●

Running on latest version of OS and
components
How?
●

Automated infrastructure

●

Shared version control - one system!

●

One step build and deploy

●

Green - Blue deployment

●

Feature flags

●

Metrics and metrics
What to automate - everything!
●

Provisioning

●

Deployment and configuration

●

Metrics

●

Monitoring

●

Scaling & up and down

●

Build process - continuous delivery

●

Log handling

●

Obscure host names

●

Never login to a server
Standardize on Ruby as lingua franca
One language for everything ops are doing!
●

Scripting in Ruby

●

Configuration management in Ruby

●

Operation applications in Ruby

●

System tools in Ruby

●

Add-on applications in Ruby

●

Application integration in Ruby
Why Ruby?

●

We like Ruby

●

Used by Chef

●

Easy to script

●

Object oriented and functional

●

Lot of good libs - gems

●

Great community - “Matz is nice so we are nice”

●

Reuse of the same gem both in Chef, system tools and
applications
What do we do with Chef?
●

Provision EC2 instances

●

Deploy packages

●

Deploy our own code

●

Deploy configurations

●

Deploy metrics

●

Update metrics

●

Collect data

●

Deploy monitoring configurations

●

Deploy users

●

Create databases

●

Provision vagrant instances

●

Local installations for customers
Chef recipe
app_name = 'xignite'
dir_inst = File.join(node['rf']['inst_dir'], app_name)
dir_conf = File.join(dir_inst, 'conf')
dir_log = File.join(node['rf']['log_dir'], app_name)

[dir_inst, dir_conf, dir_log].each do |dir|
directory dir do
recursive true
action :create
end
end

deploy_repodist app_name do
dir_inst_root dir_inst
action :deploy
end
Code
All code is code
Keep the code in the same repository

Treat all code in the same way, it doesn’t matter if it’s
application code, infra code, test code or whatever
Wrapper cookbooks
Use community cookbooks!

Wrap community cookbooks!

Cookbook elasticsearch_rf → elasticsearch
In elasticserch_rf/recipes/default.rb:
include_recipe "elasticsearch::default"

Chef rewind to override resources in original cookbooks
Use LWRP - Light Weight Resource Providers
●

Create your own providers

●

Abstraction

●

Cleaner code

●

Easier to use

●

Better error handling

deploy_build “ha_document_analyzer” do
      action :deploy
end
Search & Node data
●

●

●

Use search to populate with data during Chef run, find
servers with specific roles
Use node data collected by ohai in recipes, for example
about memory, aws instance, ip addresses etc
Gives a good overview of your infrastructure
Lint tools – to check the code
●

Use foodcritic

●

By default all rules are enabled

●

Consider to use Ruby lint tools
–

Rubocop

–

Laser

–

ruby-lint

$ foodcritic  app_sinatra_rf
FC019: Access node attributes in a consistent manner: ./providers/web_app.rb:87
FC048: Prefer Mixlib::ShellOut: ./recipes/nginx.rb:38
Manage cookbooks
●

To manage cookbooks and dependency use tool like
librarian-chef or berkshelf

●

Like bundler and maven

●

Separate your own cookbooks from community cookbooks

chef/
community_cookbooks
databags
forked_cookbooks
rf_cookbooks
roles
Orchestration
●

We use mcollective

●

RabbitMQ for messaging

●

Stable

●

Not for puppet only, fits well to Chef

mco service cluster_reindexer restart ­C role.Cluster_aggregator
Testing of Chef
●

Test kitchen!
–

kitchen test lxc

–

kitchen converge lxc

–

kitchen login lxc

●

Server spec isolated tests via Test kitchen

●

Chef spec, quick unit tests

●

Create test cookbooks with the test data
and preparation recipes

Use vagrant (lxc) for testing

.
|-attributes
|-files
|-libraries
|-providers
|-recipes
|-resources
|-templates
|-test
|---cookbooks
|-----app_java_rf_test
|-------attributes
|-------libraries
|-------recipes
|-------templates
|---integration
|-----data_bags
|-------rfapps
|-------rfconf
|-----default
|-------serverspec
|---------localhost
Roles
●

Keep roles simple, just include a recipe

●

Don't put a lot of attributes in roles

●

When using search, search for roles

●

Just roles to show what running on the server
Treat your servers as cattle not as cows

●

Autoscale

●

Make logs available

●

Make it hard to login

●

Use obscure server names

●

Make it easy to launch an instance

●

Make process manipulation easy

●

Run Chef every 30 minute or so

●

Use Chef server to collect info and query
bygge shows the jenkins build pipeline
Read more
●

Continuous delivery by Jez Humble

●

Test-Driven Infrastructure with Chef

●

Chef Infrastructure Automation Cookbook

●

#opschef

Contenu connexe

Tendances

Augmented Reality For Processing
Augmented Reality For ProcessingAugmented Reality For Processing
Augmented Reality For Processing
pau_figuerasr
 

Tendances (20)

SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web ScaleSaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
 
Redundant devops
Redundant devopsRedundant devops
Redundant devops
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
Serverspec and Sensu - Testing and Monitoring collide
Serverspec and Sensu - Testing and Monitoring collideServerspec and Sensu - Testing and Monitoring collide
Serverspec and Sensu - Testing and Monitoring collide
 
All of the thing about Postman
All of the thing about PostmanAll of the thing about Postman
All of the thing about Postman
 
Augmented Reality For Processing
Augmented Reality For ProcessingAugmented Reality For Processing
Augmented Reality For Processing
 
Configuration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needsConfiguration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needs
 
Using SaltStack to DevOps the enterprise
Using SaltStack to DevOps the enterpriseUsing SaltStack to DevOps the enterprise
Using SaltStack to DevOps the enterprise
 
Chef ignited a DevOps revolution – BK Box
Chef ignited a DevOps revolution – BK BoxChef ignited a DevOps revolution – BK Box
Chef ignited a DevOps revolution – BK Box
 
SaltConf2015: SaltStack at Scale Automating Your Automation
SaltConf2015: SaltStack at Scale Automating Your AutomationSaltConf2015: SaltStack at Scale Automating Your Automation
SaltConf2015: SaltStack at Scale Automating Your Automation
 
Incremental steps -- Lighting Talk
Incremental steps -- Lighting TalkIncremental steps -- Lighting Talk
Incremental steps -- Lighting Talk
 
Infrastructure as Code with Chef
Infrastructure as Code with ChefInfrastructure as Code with Chef
Infrastructure as Code with Chef
 
Armada - the way to ship microservices
Armada - the way to ship microservicesArmada - the way to ship microservices
Armada - the way to ship microservices
 
Arch9 - A cloud based continuous delivery implementation
Arch9 - A cloud based continuous delivery implementationArch9 - A cloud based continuous delivery implementation
Arch9 - A cloud based continuous delivery implementation
 
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
 
Effective version control
Effective version controlEffective version control
Effective version control
 
The Art and Zen of Managing Nagios With Puppet
The Art and Zen of Managing Nagios With PuppetThe Art and Zen of Managing Nagios With Puppet
The Art and Zen of Managing Nagios With Puppet
 
Saltconf16 william-cannon b
Saltconf16 william-cannon bSaltconf16 william-cannon b
Saltconf16 william-cannon b
 
Continuous Integration at Mollie
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Mollie
 
Safe deployments with Blue-Green and Spinnaker
Safe deployments with Blue-Green and SpinnakerSafe deployments with Blue-Green and Spinnaker
Safe deployments with Blue-Green and Spinnaker
 

En vedette

IntSight Demo Chemicals
IntSight Demo ChemicalsIntSight Demo Chemicals
IntSight Demo Chemicals
Facebook
 
Anti israel hackers parastoo prepare for op israel anniversary - www-recorded...
Anti israel hackers parastoo prepare for op israel anniversary - www-recorded...Anti israel hackers parastoo prepare for op israel anniversary - www-recorded...
Anti israel hackers parastoo prepare for op israel anniversary - www-recorded...
BaddddBoyyyy
 
слайдшара
слайдшараслайдшара
слайдшара
borovkovatg
 

En vedette (20)

Securing your Rails application
Securing your Rails applicationSecuring your Rails application
Securing your Rails application
 
Mobile SCADA
Mobile SCADAMobile SCADA
Mobile SCADA
 
Измеряйте эффективность маркетинга и PR в соцмедиа с YouScan - trial 30 дней
Измеряйте эффективность маркетинга и PR в соцмедиа с YouScan - trial 30 днейИзмеряйте эффективность маркетинга и PR в соцмедиа с YouScan - trial 30 дней
Измеряйте эффективность маркетинга и PR в соцмедиа с YouScan - trial 30 дней
 
Listen to Russian consumers in social media with YouScan
Listen to Russian consumers in social media with YouScanListen to Russian consumers in social media with YouScan
Listen to Russian consumers in social media with YouScan
 
IntSight Demo Chemicals
IntSight Demo ChemicalsIntSight Demo Chemicals
IntSight Demo Chemicals
 
Sensecy cti vs cti
Sensecy cti vs cti Sensecy cti vs cti
Sensecy cti vs cti
 
Gigamon U - Eye Of The Fire, Network Malware Control System
Gigamon U - Eye Of The Fire, Network Malware Control SystemGigamon U - Eye Of The Fire, Network Malware Control System
Gigamon U - Eye Of The Fire, Network Malware Control System
 
FireEye Engineering
FireEye Engineering FireEye Engineering
FireEye Engineering
 
Startup Engineering Flashpoint Batch 3 Better Startups Faster
Startup Engineering   Flashpoint Batch 3   Better Startups FasterStartup Engineering   Flashpoint Batch 3   Better Startups Faster
Startup Engineering Flashpoint Batch 3 Better Startups Faster
 
Anti israel hackers parastoo prepare for op israel anniversary - www-recorded...
Anti israel hackers parastoo prepare for op israel anniversary - www-recorded...Anti israel hackers parastoo prepare for op israel anniversary - www-recorded...
Anti israel hackers parastoo prepare for op israel anniversary - www-recorded...
 
Медиалогия медиаменеджер 2016
Медиалогия медиаменеджер 2016Медиалогия медиаменеджер 2016
Медиалогия медиаменеджер 2016
 
Каталог номинантов Премии «Медиа-Менеджер России – 2016»
Каталог номинантов Премии «Медиа-Менеджер России – 2016»Каталог номинантов Премии «Медиа-Менеджер России – 2016»
Каталог номинантов Премии «Медиа-Менеджер России – 2016»
 
FireEye
FireEyeFireEye
FireEye
 
Shocking Sharks: How Much Do You Know?
Shocking Sharks: How Much Do You Know?Shocking Sharks: How Much Do You Know?
Shocking Sharks: How Much Do You Know?
 
Reputation in the Digital Age
Reputation in the Digital AgeReputation in the Digital Age
Reputation in the Digital Age
 
BIW15: Python in the Cloud: Django and Flaks
BIW15: Python in the Cloud: Django and FlaksBIW15: Python in the Cloud: Django and Flaks
BIW15: Python in the Cloud: Django and Flaks
 
FireEye Use Cases — FireEye Solution Deployment Experience
FireEye Use Cases — FireEye Solution Deployment ExperienceFireEye Use Cases — FireEye Solution Deployment Experience
FireEye Use Cases — FireEye Solution Deployment Experience
 
Docker London: Container Security
Docker London: Container SecurityDocker London: Container Security
Docker London: Container Security
 
The Dark web - Why the hidden part of the web is even more dangerous?
The Dark web - Why the hidden part of the web is even more dangerous?The Dark web - Why the hidden part of the web is even more dangerous?
The Dark web - Why the hidden part of the web is even more dangerous?
 
слайдшара
слайдшараслайдшара
слайдшара
 

Similaire à Chef@recordedfuture

Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for Openstack
Mohit Sethi
 

Similaire à Chef@recordedfuture (20)

DevOps and Chef improve your life
DevOps and Chef improve your life DevOps and Chef improve your life
DevOps and Chef improve your life
 
Building a PaaS using Chef
Building a PaaS using ChefBuilding a PaaS using Chef
Building a PaaS using Chef
 
Dev ops
Dev opsDev ops
Dev ops
 
Habitat Managed Chef
Habitat Managed ChefHabitat Managed Chef
Habitat Managed Chef
 
Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for Openstack
 
Chef - Administration for programmers
Chef - Administration for programmersChef - Administration for programmers
Chef - Administration for programmers
 
Chef for openstack
Chef for openstackChef for openstack
Chef for openstack
 
TechWiseTV Workshop: Open NX-OS and Devops with Puppet Labs
TechWiseTV Workshop: Open NX-OS and Devops with Puppet LabsTechWiseTV Workshop: Open NX-OS and Devops with Puppet Labs
TechWiseTV Workshop: Open NX-OS and Devops with Puppet Labs
 
DevOps Roadmap.pptx
DevOps Roadmap.pptxDevOps Roadmap.pptx
DevOps Roadmap.pptx
 
Devops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftDevops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShift
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef Automate
 
Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack Summit
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
Guider: An Integrated Runtime Performance Analyzer on AGL
Guider: An Integrated Runtime Performance Analyzer on AGLGuider: An Integrated Runtime Performance Analyzer on AGL
Guider: An Integrated Runtime Performance Analyzer on AGL
 
What is Chef and how we use it at tripsta
What is Chef and how we use it at tripstaWhat is Chef and how we use it at tripsta
What is Chef and how we use it at tripsta
 
Continuous delivery with open source tools
Continuous delivery with open source toolsContinuous delivery with open source tools
Continuous delivery with open source tools
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production Parity
 
Learning chef
Learning chefLearning chef
Learning chef
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
 
Chef vs puppet
Chef vs puppetChef vs puppet
Chef vs puppet
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Chef@recordedfuture

  • 2.
  • 3. DevOps - CAMS ● Break the silos ● Culture ● Automation ● Measurement ● Sharing
  • 4. Why automation and configuration management ● Quality ● Continuous delivery, deploy many times per day ● Deployment by developers ● Everything is documented as it has been created by code ● No single point of knowledge, human redundancy ● Working in a global team
  • 5. Process driven ● Don't document ● Don't train people in processes Automate and build the processes into our tools
  • 6. Lower uptime ● We are aiming for lowering uptime to 1-2 weeks per server ● Use and throw ● Never patch ● Deploy often - every day ● Green-blue deployment ● Running on latest version of OS and components
  • 7. How? ● Automated infrastructure ● Shared version control - one system! ● One step build and deploy ● Green - Blue deployment ● Feature flags ● Metrics and metrics
  • 8. What to automate - everything! ● Provisioning ● Deployment and configuration ● Metrics ● Monitoring ● Scaling & up and down ● Build process - continuous delivery ● Log handling ● Obscure host names ● Never login to a server
  • 9. Standardize on Ruby as lingua franca One language for everything ops are doing! ● Scripting in Ruby ● Configuration management in Ruby ● Operation applications in Ruby ● System tools in Ruby ● Add-on applications in Ruby ● Application integration in Ruby
  • 10. Why Ruby? ● We like Ruby ● Used by Chef ● Easy to script ● Object oriented and functional ● Lot of good libs - gems ● Great community - “Matz is nice so we are nice” ● Reuse of the same gem both in Chef, system tools and applications
  • 11. What do we do with Chef? ● Provision EC2 instances ● Deploy packages ● Deploy our own code ● Deploy configurations ● Deploy metrics ● Update metrics ● Collect data ● Deploy monitoring configurations ● Deploy users ● Create databases ● Provision vagrant instances ● Local installations for customers
  • 12. Chef recipe app_name = 'xignite' dir_inst = File.join(node['rf']['inst_dir'], app_name) dir_conf = File.join(dir_inst, 'conf') dir_log = File.join(node['rf']['log_dir'], app_name) [dir_inst, dir_conf, dir_log].each do |dir| directory dir do recursive true action :create end end deploy_repodist app_name do dir_inst_root dir_inst action :deploy end
  • 13. Code All code is code Keep the code in the same repository Treat all code in the same way, it doesn’t matter if it’s application code, infra code, test code or whatever
  • 14. Wrapper cookbooks Use community cookbooks! Wrap community cookbooks! Cookbook elasticsearch_rf → elasticsearch In elasticserch_rf/recipes/default.rb: include_recipe "elasticsearch::default" Chef rewind to override resources in original cookbooks
  • 15. Use LWRP - Light Weight Resource Providers ● Create your own providers ● Abstraction ● Cleaner code ● Easier to use ● Better error handling deploy_build “ha_document_analyzer” do       action :deploy end
  • 16. Search & Node data ● ● ● Use search to populate with data during Chef run, find servers with specific roles Use node data collected by ohai in recipes, for example about memory, aws instance, ip addresses etc Gives a good overview of your infrastructure
  • 17. Lint tools – to check the code ● Use foodcritic ● By default all rules are enabled ● Consider to use Ruby lint tools – Rubocop – Laser – ruby-lint $ foodcritic  app_sinatra_rf FC019: Access node attributes in a consistent manner: ./providers/web_app.rb:87 FC048: Prefer Mixlib::ShellOut: ./recipes/nginx.rb:38
  • 18. Manage cookbooks ● To manage cookbooks and dependency use tool like librarian-chef or berkshelf ● Like bundler and maven ● Separate your own cookbooks from community cookbooks chef/ community_cookbooks databags forked_cookbooks rf_cookbooks roles
  • 19. Orchestration ● We use mcollective ● RabbitMQ for messaging ● Stable ● Not for puppet only, fits well to Chef mco service cluster_reindexer restart ­C role.Cluster_aggregator
  • 20. Testing of Chef ● Test kitchen! – kitchen test lxc – kitchen converge lxc – kitchen login lxc ● Server spec isolated tests via Test kitchen ● Chef spec, quick unit tests ● Create test cookbooks with the test data and preparation recipes Use vagrant (lxc) for testing . |-attributes |-files |-libraries |-providers |-recipes |-resources |-templates |-test |---cookbooks |-----app_java_rf_test |-------attributes |-------libraries |-------recipes |-------templates |---integration |-----data_bags |-------rfapps |-------rfconf |-----default |-------serverspec |---------localhost
  • 21. Roles ● Keep roles simple, just include a recipe ● Don't put a lot of attributes in roles ● When using search, search for roles ● Just roles to show what running on the server
  • 22. Treat your servers as cattle not as cows ● Autoscale ● Make logs available ● Make it hard to login ● Use obscure server names ● Make it easy to launch an instance ● Make process manipulation easy ● Run Chef every 30 minute or so ● Use Chef server to collect info and query
  • 23. bygge shows the jenkins build pipeline
  • 24. Read more ● Continuous delivery by Jez Humble ● Test-Driven Infrastructure with Chef ● Chef Infrastructure Automation Cookbook ● #opschef