Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
![Catalog Diff](https://raw.githubusercontent.com/voxpupuli/puppet-catalog_diff/master/catalog-diff.png)


#### Table of Contents
# Table of Contents

1. [Overview](#overview)
1. [Module Description](#module-description)
Expand All @@ -24,14 +24,20 @@
1. [Usage](#usage)
1. [Multi threaded compile requests](#multi-threaded-compile-requests)
1. [Fact search](#fact-search)
1. [Node list](#node-list)
1. [Changed depth](#changed-depth)
1. [Output report](#output-report)
1. [Output Report](#output-report)
1. [Non-default PuppetDB/Configuring PuppetDB](#non-default-puppetdbconfiguring-puppetdb)
1. [Use without PuppetDB](#use-without-puppetdb)
1. [Non-default Puppetserver](#non-default-puppetserver)
1. [Limitations](#limitations)
1. [Previous Authors](#previous-authors)
1. [Contributors](#contributors)
1. [See Also](#see-also)
1. [See also](#see-also)
1. [Upload facts to PuppetDB](#upload-facts-to-puppetdb)
1. [Modern fact submission](#modern-fact-submission)
1. [complex fact submission](#complex-fact-submission)
1. [Further documentation](#further-documentation)


## Overview
Expand Down Expand Up @@ -293,6 +299,12 @@ via CLI options Those are:
* `--old_puppetdb_tls_key=`
* `--old_puppetdb_tls_ca=`

#### Use without PuppetDB

It is possible to use this module without PuppetDB.
If the libraries for PuppetDB are not installed, the module will set the
puppet_url parameter to `https://puppetdb:8081` and will not use PuppetDB.

### Non-default Puppetserver

`puppet catalog diff` can request an old catalog from a Puppetserver. The
Expand Down
18 changes: 18 additions & 0 deletions lib/puppet/catalog-diff/puppetdbfactory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# Puppet::CatalogDiff
module Puppet::CatalogDiff
class Puppetdbfactory
def self.puppetdb_url
begin
require 'puppet/util/puppetdb'
puppetdb_url = Puppet::Util::Puppetdb.config.server_urls[0]
rescue LoadError
# PuppetDB is not available, so we can't use it
# This is fine, we can still run the catalog diff without it
puppetdb_url = 'https://puppetdb:8081'
end
puppetdb_url
end
end
end
28 changes: 15 additions & 13 deletions lib/puppet/face/catalog/diff.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'puppet/face'
require 'json'
require 'puppet/util/puppetdb'
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'catalog-diff', 'puppetdbfactory.rb'))

begin
require 'parallel'
Expand All @@ -13,7 +13,7 @@
action :diff do
summary 'Compare catalogs from different puppet versions.'
arguments '<catalog1> <catalog2>'
puppetdb_url = Puppet::Util::Puppetdb.config.server_urls[0]
puppetdb_url = Puppet::CatalogDiff::Puppetdbfactory.puppetdb_url
hostcert = Puppet.settings[:hostcert]
hostprivkey = Puppet.settings[:hostprivkey]
localcacert = Puppet.settings[:localcacert]
Expand Down Expand Up @@ -136,20 +136,22 @@

Validation Process:

- Grab a catalog from your existing machine running the old version
- Configure your new Puppet master, copy the facts from your old master
to the new one
- Compile the catalog for this host on the new master:
- Grab a catalog from your existing machine running the old version
- Configure your new Puppet master, copy the facts from your old master
to the new one
- Compile the catalog for this host on the new master:

puppet master --compile fqdn > fqdn.pson
puppet master --compile fqdn > fqdn.pson

- Puppet puts a header in some catalogs compiled in this way, remove it if present
- At this point you should have 2 different catalogs. To compare them run:
- Puppet puts a header in some catalogs compiled in this way, remove it if present
- At this point you should have 2 different catalogs. To compare them run:

puppet catalog diff <catalog1> <catalog2>
- Alternatively you can process a directory containing matching files
- i.e. path/to/old/node_name.yaml and path/to/new/node_name.yaml
puppet catalog diff <path/to/old> <path/to/new>
puppet catalog diff <catalog1> <catalog2>

- Alternatively you can process a directory containing matching files
- i.e. path/to/old/node_name.yaml and path/to/new/node_name.yaml

puppet catalog diff <path/to/old> <path/to/new>

This code only validates the catalogs, it cannot tell you if the behavior of
the providers that interpret the catalog has changed so testing is still
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/face/catalog/pull.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'puppet/face'
require 'digest'
require 'puppet/util/puppetdb'
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'catalog-diff', 'puppetdbfactory.rb'))

Puppet::Face.define(:catalog, '0.0.1') do
action :pull do
description 'Pull catalogs from duel puppet masters'
summary 'Pull catalogs from duel puppet masters'
arguments '/tmp/old_catalogs /tmp/new_catalogs'
puppetdb_url = Puppet::Util::Puppetdb.config.server_urls[0]
puppetdb_url = Puppet::CatalogDiff::Puppetdbfactory.puppetdb_url
hostcert = Puppet.settings[:hostcert]
hostprivkey = Puppet.settings[:hostprivkey]
localcacert = Puppet.settings[:localcacert]
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/face/catalog/seed.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'puppet/face'
require 'puppet/util/puppetdb'
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'catalog-diff', 'puppetdbfactory.rb'))

Puppet::Face.define(:catalog, '0.0.1') do
action :seed do
summary 'Generate a series of catalogs'
arguments '<path/to/seed/directory> fact=CaseSensitiveValue'
puppetdb_url = Puppet::Util::Puppetdb.config.server_urls[0]
puppetdb_url = Puppet::CatalogDiff::Puppetdbfactory.puppetdb_url
hostcert = Puppet.settings[:hostcert]
hostprivkey = Puppet.settings[:hostprivkey]
localcacert = Puppet.settings[:localcacert]
Expand Down
Loading