SlideShare a Scribd company logo
Ramesh Sencha
Agenda
• LWRP and HWRP
• Data Bags
• Linting with Rubocop and Foodcritic
• Berkshelf
• Chef-solo vs Chef-zero
• Integration testing with Test Kitchen
• Chef-provisioning
LWRP and HWRP :
Chef provides inbuilt number of resources but some time these resources doesn’t meets our requirement in that case
we can create our custom resource. Chef provides two ways for custom resource :
- LWRP (Light weight resource providers)
- HWRP (Heavy weight resource providers)
Chef cookbook structure :
cookbooks/<cookbook-name>
├── attributes
├── files
├── libraries
├── providers
├── recipes
├── resources
└── templates
LWRP :
• Define resource :
actions :create, :delete # declare the actions for resource.
default_action :create # define the default action if user not specifies action in resource.
# define the attributes for resource
attribute :name, kind_of: String, name_attribute: true, required: true
attribute :phone_no, kind_of: Integer, required: true
• Define providers for respective resource :
# define the action defination
action :create do
name = new_resource.name
# TODO
end
• User resource in recipe :
cookbook_name>_<resource_name> <name attribute value> do
<attributes>: values
end
Data Bags :
A data bag is a global variable that is stored as JSON data and is accessible from a Chef server. A data bag is
indexed for searching and can be loaded by a recipe or accessed during a search.
Data Bag Items :
A data bag is a container of related data bag items, where each individual data bag item is a JSON file.
{
"id": "ITEM_NAME", // it should be name of file
"key": "value"
}
Data Bags can be accessed in cookbook by lookup function.
Access databag :
data_bag(<data-bag-name>)
Access a single key :
data_bag_item(<data-bag-name>, <key>)
Encrypt a Data Bag Item :
A data bag item may be encrypted using shared secret encryption. This allows each data bag item to store confidential
information.
• An encrypted data bag item is written using YAML.
• Base64 encoding is used to preserve special characters in encrypted contents.
• Data is encrypted using AES-256-CBC (as defined by the OpenSSL package in the Ruby Standard Library).
To encrypt data bags first we have to create the shared key for encryption and decrypt.
$openssl rand -base64 512 | tr -d 'rn' > my_secret_key
Create encrypted data bag :
$knife data bag create <data-itme> <data-bag> --secret-file /tmp/my_data_bag_key
Decrypt data bag :
$knife data bag show --secret-file /tmp/my_data_bag_key <data-itme> <data-bag>
Access in recipes using lookup function :
data_bag_item(<bag-name>, <data-item>, <'secret‘>)
If 'secret' is not specified, the chef-client will look for a secret at the path specified by
the encrypted_data_bag_secret setting in the client.rb file.
Linting with Rubocop and Foodcritic
- Command line tool to analyze the cookbook's and Ruby code to make it consistent based on the set of conventions and
reports the violation.
- Provide the automated ways to ensure that code we write adheres to conventions that ensure code uniformity, portability,
and uses best practices.
- Both linting tools are able to turn on or off specific conventions based on you requirements.
Foodcritic :
Linting the cookbook.
Documentation : https://acrmp.github.io/foodcritic/
RuboCop :
Linting the ruby code.
Documentation : https://github.com/bbatsov/rubocop
Code Correctness Unit Testing Integration Testing
Foodcritic ChefSpec Test Kitchen
RuboCop ServerSpec
Berkshelf :
• Manage the cookbook outside of chef repository in isolation.
• Replaces portions of knife (cookbook generator, cookbook uploader, cookbook downloader)
• Dependencies are managed via the file Berksfile. Which is like Bundler’s Gemfile.
Create cookbook :
$berks cookbook myapp
install cookbooks :
$berks install
upload cookbook :
$berks upload
Install path for cookbook :
~/.berkshelf/cookbooks/
Chef-solo :
It allows cookbooks to run on nodes without requiring access to a Chef server and requires that a
cookbook (and any of its dependencies) be on the same physical disk as the node.
Chef-zero :
- Chef Zero is a full, in-memory, fast-start Chef server intended for development purposes; it persists no
data to disk, nor does it have any authentication or authorization.
- Local mode behaves exactly like Chef Solo except that, during a run, it starts up a local Chef Zero server
bound to localhost, uploads all local cookbooks & recipes to it, runs Chef Client, and then terminates the Chef Zero
server. The end user experience is identical to Solo.
Test Kitchen :
Test Kitchen is an integration tool to execute your configured code on one or more platforms in isolation.
A driver plugin architecture is used which lets you run your code on various cloud providers and virtualization technologies
such as Amazon EC2, Blue Box, CloudStack, Digital Ocean, Rackspace, OpenStack, Vagrant, Docker, LXC containers, and more.
Test kitchen provides a Kitchen executable command. Kitchen runs tests against any combination of platforms using any
combination of test suites.
.kitchen.yml
Use a .kitchen.yml file to define what is required to run Kitchen, including drivers, provisioners, platforms, and test suites. The
basic structure of a .kitchen.yml file for chef:
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: ubuntu-12.04
suites:
- name: default
run_list:
- recipe[apache::httpd]
Chef-Provisioning :
Chef-provisioning solves the problem of repeatable creating machines and infrastructures in Chef.
Chef provisioning depends on two main pillars–machine machine resource and drivers.
- “machine” is an abstract concept of a node from your infrastructure topology. In this declare what your machines do (recipes,
tags, etc.) with the machine resource, the fundamental unit of Chef Provisioning. You will typically declare machine resources in a
separate, OS/provisioning-independent file that declares the topology of your app--your machines and the recipes that will run
on them. Each “machine” resource describes whatever it does using standard Chef recipes.
- Drivers handle the real work of getting those abstract definitions into real, physical form. They handle the following tasks,
idempotently (you can run the resource again and again and it will only create the machine once--though it may notice things are
wrong and fix them!):
Acquiring machines from the cloud, creating containers or VMs, or grabbing bare metal
Connecting to those machines via ssh, winrm, or other transports
Bootstrapping chef onto the machines and converging the recipes you suggested
Example :
require ‘chef/provisioning/vsphere_driver’ #Name of driver
with_machine_options :ssh_username => '<ssh-user-id>',
:bootstrap_options => {
:key_name => '<your-pem-file>',
:image_id => ‘<ami-id>',
:instance_type => ‘<instance-size>’,
:security_group_ids => '<security-group>'
}
machine <machine-name> do
end
Thank you

More Related Content

What's hot

Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
jtyr
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
shaokun
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weibo
shaokun
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
Michael Peacock
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
Michael Peacock
 
chef loves windows
chef loves windowschef loves windows
chef loves windows
Mat Schaffer
 
Fixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data PatternsFixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data Patterns
Martin Jackson
 
Cooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefCooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with Chef
G. Ryan Fawcett
 
Shark - Lab Assignment
Shark - Lab AssignmentShark - Lab Assignment
Shark - Lab Assignment
Farzad Nozarian
 
Ansible 2 and Ansible Galaxy 2
Ansible 2 and Ansible Galaxy 2Ansible 2 and Ansible Galaxy 2
Ansible 2 and Ansible Galaxy 2
Jeff Geerling
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.IN
Rajesh Hegde
 
Redis for your boss 2.0
Redis for your boss 2.0Redis for your boss 2.0
Redis for your boss 2.0
Elena Kolevska
 
Sbt
SbtSbt
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
Yehuda Katz
 
Build Automation 101
Build Automation 101Build Automation 101
Build Automation 101
Martin Jackson
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Srijan Technologies
 
Redis for your boss
Redis for your bossRedis for your boss
Redis for your boss
Elena Kolevska
 
Medicine show2 Drupal Bristol Camp 2015
Medicine show2 Drupal Bristol Camp 2015Medicine show2 Drupal Bristol Camp 2015
Medicine show2 Drupal Bristol Camp 2015
George Boobyer
 
2011/10/08_Playframework_GAE_to_Heroku
2011/10/08_Playframework_GAE_to_Heroku2011/10/08_Playframework_GAE_to_Heroku
2011/10/08_Playframework_GAE_to_Heroku
Takeshi Hagikura
 
Pourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirentPourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirent
Nicolas Ledez
 

What's hot (20)

Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weibo
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
 
chef loves windows
chef loves windowschef loves windows
chef loves windows
 
Fixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data PatternsFixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data Patterns
 
Cooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefCooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with Chef
 
Shark - Lab Assignment
Shark - Lab AssignmentShark - Lab Assignment
Shark - Lab Assignment
 
Ansible 2 and Ansible Galaxy 2
Ansible 2 and Ansible Galaxy 2Ansible 2 and Ansible Galaxy 2
Ansible 2 and Ansible Galaxy 2
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.IN
 
Redis for your boss 2.0
Redis for your boss 2.0Redis for your boss 2.0
Redis for your boss 2.0
 
Sbt
SbtSbt
Sbt
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Build Automation 101
Build Automation 101Build Automation 101
Build Automation 101
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
 
Redis for your boss
Redis for your bossRedis for your boss
Redis for your boss
 
Medicine show2 Drupal Bristol Camp 2015
Medicine show2 Drupal Bristol Camp 2015Medicine show2 Drupal Bristol Camp 2015
Medicine show2 Drupal Bristol Camp 2015
 
2011/10/08_Playframework_GAE_to_Heroku
2011/10/08_Playframework_GAE_to_Heroku2011/10/08_Playframework_GAE_to_Heroku
2011/10/08_Playframework_GAE_to_Heroku
 
Pourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirentPourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirent
 

Similar to Chef advance

DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven Infrastructure
Antons Kranga
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with Chef
John Ewart
 
Configuration management with Chef
Configuration management with ChefConfiguration management with Chef
Configuration management with Chef
Juan Vicente Herrera Ruiz de Alejo
 
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
Chef Software, Inc.
 
DevOps hackathon Session 2: Basics of Chef
DevOps hackathon Session 2: Basics of ChefDevOps hackathon Session 2: Basics of Chef
DevOps hackathon Session 2: Basics of Chef
Antons Kranga
 
Understand Chef
Understand ChefUnderstand Chef
Understand Chef
devopsjourney
 
Chef - Infrastructure Automation for the Masses
Chef - Infrastructure Automation for the Masses�Chef - Infrastructure Automation for the Masses�
Chef - Infrastructure Automation for the Masses
Sai Perchard
 
IT Automation with Chef
IT Automation with ChefIT Automation with Chef
IT Automation with Chef
Anuchit Chalothorn
 
London Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef StuffLondon Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef Stuff
Chef
 
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
 
AWS ElasticBeanstalk Advanced configuration
AWS ElasticBeanstalk Advanced configurationAWS ElasticBeanstalk Advanced configuration
AWS ElasticBeanstalk Advanced configuration
Lionel LONKAP TSAMBA
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
Sri Ram
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
Sri Ram
 
A Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef SupermarketA Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef Supermarket
Nell Shamrell-Harrington
 
CHEF - by Scott Russel
CHEF - by Scott RusselCHEF - by Scott Russel
CHEF - by Scott Russel
Kangaroot
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Software, Inc.
 
Kickstarter - Chef Opswork
Kickstarter - Chef OpsworkKickstarter - Chef Opswork
Kickstarter - Chef Opswork
Hamza Waqas
 
Apache Hive micro guide - ConfusedCoders
Apache Hive micro guide - ConfusedCodersApache Hive micro guide - ConfusedCoders
Apache Hive micro guide - ConfusedCoders
Yash Sharma
 
Ignite Talk on Chef
Ignite Talk on ChefIgnite Talk on Chef
Ignite Talk on Chef
Bob Nowadly
 
Chef: Smart infrastructure automation
Chef: Smart infrastructure automationChef: Smart infrastructure automation
Chef: Smart infrastructure automation
Johannes H. P. Skov Frandsen
 

Similar to Chef advance (20)

DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven Infrastructure
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with Chef
 
Configuration management with Chef
Configuration management with ChefConfiguration management with Chef
Configuration management with Chef
 
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
 
DevOps hackathon Session 2: Basics of Chef
DevOps hackathon Session 2: Basics of ChefDevOps hackathon Session 2: Basics of Chef
DevOps hackathon Session 2: Basics of Chef
 
Understand Chef
Understand ChefUnderstand Chef
Understand Chef
 
Chef - Infrastructure Automation for the Masses
Chef - Infrastructure Automation for the Masses�Chef - Infrastructure Automation for the Masses�
Chef - Infrastructure Automation for the Masses
 
IT Automation with Chef
IT Automation with ChefIT Automation with Chef
IT Automation with Chef
 
London Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef StuffLondon Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef Stuff
 
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
 
AWS ElasticBeanstalk Advanced configuration
AWS ElasticBeanstalk Advanced configurationAWS ElasticBeanstalk Advanced configuration
AWS ElasticBeanstalk Advanced configuration
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
A Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef SupermarketA Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef Supermarket
 
CHEF - by Scott Russel
CHEF - by Scott RusselCHEF - by Scott Russel
CHEF - by Scott Russel
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
 
Kickstarter - Chef Opswork
Kickstarter - Chef OpsworkKickstarter - Chef Opswork
Kickstarter - Chef Opswork
 
Apache Hive micro guide - ConfusedCoders
Apache Hive micro guide - ConfusedCodersApache Hive micro guide - ConfusedCoders
Apache Hive micro guide - ConfusedCoders
 
Ignite Talk on Chef
Ignite Talk on ChefIgnite Talk on Chef
Ignite Talk on Chef
 
Chef: Smart infrastructure automation
Chef: Smart infrastructure automationChef: Smart infrastructure automation
Chef: Smart infrastructure automation
 

Recently uploaded

How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 

Recently uploaded (20)

How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 

Chef advance

  • 2. Agenda • LWRP and HWRP • Data Bags • Linting with Rubocop and Foodcritic • Berkshelf • Chef-solo vs Chef-zero • Integration testing with Test Kitchen • Chef-provisioning
  • 3. LWRP and HWRP : Chef provides inbuilt number of resources but some time these resources doesn’t meets our requirement in that case we can create our custom resource. Chef provides two ways for custom resource : - LWRP (Light weight resource providers) - HWRP (Heavy weight resource providers) Chef cookbook structure : cookbooks/<cookbook-name> ├── attributes ├── files ├── libraries ├── providers ├── recipes ├── resources └── templates
  • 4. LWRP : • Define resource : actions :create, :delete # declare the actions for resource. default_action :create # define the default action if user not specifies action in resource. # define the attributes for resource attribute :name, kind_of: String, name_attribute: true, required: true attribute :phone_no, kind_of: Integer, required: true • Define providers for respective resource : # define the action defination action :create do name = new_resource.name # TODO end • User resource in recipe : cookbook_name>_<resource_name> <name attribute value> do <attributes>: values end
  • 5. Data Bags : A data bag is a global variable that is stored as JSON data and is accessible from a Chef server. A data bag is indexed for searching and can be loaded by a recipe or accessed during a search. Data Bag Items : A data bag is a container of related data bag items, where each individual data bag item is a JSON file. { "id": "ITEM_NAME", // it should be name of file "key": "value" } Data Bags can be accessed in cookbook by lookup function. Access databag : data_bag(<data-bag-name>) Access a single key : data_bag_item(<data-bag-name>, <key>)
  • 6. Encrypt a Data Bag Item : A data bag item may be encrypted using shared secret encryption. This allows each data bag item to store confidential information. • An encrypted data bag item is written using YAML. • Base64 encoding is used to preserve special characters in encrypted contents. • Data is encrypted using AES-256-CBC (as defined by the OpenSSL package in the Ruby Standard Library). To encrypt data bags first we have to create the shared key for encryption and decrypt. $openssl rand -base64 512 | tr -d 'rn' > my_secret_key Create encrypted data bag : $knife data bag create <data-itme> <data-bag> --secret-file /tmp/my_data_bag_key Decrypt data bag : $knife data bag show --secret-file /tmp/my_data_bag_key <data-itme> <data-bag> Access in recipes using lookup function : data_bag_item(<bag-name>, <data-item>, <'secret‘>) If 'secret' is not specified, the chef-client will look for a secret at the path specified by the encrypted_data_bag_secret setting in the client.rb file.
  • 7. Linting with Rubocop and Foodcritic - Command line tool to analyze the cookbook's and Ruby code to make it consistent based on the set of conventions and reports the violation. - Provide the automated ways to ensure that code we write adheres to conventions that ensure code uniformity, portability, and uses best practices. - Both linting tools are able to turn on or off specific conventions based on you requirements. Foodcritic : Linting the cookbook. Documentation : https://acrmp.github.io/foodcritic/ RuboCop : Linting the ruby code. Documentation : https://github.com/bbatsov/rubocop Code Correctness Unit Testing Integration Testing Foodcritic ChefSpec Test Kitchen RuboCop ServerSpec
  • 8. Berkshelf : • Manage the cookbook outside of chef repository in isolation. • Replaces portions of knife (cookbook generator, cookbook uploader, cookbook downloader) • Dependencies are managed via the file Berksfile. Which is like Bundler’s Gemfile. Create cookbook : $berks cookbook myapp install cookbooks : $berks install upload cookbook : $berks upload Install path for cookbook : ~/.berkshelf/cookbooks/
  • 9. Chef-solo : It allows cookbooks to run on nodes without requiring access to a Chef server and requires that a cookbook (and any of its dependencies) be on the same physical disk as the node. Chef-zero : - Chef Zero is a full, in-memory, fast-start Chef server intended for development purposes; it persists no data to disk, nor does it have any authentication or authorization. - Local mode behaves exactly like Chef Solo except that, during a run, it starts up a local Chef Zero server bound to localhost, uploads all local cookbooks & recipes to it, runs Chef Client, and then terminates the Chef Zero server. The end user experience is identical to Solo.
  • 10. Test Kitchen : Test Kitchen is an integration tool to execute your configured code on one or more platforms in isolation. A driver plugin architecture is used which lets you run your code on various cloud providers and virtualization technologies such as Amazon EC2, Blue Box, CloudStack, Digital Ocean, Rackspace, OpenStack, Vagrant, Docker, LXC containers, and more. Test kitchen provides a Kitchen executable command. Kitchen runs tests against any combination of platforms using any combination of test suites. .kitchen.yml Use a .kitchen.yml file to define what is required to run Kitchen, including drivers, provisioners, platforms, and test suites. The basic structure of a .kitchen.yml file for chef: driver: name: vagrant provisioner: name: chef_zero platforms: - name: ubuntu-12.04 suites: - name: default run_list: - recipe[apache::httpd]
  • 11. Chef-Provisioning : Chef-provisioning solves the problem of repeatable creating machines and infrastructures in Chef. Chef provisioning depends on two main pillars–machine machine resource and drivers. - “machine” is an abstract concept of a node from your infrastructure topology. In this declare what your machines do (recipes, tags, etc.) with the machine resource, the fundamental unit of Chef Provisioning. You will typically declare machine resources in a separate, OS/provisioning-independent file that declares the topology of your app--your machines and the recipes that will run on them. Each “machine” resource describes whatever it does using standard Chef recipes. - Drivers handle the real work of getting those abstract definitions into real, physical form. They handle the following tasks, idempotently (you can run the resource again and again and it will only create the machine once--though it may notice things are wrong and fix them!): Acquiring machines from the cloud, creating containers or VMs, or grabbing bare metal Connecting to those machines via ssh, winrm, or other transports Bootstrapping chef onto the machines and converging the recipes you suggested
  • 12. Example : require ‘chef/provisioning/vsphere_driver’ #Name of driver with_machine_options :ssh_username => '<ssh-user-id>', :bootstrap_options => { :key_name => '<your-pem-file>', :image_id => ‘<ami-id>', :instance_type => ‘<instance-size>’, :security_group_ids => '<security-group>' } machine <machine-name> do end