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

Fix duplicate resource errors for puppet service due to parse order #250

Merged
merged 2 commits into from
Jul 5, 2017

Conversation

kpaulisse
Copy link

The defined(Service[$puppet_service_name]) pattern in this module is parse-order dependent, and I was unable to declare a service { 'puppetserver' ...} in some code I was writing because this module was parsed first and had already declared the resource.

To work around this, I've added a parameter to the class, which defaults to the existing behavior of true so it won't break existing behavior for anyone. However, one can override this to false which skips the creation of the $puppet_service_name service resource in this module and thereby avoids a duplicate resource error when compiling the catalog.

@mullr
Copy link
Contributor

mullr commented Mar 8, 2017

Hey @kpaulisse , thanks for the PR!

Two comments:

  • First, by way of consistency, what do you think about changing this param to be named manage_puppet_service or something similar?
  • Second, could we ask for a test case (probably in spec/unit/classes/master/config_spec.rb) to exercise this? It's clearly simple code, but it'll help us keep it working in the future.

Thanks!

@kpaulisse
Copy link
Author

@mullr I'll look at adding a test.

My personal opinion is that manage_puppet_service is not an appropriate name, because this code is really not managing the service. Rather it's creating the resource if it doesn't exist yet in the portion of the catalog that's been evaluated thus far. While I understand why you're doing this, subtle changes can suddenly cause this to break - in my particular case it was the simple rename of a class that caused that things to be evaluated in a different order and therefore start throwing a duplicate resource error. So I personally believe that "create puppet service resource" is exactly what this is doing, but it's not really managing anything. However I'll defer to your wishes regarding the variable name, so if you want manage_puppet_service or something else, even in light of this explanation, tell me what you want it to be named and I'll make it happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants