SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
R.I.Pienaar
PuppetConf 2016
External Data in Puppet 4
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Who am I?
• Puppet User since 0.22
• Really into external data
• Author facts.d, extlookup, Hiera, MCollective
• Consultant - DevOps, Automation,
Architect, Development
• Open Source @ github.com/ripienaar
• Volcane on IRC
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
External Data
Is Configuration For
Your Code
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Hierarchical Data
class monitor (
Array[Monitor::Plugin] $plugins = []
) {
…
}
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Hierarchical Data
class{“monitor”:
plugins => [
“cpu",
“write_graphite”,
“df”, …
]
}
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Automatic Param Lookup
include monitor
# hieradb/nodes/host1.yaml
monitor::plugins:
- my_app
class{“monitor”:
plugins => [
“my_app”, “cpu”, “df”, …
]
}
+
=
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Hierarchical Data
host1 host2 host3 host4 host5 host6
prod stage dev
dc1 dc2
Site wide common data
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Hierarchical Data
host1 host2 host3 host4 host5 host6
prod stage dev
dc1 dc2
Site wide common data
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Hierarchical Data
host1 host2 host3 host4 host5 host6
prod stage dev
dc1 dc2
Site wide common data
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Hierarchical Data
host1 host2 host3 host4 host5 host6
prod stage dev
dc1 dc2
Site wide common data
$trusted[“certname”]
$environment
$facts[“dc”]
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Automatic Param Lookup
include monitor
# hieradb/nodes/host1.yaml
monitor::plugins:
- my_app
class{“monitor”:
plugins => [
“my_app”, “cpu”, “df”, …
]
}
+
=
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup
• lookup() function replaces hiera*()
• Automatic Param Lookup more useful
• environment and module aware
• Great CLI
• YAML/JSON out of the box, more to come
• Data compatible with Hiera, cohabits with
Hiera
• Pluggable
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - CLI
$ puppet lookup monitor::plugins —merge unique
——
- my_app
- write_graphite
- cpu
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
$ puppet lookup monitor::plugins —merge unique —explain
Merge strategy unique
…
Data Provider "Nodes"
Path “/etc/…/production/data/nodes/dev3.devco.net.yaml”
Original path: "nodes/%{trusted.certname}"
Found key: "monitor::plugins" value: [
"my_app"
]
…
Data Provider "common"
Path “/etc/…/data/common.yaml”
Original path: "common"
Found key: "monitor::plugins" value: [
"cpu",
"write_graphite"
]
…
Merged result: [
"my_app",
"cpu",
"write_graphite"
]
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
$ puppet lookup monitor::plugins —merge unique —explain
Merge strategy unique
…
Data Provider "Nodes"
Path “/etc/…/production/data/nodes/dev3.devco.net.yaml”
Original path: "nodes/%{trusted.certname}"
Found key: "monitor::plugins" value: [
"my_app"
]
…
Data Provider "common"
Path “/etc/…/data/common.yaml”
Original path: "common"
Found key: "monitor::plugins" value: [
"cpu",
"write_graphite"
]
…
Merged result: [
"my_app",
"cpu",
"write_graphite"
]
Every tier
Final result
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - Config
# environments/production/hiera.yaml
---
version: 4
datadir: data
hierarchy:
- name: "Nodes"
backend: yaml
path: "nodes/%{trusted.certname}"
- name: "common"
backend: yaml
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
$plugins = lookup(“monitor::plugins”)
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
$plugins = lookup(“monitor::plugins”, {
“value_type” => Array[Monitor::Plugin],
“default_value” => [“cpu”, …]
})
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
function monitor::params() {
$result = {
“monitor::plugins” => [
“cpu”, …
]
}
}
$plugins = lookup(“monitor::plugins”, {
“default_value_hash” => monitor::params()
})
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
$servers = lookup(“monitor::plugins”, {
“merge” => “first”
})
Default behaviour
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
$servers = lookup(“monitor::plugins”, {
“merge” => “unique”
})
Array Merge (hiera_array())
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
$servers = lookup(“monitor::plugins”, {
“merge” => “hash”
})
Shallow Hash Merge (hiera_hash())
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
$servers = lookup(“monitor::plugins”, {
“merge” => “deep”,
})
Deep Hash Merge
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
# common.yaml
users::local:
rip:
email: “rip@devco.net"
comment: “R.I.Pienaar”
sudoer: true
shell: “/bin/zsh”
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
# nodes/dev3.devco.net
users::local:
rip:
email: “arri.pienaar@client.com”
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
$ puppet lookup users::local —merge deep
---
rip:
email: arri.pienaar@client.com
comment: R.I.Pienaar
sudoer: true
shell: "/bin/zsh"
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Automatic Param Lookup
include monitor
# hieradb/nodes/host1.yaml
monitor::plugins:
- my_app
class{“monitor”:
plugins => [
“my_app”, “cpu”, “df”, …
]
}
+
=
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
$lookup_options = {
“merge” => {
“strategy” => “unique”
}
}
$plugins = lookup(“monitor::plugins”, $lookup_options)
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - function
$plugins = lookup(“monitor::plugins”)
# hieradata/common.yaml
lookup_options:
monitor::plugins:
merge:
strategy: unique
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
include monitor
# …/production/hieradata/common.yaml
lookup_options:
monitor::plugins:
strategy: unique
monitor::plugins:
- cpu
- …
class monitor (
Array[Monitor::Plugin] $plugins = []
) {}
Lookup - function
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Lookup - Data In Modules
# modules/monitor/hiera.yaml
---
version: 4
datadir: "data"
hierarchy:
- name: "common"
backend: "yaml"
# modules/monitor/data/common.yaml
lookup_options:
monitor::plugins:
strategy: unique
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
include monitor
# hieradata/common.yaml
monitor::plugins:
- cpu
- write_graphite
Lookup - Data In Modules
# hieradata/nodes/node1.yaml
monitor::plugins:
- my_app
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Tips and Tricks
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
lookup(“classes”, {“merge” => “unique”}).include
hiera_include()
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
hiera_include()
# common.yaml
lookup_options:
classes:
merge:
strategy: “deep”
knockout_prefix: “-“
classes:
- nagios
# nodes/node1.yaml
classes:
- -nagios
- sensu
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
lookup(“classes”).include
hiera_include()
# common.yaml
lookup_options:
classes:
merge:
strategy: “deep”
knockout_prefix: “-“
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
params.pp
# modules/ntp/hiera.yaml
---
version: 4
datadir: data
hierarchy:
- name: "Operating System Family"
backend: yaml
path: "%{facts.os.family}"
- name: "common"
backend: yaml
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
params.pp
# modules/ntp/data/AIX.yaml
---
ntp::driftfile: '/etc/ntp.drift'
ntp::package_name:
- 'bos.net.tcp.client'
ntp::restrict:
- 'default nomodify notrap nopeer noquery'
- '127.0.0.1'
ntp::service_name: 'xntpd'
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
params.pp
# modules/ntp/data/Debian.yaml
ntp::restrict:
- '-4 default kod nomodify notrap nopeer noquery'
- '-6 default kod nomodify notrap nopeer noquery'
- '127.0.0.1'
- '::1'
ntp::service_name: 'ntp'
ntp::servers:
- '0.debian.pool.ntp.org'
- '1.debian.pool.ntp.org'
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Future
• Hiera deprecated
• No more site wide hiera, only environment
and modules
• Pluggable via functions in modules - native or
ruby, much much simpler than old backends
• lookup.yaml or lookup.conf
R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar
Questions?
twitter: @ripienaar
email: rip@devco.net
blog: www.devco.net
github: ripienaar
freenode: Volcane
slack.puppet.com: ripienaar
https://www.devco.net/

Mais conteúdo relacionado

Mais procurados

Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)Robert Nelson
 
EuroPython 2015 - Decorators demystified
EuroPython 2015 - Decorators demystifiedEuroPython 2015 - Decorators demystified
EuroPython 2015 - Decorators demystifiedPablo Enfedaque
 
Introduction to Marionette Collective
Introduction to Marionette CollectiveIntroduction to Marionette Collective
Introduction to Marionette CollectivePuppet
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantBrian Hogan
 
Apollo ecosystem
Apollo ecosystemApollo ecosystem
Apollo ecosystemJames Akwuh
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansiblebcoca
 
Creating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoCreating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoBrian Hogan
 
Puppet control-repo 
to the next level
Puppet control-repo 
to the next levelPuppet control-repo 
to the next level
Puppet control-repo 
to the next levelAlessandro Franceschi
 
Django productivity tips and tricks
Django productivity tips and tricksDjango productivity tips and tricks
Django productivity tips and tricksSimone Federici
 
Webinar - Windows Application Management with Puppet
Webinar - Windows Application Management with PuppetWebinar - Windows Application Management with Puppet
Webinar - Windows Application Management with PuppetOlinData
 
GenStage and Flow - Jose Valim
GenStage and Flow - Jose Valim GenStage and Flow - Jose Valim
GenStage and Flow - Jose Valim Elixir Club
 
Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0bcoca
 
Webinar - Managing Files with Puppet
Webinar - Managing Files with PuppetWebinar - Managing Files with Puppet
Webinar - Managing Files with PuppetOlinData
 
Perl in the Internet of Things
Perl in the Internet of ThingsPerl in the Internet of Things
Perl in the Internet of ThingsDave Cross
 
Webpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoRyan Weaver
 
Writing Ansible Modules (CLT'19)
Writing Ansible Modules (CLT'19)Writing Ansible Modules (CLT'19)
Writing Ansible Modules (CLT'19)Martin Schütte
 

Mais procurados (20)

Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
 
EuroPython 2015 - Decorators demystified
EuroPython 2015 - Decorators demystifiedEuroPython 2015 - Decorators demystified
EuroPython 2015 - Decorators demystified
 
Puppet: From 0 to 100 in 30 minutes
Puppet: From 0 to 100 in 30 minutesPuppet: From 0 to 100 in 30 minutes
Puppet: From 0 to 100 in 30 minutes
 
Refactoring Infrastructure Code
Refactoring Infrastructure CodeRefactoring Infrastructure Code
Refactoring Infrastructure Code
 
Introduction to Marionette Collective
Introduction to Marionette CollectiveIntroduction to Marionette Collective
Introduction to Marionette Collective
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
 
Apollo ecosystem
Apollo ecosystemApollo ecosystem
Apollo ecosystem
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
Creating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoCreating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with Hugo
 
Puppet control-repo 
to the next level
Puppet control-repo 
to the next levelPuppet control-repo 
to the next level
Puppet control-repo 
to the next level
 
Refactoring terraform
Refactoring terraformRefactoring terraform
Refactoring terraform
 
Django productivity tips and tricks
Django productivity tips and tricksDjango productivity tips and tricks
Django productivity tips and tricks
 
Webinar - Windows Application Management with Puppet
Webinar - Windows Application Management with PuppetWebinar - Windows Application Management with Puppet
Webinar - Windows Application Management with Puppet
 
GenStage and Flow - Jose Valim
GenStage and Flow - Jose Valim GenStage and Flow - Jose Valim
GenStage and Flow - Jose Valim
 
Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0
 
Webinar - Managing Files with Puppet
Webinar - Managing Files with PuppetWebinar - Managing Files with Puppet
Webinar - Managing Files with Puppet
 
Perl in the Internet of Things
Perl in the Internet of ThingsPerl in the Internet of Things
Perl in the Internet of Things
 
Webpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San Francisco
 
Writing Ansible Modules (CLT'19)
Writing Ansible Modules (CLT'19)Writing Ansible Modules (CLT'19)
Writing Ansible Modules (CLT'19)
 
Concurrecny inf sharp
Concurrecny inf sharpConcurrecny inf sharp
Concurrecny inf sharp
 

Semelhante a External Data in Puppet 4 with Lookup Function

PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
Let's build Developer Portal with Backstage
Let's build Developer Portal with BackstageLet's build Developer Portal with Backstage
Let's build Developer Portal with BackstageOpsta
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk PemulaOon Arfiandwi
 
Hands-on go profiling
Hands-on go profilingHands-on go profiling
Hands-on go profilingDaniel Ammar
 
Large Scale Continuous Delivery
Large Scale Continuous DeliveryLarge Scale Continuous Delivery
Large Scale Continuous Deliveryripienaar
 
Introduction to interactive data visualisation using R Shiny
Introduction to interactive data visualisation using R ShinyIntroduction to interactive data visualisation using R Shiny
Introduction to interactive data visualisation using R Shinyanamarisaguedes
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
Monitoring using Sensu
Monitoring using SensuMonitoring using Sensu
Monitoring using Sensuripienaar
 
Introduction to Configuration Management
Introduction to Configuration ManagementIntroduction to Configuration Management
Introduction to Configuration Managementripienaar
 
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015Innomatic Platform
 
Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.CocoaHeads France
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with pythonroskakori
 
Advanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automationAdvanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automationCysinfo Cyber Security Community
 
Virtual Environment and Web development using Django
Virtual Environment and Web development using DjangoVirtual Environment and Web development using Django
Virtual Environment and Web development using DjangoSunil kumar Mohanty
 
2nd Content Providers Community Call
2nd Content Providers Community Call2nd Content Providers Community Call
2nd Content Providers Community CallOpenAIRE
 
Website Testing Practices
Website Testing PracticesWebsite Testing Practices
Website Testing Practicesdeseomar
 

Semelhante a External Data in Puppet 4 with Lookup Function (20)

PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
Let's build Developer Portal with Backstage
Let's build Developer Portal with BackstageLet's build Developer Portal with Backstage
Let's build Developer Portal with Backstage
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
 
Hands-on go profiling
Hands-on go profilingHands-on go profiling
Hands-on go profiling
 
Large Scale Continuous Delivery
Large Scale Continuous DeliveryLarge Scale Continuous Delivery
Large Scale Continuous Delivery
 
Introduction to interactive data visualisation using R Shiny
Introduction to interactive data visualisation using R ShinyIntroduction to interactive data visualisation using R Shiny
Introduction to interactive data visualisation using R Shiny
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Monitoring using Sensu
Monitoring using SensuMonitoring using Sensu
Monitoring using Sensu
 
Introduction to Configuration Management
Introduction to Configuration ManagementIntroduction to Configuration Management
Introduction to Configuration Management
 
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
 
Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with python
 
Advanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automationAdvanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automation
 
Virtual Environment and Web development using Django
Virtual Environment and Web development using DjangoVirtual Environment and Web development using Django
Virtual Environment and Web development using Django
 
实战Ecos
实战Ecos实战Ecos
实战Ecos
 
2nd Content Providers Community Call
2nd Content Providers Community Call2nd Content Providers Community Call
2nd Content Providers Community Call
 
router-simple.cr
router-simple.crrouter-simple.cr
router-simple.cr
 
Mini Curso de Django
Mini Curso de DjangoMini Curso de Django
Mini Curso de Django
 
Website Testing Practices
Website Testing PracticesWebsite Testing Practices
Website Testing Practices
 

Último

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
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
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 

Último (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
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
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
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?
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 

External Data in Puppet 4 with Lookup Function

  • 2. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Who am I? • Puppet User since 0.22 • Really into external data • Author facts.d, extlookup, Hiera, MCollective • Consultant - DevOps, Automation, Architect, Development • Open Source @ github.com/ripienaar • Volcane on IRC
  • 3. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar External Data Is Configuration For Your Code
  • 4. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Hierarchical Data class monitor ( Array[Monitor::Plugin] $plugins = [] ) { … }
  • 5. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Hierarchical Data class{“monitor”: plugins => [ “cpu", “write_graphite”, “df”, … ] }
  • 6. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Automatic Param Lookup include monitor # hieradb/nodes/host1.yaml monitor::plugins: - my_app class{“monitor”: plugins => [ “my_app”, “cpu”, “df”, … ] } + =
  • 7. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Hierarchical Data host1 host2 host3 host4 host5 host6 prod stage dev dc1 dc2 Site wide common data
  • 8. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Hierarchical Data host1 host2 host3 host4 host5 host6 prod stage dev dc1 dc2 Site wide common data
  • 9. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Hierarchical Data host1 host2 host3 host4 host5 host6 prod stage dev dc1 dc2 Site wide common data
  • 10. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Hierarchical Data host1 host2 host3 host4 host5 host6 prod stage dev dc1 dc2 Site wide common data $trusted[“certname”] $environment $facts[“dc”]
  • 11. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Automatic Param Lookup include monitor # hieradb/nodes/host1.yaml monitor::plugins: - my_app class{“monitor”: plugins => [ “my_app”, “cpu”, “df”, … ] } + =
  • 12. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup • lookup() function replaces hiera*() • Automatic Param Lookup more useful • environment and module aware • Great CLI • YAML/JSON out of the box, more to come • Data compatible with Hiera, cohabits with Hiera • Pluggable
  • 13. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - CLI $ puppet lookup monitor::plugins —merge unique —— - my_app - write_graphite - cpu
  • 14. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar $ puppet lookup monitor::plugins —merge unique —explain Merge strategy unique … Data Provider "Nodes" Path “/etc/…/production/data/nodes/dev3.devco.net.yaml” Original path: "nodes/%{trusted.certname}" Found key: "monitor::plugins" value: [ "my_app" ] … Data Provider "common" Path “/etc/…/data/common.yaml” Original path: "common" Found key: "monitor::plugins" value: [ "cpu", "write_graphite" ] … Merged result: [ "my_app", "cpu", "write_graphite" ]
  • 15. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar $ puppet lookup monitor::plugins —merge unique —explain Merge strategy unique … Data Provider "Nodes" Path “/etc/…/production/data/nodes/dev3.devco.net.yaml” Original path: "nodes/%{trusted.certname}" Found key: "monitor::plugins" value: [ "my_app" ] … Data Provider "common" Path “/etc/…/data/common.yaml” Original path: "common" Found key: "monitor::plugins" value: [ "cpu", "write_graphite" ] … Merged result: [ "my_app", "cpu", "write_graphite" ] Every tier Final result
  • 16. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - Config # environments/production/hiera.yaml --- version: 4 datadir: data hierarchy: - name: "Nodes" backend: yaml path: "nodes/%{trusted.certname}" - name: "common" backend: yaml
  • 17. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function $plugins = lookup(“monitor::plugins”)
  • 18. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function $plugins = lookup(“monitor::plugins”, { “value_type” => Array[Monitor::Plugin], “default_value” => [“cpu”, …] })
  • 19. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function function monitor::params() { $result = { “monitor::plugins” => [ “cpu”, … ] } } $plugins = lookup(“monitor::plugins”, { “default_value_hash” => monitor::params() })
  • 20. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function $servers = lookup(“monitor::plugins”, { “merge” => “first” }) Default behaviour
  • 21. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function $servers = lookup(“monitor::plugins”, { “merge” => “unique” }) Array Merge (hiera_array())
  • 22. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function $servers = lookup(“monitor::plugins”, { “merge” => “hash” }) Shallow Hash Merge (hiera_hash())
  • 23. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function $servers = lookup(“monitor::plugins”, { “merge” => “deep”, }) Deep Hash Merge
  • 24. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function # common.yaml users::local: rip: email: “rip@devco.net" comment: “R.I.Pienaar” sudoer: true shell: “/bin/zsh”
  • 25. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function # nodes/dev3.devco.net users::local: rip: email: “arri.pienaar@client.com”
  • 26. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function $ puppet lookup users::local —merge deep --- rip: email: arri.pienaar@client.com comment: R.I.Pienaar sudoer: true shell: "/bin/zsh"
  • 27. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Automatic Param Lookup include monitor # hieradb/nodes/host1.yaml monitor::plugins: - my_app class{“monitor”: plugins => [ “my_app”, “cpu”, “df”, … ] } + =
  • 28. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function $lookup_options = { “merge” => { “strategy” => “unique” } } $plugins = lookup(“monitor::plugins”, $lookup_options)
  • 29. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - function $plugins = lookup(“monitor::plugins”) # hieradata/common.yaml lookup_options: monitor::plugins: merge: strategy: unique
  • 30. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar include monitor # …/production/hieradata/common.yaml lookup_options: monitor::plugins: strategy: unique monitor::plugins: - cpu - … class monitor ( Array[Monitor::Plugin] $plugins = [] ) {} Lookup - function
  • 31. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Lookup - Data In Modules # modules/monitor/hiera.yaml --- version: 4 datadir: "data" hierarchy: - name: "common" backend: "yaml" # modules/monitor/data/common.yaml lookup_options: monitor::plugins: strategy: unique
  • 32. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar include monitor # hieradata/common.yaml monitor::plugins: - cpu - write_graphite Lookup - Data In Modules # hieradata/nodes/node1.yaml monitor::plugins: - my_app
  • 33. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Tips and Tricks
  • 34. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar lookup(“classes”, {“merge” => “unique”}).include hiera_include()
  • 35. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar hiera_include() # common.yaml lookup_options: classes: merge: strategy: “deep” knockout_prefix: “-“ classes: - nagios # nodes/node1.yaml classes: - -nagios - sensu
  • 36. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar lookup(“classes”).include hiera_include() # common.yaml lookup_options: classes: merge: strategy: “deep” knockout_prefix: “-“
  • 37. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar params.pp # modules/ntp/hiera.yaml --- version: 4 datadir: data hierarchy: - name: "Operating System Family" backend: yaml path: "%{facts.os.family}" - name: "common" backend: yaml
  • 38. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar params.pp # modules/ntp/data/AIX.yaml --- ntp::driftfile: '/etc/ntp.drift' ntp::package_name: - 'bos.net.tcp.client' ntp::restrict: - 'default nomodify notrap nopeer noquery' - '127.0.0.1' ntp::service_name: 'xntpd'
  • 39. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar params.pp # modules/ntp/data/Debian.yaml ntp::restrict: - '-4 default kod nomodify notrap nopeer noquery' - '-6 default kod nomodify notrap nopeer noquery' - '127.0.0.1' - '::1' ntp::service_name: 'ntp' ntp::servers: - '0.debian.pool.ntp.org' - '1.debian.pool.ntp.org'
  • 40. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Future • Hiera deprecated • No more site wide hiera, only environment and modules • Pluggable via functions in modules - native or ruby, much much simpler than old backends • lookup.yaml or lookup.conf
  • 41. R.I.Pienaar | rip@devco.net | http://devco.net | @ripienaar Questions? twitter: @ripienaar email: rip@devco.net blog: www.devco.net github: ripienaar freenode: Volcane slack.puppet.com: ripienaar https://www.devco.net/