SlideShare a Scribd company logo
1 of 12
Download to read offline
Chef-Zero & Local Mode
Michael Goetz
Automation Consulting Engineer, Chef
mpgoetz@getchef.com

v1.2.3
Back in my day…
• Getting started with
Chef involved a lot of
setup
• Configure
workstation
• Configure Chef
server
• Bootstrap node
Chef-Client with Chef Server
• Chef-client
communicates with
Chef server
• Node object stored on
Chef server
• Cookbooks, roles,
environments, etc.
uploaded from
workstation with knife

chef-client
Chef-Solo
• Runs locally on node
• Cookbooks, data bags,
roles, environments
stored on disk
• Does not support
• Node storage
• Search indexes
• Persistent attributes

chef-solo -c ~/solo.rb -j ~/node.json
Chef-Zero
• Chef 11+ compliant
• Easy to run, fast to start
• Runs in memory
• Great for mocking a Chef
server locally
!

• Not intended for production use
• No input validation,
authentication, authorization
• Data does not persist between
restarts

http://www.nevinmartell.com/wp-content/uploads/2012/10/always_trust_a_skinny_chef.jpg
But does it blend?
• Search
• Node data
• Client data
• Cookbooks
• Data bags
• Roles
• Environments
Using Chef-Zero
• Install chef-zero gem
• $ gem install chef-zero
• Start chef-zero server (defaults to 127.0.0.1:8889)
• $ chef-zero
• Setup knife.rb with server details
• chef_server_url 'http://127.0.0.1:8889'
node_name
client_key

'tastesgreat'
‘dummy_key.pem'
Great… So now what?
• Vagrant integration with vagrant-chef-zero
• https://github.com/andrewgross/vagrant-chef-zero
• Allows testing of searches, node data without
connecting to a “real” chef server
• Mock cluster node data
• Validate data bag queries
• Automated testing with Test-Kitchen
• http://kitchen.ci/
• provisioner
name: chef_zero
Going native with local mode

http://www.prosperapartners.org/wp-content/uploads/2012/07/i-am-a-localist.png

• Harness the power of chef-zero
within chef-client
• chef-client -z & knife -z
• Loads files from current directory
• /cookbooks
• /nodes
• /roles
• /environments
• Writes data changes back to
local file system
• knife works too!
Setup Data Bag & Recipe
• Create default recipe
• Search for node data,
printed out to “/tmp/
zerofiles”
!

• Setup data bag
structure
• Print content of data
bag out to “/tmp/fluff”

cookbooks/zero/recipes/default.rb
a = search(:node, "*:*")!
b = data_bag_item("zero", "fluff")!
!
file "/tmp/zerofiles" do!
content a[0].to_s!
end!
!
file "/tmp/fluff" do!
content b.to_s!
end

data_bags/zero/fluff
{!
"id": "fluff",!
"clouds": "Are fluffy"!
}
Converge!
$ chef-client -z -o zero
[2013-12-10T23:53:32-06:00] WARN: No config file found or specified on command line, not loading.!
Starting Chef Client, version 11.8.2!
[2013-12-10T23:53:36-06:00] WARN: Run List override has been provided.!
[2013-12-10T23:53:36-06:00] WARN: Original Run List: [recipe[zero]]!
[2013-12-10T23:53:36-06:00] WARN: Overridden Run List: [recipe[zero]]!
resolving cookbooks for run list: ["zero"]!
Synchronizing Cookbooks:!
- zero!
Compiling Cookbooks...!
Converging 2 resources!
Recipe: zero::default!
* file[/tmp/zerofiles] action create!
- create new file /tmp/zerofiles!
- update content in file /tmp/zerofiles from none to 0a038a!
--- /tmp/zerofiles
2013-12-10 23:53:36.368059768 -0600!
+++ /tmp/.zerofiles20131210-6903-10cvytu
2013-12-10 23:53:36.368059768 -0600!
@@ -1 +1,2 @@!
+node[localhost]!
* file[/tmp/fluff] action create!
- create new file /tmp/fluff!
- update content in file /tmp/fluff from none to d46bab!
--- /tmp/fluff 2013-12-10 23:53:36.372059683 -0600!
+++ /tmp/.fluff20131210-6903-1l3i1h
2013-12-10 23:53:36.372059683 -0600!
@@ -1 +1,2 @@!
+data_bag_item[fluff]!
Chef Client finished, 2 resources updated
Learn more
• From Zero to Chef in 8.5 Seconds
• http://www.getchef.com/blog/2013/10/31/chef-client-z-fromzero-to-chef-in-8-5-seconds/
!

• Chef Docs Site
• http://docs.opscode.com/release_notes.html#chef-client-localmode
!

• Chef-Zero on GitHub
• https://github.com/opscode/chef-zero

More Related Content

Similar to Chef-Zero & Local Mode for Testing

Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Chef
 
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Software, Inc.
 
Introduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationIntroduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationNicole Johnson
 
Infrastructure modeling with chef
Infrastructure modeling with chefInfrastructure modeling with chef
Infrastructure modeling with chefCharles Johnson
 
CIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef CookbooksCIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef CookbooksICF CIRCUIT
 
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Atmosphere 2014: Really large scale systems configuration - Phil DibowitzAtmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Atmosphere 2014: Really large scale systems configuration - Phil DibowitzPROIDEA
 
Chef - Infrastructure Automation for the Masses
Chef - Infrastructure Automation for the Masses�Chef - Infrastructure Automation for the Masses�
Chef - Infrastructure Automation for the MassesSai Perchard
 
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & TomorrowTXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & TomorrowMatt Ray
 
Chef - managing yours servers with Code
Chef - managing yours servers with CodeChef - managing yours servers with Code
Chef - managing yours servers with Codem_richardson
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerGeorge Miranda
 
OSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy HawkinsOSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy HawkinsNETWAYS
 
Achieving Infrastructure Portability with Chef
Achieving Infrastructure Portability with ChefAchieving Infrastructure Portability with Chef
Achieving Infrastructure Portability with ChefMatt Ray
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with ChefJohn Ewart
 
Chef at WebMD
Chef at WebMDChef at WebMD
Chef at WebMDadamleff
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefNathen Harvey
 
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 1Chef
 

Similar to Chef-Zero & Local Mode for Testing (20)

Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3
 
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation Setup
 
Introduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationIntroduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & Remediation
 
Chef: Smart infrastructure automation
Chef: Smart infrastructure automationChef: Smart infrastructure automation
Chef: Smart infrastructure automation
 
Infrastructure modeling with chef
Infrastructure modeling with chefInfrastructure modeling with chef
Infrastructure modeling with chef
 
CIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef CookbooksCIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
 
Chef advance
Chef advanceChef advance
Chef advance
 
Chef advance
Chef advanceChef advance
Chef advance
 
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Atmosphere 2014: Really large scale systems configuration - Phil DibowitzAtmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
 
Chef - Infrastructure Automation for the Masses
Chef - Infrastructure Automation for the Masses�Chef - Infrastructure Automation for the Masses�
Chef - Infrastructure Automation for the Masses
 
Configuration management with Chef
Configuration management with ChefConfiguration management with Chef
Configuration management with Chef
 
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & TomorrowTXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
 
Chef - managing yours servers with Code
Chef - managing yours servers with CodeChef - managing yours servers with Code
Chef - managing yours servers with Code
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and Packer
 
OSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy HawkinsOSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy Hawkins
 
Achieving Infrastructure Portability with Chef
Achieving Infrastructure Portability with ChefAchieving Infrastructure Portability with Chef
Achieving Infrastructure Portability with Chef
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with Chef
 
Chef at WebMD
Chef at WebMDChef at WebMD
Chef at WebMD
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
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
 

More from Michael Goetz

Validation driven change
Validation driven changeValidation driven change
Validation driven changeMichael Goetz
 
Inspec, or how to translate compliance spreadsheets into code
Inspec, or how to translate compliance spreadsheets into codeInspec, or how to translate compliance spreadsheets into code
Inspec, or how to translate compliance spreadsheets into codeMichael Goetz
 
Step away from that knife!
Step away from that knife!Step away from that knife!
Step away from that knife!Michael Goetz
 
Packing It In: Images, Containers, and Config Management
Packing It In: Images, Containers, and Config ManagementPacking It In: Images, Containers, and Config Management
Packing It In: Images, Containers, and Config ManagementMichael Goetz
 
Packing It In: Images, Containers and Config Management
Packing It In: Images, Containers and Config ManagementPacking It In: Images, Containers and Config Management
Packing It In: Images, Containers and Config ManagementMichael Goetz
 
My Parents Configured Their Living Room
My Parents Configured Their Living RoomMy Parents Configured Their Living Room
My Parents Configured Their Living RoomMichael Goetz
 

More from Michael Goetz (6)

Validation driven change
Validation driven changeValidation driven change
Validation driven change
 
Inspec, or how to translate compliance spreadsheets into code
Inspec, or how to translate compliance spreadsheets into codeInspec, or how to translate compliance spreadsheets into code
Inspec, or how to translate compliance spreadsheets into code
 
Step away from that knife!
Step away from that knife!Step away from that knife!
Step away from that knife!
 
Packing It In: Images, Containers, and Config Management
Packing It In: Images, Containers, and Config ManagementPacking It In: Images, Containers, and Config Management
Packing It In: Images, Containers, and Config Management
 
Packing It In: Images, Containers and Config Management
Packing It In: Images, Containers and Config ManagementPacking It In: Images, Containers and Config Management
Packing It In: Images, Containers and Config Management
 
My Parents Configured Their Living Room
My Parents Configured Their Living RoomMy Parents Configured Their Living Room
My Parents Configured Their Living Room
 

Recently uploaded

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Chef-Zero & Local Mode for Testing

  • 1. Chef-Zero & Local Mode Michael Goetz Automation Consulting Engineer, Chef mpgoetz@getchef.com v1.2.3
  • 2. Back in my day… • Getting started with Chef involved a lot of setup • Configure workstation • Configure Chef server • Bootstrap node
  • 3. Chef-Client with Chef Server • Chef-client communicates with Chef server • Node object stored on Chef server • Cookbooks, roles, environments, etc. uploaded from workstation with knife chef-client
  • 4. Chef-Solo • Runs locally on node • Cookbooks, data bags, roles, environments stored on disk • Does not support • Node storage • Search indexes • Persistent attributes chef-solo -c ~/solo.rb -j ~/node.json
  • 5. Chef-Zero • Chef 11+ compliant • Easy to run, fast to start • Runs in memory • Great for mocking a Chef server locally ! • Not intended for production use • No input validation, authentication, authorization • Data does not persist between restarts http://www.nevinmartell.com/wp-content/uploads/2012/10/always_trust_a_skinny_chef.jpg
  • 6. But does it blend? • Search • Node data • Client data • Cookbooks • Data bags • Roles • Environments
  • 7. Using Chef-Zero • Install chef-zero gem • $ gem install chef-zero • Start chef-zero server (defaults to 127.0.0.1:8889) • $ chef-zero • Setup knife.rb with server details • chef_server_url 'http://127.0.0.1:8889' node_name client_key 'tastesgreat' ‘dummy_key.pem'
  • 8. Great… So now what? • Vagrant integration with vagrant-chef-zero • https://github.com/andrewgross/vagrant-chef-zero • Allows testing of searches, node data without connecting to a “real” chef server • Mock cluster node data • Validate data bag queries • Automated testing with Test-Kitchen • http://kitchen.ci/ • provisioner name: chef_zero
  • 9. Going native with local mode http://www.prosperapartners.org/wp-content/uploads/2012/07/i-am-a-localist.png • Harness the power of chef-zero within chef-client • chef-client -z & knife -z • Loads files from current directory • /cookbooks • /nodes • /roles • /environments • Writes data changes back to local file system • knife works too!
  • 10. Setup Data Bag & Recipe • Create default recipe • Search for node data, printed out to “/tmp/ zerofiles” ! • Setup data bag structure • Print content of data bag out to “/tmp/fluff” cookbooks/zero/recipes/default.rb a = search(:node, "*:*")! b = data_bag_item("zero", "fluff")! ! file "/tmp/zerofiles" do! content a[0].to_s! end! ! file "/tmp/fluff" do! content b.to_s! end data_bags/zero/fluff {! "id": "fluff",! "clouds": "Are fluffy"! }
  • 11. Converge! $ chef-client -z -o zero [2013-12-10T23:53:32-06:00] WARN: No config file found or specified on command line, not loading.! Starting Chef Client, version 11.8.2! [2013-12-10T23:53:36-06:00] WARN: Run List override has been provided.! [2013-12-10T23:53:36-06:00] WARN: Original Run List: [recipe[zero]]! [2013-12-10T23:53:36-06:00] WARN: Overridden Run List: [recipe[zero]]! resolving cookbooks for run list: ["zero"]! Synchronizing Cookbooks:! - zero! Compiling Cookbooks...! Converging 2 resources! Recipe: zero::default! * file[/tmp/zerofiles] action create! - create new file /tmp/zerofiles! - update content in file /tmp/zerofiles from none to 0a038a! --- /tmp/zerofiles 2013-12-10 23:53:36.368059768 -0600! +++ /tmp/.zerofiles20131210-6903-10cvytu 2013-12-10 23:53:36.368059768 -0600! @@ -1 +1,2 @@! +node[localhost]! * file[/tmp/fluff] action create! - create new file /tmp/fluff! - update content in file /tmp/fluff from none to d46bab! --- /tmp/fluff 2013-12-10 23:53:36.372059683 -0600! +++ /tmp/.fluff20131210-6903-1l3i1h 2013-12-10 23:53:36.372059683 -0600! @@ -1 +1,2 @@! +data_bag_item[fluff]! Chef Client finished, 2 resources updated
  • 12. Learn more • From Zero to Chef in 8.5 Seconds • http://www.getchef.com/blog/2013/10/31/chef-client-z-fromzero-to-chef-in-8-5-seconds/ ! • Chef Docs Site • http://docs.opscode.com/release_notes.html#chef-client-localmode ! • Chef-Zero on GitHub • https://github.com/opscode/chef-zero