You are on page 1of 60

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
more Faster
s ys t e ms provisioning
The Challenge
more Faster
s ys t e ms provisioning
more environments
dyn
env ami
iron c
me
nts

The Challenge
more Faster
s ys t e ms provisioning
more environments
dyn
env ami
iron c
g me
a lin nts
t o sc
a u
The Challenge
more Faster
s ys t e ms provisioning
more environments
micro-services dyn
env ami
iron c
g me
a lin nts
t o sc
a u
The Challenge
more Faster
s ys t e ms provisioning
more environments
micro-services dyn
env ami
iron c
g me
a lin nts
t o sc
a u
The Challenge
more Faster
s ys t e ms provisioning
more environments
Tools like Puppet have
become essential
The need for
automated, repeatable, versioned
provisioning and configuration
management of infrastructure and
services
Let’s raise the bar

We need
automated, repeatable, versioned
learning, reactive and adaptive
provisioning and configuration
management of infrastructure and
services
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

Puppet
Master PuppetDB Postgres

agent agent agent agent


PuppetDB

Puppet
Master PuppetDB Postgres

agent agent agent agent


PuppetDB
Puppet
Master PuppetDB
Load
balancer Postgres
Puppet
Master PuppetDB

agent agent agent agent


What data goes in PuppetDB
Node Facts
ipaddress network
y s te m
ti ng s host
p e r a macaddress nam
o e
sshrsakey kernel osfamily
rysize

Node Facts
memo

rs i on
e tve
pupp operatingsystemrelease
t
arch
itect FQDN ce s s o r cou n
ure pro
Node Catalog’s
a t ion
s s i fi c
c la classes

Node Catalog’s
Relations
h ip
resources / depende
ncies
Facts about every node
Catalog for every node

CMDB??
So much useful data
How do we access it?
PuppetDB has an API
PuppetDB API
PuppetDB REST API has the following endpoints:

• Nodes • Environments
• Catalogs • Metrics
• Facts • Reports
• Fact-names • Events
• Resources • 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

https://forge.puppetlabs.com/dalen/puppetdbquery

Again, thank you Erik Dalén


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

Hiera data
facts

catalog Puppet
agent Puppet code
report Master
Puppet run with
puppetdbquery
Hiera data
facts

catalog Puppet
agent Puppet code
report Master

PuppetDB
query_nodes
Accepts 2 arguments 1. Query to filter nodes
2. Fact to return (optional)

query fact
query_nodes
Accepts 2 arguments 1. Query to filter nodes
2. Fact to return (optional)

query fact
Returns an array of results

webservers = [‘node2.local’, ‘node3.local’]


foo_db_ip = [‘10.10.40.12’]
query_facts
Accepts 2 arguments
1. Query to filter nodes
2. List of facts to return

query facts
query_facts
Accepts 2 arguments
1. Query to filter nodes
2. List of facts to return

query facts

Returns nested hash of results


webserver_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

You might also like