Closed seanmil closed 3 years ago
This seems okay to me, in general. Since I don't have a way to test against PE at the moment, could you post a diff output when this feature is used?
Let me see if I can come up with something simple but effective to show the behavior.
This seems okay to me, in general. Since I don't have a way to test against PE at the moment, could you post a diff output when this feature is used?
@ahayworth Given that the only difference when enabling this option is the addition of one extra fact in both the from and to compiles it wasn't quite as simple as doing notify
on the fact and seeing the difference (because enabled or disabled the fact value should be the same), so I came up with the following:
$timestamp = Timestamp.new()
$pkgs = $facts.dig('_puppet_inventory_1', 'packages')
if $pkgs {
$pkg_count = $pkgs.length
$msg = "${String($timestamp)}: ${pkg_count} packages"
} else {
$msg = "${String($timestamp)}: ${String($facts['_puppet_inventory_1'], '%p')}"
}
notify { 'package_inventory_count':
message => $msg,
}
The idea is that the timestamp will differ, even if the actual fact does not. With the above code I get:
$ bundle exec octocatalog-diff <a bunch of options> --no-puppetdb-package-inventory
I, [2020-12-18T17:00:53.677306 #12217] INFO -- : Catalogs compiled for mytestnode
I, [2020-12-18T17:00:53.678453 #12217] INFO -- : Diffs computed for mytestnode
Notify[package_inventory_count] =>
parameters =>
message =>
- 2020-12-18T17:00:53.524052575 UTC: undef
+ 2020-12-18T17:00:53.601770732 UTC: undef
*******************************************
With the new option enabled:
$ bundle exec octocatalog-diff <a bunch of options> --puppetdb-package-inventory
I, [2020-12-18T17:01:56.641819 #12576] INFO -- : Catalogs compiled for mytestnode
I, [2020-12-18T17:01:56.643138 #12576] INFO -- : Diffs computed for mytestnode
Notify[package_inventory_count] =>
parameters =>
message =>
- 2020-12-18T17:01:56.529232507 UTC: 773 packages
+ 2020-12-18T17:01:56.560630729 UTC: 773 packages
*******************************************
Was that what you were looking for?
@seanmil Yeah, that works! Seeing the puppet code is actually what made sense to me. In retrospect ... the change actually makes a lot more sense than I initially thought and I am not really sure what I was worried about. 😆
Overview
This pull request introduces functionality to feed the data from the Puppet Enterprise package inventory feature back into the compile process.
When an agent gathers facts in a Puppet Enterprise environment with the PE-specific package inventory feature turned on, the package inventory is returned as part of the fact upload and then that package data is available in a PuppetDB endpoint independent of the rest of the facter data.
You should not generally need to include the package inventory data for Octocatalog-Diff testing, but if you have a specific reason to want it included to more closely match what occurs in production this addition allows it to be included.
Checklist
rake
in your checkout directory, or review the CI job triggered whenever you push to a pull request.rake coverage:spec
or ignoring untestable sections of code with# :nocov
comments. If you need help getting to 100% coverage please ask; however, don't just submit code with no tests..gem
file into the vendor/cache directory.