Skip to content
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

Limitations for files with changing source #134

Open
baurmatt opened this issue Jun 19, 2017 · 4 comments
Open

Limitations for files with changing source #134

baurmatt opened this issue Jun 19, 2017 · 4 comments
Labels

Comments

@baurmatt
Copy link

  • 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:
    2.4.0

  • Your version of Puppet:
    4.10.1

  • Your version of octocatalog-diff:
    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?

@kpaulisse
Copy link
Contributor

kpaulisse commented Jun 20, 2017

@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-text option (enabled by default) will "diff" the files generated from source => ... 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 the source attribute 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-text logic 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?)

@baurmatt
Copy link
Author

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?

@kpaulisse kpaulisse self-assigned this Jul 31, 2017
@kpaulisse
Copy link
Contributor

I can clarify this in the docs.

@baurmatt
Copy link
Author

baurmatt commented Aug 1, 2017

Sounds good, thanks! :) Do you have experience in using static catalogs?

@kpaulisse kpaulisse removed their assignment Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants