github / octocatalog-diff

Compile Puppet catalogs from 2 branches, versions, etc., and compare them
https://rubygems.org/gems/octocatalog-diff/
MIT License
238 stars 85 forks source link

not showing any differences #132

Open derekedmond opened 7 years ago

derekedmond commented 7 years ago

Description of problem

octodiff is not showing any differences when there should be differences.

I made a branch called 'octodiff_test'. I made a change in this branch that would impact node 'blah.domain.com'. When I run octodiff, it says 'No differences'. I expected differences to be be shown.

If I repeat this for a node that doesn't exist, I get the same outcome.

I followed the troubleshooting and when I create look at the compiled JSON, the file is basically empty.

Command used and debugging output

See run_output.txt attached.

I tried following the troubleshooting and the catalog that is compiled is basically empty. I assume its creating this catalog for each branch and finding no diff.

See troubleshooting.txt attached.

I think the issue is related to classification. We are setting the role of the host in environments/stress_test/manifests/site.pp, We dont use ENC, so I'm not sure how we can classify a node in Hiera.

Platform and version information

Do the tests pass from a clean checkout?

I installed from gem, so assume this does not apply.

Anything else to add that you think will be helpful?

kpaulisse commented 7 years ago

The catalog you posted has no resources in it. Without knowing your exact setup it is difficult to suggest a specific solution. My general advice would be to consider how you're currently classifying nodes.

For example, do you use an external node classifier (ENC) that supplies classes as a parameter? If so, you need to configure octocatalog-diff to call that ENC, or perhaps use Puppet Enterprise's ENC.

Or, perhaps you use node definitions? If so, is there a node definition for the actual hostname you're using -- "blah.domain.com" in your example?

derekedmond commented 7 years ago

Hi, I agree, there are no resources. Its like the node is not being classified, but we are using the following node definition:

environments/stress_test/manifests/site.pp:

node 'blah.domain.com' {
   include roles::webin
}

We're not using PE, or any ENC. We are not using r10k-style 'environments per branch'. Its a git repo with and the node definitions are under the environments dir.

$ ls environments/
accred  production  stress_test  qa
derekedmond commented 7 years ago

Hi, @kpaulisse I managed to get things working, but with a quite a few workarounds. octocatalog-diff is serving our purpose for now. I'm hoping you can tell me how I can do this quicker and easier.

In a nutshell, I need to 'fix' the repo by adding a few symbolic links. This solution works. If there is a way to avoid this, it would be great.

Example: Compare branches master and PR13990 against a list of nodes.

  1. Create a clone of the repo on our master in a tmp location: /tmp/octocatalog-diff/puppet-repo/
  2. Create list of nodes: /tmp/production.nodelist
  3. Create fudged Hiera config file octo_hiera.yaml containing:
    
    :eyaml:
      :datadir: /tmp/octocatalog-diff/puppet-repo/hiera/data
4. Clean out any cached dirs: 
`   sudo rm -rf /tmp/d$(date +%Y)*
`
5. 'Fix' the repo:
for branch in ('master' 'PR13990')
do
  cd /tmp/octocatalog-diff/puppet-repo/
  git checkout $branch
  ln -sf environments/production/manifests/ manifests
  cd $BASEDIR/environments/${ENV}/
  ln -snf ../../hiera
  cd /tmp/octocatalog-diff/puppet-repo/
  git add -A && git commit -m "fixed the repo" --quiet
done
6. Compare branches:
for node in /tmp/production.nodelist
do
  sudo /opt/puppetlabs/server/data/puppetserver/jruby-gems/bin/octocatalog-diff -n ${NODE} --basedir /tmp/octocatalog-diff/puppet-repo/ --hiera-config octo_hiera.yaml -f master -t PR13990 --environment production --fact-file /opt/puppetlabs/server/data/puppetserver/yaml/facts/${NODE}.yaml --puppet-binary /opt/puppetlabs/puppet/bin/puppet --hiera-path hiera/data --display-source --pass-env-var GEM_HOME /opt/puppetlabs/server/data/puppetserver/jruby-gems --color -o ${OUTPUT_FILE}
done


This command then works as expected. 

Here I am comparing the catalogs for one node at a time. Is it possible to do these in parallel as it would be much faster. When I tried to background the bin/octocatalog-diff command, it didnt like it. Any advice would be appreciated.
KlavsKlavsen commented 4 years ago

Did you ever get anywhere with this? or is comparing branches with octocatalog-diff dead :(

SakaZhang commented 2 years ago

Hi, @kpaulisse I managed to get things working, but with a quite a few workarounds. octocatalog-diff is serving our purpose for now. I'm hoping you can tell me how I can do this quicker and easier.

In a nutshell, I need to 'fix' the repo by adding a few symbolic links. This solution works. If there is a way to avoid this, it would be great.

Example: Compare branches master and PR13990 against a list of nodes.

  1. Create a clone of the repo on our master in a tmp location: /tmp/octocatalog-diff/puppet-repo/
  2. Create list of nodes: /tmp/production.nodelist
  3. Create fudged Hiera config file octo_hiera.yaml containing:
  :eyaml:
    :datadir: /tmp/octocatalog-diff/puppet-repo/hiera/data
  1. Clean out any cached dirs: sudo rm -rf /tmp/d$(date +%Y)*
  2. 'Fix' the repo:
  for branch in ('master' 'PR13990')
  do
    cd /tmp/octocatalog-diff/puppet-repo/
    git checkout $branch
    ln -sf environments/production/manifests/ manifests
    cd $BASEDIR/environments/${ENV}/
    ln -snf ../../hiera
    cd /tmp/octocatalog-diff/puppet-repo/
    git add -A && git commit -m "fixed the repo" --quiet
    done
  1. Compare branches:
  for node in /tmp/production.nodelist
  do
    sudo /opt/puppetlabs/server/data/puppetserver/jruby-gems/bin/octocatalog-diff -n ${NODE} --basedir /tmp/octocatalog-diff/puppet-repo/ --hiera-config octo_hiera.yaml -f master -t PR13990 --environment production --fact-file /opt/puppetlabs/server/data/puppetserver/yaml/facts/${NODE}.yaml --puppet-binary /opt/puppetlabs/puppet/bin/puppet --hiera-path hiera/data --display-source --pass-env-var GEM_HOME /opt/puppetlabs/server/data/puppetserver/jruby-gems --color -o ${OUTPUT_FILE}
    done

This command then works as expected.

Here I am comparing the catalogs for one node at a time. Is it possible to do these in parallel as it would be much faster. When I tried to background the bin/octocatalog-diff command, it didnt like it. Any advice would be appreciated.

Thx a lot.It works. But i really wonder how did u come up with "ln -sf XXX/manifests" this way? And if there are some err about

Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class

can try do "ln -sf XXX/modules modules" in basedir