On Saturday, June 8, 2013 3:23:33 PM UTC-5, Francisco Reyes wrote:
>
> Trying to understand how puppet reports errors
> Example of why I am asking the question (on a test setup environment)
>
> Created a base-1 node
> Created 2 slave nodes that inherit from base-1
> Let's call those slave1 and slave2
>
> No errors. It all works.
>
> Created a base-2 node
> created a third slave that inherits from base-2. Let's call that slave3
>
> Get an error
> Could not retrieve catalog from remote server: Error 400 on SERVER: 
> Duplicate declaration: Adduser[USERNAME] is already declared in file 
> /etc/puppet/manifests/nodes/base-1.pp at line 15; cannot redeclare on node 
> slave1
>
> What I am trying to figure out is why the error is reported in 
> base-1/slave-1... even though those 2 alone work until I introduce 
> base-2/slave3.
>


First guess: slave3.pp contains an adduser { <USERNAME>: } declaration at 
top level (that is, not in a class, definition, or node block), or possibly 
a global variable declaration that influences the behavior of node 
'base1'.  Top-level declarations apply to all nodes, the file in which they 
appear notwithstanding.

Second guess: you accidentally made some change to the base1 or slave1 node 
declaration when you added base2 and slave3.

There are other possibilities.  If you post your init.pp and all manifests 
'import'ed into it, directly or indirectly, then I suspect we will be able 
to identify the problem pretty quickly.

 

>
> I would have expected the error to report say in slave-3.. that  the 
> adduser was already defined in base1-/slave-1.. but don't understand why it 
> refers to base1/slave1
>
>

Your error message indicates that the master has selected the 'slave1' node 
declaration, or possibly one inheriting from it, as the one best matching 
the client.  The master therefore attempts evaluate that node declaration, 
and the error occurs in the context of that evaluation.  If that node 
declaration was working before then you have somehow broken it.

 

> If I had come to this error without knowing I just added base-2 and slave3 
> I would be looking, possibly, at the wrong files.
>
> Is: puppet catalog find <any-node-name>
> the best way to "lint" after making changes?
>


Compiling catalogs is a reasonable way to test changes, but not an 
exhaustive one.  It cannot be exhaustive, because catalog compilation 
depends on node facts, and it is impossible to exhaustively enumerate all 
the possible values of all facts of even one node, let alone of all your 
nodes.  However, although I think you could use "puppet catalog" to do test 
compiles, my first inclination would be to use "puppet master --compile 
<nodename>" instead.

Folks around here also tend to point to rspec for testing puppet 
manifests.  I guess you could go pretty much as far as you want with 
setting up rspec tests for your manifest set.  Again, however, you will 
only end up testing the scenarios you think to test.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to