Joao Morais
2014-Jul-10 14:03 UTC
[Puppet Users] Duplicate declaration with nested create_resources
Hello list, I have some services that may be duplicated in some machines. They are much like an Apache vhost. In order to remove details from my manifests, I moved the service names to ENC because they are machine-dependent. Here are my datasources and manifests: ENC: parameters: myservices: host1: myperserviceconfig host2: myperserviceconfig Hiera: myservice_host: myproblematicconfig: config1: data config2: data myotherconfig: ... Manifests: class profile::my::myservice { # ENC: $myservices $hiera_myservice_host = hiera("myservice_host") # ENC has per-host/service and hiera has per-environment configurations create_resources(::myservice::host, $myservices, $hiera_myservice_host) } define myservice::host (myconfigs...) { ... if $myproblematicconfig { create_resources(::myservice::myconfig, $myproblematicconfig) } } Each myproblematicconfig key is a new resource and I can have zero to N keys. This configuration is working nice if I have only one service, but if I have two or more services, Puppet Master correctly says: Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: myservice::myconfig[config1] is already declared Tried prefix (from puppetlabs/stdlib) in order to change the resource name but it only supports arrays. Changing create_resources to $var.each should help but it requires parser=future which I cannot use right now. Do you see another approach I could try? -- 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 puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/23c7967c-f732-4d6a-b2d4-a8c4347f48a9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.