SlideShare a Scribd company logo
Solving real world data
problems with Jerakia
Craig Dunn, Config Management Camp, Ghent 2016
• Best practice
• Code base design
• Workflow mangement
• Scaling Puppet
• Installation and support
• Module writing
• Throughout Europe
www.enviatics.com
• Puppet user since 2008
• IT consultant for 15+ years
• Active community member
• The “Roles and Profiles” guy
• Problem solver
• Lives in Málaga, Spain.
• …. and hotels
• Daddy!
www.craigdunn.org
Craig Dunn
@crayfishx
A brief history of Puppet
In the beginning…
• Over complex code
• Unsharable modules
• Making simple changes required alot of skill.
The embedded data era
class ntp {
if $env == ‘dev’ {
$server = ‘dev.ntp.local’
} else {
if $hostname == ‘gateway’ {
$server = ‘pool.ntp.org’
} else {
$server = ‘prod.ntp.local’
}
}
…
}
And then…
Hiera
The dawn of the data separation era
• Separation of data from code
• Module authors could write sharable re-usable code
• Code was less complex and more readable
• The Forge became useful
• Managing data became a lot easier
Hierarchical Search
Pluggable
• Pluggable interchangable backends
• Data can be sourced from multiple formats
• hiera-eyaml
• hiera-mysql
• hiera-http
• hiera-redis
• hiera-consul
Solving real world data problems with Jerakia
Managing our data is now
a critical part of configuration management
Infrastructure grows and requirements
get more complex
Solving real world data problems with Jerakia
• Different teams and customers require different hierarchies
• A particular application needs to source data from a different place
• Control access to sub-sets of data for teams within an organisation
• Dynamically generate the lookup hierarchy at runtime
• Group together application specific data into separate files
• Manage encrypted data from any data source
• Global hiera.yaml file creates restrictions
Introducing Jerakia
jerakia.io
Jerakia
• Data lookup tool
• Open source
• Extendable framework
• Solving the most complex edge cases
Jerakia
• Can be used as a Hiera backend
• Can be wired directly into Puppet as a data binding terminus
• Drop in replacement for Hiera, or not.
Why Jerakia?
One design goal…
Flexibility
• Lookup behaviour written in Ruby DSL
• Almost everything is pluggable
• Inter-changable data sources
• Easy integration
• Hiera compatible*
$ gem install jerakia
$ puppet module install crayfishx/jerakia
• A request is received containing a key and a namespace
• A policy is chosen to perform the request
• One or more lookups are called to act on the request
• A response is sent back to the requestor
• Container for lookups
• Written in Ruby DSL
• Different policies for different apps
Policy File
An Example Jerakia Policy File
policy :main do
lookup :default do
datasource :file, {
:docroot => "/var/jerakia/data",
:format => :yaml,
:searchpath => [
"host/#{scope[:hostname]}",
"env/#{scope[:env]}",
"common",
]
}
end
end
An Example Jerakia Policy File
policy :main do
lookup :default do
datasource :file, {
:docroot => "/var/jerakia/data",
:format => :yaml,
:searchpath => [
"host/#{scope[:hostname]}",
"env/#{scope[:env]}",
"common",
]
}
end
end
An Example Jerakia Policy File
policy :main do
lookup :default do
datasource :file, {
:docroot => "/var/jerakia/data",
:format => :yaml,
:searchpath => [
"host/#{scope[:hostname]}",
"env/#{scope[:env]}",
"common",
]
}
end
end
An Example Jerakia Policy File
policy :main do
lookup :default do
datasource :file, {
:docroot => "/var/jerakia/data",
:format => :yaml,
:searchpath => [
"host/#{scope[:hostname]}",
"env/#{scope[:env]}",
"common",
]
}
end
end
• Lookups are contained within policies
• A policy can contain multiple lookups
• A lookup always contains at least a data source
Lookups
Scope
Handler
Request
Lookup
Plugins
Data Source
Output Filter
Response Data
Anatomy of a Jerakia lookup
Scope
Handler
Request
Lookup
Plugins
Data Source
Output Filter
Response Data
Anatomy of a Jerakia lookup
Request consists of a
lookup key, a namespace
and some metadata
Scope
Handler
Request
Lookup
Plugins
Data Source
Output Filter
Response Data
Anatomy of a Jerakia lookup
Information to be
used in determining
how data is looked up
Scope
Handler
Request
Lookup
Plugins
Data Source
Output Filter
Response Data
Anatomy of a Jerakia lookup
Lookup plugins can read
and modify the scope and
request objects
Scope
Handler
Request
Lookup
Plugins
Data Source
Output Filter
Response Data
Anatomy of a Jerakia lookup
A pluggable data source is
used to lookup data
Scope
Handler
Request
Lookup
Plugins
Data Source
Output Filter
Response Data
Anatomy of a Jerakia lookup
Data returned from the
datasource is passed to a
pluggable output filter
Lookup methods
confine / exclude
Invalidates a lookup unless/if the criteria is met
confine request.namespsace[0], "apache"
confine request.namespsace[0], [
/website_.*/,
"apache",
"php"
]
Stop
Do not proceed to the next lookup if this lookup is valid
lookup :special do
…
confine request.namespsace[0], "apache"
stop
end
lookup :main do
…
Datasources
• Easily pluggable and extendable
• File and HTTP datasources shipped out-of-the-box
Datasources
datasource :name, { :option => “value”… }
Datasource definition
lookup :main do
datasource :file, {
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"host/#{scope[:certname]}",
"env/#{scope[:environment]}",
"common",
]
}
end
/var/lib/jerakia/env/dev/apache.yaml
lookup :main do
datasource :file, {
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"host/#{scope[:certname]}",
"env/#{scope[:environment]}",
"common",
]
}
end
/var/lib/jerakia/env/dev/apache.yaml
Datasource definition
lookup :main do
datasource :file, {
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"host/#{scope[:certname]}",
"env/#{scope[:environment]}",
"common",
]
}
end
/var/lib/jerakia/env/dev/apache.yaml
Datasource definition
/var/lib/jerakia/env/dev/apache.yaml
/var/lib/jerakia/env/dev/apache.d/www_corp_com.yaml
/var/lib/jerakia/env/dev/apache.d/www_acme_net.yaml
/var/lib/jerakia/env/dev/apache.d/www_fake_org.yaml
Fragments
• Introduced in 0.4
• If a .d directory is found, files within are
concatenated
• One document is returned
Data Layout
:searchpath => [
"host/#{scope[:certname]}",
"env/#{scope[:environment]}",
]
# cat /var/lib/jerakia/env/dev/apache.yaml
—-
port: 80
# cat /var/lib/jerakia/env/dev.yaml
—-
apache::port: 80
Hiera
Jerakia
Plugins
• Access to request and scope
• Can read or modify on-the-fly
• Re-usable
• Cleaner code in policy files
class Jerakia::Lookup::Plugin
module Mything
def do_something
…
end
end
end
Writing plugins
• Written as Ruby extensions
• Can be placed in the plugin dir
• Or shipped as rubygems
lookup :main, :use => :mything do
plugin.mything.do_something
…
end
Using plugins
• Plugins are loaded into the lookup
• Referenced as plugin.name.method
lookup :main, :use => [ :mything, :foo ] do
…
end
lookup :main, :use => :hiera do
plugin.hiera.rewrite_lookup
datasource :file, {
:docroot => "/var/lib/jerakia",
:format => :yaml,
:searchpath => [
"env/#{scope[:environment]}",
"common",
]
end
The hiera plugin
• Provides compatibility to hiera filesystem layouts
• Shipped with Jerakia
# cat /var/lib/jerakia/env/dev.yaml
—-
apache::port: 80
Output filters
• Pluggable
• Specified in the lookup
• Parses data returned from the datasource
Output filters
• Two are currently shipped
• Encryption (provided by eyaml*)
• Strsub
*https://github.com/TomPoulton/hiera-eyaml
Output filters
lookup :main do
…
output_handler :encryption
end
Output filters
lookup :main do
…
output_handler :encryption
end
Example User Story
• Team in Ireland manage PHP/Apache
• Autonomous team that don’t manage infra
• Their optimal hierarchy is different from “ours”
• “We” need to service them from Puppet
• They must not modify infra services
• “We” also manage PHP/Apache for other clients
policy :default do
lookup :main, do
datasource :file, {
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"hostname/#{scope[:fqdn]}",
"environment/#{scope[:environment]}",
"common"
],
}
end
end
Our main lookup is
responsible for the entire
infrastructure
policy :default do
lookup :ireland do
datasource :file, {
:format => :yaml,
:docroot => "/var/external/data/ie",
:searchpath => [
"project/#{scope[:project]}",
"common",
]
}
end
lookup :main, do
datasource :file, {
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"hostname/#{scope[:fqdn]}",
"environment/#{scope[:environment]}",
"common"
],
}
end
end
Lookup for the Ireland
team added above the
main lookup with
separate docroot and
searchpath
policy :default do
lookup :ireland do
datasource :file, {
:format => :yaml,
:docroot => "/var/external/data/ie",
:searchpath => [
"project/#{scope[:project]}",
"common",
]
}
confine scope[:location], "ie"
confine request.namespace[0], [
"apache",
"php",
]
end
lookup :main, do
datasource :file, {
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"hostname/#{scope[:fqdn]}",
"environment/#{scope[:environment]}",
"common"
],
}
end
end
Only use this lookup if the
requestor location is IE
and the namespace is
apache or php
policy :default do
lookup :ireland do
datasource :file, {
:format => :yaml,
:docroot => "/var/external/data/ie",
:searchpath => [
"project/#{scope[:project]}",
"common",
]
}
confine scope[:location], "ie"
confine request.namespace[0], [
"apache",
"php",
]
stop
end
lookup :main, do
datasource :file, {
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"hostname/#{scope[:fqdn]}",
"environment/#{scope[:environment]}",
"common"
],
}
end
end
If this lookup is valid then
do not proceed to the
main lookup, even if data
is not found.
Command line
$ jerakia lookup port —namespace apache
$ jerakia help lookup
Usage:
jerakia lookup [KEY]
Options:
c, [--config=CONFIG] # Configuration file
p, [--policy=POLICY] # Lookup policy
# Default: default
n, [--namespace=NAMESPACE] # Lookup namespace
t, [--type=TYPE] # Lookup type
# Default: first
s, [--scope=SCOPE] # Scope handler
# Default: metadata
[--scope-options=key:value] # Key/value pairs to be passed to the scope handler
m, [--merge-type=MERGE_TYPE] # Merge type
# Default: array
l, [--log-level=LOG_LEVEL] # Log level
v, [--verbose], [--no-verbose] # Print verbose information
D, [--debug], [--no-debug] # Debug information to console, implies --log-level debug
d, [--metadata=key:value] # Key/value pairs to be used as metadata for the lookup
Lookup [KEY] with Jerakia
Integration with Puppet
—-
:backends:
- jerakia
[master]
. . .
data_binding_terminus = jerakia
Roadmap &
Contributing
Upcoming in 0.5
• Data Schemas
• Better REST client/server
• Deep merge behaviour
• Lookup plugin “load method”
Contributions wanted
• Code maturity
• Caching
• Features
• Bugfixes
• Documentation
• #jerakia (freenode) Sponsored by
Jerakia 1.0
Thank you
Questions?
jerakia.io
@crayfishx

More Related Content

PPTX
Introduction to Lucene & Solr and Usecases
PDF
Scaling Recommendations, Semantic Search, & Data Analytics with solr
ODP
If You Have The Content, Then Apache Has The Technology!
PPTX
Using Neo4j from Java
KEY
State-of-the-Art Drupal Search with Apache Solr
PPTX
REST Api Tips and Tricks
PDF
Solr: 4 big features
PDF
Solr Recipes Workshop
Introduction to Lucene & Solr and Usecases
Scaling Recommendations, Semantic Search, & Data Analytics with solr
If You Have The Content, Then Apache Has The Technology!
Using Neo4j from Java
State-of-the-Art Drupal Search with Apache Solr
REST Api Tips and Tricks
Solr: 4 big features
Solr Recipes Workshop

What's hot (20)

PDF
Introduction to Apache Solr
PDF
Json Rpc Proxy Generation With Php
PPTX
Battle of the giants: Apache Solr vs ElasticSearch
PDF
Solr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabs
PPTX
Cloud Security Monitoring and Spark Analytics
PDF
What's new with Apache Tika?
PPT
20120606 Lazy Programmers Write Self-Modifying Code /or/ Dealing with XML Ord...
PPT
Content Analysis with Apache Tika
PPTX
Introduction to Apache Lucene/Solr
PDF
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
PDF
it's just search
PDF
Solr Architecture
KEY
Content extraction with apache tika
PPTX
Apache Solr
PPTX
Big data elasticsearch practical
PPTX
Practical Machine Learning for Smarter Search with Solr and Spark
PPT
Building Intelligent Search Applications with Apache Solr and PHP5
PDF
Building a Real-time Solr-powered Recommendation Engine
PDF
Intro to Elasticsearch
ODP
Cool bonsai cool - an introduction to ElasticSearch
Introduction to Apache Solr
Json Rpc Proxy Generation With Php
Battle of the giants: Apache Solr vs ElasticSearch
Solr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabs
Cloud Security Monitoring and Spark Analytics
What's new with Apache Tika?
20120606 Lazy Programmers Write Self-Modifying Code /or/ Dealing with XML Ord...
Content Analysis with Apache Tika
Introduction to Apache Lucene/Solr
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
it's just search
Solr Architecture
Content extraction with apache tika
Apache Solr
Big data elasticsearch practical
Practical Machine Learning for Smarter Search with Solr and Spark
Building Intelligent Search Applications with Apache Solr and PHP5
Building a Real-time Solr-powered Recommendation Engine
Intro to Elasticsearch
Cool bonsai cool - an introduction to ElasticSearch
Ad

Similar to Solving real world data problems with Jerakia (20)

PDF
Understanding the Data Lookup Pattern
PPTX
Berlin Buzz Words - Apache Drill by Ted Dunning & Michael Hausenblas
PDF
Delegated Configuration with Multiple Hiera Databases - PuppetConf 2014
PPTX
Yihan Lian & Zhibin Hu - Smarter Peach: Add Eyes to Peach Fuzzer [rooted2017]
PDF
Rapid API Development ArangoDB Foxx
KEY
QueryPath, Mash-ups, and Web Services
PPTX
Introduction to Hadoop Administration
PDF
Introduction to Hadoop Administration
PDF
Introduction to Hadoop Administration
PDF
Getting Started on Google Cloud Platform
PDF
How to obtain the Cloudera Data Engineer Certification
PPTX
Hadoop Data Modeling
PDF
Documentation Insight技术架构与开发历程
PPTX
MongoDB Days Germany: Data Processing with MongoDB
PPTX
Berlin Hadoop Get Together Apache Drill
PPTX
Hadoop introduction
PDF
20181019 code.talks graph_analytics_k_patenge
PDF
Drupal Camp Berlin 2014 - Content Import in Drupal 7 Using Feeds
PDF
REST easy with API Platform
PDF
13 practical tips for writing secure golang applications
Understanding the Data Lookup Pattern
Berlin Buzz Words - Apache Drill by Ted Dunning & Michael Hausenblas
Delegated Configuration with Multiple Hiera Databases - PuppetConf 2014
Yihan Lian & Zhibin Hu - Smarter Peach: Add Eyes to Peach Fuzzer [rooted2017]
Rapid API Development ArangoDB Foxx
QueryPath, Mash-ups, and Web Services
Introduction to Hadoop Administration
Introduction to Hadoop Administration
Introduction to Hadoop Administration
Getting Started on Google Cloud Platform
How to obtain the Cloudera Data Engineer Certification
Hadoop Data Modeling
Documentation Insight技术架构与开发历程
MongoDB Days Germany: Data Processing with MongoDB
Berlin Hadoop Get Together Apache Drill
Hadoop introduction
20181019 code.talks graph_analytics_k_patenge
Drupal Camp Berlin 2014 - Content Import in Drupal 7 Using Feeds
REST easy with API Platform
13 practical tips for writing secure golang applications
Ad

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PPTX
Cloud computing and distributed systems.
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
cuic standard and advanced reporting.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
Cloud computing and distributed systems.
MYSQL Presentation for SQL database connectivity
Network Security Unit 5.pdf for BCA BBA.
Dropbox Q2 2025 Financial Results & Investor Presentation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
cuic standard and advanced reporting.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
The AUB Centre for AI in Media Proposal.docx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectroscopy.pptx food analysis technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Encapsulation_ Review paper, used for researhc scholars
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Solving real world data problems with Jerakia

  • 1. Solving real world data problems with Jerakia Craig Dunn, Config Management Camp, Ghent 2016
  • 2. • Best practice • Code base design • Workflow mangement • Scaling Puppet • Installation and support • Module writing • Throughout Europe www.enviatics.com
  • 3. • Puppet user since 2008 • IT consultant for 15+ years • Active community member • The “Roles and Profiles” guy • Problem solver • Lives in Málaga, Spain. • …. and hotels • Daddy! www.craigdunn.org Craig Dunn @crayfishx
  • 4. A brief history of Puppet
  • 5. In the beginning… • Over complex code • Unsharable modules • Making simple changes required alot of skill. The embedded data era
  • 6. class ntp { if $env == ‘dev’ { $server = ‘dev.ntp.local’ } else { if $hostname == ‘gateway’ { $server = ‘pool.ntp.org’ } else { $server = ‘prod.ntp.local’ } } … }
  • 8. Hiera The dawn of the data separation era
  • 9. • Separation of data from code • Module authors could write sharable re-usable code • Code was less complex and more readable • The Forge became useful • Managing data became a lot easier
  • 11. Pluggable • Pluggable interchangable backends • Data can be sourced from multiple formats • hiera-eyaml • hiera-mysql • hiera-http • hiera-redis • hiera-consul
  • 13. Managing our data is now a critical part of configuration management
  • 14. Infrastructure grows and requirements get more complex
  • 16. • Different teams and customers require different hierarchies • A particular application needs to source data from a different place • Control access to sub-sets of data for teams within an organisation • Dynamically generate the lookup hierarchy at runtime • Group together application specific data into separate files • Manage encrypted data from any data source • Global hiera.yaml file creates restrictions
  • 18. Jerakia • Data lookup tool • Open source • Extendable framework • Solving the most complex edge cases
  • 19. Jerakia • Can be used as a Hiera backend • Can be wired directly into Puppet as a data binding terminus • Drop in replacement for Hiera, or not.
  • 23. • Lookup behaviour written in Ruby DSL • Almost everything is pluggable • Inter-changable data sources • Easy integration • Hiera compatible*
  • 24. $ gem install jerakia
  • 25. $ puppet module install crayfishx/jerakia
  • 26. • A request is received containing a key and a namespace • A policy is chosen to perform the request • One or more lookups are called to act on the request • A response is sent back to the requestor • Container for lookups • Written in Ruby DSL • Different policies for different apps Policy File
  • 27. An Example Jerakia Policy File policy :main do lookup :default do datasource :file, { :docroot => "/var/jerakia/data", :format => :yaml, :searchpath => [ "host/#{scope[:hostname]}", "env/#{scope[:env]}", "common", ] } end end
  • 28. An Example Jerakia Policy File policy :main do lookup :default do datasource :file, { :docroot => "/var/jerakia/data", :format => :yaml, :searchpath => [ "host/#{scope[:hostname]}", "env/#{scope[:env]}", "common", ] } end end
  • 29. An Example Jerakia Policy File policy :main do lookup :default do datasource :file, { :docroot => "/var/jerakia/data", :format => :yaml, :searchpath => [ "host/#{scope[:hostname]}", "env/#{scope[:env]}", "common", ] } end end
  • 30. An Example Jerakia Policy File policy :main do lookup :default do datasource :file, { :docroot => "/var/jerakia/data", :format => :yaml, :searchpath => [ "host/#{scope[:hostname]}", "env/#{scope[:env]}", "common", ] } end end
  • 31. • Lookups are contained within policies • A policy can contain multiple lookups • A lookup always contains at least a data source Lookups
  • 33. Scope Handler Request Lookup Plugins Data Source Output Filter Response Data Anatomy of a Jerakia lookup Request consists of a lookup key, a namespace and some metadata
  • 34. Scope Handler Request Lookup Plugins Data Source Output Filter Response Data Anatomy of a Jerakia lookup Information to be used in determining how data is looked up
  • 35. Scope Handler Request Lookup Plugins Data Source Output Filter Response Data Anatomy of a Jerakia lookup Lookup plugins can read and modify the scope and request objects
  • 36. Scope Handler Request Lookup Plugins Data Source Output Filter Response Data Anatomy of a Jerakia lookup A pluggable data source is used to lookup data
  • 37. Scope Handler Request Lookup Plugins Data Source Output Filter Response Data Anatomy of a Jerakia lookup Data returned from the datasource is passed to a pluggable output filter
  • 39. confine / exclude Invalidates a lookup unless/if the criteria is met confine request.namespsace[0], "apache" confine request.namespsace[0], [ /website_.*/, "apache", "php" ]
  • 40. Stop Do not proceed to the next lookup if this lookup is valid lookup :special do … confine request.namespsace[0], "apache" stop end lookup :main do …
  • 41. Datasources • Easily pluggable and extendable • File and HTTP datasources shipped out-of-the-box
  • 42. Datasources datasource :name, { :option => “value”… }
  • 43. Datasource definition lookup :main do datasource :file, { :format => :yaml, :docroot => "/var/lib/jerakia", :searchpath => [ "host/#{scope[:certname]}", "env/#{scope[:environment]}", "common", ] } end /var/lib/jerakia/env/dev/apache.yaml
  • 44. lookup :main do datasource :file, { :format => :yaml, :docroot => "/var/lib/jerakia", :searchpath => [ "host/#{scope[:certname]}", "env/#{scope[:environment]}", "common", ] } end /var/lib/jerakia/env/dev/apache.yaml Datasource definition
  • 45. lookup :main do datasource :file, { :format => :yaml, :docroot => "/var/lib/jerakia", :searchpath => [ "host/#{scope[:certname]}", "env/#{scope[:environment]}", "common", ] } end /var/lib/jerakia/env/dev/apache.yaml Datasource definition
  • 47. Data Layout :searchpath => [ "host/#{scope[:certname]}", "env/#{scope[:environment]}", ] # cat /var/lib/jerakia/env/dev/apache.yaml —- port: 80 # cat /var/lib/jerakia/env/dev.yaml —- apache::port: 80 Hiera Jerakia
  • 48. Plugins • Access to request and scope • Can read or modify on-the-fly • Re-usable • Cleaner code in policy files
  • 49. class Jerakia::Lookup::Plugin module Mything def do_something … end end end Writing plugins • Written as Ruby extensions • Can be placed in the plugin dir • Or shipped as rubygems
  • 50. lookup :main, :use => :mything do plugin.mything.do_something … end Using plugins • Plugins are loaded into the lookup • Referenced as plugin.name.method lookup :main, :use => [ :mything, :foo ] do … end
  • 51. lookup :main, :use => :hiera do plugin.hiera.rewrite_lookup datasource :file, { :docroot => "/var/lib/jerakia", :format => :yaml, :searchpath => [ "env/#{scope[:environment]}", "common", ] end The hiera plugin • Provides compatibility to hiera filesystem layouts • Shipped with Jerakia # cat /var/lib/jerakia/env/dev.yaml —- apache::port: 80
  • 52. Output filters • Pluggable • Specified in the lookup • Parses data returned from the datasource
  • 53. Output filters • Two are currently shipped • Encryption (provided by eyaml*) • Strsub *https://github.com/TomPoulton/hiera-eyaml
  • 54. Output filters lookup :main do … output_handler :encryption end
  • 55. Output filters lookup :main do … output_handler :encryption end
  • 56. Example User Story • Team in Ireland manage PHP/Apache • Autonomous team that don’t manage infra • Their optimal hierarchy is different from “ours” • “We” need to service them from Puppet • They must not modify infra services • “We” also manage PHP/Apache for other clients
  • 57. policy :default do lookup :main, do datasource :file, { :format => :yaml, :docroot => "/var/lib/jerakia", :searchpath => [ "hostname/#{scope[:fqdn]}", "environment/#{scope[:environment]}", "common" ], } end end Our main lookup is responsible for the entire infrastructure
  • 58. policy :default do lookup :ireland do datasource :file, { :format => :yaml, :docroot => "/var/external/data/ie", :searchpath => [ "project/#{scope[:project]}", "common", ] } end lookup :main, do datasource :file, { :format => :yaml, :docroot => "/var/lib/jerakia", :searchpath => [ "hostname/#{scope[:fqdn]}", "environment/#{scope[:environment]}", "common" ], } end end Lookup for the Ireland team added above the main lookup with separate docroot and searchpath
  • 59. policy :default do lookup :ireland do datasource :file, { :format => :yaml, :docroot => "/var/external/data/ie", :searchpath => [ "project/#{scope[:project]}", "common", ] } confine scope[:location], "ie" confine request.namespace[0], [ "apache", "php", ] end lookup :main, do datasource :file, { :format => :yaml, :docroot => "/var/lib/jerakia", :searchpath => [ "hostname/#{scope[:fqdn]}", "environment/#{scope[:environment]}", "common" ], } end end Only use this lookup if the requestor location is IE and the namespace is apache or php
  • 60. policy :default do lookup :ireland do datasource :file, { :format => :yaml, :docroot => "/var/external/data/ie", :searchpath => [ "project/#{scope[:project]}", "common", ] } confine scope[:location], "ie" confine request.namespace[0], [ "apache", "php", ] stop end lookup :main, do datasource :file, { :format => :yaml, :docroot => "/var/lib/jerakia", :searchpath => [ "hostname/#{scope[:fqdn]}", "environment/#{scope[:environment]}", "common" ], } end end If this lookup is valid then do not proceed to the main lookup, even if data is not found.
  • 61. Command line $ jerakia lookup port —namespace apache $ jerakia help lookup Usage: jerakia lookup [KEY] Options: c, [--config=CONFIG] # Configuration file p, [--policy=POLICY] # Lookup policy # Default: default n, [--namespace=NAMESPACE] # Lookup namespace t, [--type=TYPE] # Lookup type # Default: first s, [--scope=SCOPE] # Scope handler # Default: metadata [--scope-options=key:value] # Key/value pairs to be passed to the scope handler m, [--merge-type=MERGE_TYPE] # Merge type # Default: array l, [--log-level=LOG_LEVEL] # Log level v, [--verbose], [--no-verbose] # Print verbose information D, [--debug], [--no-debug] # Debug information to console, implies --log-level debug d, [--metadata=key:value] # Key/value pairs to be used as metadata for the lookup Lookup [KEY] with Jerakia
  • 62. Integration with Puppet —- :backends: - jerakia [master] . . . data_binding_terminus = jerakia
  • 64. Upcoming in 0.5 • Data Schemas • Better REST client/server • Deep merge behaviour • Lookup plugin “load method”
  • 65. Contributions wanted • Code maturity • Caching • Features • Bugfixes • Documentation • #jerakia (freenode) Sponsored by