Skip to content

Commit

Permalink
Adding --node_list option (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: Taylor Owen <towen@athenahealth.com>
  • Loading branch information
Taylor Owen and serialh0bbyist authored Feb 23, 2022
1 parent b7f3031 commit feaec28
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ $ puppet catalog diff \
--output_report "${HOME}/lastrun-$$.json" \
--debug \
\ #--fact_search kernel='Darwin' \
--threads 50
--threads 50 \
\ #--node_list=node1.example.come,node2.example.com
```


Expand All @@ -174,6 +175,12 @@ This currently defaults to `kernel=Linux` if you do not pass it.
This query will be passed as a filter to the PuppetDB to retrieve the list of
nodes to compare.

### Node list

Passing `--node_list` will bypass the dynamic generation of node lists from PuppetDB
including the `--fact_search` filter. The list of nodes are not validated against
PuppetDB, and it is up to the user to ensure that the nodes exist and are active.

### Changed depth

Once each catalog is compiled , it is saved to the /tmp directory on the system and the
Expand Down
7 changes: 6 additions & 1 deletion lib/puppet/face/catalog/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
summary 'Use the certless catalog API (Puppet >= 6.3.0)'
end

option '--node_list=' do
summary 'A manual list of nodes to run catalog diffs against'
end

description <<-'EOT'
Prints the differences between catalogs compiled by different puppet master to help
during migrating to a new Puppet version.
Expand Down Expand Up @@ -171,7 +175,8 @@
filter_old_env: options[:filter_old_env],
certless: options[:certless],
old_catalog_from_puppetdb: options[:old_catalog_from_puppetdb],
new_catalog_from_puppetdb: options[:new_catalog_from_puppetdb]
new_catalog_from_puppetdb: options[:new_catalog_from_puppetdb],
node_list: options[:node_list]
)
diff_output = Puppet::Face[:catalog, '0.0.1'].diff(old_catalogs, new_catalogs, options)
nodes = diff_output
Expand Down
10 changes: 9 additions & 1 deletion lib/puppet/face/catalog/pull.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
summary 'Use the certless catalog API (Puppet >= 6.3.0)'
end

option '--node_list=' do
summary 'A manual list of nodes to run catalog diffs against'
end

description <<-'EOT'
This action is used to seed a series of catalogs from two servers
EOT
Expand All @@ -64,7 +68,11 @@
when_invoked do |catalog1, catalog2, args, options|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'catalog-diff', 'searchfacts.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'catalog-diff', 'compilecatalog.rb'))
nodes = Puppet::CatalogDiff::SearchFacts.new(args).find_nodes(options)
nodes = if options[:node_list].nil?
Puppet::CatalogDiff::SearchFacts.new(args).find_nodes(options)
else
options[:node_list].split(',')
end
raise "Problem finding nodes with query #{args}" unless nodes

total_nodes = nodes.size
Expand Down

0 comments on commit feaec28

Please sign in to comment.