SlideShare a Scribd company logo
Infrastructure modeling with chef
Modeling Infrastructure With Chef
Charles Johnson
• Product Engineer, Chef
• Career Sysadmin (~20 years)
• Opscode Chef Employee since 2012
• @chipadeedoodah
• charles@chef.io
Where Does Configuration Live?
Layers of Policy
Typical Boring Infrastructure
• Datacenter
(US-EAST)
Datacenter
Datacenter
Zone
Zone
Typical Boring Infrastructure
• Datacenter
(US-EAST)
• Zone / Shard / Replica
(US-EAST-1C)
Datacenter
Zone
Zone
Typical Boring Infrastructure
• Datacenter
(US-EAST)
• Zone / Shard / Replica
(US-EAST-1C)
• Logical / Lifecycle stage
(Dev/Stage/Prod)
Dev Stage Prod
Datacenter
Zone
Zone
Typical Boring Infrastructure
• Datacenter
(US-EAST)
• Zone / Shard / Replica
(US-EAST-1C)
• Logical / Lifecycle stage
(Dev/Stage/Prod)
• Hostgroup
(Web, App, Cache, DB, etc)
Dev Stage Prod
Web
App
Cache
DB
Web
App
Cache
DB
Web
App
Cache
DB
Datacenter
Zone
Zone
Typical Boring Infrastructure
• Datacenter
(US-EAST)
• Zone / Shard / Replica
(US-EAST-1C)
• Logical / Lifecycle stage
(Dev/Stage/Prod)
• Hostgroup
(Web, App, Cache, DB, etc)
• ... And one more place.
(Can you guess where?)
Dev Stage Prod
Web
App
Cache
DB
Web
App
Cache
DB
Web
App
Cache
DB
THE HOST?
THE “NO SNOWFLAKES” RULE
• Rule #1 of modeling infrastructure with
Chef: There Shall Be No Host-Specific
Configuration.
• That one server in the corner that
nobody touches because the person
who built it is long-gone and if that
server dies you’re all screwed? No
longer allowed.
• So where, then?
Datacenter
• Example Configuration / Policy:
• “All hosts in the US-EAST Datacenter must
be built from the US-EAST-RHEL image set.”
• “At least two independent failure domains
must be established inside the US-EAST
Datacenter.”
• All hosts in the US-EAST Datacenter must
have an active MTA. No MTA other than
Postfix will be allowed.”
• “All hosts in the US-EAST Datacenter must
deny remote-root logins via SSH.”
https://www.flickr.com/photos/photoblog0001/2219131561
Zone / Shard / Replica
• Example Configuration / Policy:
• “In order to comply with the failure domain
policy within the US-EAST Datacenter, all
configurations, policies, and changes in US-
EAST-1A must be duplicated locally in zone
US-EAST-1D.”
• “All hosts in each zone must use zone-local
DNS and NTP servers.”
https://www.flickr.com/photos/winnieshuman/3559464042/
Logical Stage
• Example Configuration / Policy:
• “All Development servers must route
outbound mail to /dev/null.”
• “All staging servers cannot run in debug log-
level for more than 6h.”
• “All Production servers must route outbound
mail through a specific named relay.”
https://www.flickr.com/photos/srkkiran/6096554915
Hostgroup
• Example Configuration / Policy:
• “All Web Servers must run NGINX.”
• “All Web Servers should have a specific SSL
certificate.”
• “All Web servers should listen on TCP ports
443 and 80.”
• “All Database servers should run
PostgreSQL.”
• “All monitoring servers must run Sensu.”
https://www.flickr.com/photos/mr_t_in_dc/4800819674
Datacenter
Zone
Zone
That Last Place Configuration Lives?
• Datacenter
(US-EAST)
• Zone / Shard / Replica
(US-EAST-1C)
• Logical / Lifecycle stage
(Dev/Stage/Prod)
• Hostgroup
(Web, App, Cache, DB, etc)
• The intersection of
Hostgroup + Logical
Dev Stage Prod
Web
App
Cache
DB
Web
App
Cache
DB
Web
App
Cache
DB
The Intersection of Hostgroup and Logical Stage
• Example Configuration / Policy:
• “All staging application servers must only
communicate with staging database
servers.”
• “No cross-stage communication may be
allowed.”
• Exceptions! “Development database servers
should be refreshed with replicated data
from production database servers every 72
hours.”
https://www.flickr.com/photos/collylogic/12620887894
Infrastructure Modeling With Chef
Available Primitives
Organizations
• Immutable & stateless
• Have no data or policy of their own
• Isolated / Sandboxed “tenants”
• Data cannot be shared between organizations
• Each has its own API endpoint and keys
• Container objects
• All other objects exist within an organization
• Can represent different companies, business units, departments, or even isolate
production from dev/stage.
Nodes
• Represent individual compute resources in the infrastructure (hosts)
• Have a single environment, and 0 or more roles
• Contain a run_list
• An order list of Chef recipes (programs) that will be executed on the node
• Contain attributes
• Store state data such as the default webserver ports
• Store information about the node, such as number of CPUs, block devices, runtimes, etc.
• Are their own SOA
• The node object in Chef is the sole authority for the configuration of the node.
• Autonomous individual nodes acting together correctly comprise a working, reliable
infrastructure.
Roles
• Collects multiple policies into a single object for easy duplication
• Contain a run_list
• An order list of Chef recipes (programs) that will be executed on the node
• Contain attributes
• Store state data such as the default webserver ports
• The relationships between role and node are defined at the node, not at the role.
Environments
• Have no run_list
• Contain attributes
• Store blanket policies such as “all nodes in this environment must behave in a particular way.”
• Can be used to version cookbook releases and model application lifecycle for
Chef code.
• The relationship between environment and node is defined at the node, not at
the environment.
Data Bags
• Collections of indexed data, stored in JSON format. “A hash table in the sky.”
• Can be read from and written to on the fly by Chef recipes.
• No drivers necessary, data bags are searchable from Chef code without any
additional libraries.
• Suitable for storing information that is true of the entire infrastructure, without
necessarily being true for any one individual node. eg. A list of users, a list of
current code version releases, etc.
Cookbooks
• Unit of code sharing in Chef: Thousands of existing cookbooks are available for
free on the Chef Supermarket repository!
• Contain executable code
• Recipes
• Libraries
• LWRPs
• Configuration file templates
• Contain Attributes
• Typically default data, such as “Web servers listen on TCP port 80.”
Example policies, modeled in Chef
Disclaimer: With Chef, there is almost always more than one way to do
anything. These are examples, not dogma.
All hosts must deny remote-root logins via SSH.
• Upload the OpenSSH cookbook from the Chef Supermarket to the Chef Server
• Create a “base” role that will be applied to all hosts as a default set of
configuration, regardless of environment
• Include “recipe[‘openssh::default’] in the role run_list
• Add an attribute to the role that sets the OpenSSH permitRootLogin value to ‘no’
• Modify the node object so that role[‘base’] is the first item in the run_list.
• Execute chef-client on the node.
Example roles/base.json file:
{
"name":"base",
"description":"Default run_list for the Krustylu Studios”,
"chef_type": "role”,
"default_attributes":{
"openssh":{
"server":{
"permit_root_login": "no"
}
}
},
"run_list":[
"recipe[openssh]"
],
}
All Production servers must use the Postfix MTA,
and must route outbound mail through a specific
named relay.
• Upload the Postfix cookbook from the Chef Supermarket to the Chef Server
• Add the postfix cookbook to the run_list in the previously created ‘base’ role
• Create a production environment
• Add an attribute that sets the Postfix remote relay to our specific named relay
• Modify the node object so that it is associated with the production environment.
• Execute chef-client on the node.
Example environments/production.json file:
{
"name": "production",
"description": "for production nodes",
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
"postfix":{
"main":{
"relayhost": "my_external_relay.dns.local"
}
}
},
"cookbook_versions": {
}
}
Benefits
• Separating code (cookbooks) from configuration (roles, environments, etc.) leads
to greater re-use across teams, and allows teams to focus on their own domain
without interfering with others
• Quickly react to policy changes
• Centralize the flow of change into the infrastructure
• Chef has precedence rules for automatically layering conflicting configurations
together to create exceptions: “All production servers must use external DNS
except for machines on the TRUST VLAN segments.”
Wrapping Up
• Datacenter & IT Compute Infrastructure is typically modeled by subdividing
nodes into smaller groups
• Management and security policies typically exist at every layer
• These policies often intersect, complement, or conflict with one another, and
these must also be modeled.
• Chef provides primitives for accurately modeling all of these layers and
intersections of policy
Charles Johnson
• Product Engineer, Chef
• Career Sysadmin (~20 years)
• Opscode Chef Employee since 2012
• @chipadeedoodah
• charles@chef.io
Thanks!
Q&A?

More Related Content

What's hot (20)

PDF
Velocity2011 chef-workshop
jtimberman
 
PPTX
Ansible for large scale deployment
Karthik .P.R
 
PPTX
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Chef Software, Inc.
 
PPTX
Chef introduction
FENG Zhichao
 
PDF
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Josh Padnick
 
ODP
CommandBox REPL, CLI, and Package Manager
bdw429s
 
PDF
Introduction to Chef - April 22 2015
Jennifer Davis
 
PDF
Server Check.in case study - Drupal and Node.js
Jeff Geerling
 
PDF
Introduction to Chef - Techsuperwomen Summit
Jennifer Davis
 
PDF
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Software, Inc.
 
PDF
SaltConf14 - Justin Carmony, Deseret Digital Media - Teaching Devs About DevOps
SaltStack
 
PDF
Automating Infrastructure with Chef
Jennifer Davis
 
PDF
Chef ignited a DevOps revolution – BK Box
Chef Software, Inc.
 
PDF
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Software, Inc.
 
PDF
Chef: Smart infrastructure automation
Johannes H. P. Skov Frandsen
 
PPTX
Serverspec and Sensu - Testing and Monitoring collide
m_richardson
 
PDF
Using SaltStack to DevOps the enterprise
Christian McHugh
 
PDF
Overview of Chef - Fundamentals Webinar Series Part 1
Chef
 
PDF
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
PROIDEA
 
PDF
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Software, Inc.
 
Velocity2011 chef-workshop
jtimberman
 
Ansible for large scale deployment
Karthik .P.R
 
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Chef Software, Inc.
 
Chef introduction
FENG Zhichao
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Josh Padnick
 
CommandBox REPL, CLI, and Package Manager
bdw429s
 
Introduction to Chef - April 22 2015
Jennifer Davis
 
Server Check.in case study - Drupal and Node.js
Jeff Geerling
 
Introduction to Chef - Techsuperwomen Summit
Jennifer Davis
 
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Software, Inc.
 
SaltConf14 - Justin Carmony, Deseret Digital Media - Teaching Devs About DevOps
SaltStack
 
Automating Infrastructure with Chef
Jennifer Davis
 
Chef ignited a DevOps revolution – BK Box
Chef Software, Inc.
 
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Software, Inc.
 
Chef: Smart infrastructure automation
Johannes H. P. Skov Frandsen
 
Serverspec and Sensu - Testing and Monitoring collide
m_richardson
 
Using SaltStack to DevOps the enterprise
Christian McHugh
 
Overview of Chef - Fundamentals Webinar Series Part 1
Chef
 
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
PROIDEA
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Software, Inc.
 

Viewers also liked (6)

PDF
Automating secure server baselines with Chef
Chef Software, Inc.
 
PDF
Scaling Cassandra for Big Data
DataStax Academy
 
PDF
DataStax: Backup and Restore in Cassandra and OpsCenter
DataStax Academy
 
PDF
Aggregated queries with Druid on terrabytes and petabytes of data
Rostislav Pashuto
 
PDF
CAPS: What's best for deploying and managing OpenStack? Chef vs. Ansible vs. ...
Animesh Singh
 
PDF
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Erica Windisch
 
Automating secure server baselines with Chef
Chef Software, Inc.
 
Scaling Cassandra for Big Data
DataStax Academy
 
DataStax: Backup and Restore in Cassandra and OpsCenter
DataStax Academy
 
Aggregated queries with Druid on terrabytes and petabytes of data
Rostislav Pashuto
 
CAPS: What's best for deploying and managing OpenStack? Chef vs. Ansible vs. ...
Animesh Singh
 
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Erica Windisch
 
Ad

Similar to Infrastructure modeling with chef (20)

PPTX
Chef fundamentals
Ygor Nascimento
 
PDF
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
Matt Ray
 
PDF
Chef for openstack
openstackindia
 
PPTX
Chef for Openstack
Mohit Sethi
 
PDF
HBaseCon 2012 | HBase Coprocessors – Deploy Shared Functionality Directly on ...
Cloudera, Inc.
 
PDF
Sharepoint Deployments
Information Technology
 
PDF
Introduction to Cooking with Chef
John Osborne
 
PDF
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
NASIG
 
PPTX
Pascal benois performance_troubleshooting-spsbe18
BIWUG
 
ODP
Configuration management with Chef
Juan Vicente Herrera Ruiz de Alejo
 
PDF
Introduction to Chef
kevsmith
 
PPTX
Deployment and Configuration 3.7
StephenKardian
 
PPTX
SharePoint 2014: Where to save my data, for devs!
Ben Steinhauser
 
PDF
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Nathen Harvey
 
PDF
SCALE12X: Chef for OpenStack
Matt Ray
 
ODP
Deep Dive: OpenStack Summit (Red Hat Summit 2014)
Stephen Gordon
 
PDF
MIgrating to RAC using Dataguard
Fuad Arshad
 
PDF
Introduction to Infrastructure as Code & Automation / Introduction to Chef
All Things Open
 
PPTX
Compliance Automation with InSpec
Nathen Harvey
 
PDF
Chef for OpenStack December 2012
Matt Ray
 
Chef fundamentals
Ygor Nascimento
 
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
Matt Ray
 
Chef for openstack
openstackindia
 
Chef for Openstack
Mohit Sethi
 
HBaseCon 2012 | HBase Coprocessors – Deploy Shared Functionality Directly on ...
Cloudera, Inc.
 
Sharepoint Deployments
Information Technology
 
Introduction to Cooking with Chef
John Osborne
 
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
NASIG
 
Pascal benois performance_troubleshooting-spsbe18
BIWUG
 
Configuration management with Chef
Juan Vicente Herrera Ruiz de Alejo
 
Introduction to Chef
kevsmith
 
Deployment and Configuration 3.7
StephenKardian
 
SharePoint 2014: Where to save my data, for devs!
Ben Steinhauser
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Nathen Harvey
 
SCALE12X: Chef for OpenStack
Matt Ray
 
Deep Dive: OpenStack Summit (Red Hat Summit 2014)
Stephen Gordon
 
MIgrating to RAC using Dataguard
Fuad Arshad
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
All Things Open
 
Compliance Automation with InSpec
Nathen Harvey
 
Chef for OpenStack December 2012
Matt Ray
 
Ad

Recently uploaded (20)

PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Tally software_Introduction_Presentation
AditiBansal54083
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 

Infrastructure modeling with chef

  • 3. Charles Johnson • Product Engineer, Chef • Career Sysadmin (~20 years) • Opscode Chef Employee since 2012 • @chipadeedoodah • [email protected]
  • 4. Where Does Configuration Live? Layers of Policy
  • 5. Typical Boring Infrastructure • Datacenter (US-EAST) Datacenter
  • 6. Datacenter Zone Zone Typical Boring Infrastructure • Datacenter (US-EAST) • Zone / Shard / Replica (US-EAST-1C)
  • 7. Datacenter Zone Zone Typical Boring Infrastructure • Datacenter (US-EAST) • Zone / Shard / Replica (US-EAST-1C) • Logical / Lifecycle stage (Dev/Stage/Prod) Dev Stage Prod
  • 8. Datacenter Zone Zone Typical Boring Infrastructure • Datacenter (US-EAST) • Zone / Shard / Replica (US-EAST-1C) • Logical / Lifecycle stage (Dev/Stage/Prod) • Hostgroup (Web, App, Cache, DB, etc) Dev Stage Prod Web App Cache DB Web App Cache DB Web App Cache DB
  • 9. Datacenter Zone Zone Typical Boring Infrastructure • Datacenter (US-EAST) • Zone / Shard / Replica (US-EAST-1C) • Logical / Lifecycle stage (Dev/Stage/Prod) • Hostgroup (Web, App, Cache, DB, etc) • ... And one more place. (Can you guess where?) Dev Stage Prod Web App Cache DB Web App Cache DB Web App Cache DB
  • 11. THE “NO SNOWFLAKES” RULE • Rule #1 of modeling infrastructure with Chef: There Shall Be No Host-Specific Configuration. • That one server in the corner that nobody touches because the person who built it is long-gone and if that server dies you’re all screwed? No longer allowed. • So where, then?
  • 12. Datacenter • Example Configuration / Policy: • “All hosts in the US-EAST Datacenter must be built from the US-EAST-RHEL image set.” • “At least two independent failure domains must be established inside the US-EAST Datacenter.” • All hosts in the US-EAST Datacenter must have an active MTA. No MTA other than Postfix will be allowed.” • “All hosts in the US-EAST Datacenter must deny remote-root logins via SSH.” https://www.flickr.com/photos/photoblog0001/2219131561
  • 13. Zone / Shard / Replica • Example Configuration / Policy: • “In order to comply with the failure domain policy within the US-EAST Datacenter, all configurations, policies, and changes in US- EAST-1A must be duplicated locally in zone US-EAST-1D.” • “All hosts in each zone must use zone-local DNS and NTP servers.” https://www.flickr.com/photos/winnieshuman/3559464042/
  • 14. Logical Stage • Example Configuration / Policy: • “All Development servers must route outbound mail to /dev/null.” • “All staging servers cannot run in debug log- level for more than 6h.” • “All Production servers must route outbound mail through a specific named relay.” https://www.flickr.com/photos/srkkiran/6096554915
  • 15. Hostgroup • Example Configuration / Policy: • “All Web Servers must run NGINX.” • “All Web Servers should have a specific SSL certificate.” • “All Web servers should listen on TCP ports 443 and 80.” • “All Database servers should run PostgreSQL.” • “All monitoring servers must run Sensu.” https://www.flickr.com/photos/mr_t_in_dc/4800819674
  • 16. Datacenter Zone Zone That Last Place Configuration Lives? • Datacenter (US-EAST) • Zone / Shard / Replica (US-EAST-1C) • Logical / Lifecycle stage (Dev/Stage/Prod) • Hostgroup (Web, App, Cache, DB, etc) • The intersection of Hostgroup + Logical Dev Stage Prod Web App Cache DB Web App Cache DB Web App Cache DB
  • 17. The Intersection of Hostgroup and Logical Stage • Example Configuration / Policy: • “All staging application servers must only communicate with staging database servers.” • “No cross-stage communication may be allowed.” • Exceptions! “Development database servers should be refreshed with replicated data from production database servers every 72 hours.” https://www.flickr.com/photos/collylogic/12620887894
  • 18. Infrastructure Modeling With Chef Available Primitives
  • 19. Organizations • Immutable & stateless • Have no data or policy of their own • Isolated / Sandboxed “tenants” • Data cannot be shared between organizations • Each has its own API endpoint and keys • Container objects • All other objects exist within an organization • Can represent different companies, business units, departments, or even isolate production from dev/stage.
  • 20. Nodes • Represent individual compute resources in the infrastructure (hosts) • Have a single environment, and 0 or more roles • Contain a run_list • An order list of Chef recipes (programs) that will be executed on the node • Contain attributes • Store state data such as the default webserver ports • Store information about the node, such as number of CPUs, block devices, runtimes, etc. • Are their own SOA • The node object in Chef is the sole authority for the configuration of the node. • Autonomous individual nodes acting together correctly comprise a working, reliable infrastructure.
  • 21. Roles • Collects multiple policies into a single object for easy duplication • Contain a run_list • An order list of Chef recipes (programs) that will be executed on the node • Contain attributes • Store state data such as the default webserver ports • The relationships between role and node are defined at the node, not at the role.
  • 22. Environments • Have no run_list • Contain attributes • Store blanket policies such as “all nodes in this environment must behave in a particular way.” • Can be used to version cookbook releases and model application lifecycle for Chef code. • The relationship between environment and node is defined at the node, not at the environment.
  • 23. Data Bags • Collections of indexed data, stored in JSON format. “A hash table in the sky.” • Can be read from and written to on the fly by Chef recipes. • No drivers necessary, data bags are searchable from Chef code without any additional libraries. • Suitable for storing information that is true of the entire infrastructure, without necessarily being true for any one individual node. eg. A list of users, a list of current code version releases, etc.
  • 24. Cookbooks • Unit of code sharing in Chef: Thousands of existing cookbooks are available for free on the Chef Supermarket repository! • Contain executable code • Recipes • Libraries • LWRPs • Configuration file templates • Contain Attributes • Typically default data, such as “Web servers listen on TCP port 80.”
  • 25. Example policies, modeled in Chef Disclaimer: With Chef, there is almost always more than one way to do anything. These are examples, not dogma.
  • 26. All hosts must deny remote-root logins via SSH. • Upload the OpenSSH cookbook from the Chef Supermarket to the Chef Server • Create a “base” role that will be applied to all hosts as a default set of configuration, regardless of environment • Include “recipe[‘openssh::default’] in the role run_list • Add an attribute to the role that sets the OpenSSH permitRootLogin value to ‘no’ • Modify the node object so that role[‘base’] is the first item in the run_list. • Execute chef-client on the node.
  • 27. Example roles/base.json file: { "name":"base", "description":"Default run_list for the Krustylu Studios”, "chef_type": "role”, "default_attributes":{ "openssh":{ "server":{ "permit_root_login": "no" } } }, "run_list":[ "recipe[openssh]" ], }
  • 28. All Production servers must use the Postfix MTA, and must route outbound mail through a specific named relay. • Upload the Postfix cookbook from the Chef Supermarket to the Chef Server • Add the postfix cookbook to the run_list in the previously created ‘base’ role • Create a production environment • Add an attribute that sets the Postfix remote relay to our specific named relay • Modify the node object so that it is associated with the production environment. • Execute chef-client on the node.
  • 29. Example environments/production.json file: { "name": "production", "description": "for production nodes", "json_class": "Chef::Environment", "chef_type": "environment", "default_attributes": { "postfix":{ "main":{ "relayhost": "my_external_relay.dns.local" } } }, "cookbook_versions": { } }
  • 30. Benefits • Separating code (cookbooks) from configuration (roles, environments, etc.) leads to greater re-use across teams, and allows teams to focus on their own domain without interfering with others • Quickly react to policy changes • Centralize the flow of change into the infrastructure • Chef has precedence rules for automatically layering conflicting configurations together to create exceptions: “All production servers must use external DNS except for machines on the TRUST VLAN segments.”
  • 31. Wrapping Up • Datacenter & IT Compute Infrastructure is typically modeled by subdividing nodes into smaller groups • Management and security policies typically exist at every layer • These policies often intersect, complement, or conflict with one another, and these must also be modeled. • Chef provides primitives for accurately modeling all of these layers and intersections of policy
  • 32. Charles Johnson • Product Engineer, Chef • Career Sysadmin (~20 years) • Opscode Chef Employee since 2012 • @chipadeedoodah • [email protected]