SlideShare une entreprise Scribd logo
1  sur  51
Télécharger pour lire hors ligne
Hacking
The Data
out of Puppet
 Dan Bode| Puppet Labs
 dan@puppetlabs.com
Who is this talk for?

      •  People who already understand Puppet
      •  Developers or people who are dev-curious




 # puppetconf           # puppetize         @ puppetlabs
Shameless plug




 # puppetconf   # puppetize   @ puppetlabs
What is it about?

      •  Deconstructing Puppet to data




 # puppetconf           # puppetize      @ puppetlabs
Puppet as Data
 Dissecting a Puppet Run
Facter, who am I?	





                                     Hi! your facts are:	

                                     	

                                     kernel=linux	

                                     ipaddress=10.0.0.3	

        Agent	

                     macaddress=…	





    # puppetconf       # puppetize                        @ puppetlabs
facts	





                   Hi Mr. Master, 	

               I need a catalog. Here
    Agent	

        are my facts	


                                          http://www.dgcomputers.org/testimonials.php	



# puppetconf                # puppetize                                    @ puppetlabs
facts	





      Thanks for you facts.	

    Agent	

 store them in
      I’ll just
              PuppetDB	


                                               PuppetDB	

# puppetconf                     # puppetize                 @ puppetlabs
Mr. ENC, is this host
               defined as an external                       Yep, he should be an
                      node?	

                            apache server. Here is
                                                              the definition	





                                                               nodes	

                                                                        ENC	


    Agent	

                                     PuppetDB	

                                                                 facts	

# puppetconf                       # puppetize                   @ puppetlabs
catalog	



        Just compiled your
    Agent	

 One sec while
     catalog.                                   PuppetDB	

     I store it in PuppetDB.	

                                                                 facts	

# puppetconf                      # puppetize                    @ puppetlabs
Here is your
                                           catalog. Send me
                                            a report and let
                                           me know how it
                                                 went!	



                                 catalog	



    Agent	

                 PuppetDB	

                                            catalog	

                                              facts	

# puppetconf   # puppetize                     @ puppetlabs
I hate to be a
                    bother, but can
                     you compute
                   the md5sums of
                       a few files?	





               catalog	




    Agent	

                                 PuppetDB	

                                                           catalog	

                                                             facts	

# puppetconf                   # puppetize                   @ puppetlabs
report	





      Just finished applying.
    Agent	

are the results.	

      Here                                      PuppetDB	

                                                              catalog	

                                                                facts	

# puppetconf                      # puppetize                   @ puppetlabs
Termini and the indirector
 Interacting with Puppet’s Data
facts find from
terminus facter	





        Agent	



    # puppetconf     # puppetize   @ puppetlabs
facts	





               catalog find from
                 terminus rest	

    Agent	


                                        http://www.dgcomputers.org/testimonials.php	



# puppetconf              # puppetize                                    @ puppetlabs
facts	





     facts save to terminus
    Agent	

puppetdb	


                                            PuppetDB	

# puppetconf                  # puppetize                 @ puppetlabs
node find from
               terminus exec (or
                     ldap) 	





                                                               nodes	

                                                                       ENC	


    Agent	

                                     PuppetDB	

                                                                facts	

# puppetconf                       # puppetize                  @ puppetlabs
catalog	



        catalog find from
    Agent	

 compiler	

       terminus                          PuppetDB	

                                                          facts	

# puppetconf               # puppetize                    @ puppetlabs
catalog	



        catalog save to
    Agent	

 puppetdb	

      terminus                           PuppetDB	

                                                          facts	

# puppetconf               # puppetize                    @ puppetlabs
Disecting a Puppet Run


Facter	

            Facts	

    ENC	

          Nodes/
                                                 Manifest	





                                                    Compiler	

                    Reports	

     Config	

 Catalogs	




     # puppetconf                  # puppetize                    @ puppetlabs
CLI commands


               puppet	

              facts	

    find	


               puppet	

              node	

     find	


               puppet	

             catalog	

   find	





# puppetconf           # puppetize                         @ puppetlabs
CLI Puppet Facts

# mkdir –p /tmp/yaml/facts


# puppet facts find node_name --render-as yaml 
    > /tmp/yaml/facts/node_name.yaml




# puppetconf         # puppetize        @ puppetlabs
Creating a node (optional):
   # puppet node find node_name 
   --node_terminus=exec 
   --external_nodes=/etc/puppet/nodes.sh 
   --facts_terminus=yaml 
   --clientyamldir=/tmp/yaml/ --render-as=yaml 
   > /tmp/yaml/nodes/node_name.yaml




   # puppetconf         # puppetize           @ puppetlabs
Creating a catalog:
# puppet catalog find node_name 
--facts_terminus=yaml 


# puppet catalog find node_name 
--node_terminus=yaml 
--manifest=/etc/puppet/manifest/site.pp 
--modulepath=/etc/puppet/modules/
--clientyamldir=/tmp/yaml/ > /tmp/catalog.yaml
# puppetconf          # puppetize           @ puppetlabs
Fun with IRB

               Puppet::Node::Facts.indirection.find	

    facts	


                       Puppet::Node.new	

              nodes	


                 Puppet::Catalog.indirection.find	

     catalog	





# puppetconf                          # puppetize                   @ puppetlabs
IRB Facts

irb:> require ‘puppet/face’
    > facts=Puppet::Face[:facts, :current].find('node’)




 # puppetconf            # puppetize           @ puppetlabs
Access a Fact value (irb):
  …
  > facts.values['ipaddress']
  => "10.0.2.15"




  # puppetconf          # puppetize   @ puppetlabs
Creating a node (from irb):
   …
   > node=Puppet::Node.new('node_name',
   {:classes => {:foo => {:bar => :baz}}})
   >node.merge(facts.values)




   # puppetconf           # puppetize        @ puppetlabs
Creating a catalog:
…
irb> catalog=Puppet::Resource::Catalog.indirection.
    find('node_name’, :node => node)




    # puppetconf          # puppetize          @ puppetlabs
Use Cases
 Interacting with Puppet’s Data
Inspecting the catalog:

 •  What types are in the catalog?
 irb> catalog.resources.collect do |r| r.type end.uniq

 •  Gimme a resource:
 irb>catalog.resource(‘Package[httpd]’)




 # puppetconf           # puppetize           @ puppetlabs
Rspec Puppet:
    let :facts do
       {:operatingsystem => ‘Redhat’}
    end
    let :params do
      {:bind_address => ‘0.0.0.0’
    end
    it { should contain_file(‘/tmp/foo.conf’) }


# puppetconf             # puppetize              @ puppetlabs
Thundering Herd

Pre-compile catalogs for faster auto-scaling




# puppetconf          # puppetize              @ puppetlabs
Applying pre-compiled
      catalogs:

puppet apply --catalog /tmp/catalog.json –server
puppet-fileserver




# puppetconf         # puppetize           @ puppetlabs
DMZ

tcp over USB




# puppetconf     # puppetize   @ puppetlabs
Use Cases
 Interacting with Puppet’s Data
Hacking reports


 Everything in Puppet is a state transition


 User[‘dan’] : absent -> present
 User[‘dan’][‘shell’] -> ‘/sbin/nologin’ -> /bin/bash




# puppetconf            # puppetize             @ puppetlabs
Setting up the agent:



 [agent]
   report=true




# puppetconf     # puppetize   @ puppetlabs
Archive reports in your
yamldir


 [master]
   reports = store




# puppetconf         # puppetize   @ puppetlabs
Puppet reports

 $ cd `puppet config print reportdir`
 $ ls
 node1 node2 node3
 $ ls node1




# puppetconf           # puppetize      @ puppetlabs
Every report from every run
ever


 $ ls node1
 201206060256.yaml 201206060303.yaml
 201206060519.yaml 201206122349.yaml
 201206122354.yaml 201206130002.yaml




# puppetconf      # puppetize          @ puppetlabs
Lets crack one open!



 Irb > require ‘yaml’
 >reports=YAML.load_file('201206130002.yaml')




# puppetconf            # puppetize     @ puppetlabs
Have a look

 >(reports.methods - Object.methods).sort


 Notice the following methods:




# puppetconf          # puppetize           @ puppetlabs
High level data
 > reports.exit_status
 ⇒ 0
 > reports.status
 => "unchanged"
 > reports.host
 ⇒ ”node1”

# puppetconf             # puppetize   @ puppetlabs
metrics

 > reports.metrics.keys
 ⇒ ["resources", "events", "changes", "time"]
 > reports.metrics['resources']
 ⇒ [‘failed’, 0],[ ‘changed’, ‘7’]


# puppetconf            # puppetize        @ puppetlabs
And the awesome sauce

 > reports.resource_statuses.keys
 => ["Package[xinetd]", "File[/srv/node/1]",
 "Package[swift]", "Exec[compile fragments]",
 "Package[swift-container]", "File[/var/opt/lib/pe-
 puppet/concat/_etc_swift_object-server.conf]",
 "File[/etc/rsync.d/frag-account]”]




# puppetconf           # puppetize            @ puppetlabs
And the awesome sauce

 > status = reports.resource_statuses
 > status.keys
 => ["Package[xinetd]", "File[/srv/node/1]",
 "Package[swift]", "Exec[compile fragments]",
 "Package[swift-container]", "File[/var/opt/lib/pe-
 puppet/concat/_etc_swift_object-server.conf]",
 "File[/etc/rsync.d/frag-account]”]



# puppetconf           # puppetize            @ puppetlabs
And the awesome sauce
 >events = status["File[/etc/swift/swift.conf]"].events

 > events.first.status

 ⇒ "success”
 > events.first.desired_value

 ⇒ :present
 > events.first.previous_value

 => :absent




# puppetconf                    # puppetize               @ puppetlabs
Thank You
Dan Bode| Puppet Labs
dan@puppetlabs.com
Hacking The Data out of Puppet - PuppetConf '12

Contenu connexe

En vedette

PuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbqueryPuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbqueryPuppet
 
Network Automation at Shapeways
Network Automation at ShapewaysNetwork Automation at Shapeways
Network Automation at ShapewaysPuppet
 
Managing Puppet using MCollective
Managing Puppet using MCollectiveManaging Puppet using MCollective
Managing Puppet using MCollectivePuppet
 
Introduction to puppet
Introduction to puppetIntroduction to puppet
Introduction to puppetHabeeb Rahman
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetMichael Lessard
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansiblefmaccioni
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestrationbcoca
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricksbcoca
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction Robert Reiz
 
How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation EasyPeter Sankauskas
 
Adopting Kubernetes with Puppet
Adopting Kubernetes with PuppetAdopting Kubernetes with Puppet
Adopting Kubernetes with PuppetPuppet
 

En vedette (11)

PuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbqueryPuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbquery
 
Network Automation at Shapeways
Network Automation at ShapewaysNetwork Automation at Shapeways
Network Automation at Shapeways
 
Managing Puppet using MCollective
Managing Puppet using MCollectiveManaging Puppet using MCollective
Managing Puppet using MCollective
 
Introduction to puppet
Introduction to puppetIntroduction to puppet
Introduction to puppet
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with Puppet
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansible
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 
How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation Easy
 
Adopting Kubernetes with Puppet
Adopting Kubernetes with PuppetAdopting Kubernetes with Puppet
Adopting Kubernetes with Puppet
 

Similaire à Hacking The Data out of Puppet - PuppetConf '12

Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionJoshua Thijssen
 
Google compute presentation puppet conf
Google compute presentation puppet confGoogle compute presentation puppet conf
Google compute presentation puppet confbodepd
 
Puppet 3: Present and Future Tense
Puppet 3: Present and Future TensePuppet 3: Present and Future Tense
Puppet 3: Present and Future TenseEric Sorenson
 
Puppet 3: Present and Future Tense
Puppet 3: Present and Future TensePuppet 3: Present and Future Tense
Puppet 3: Present and Future TensePuppet
 
Getting Started With Puppet - Chad Metcalf
Getting Started With Puppet - Chad MetcalfGetting Started With Puppet - Chad Metcalf
Getting Started With Puppet - Chad MetcalfPuppet
 
State of Puppet London
State of Puppet LondonState of Puppet London
State of Puppet LondonPuppet
 
State of Puppet - London
State of Puppet - LondonState of Puppet - London
State of Puppet - LondonPuppet
 

Similaire à Hacking The Data out of Puppet - PuppetConf '12 (7)

Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 Edition
 
Google compute presentation puppet conf
Google compute presentation puppet confGoogle compute presentation puppet conf
Google compute presentation puppet conf
 
Puppet 3: Present and Future Tense
Puppet 3: Present and Future TensePuppet 3: Present and Future Tense
Puppet 3: Present and Future Tense
 
Puppet 3: Present and Future Tense
Puppet 3: Present and Future TensePuppet 3: Present and Future Tense
Puppet 3: Present and Future Tense
 
Getting Started With Puppet - Chad Metcalf
Getting Started With Puppet - Chad MetcalfGetting Started With Puppet - Chad Metcalf
Getting Started With Puppet - Chad Metcalf
 
State of Puppet London
State of Puppet LondonState of Puppet London
State of Puppet London
 
State of Puppet - London
State of Puppet - LondonState of Puppet - London
State of Puppet - London
 

Plus de Puppet

Puppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet
 
Puppetcamp r10kyaml
Puppetcamp r10kyamlPuppetcamp r10kyaml
Puppetcamp r10kyamlPuppet
 
2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)Puppet
 
Puppet camp vscode
Puppet camp vscodePuppet camp vscode
Puppet camp vscodePuppet
 
Modules of the twenties
Modules of the twentiesModules of the twenties
Modules of the twentiesPuppet
 
Applying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance codeApplying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance codePuppet
 
KGI compliance as-code approach
KGI compliance as-code approachKGI compliance as-code approach
KGI compliance as-code approachPuppet
 
Enforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automationEnforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automationPuppet
 
Keynote: Puppet camp compliance
Keynote: Puppet camp complianceKeynote: Puppet camp compliance
Keynote: Puppet camp compliancePuppet
 
Automating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNowAutomating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNowPuppet
 
Puppet: The best way to harden Windows
Puppet: The best way to harden WindowsPuppet: The best way to harden Windows
Puppet: The best way to harden WindowsPuppet
 
Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020Puppet
 
Accelerating azure adoption with puppet
Accelerating azure adoption with puppetAccelerating azure adoption with puppet
Accelerating azure adoption with puppetPuppet
 
Puppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael PinsonPuppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael PinsonPuppet
 
ServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin ReeuwijkServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin ReeuwijkPuppet
 
Take control of your dev ops dumping ground
Take control of your  dev ops dumping groundTake control of your  dev ops dumping ground
Take control of your dev ops dumping groundPuppet
 
100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy Software100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy SoftwarePuppet
 
Puppet User Group
Puppet User GroupPuppet User Group
Puppet User GroupPuppet
 
Continuous Compliance and DevSecOps
Continuous Compliance and DevSecOpsContinuous Compliance and DevSecOps
Continuous Compliance and DevSecOpsPuppet
 
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick MaludyThe Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick MaludyPuppet
 

Plus de Puppet (20)

Puppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepo
 
Puppetcamp r10kyaml
Puppetcamp r10kyamlPuppetcamp r10kyaml
Puppetcamp r10kyaml
 
2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)
 
Puppet camp vscode
Puppet camp vscodePuppet camp vscode
Puppet camp vscode
 
Modules of the twenties
Modules of the twentiesModules of the twenties
Modules of the twenties
 
Applying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance codeApplying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance code
 
KGI compliance as-code approach
KGI compliance as-code approachKGI compliance as-code approach
KGI compliance as-code approach
 
Enforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automationEnforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automation
 
Keynote: Puppet camp compliance
Keynote: Puppet camp complianceKeynote: Puppet camp compliance
Keynote: Puppet camp compliance
 
Automating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNowAutomating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNow
 
Puppet: The best way to harden Windows
Puppet: The best way to harden WindowsPuppet: The best way to harden Windows
Puppet: The best way to harden Windows
 
Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020
 
Accelerating azure adoption with puppet
Accelerating azure adoption with puppetAccelerating azure adoption with puppet
Accelerating azure adoption with puppet
 
Puppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael PinsonPuppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael Pinson
 
ServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin ReeuwijkServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin Reeuwijk
 
Take control of your dev ops dumping ground
Take control of your  dev ops dumping groundTake control of your  dev ops dumping ground
Take control of your dev ops dumping ground
 
100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy Software100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy Software
 
Puppet User Group
Puppet User GroupPuppet User Group
Puppet User Group
 
Continuous Compliance and DevSecOps
Continuous Compliance and DevSecOpsContinuous Compliance and DevSecOps
Continuous Compliance and DevSecOps
 
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick MaludyThe Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
 

Dernier

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Dernier (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Hacking The Data out of Puppet - PuppetConf '12

  • 1. Hacking The Data out of Puppet Dan Bode| Puppet Labs dan@puppetlabs.com
  • 2. Who is this talk for? •  People who already understand Puppet •  Developers or people who are dev-curious # puppetconf # puppetize @ puppetlabs
  • 3. Shameless plug # puppetconf # puppetize @ puppetlabs
  • 4. What is it about? •  Deconstructing Puppet to data # puppetconf # puppetize @ puppetlabs
  • 5. Puppet as Data Dissecting a Puppet Run
  • 6. Facter, who am I? Hi! your facts are: kernel=linux ipaddress=10.0.0.3 Agent macaddress=… # puppetconf # puppetize @ puppetlabs
  • 7. facts Hi Mr. Master, I need a catalog. Here Agent are my facts http://www.dgcomputers.org/testimonials.php # puppetconf # puppetize @ puppetlabs
  • 8. facts Thanks for you facts. Agent store them in I’ll just PuppetDB PuppetDB # puppetconf # puppetize @ puppetlabs
  • 9. Mr. ENC, is this host defined as an external Yep, he should be an node? apache server. Here is the definition nodes ENC Agent PuppetDB facts # puppetconf # puppetize @ puppetlabs
  • 10. catalog Just compiled your Agent One sec while catalog. PuppetDB I store it in PuppetDB. facts # puppetconf # puppetize @ puppetlabs
  • 11. Here is your catalog. Send me a report and let me know how it went! catalog Agent PuppetDB catalog facts # puppetconf # puppetize @ puppetlabs
  • 12. I hate to be a bother, but can you compute the md5sums of a few files? catalog Agent PuppetDB catalog facts # puppetconf # puppetize @ puppetlabs
  • 13. report Just finished applying. Agent are the results. Here PuppetDB catalog facts # puppetconf # puppetize @ puppetlabs
  • 14. Termini and the indirector Interacting with Puppet’s Data
  • 15. facts find from terminus facter Agent # puppetconf # puppetize @ puppetlabs
  • 16. facts catalog find from terminus rest Agent http://www.dgcomputers.org/testimonials.php # puppetconf # puppetize @ puppetlabs
  • 17. facts facts save to terminus Agent puppetdb PuppetDB # puppetconf # puppetize @ puppetlabs
  • 18. node find from terminus exec (or ldap) nodes ENC Agent PuppetDB facts # puppetconf # puppetize @ puppetlabs
  • 19. catalog catalog find from Agent compiler terminus PuppetDB facts # puppetconf # puppetize @ puppetlabs
  • 20. catalog catalog save to Agent puppetdb terminus PuppetDB facts # puppetconf # puppetize @ puppetlabs
  • 21. Disecting a Puppet Run Facter Facts ENC Nodes/ Manifest Compiler Reports Config Catalogs # puppetconf # puppetize @ puppetlabs
  • 22. CLI commands puppet facts find puppet node find puppet catalog find # puppetconf # puppetize @ puppetlabs
  • 23. CLI Puppet Facts # mkdir –p /tmp/yaml/facts # puppet facts find node_name --render-as yaml > /tmp/yaml/facts/node_name.yaml # puppetconf # puppetize @ puppetlabs
  • 24. Creating a node (optional): # puppet node find node_name --node_terminus=exec --external_nodes=/etc/puppet/nodes.sh --facts_terminus=yaml --clientyamldir=/tmp/yaml/ --render-as=yaml > /tmp/yaml/nodes/node_name.yaml # puppetconf # puppetize @ puppetlabs
  • 25. Creating a catalog: # puppet catalog find node_name --facts_terminus=yaml # puppet catalog find node_name --node_terminus=yaml --manifest=/etc/puppet/manifest/site.pp --modulepath=/etc/puppet/modules/ --clientyamldir=/tmp/yaml/ > /tmp/catalog.yaml # puppetconf # puppetize @ puppetlabs
  • 26. Fun with IRB Puppet::Node::Facts.indirection.find facts Puppet::Node.new nodes Puppet::Catalog.indirection.find catalog # puppetconf # puppetize @ puppetlabs
  • 27. IRB Facts irb:> require ‘puppet/face’ > facts=Puppet::Face[:facts, :current].find('node’) # puppetconf # puppetize @ puppetlabs
  • 28. Access a Fact value (irb): … > facts.values['ipaddress'] => "10.0.2.15" # puppetconf # puppetize @ puppetlabs
  • 29. Creating a node (from irb): … > node=Puppet::Node.new('node_name', {:classes => {:foo => {:bar => :baz}}}) >node.merge(facts.values) # puppetconf # puppetize @ puppetlabs
  • 30. Creating a catalog: … irb> catalog=Puppet::Resource::Catalog.indirection. find('node_name’, :node => node) # puppetconf # puppetize @ puppetlabs
  • 31. Use Cases Interacting with Puppet’s Data
  • 32. Inspecting the catalog: •  What types are in the catalog? irb> catalog.resources.collect do |r| r.type end.uniq •  Gimme a resource: irb>catalog.resource(‘Package[httpd]’) # puppetconf # puppetize @ puppetlabs
  • 33. Rspec Puppet: let :facts do {:operatingsystem => ‘Redhat’} end let :params do {:bind_address => ‘0.0.0.0’ end it { should contain_file(‘/tmp/foo.conf’) } # puppetconf # puppetize @ puppetlabs
  • 34. Thundering Herd Pre-compile catalogs for faster auto-scaling # puppetconf # puppetize @ puppetlabs
  • 35. Applying pre-compiled catalogs: puppet apply --catalog /tmp/catalog.json –server puppet-fileserver # puppetconf # puppetize @ puppetlabs
  • 36. DMZ tcp over USB # puppetconf # puppetize @ puppetlabs
  • 37. Use Cases Interacting with Puppet’s Data
  • 38. Hacking reports Everything in Puppet is a state transition User[‘dan’] : absent -> present User[‘dan’][‘shell’] -> ‘/sbin/nologin’ -> /bin/bash # puppetconf # puppetize @ puppetlabs
  • 39. Setting up the agent: [agent] report=true # puppetconf # puppetize @ puppetlabs
  • 40. Archive reports in your yamldir [master] reports = store # puppetconf # puppetize @ puppetlabs
  • 41. Puppet reports $ cd `puppet config print reportdir` $ ls node1 node2 node3 $ ls node1 # puppetconf # puppetize @ puppetlabs
  • 42. Every report from every run ever $ ls node1 201206060256.yaml 201206060303.yaml 201206060519.yaml 201206122349.yaml 201206122354.yaml 201206130002.yaml # puppetconf # puppetize @ puppetlabs
  • 43. Lets crack one open! Irb > require ‘yaml’ >reports=YAML.load_file('201206130002.yaml') # puppetconf # puppetize @ puppetlabs
  • 44. Have a look >(reports.methods - Object.methods).sort Notice the following methods: # puppetconf # puppetize @ puppetlabs
  • 45. High level data > reports.exit_status ⇒ 0 > reports.status => "unchanged" > reports.host ⇒ ”node1” # puppetconf # puppetize @ puppetlabs
  • 46. metrics > reports.metrics.keys ⇒ ["resources", "events", "changes", "time"] > reports.metrics['resources'] ⇒ [‘failed’, 0],[ ‘changed’, ‘7’] # puppetconf # puppetize @ puppetlabs
  • 47. And the awesome sauce > reports.resource_statuses.keys => ["Package[xinetd]", "File[/srv/node/1]", "Package[swift]", "Exec[compile fragments]", "Package[swift-container]", "File[/var/opt/lib/pe- puppet/concat/_etc_swift_object-server.conf]", "File[/etc/rsync.d/frag-account]”] # puppetconf # puppetize @ puppetlabs
  • 48. And the awesome sauce > status = reports.resource_statuses > status.keys => ["Package[xinetd]", "File[/srv/node/1]", "Package[swift]", "Exec[compile fragments]", "Package[swift-container]", "File[/var/opt/lib/pe- puppet/concat/_etc_swift_object-server.conf]", "File[/etc/rsync.d/frag-account]”] # puppetconf # puppetize @ puppetlabs
  • 49. And the awesome sauce >events = status["File[/etc/swift/swift.conf]"].events > events.first.status ⇒ "success” > events.first.desired_value ⇒ :present > events.first.previous_value => :absent # puppetconf # puppetize @ puppetlabs
  • 50. Thank You Dan Bode| Puppet Labs dan@puppetlabs.com