When you make changes to code or classification, a Puppet run might fail with a Duplicate declaration
error.
Error messages
An error similar to:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: <RESOURCE OR CLASS> is already declared; cannot redeclare (file: <MANIFEST FILE PATH>, line: 326) (file: <MANIFEST FILE PATH>, line: 326, column: 3) on node <NODE NAME>
This error occurs due to duplication in classes, resources, or both:
-
A class is included in the catalogue for compilation more than once.
-
A Puppet resource (such as a file, package, or service) is declared more than once.
-
Two or more different resources are declared with the same name.
Version and installation information
PE version: All supported
Solution
To find and fix a duplicate declaration issue, use the following tips to search your classification and Puppet code for the resource, class, and file path included in the error. Determine which classes and resources are duplicates and remove them, making sure to correct parameters as needed.
-
Check the file path in the error for duplicate resources and classes. Don’t worry if the file path refers to the same place in a manifest more than once, that won’t cause errors.
-
When trying to update parameters in the console, a whole class might be added in error to a node group in the classes section. Check console node groups for recently added classes with this issue. Remove classes added in error and set parameter values in that node group as needed using the Data field or by setting values in Hiera.
-
Using a text editor, search your code repository for the classes and resources in the error. Rename duplicates that you find and evaluate iterative functions to see if they are causing duplication.
-
Class inheritance and parameterized classes can cause the same resource to be declared more than once. Check classes indicated in the error to see if they are inheriting from or calling classes. Check the inherited and called classes for issues.
How can we improve this article?
0 comments
Please sign in to leave a comment.
Related articles