Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Puppet Catalog Testing

Puppet Catalog Testing

At the London Puppet User Group Meetup in May 2016, Mike Mead spoke about how we use catalog testing to quickly check for correctness in our Puppet manifests.

The Scale Factory

May 19, 2016
Tweet

More Decks by The Scale Factory

Other Decks in Technology

Transcript

  1. WHAT IS A CATALOG_ “A catalog is a document that

    describes the desired system state for one specific computer.”
  2. RSPEC PUPPET_ • Unit testing framework • Finds dependency cycles

    • Check that the catalog contains a particular resource
  3. describe 'apache', :type => 'class' do context "on a Debian

    OS" do let(:facts) {{ :osfamily => 'Debian' }} it { should compile.with_all_deps } end context "on a RedHat OS" do let(:facts) {{ :osfamily => 'RedHat' }} it { should compile.with_all_deps } end end
  4. __default_facts: &default_facts architecture: x86_64 centos_webserver: <<: *default_facts osfamily: RedHat operatingsystem:

    CentOS fqdn: webserver-a.local ubuntu_webserver: <<: *default_facts osfamily: Debian operatingsystem: Ubuntu fqdn: webserver-b.local
  5. [INFO] Using puppet 3.8.7 [PASSED] centos_webserver (compile time: 0.064285695 seconds)

    [PASSED] ubuntu_webserver (compile time: 0.064342 seconds) ---------------------------------------- Compiled 2 catalogs in 0.1131 seconds (avg: 0.0566 seconds)
  6. [INFO] Using puppet 3.8.7 [FAILED] ubuntu_webserver (compile time: 0.086619958 seconds)

    [FAILED] centos_webserver (compile time: 0.08667039 seconds) ---------------------------------------- Compiled 2 catalogs in 0.1462 seconds (avg: 0.0731 seconds) 2 test cases failed. [F] centos_webserver: Could not find class nginx for webserver-a on node webserver-a [F] ubuntu_webserver: Could not find class nginx for webserver-b on node webserver-b 2 / 2 FAILED
  7. PUPPET CATALOG TEST_ • No catalog inspection • No checks

    for missing dependencies • or dependency cycles
  8. IT’S NOT AN IDEAL WORLD_ • RSpec is hard to

    retrofit • ...and it’s time-consuming to write tests for • Puppet-catalog-test is quick to implement, easy to maintain, and gives great ROI