Skip to content

make puppetdb-termini optional #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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: 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