Puppetcamp Melbourne - puppetdb
-
Upload
mrichardson -
Category
Technology
-
view
337 -
download
2
description
Transcript of Puppetcamp Melbourne - puppetdb
Node
Collaboration with
PuppetDB
Michael Richardson @m_richo
Agenda
1. Who am i
2. The challenges we face
3. What is PuppetDB
4. How can PuppetDB help
5. Examples
$ whoami
• Michael Richardson @m_richo
• engineer at Odecee
• Solaris/Linux Sys Admin
• currently battling Windows
• coffee consumer
• devops enthusiast
• puppet certified
The Challenge
The Challenge
Faster
provisioning
The Challenge
Faster
provisioning
The Challenge
more environments
Faster
provisioning
The Challenge
more environments
Faster
provisioning
The Challenge
more environments
Faster
provisioning
The Challenge
micro-services
more environments
Faster
provisioning
The Challenge
micro-services
more environments
Faster
provisioning
Tools like Puppet have
become essential
The need for
automated, repeatable, versioned
provisioning and configuration
management of infrastructure and
services
We need
automated, repeatable, versioned
learning, reactive and adaptive
provisioning and configuration
management of infrastructure and
services
Let’s raise the bar
This is where
PuppetDB
and tools can help
So what is PuppetDB?
So what is PuppetDB?
1. PuppetLabs product.
2. Storage service for Puppet produced
data.
3. Written in Clojure.
4. Persists data to a Postgres DB
5. Supports Puppet Enterprise and Puppet
Open Source environments.
PuppetDB
PuppetDBPuppetMaster
agent agent agent agent
Postgres
PuppetDB
PuppetDBPuppetMaster
agent agent agent agent
Postgres
PuppetDB
PuppetDBPuppetMaster
agent agent agent agent
Postgres
PuppetDBPuppetMaster
Load balancer
What data goes in PuppetDB
Node Facts
Node Facts
ipaddress network
FQDN
macaddress
operatingsystemrelease
osfamilysshrsakey kernel
Node Catalog’s
Node Catalog’s
CMDB??So much useful data
Facts about every node
Catalog for every node
How do we access it?
PuppetDB has an API
PuppetDB API
PuppetDB REST API has the following endpoints:
• Nodes
• Catalogs
• Facts
• Fact-names
• Resources
• Environments
• Metrics
• Reports
• Events
• And more
Query PuppetDB
Query all the nodes
Query PuppetDB
Query nodes and filter results
Query PuppetDB
Query all facts for a given node
Query PuppetDB
Query an individual fact for a given node
Sick of running curl?
Check out Puppet Explorer
thank you Erik Dalén and
Check out Puppetboard
thank you Daniele Sluijters
Dashboards are lovely.
But how can we use
this data to allow
node collaboration
Introducing
PuppetDBquery module
Again, thank you Erik Dalén
https://forge.puppetlabs.com/dalen/puppetdbquery
PuppetDB query
Provides
1. CLI commands
2. PuppetDB Hiera backend
3. PuppetDB functions
PuppetDB query
Provides
1. CLI commands
2. PuppetDB Hiera backend
3. PuppetDB functions
PuppetDB query
Provides
1. CLI commands
2. PuppetDB Hiera backend
3. PuppetDB functions
o query_nodes
o query_facts
Puppet run
PuppetMaster
agent
facts
Puppet code
Hiera data
catalog
report
Puppet run with puppetdbquery
PuppetDB
PuppetMaster
agent
facts
Puppet code
Hiera data
catalog
report
query_nodesAccepts 2 arguments 1. Query to filter nodes
2. Fact to return (optional)
query_nodesAccepts 2 arguments 1. Query to filter nodes
2. Fact to return (optional)
Returns an array of results
webservers = [‘node2.local’, ‘node3.local’]
foo_db_ip = [‘10.10.40.12’]
query_factsAccepts 2 arguments
1. Query to filter nodes
2. List of facts to return
query_factsAccepts 2 arguments
1. Query to filter nodes
2. List of facts to return
Returns nested hash of resultswebserver_network = {"node2.local"=>{"macaddress”
=>"08:00:27:99:4B:CB", "ipaddress"=>"10.0.2.15"},
"node3.local"=>{"macaddress"=>"08:00:27:99:4B:CB",
"ipaddress"=>"10.0.2.15"}}
What’s this give us?
What’s this give us?
The ability to dynamically configure a system based on the state of other systems in
the infrastructure.
Examples
populate files with query results
populate files with query results
populate files with query results
Examples – load balancer
Examples – whitelist addresses
Examples – search for service
Summary
• PuppetDB has a wealth of information
about your systems. Start using it!
• Populate dynamic configuration based on
PuppetDB data.
• Allow hosts and services to simply be
discovered by their peers.
Thank you.
#protip
Go buy this book now
By Alessandro Franceschi
It is EXCELLENT!
Thank you.
For folks from Sydney
Sydney Puppet User Group
http://www.meetup.com/Sydney-Puppet-User-Group/
Come along
Thank you
Any Questions?
Michael Richardson @m_richo