Limitations for files with changing source
- What did you do?
Diff two already generated catalogs against each other by using the API functionality:
catalog_old.write(getCatalog(@options.merge({:puppetdb_url => 'https://puppetdb-live.example.org:8081'}), logger))
catalog_new.write(getCatalog(@options.merge({:puppetdb_url => 'https://puppetdb-dev.example.org:8081'}), logger))
catalog_diff_result = OctocatalogDiff::API::V1.catalog_diff(
{
:to_catalog => catalog_new.path,
:from_catalog => catalog_old.path,
}
)
diff_printer = OctocatalogDiff::Cli::Printer.new(@options, logger)
diff_printer.printer(catalog_diff_result.diffs)
Resource that changed looked like this:
file { "${nagios::nrpe::plugindir}/check_ram":
owner => 'root',
group => 'root',
mode => '0555',
source => 'puppet:///modules/ve_base/check_ram',
}
The content of the source file "ve_base/check_ram" changed.
- What happened?
octocatalog-diff didn't show any changes
- What did you expect to happen?
Show diffs on the changed content of the file
- How can someone reproduce the problem?
Generate two catalogs with a file {} resource which source file changed.
Command used and debugging output
Platform and version information
-
Your OS: Ubuntu 14.04
-
Your Ruby version: <!-- type
ruby --versionat the command prompt --> 2.4.0 -
Your version of Puppet: 4.10.1
-
Your version of octocatalog-diff: <!-- type
octocatalog-diff --version--> 1.0.1
Do the tests pass from a clean checkout? Installed from gem, so hopefully ;)
Anything else to add that you think will be helpful?
I think this has to do with how Puppet itself operates. Content of a file {} source parameter is retrieve while applying the catalog. My question therefor is: Are you aware of this limitation? Do you know any workaround which could help detect the change?
@baurmatt what you request is implemented already for compiled catalogs, but not other methods of retrieving catalogs. There are some cases where it can't be implemented.
Details:
-
If you generate catalogs by compiling them, the
--compare-file-textoption (enabled by default) will "diff" the files generated fromsource => ...and display the output of that diff if any. This means that if the text changed, the diff will be shown. If the path to the file in thesourceattribute changed but the content of the file is identical, no diff is shown. -
If you get catalogs from a puppet master, it turns off
--compare-file-text. It would be possible to contact the puppet master's API to retrieve the content of the files and then do--compare-file-textlogic on them. This functionality is possible, but it doesn't exist now because nobody's written it. (I only get catalogs from the puppet master in very limited situations -- see for example https://puppet.com/blog/upgrading-to-puppet-4-at-github, so writing this is not a high priority for me for work purposes at least.) -
If you get catalogs from a JSON file or from puppetdb, there's no way to get the actual source of the files in question from the catalog. That information is simply not in the catalog. (Maybe, we could pass a supplementary argument with the path to the puppet repository and look up the files from there?)
Hmm damn, yeah this is pretty much what I suspected. Thanks for clarifying! :) Do you see a chance that static catalogs could help? Also could this perhaps be mention in Limitations?
I can clarify this in the docs.
Sounds good, thanks! :) Do you have experience in using static catalogs?