Classes & Defines in Puppet
Resources in Puppet have to be unique, i. e. have to have a unique name.
In the described case, you had the resource Exec["sleep 5"]
in your definition and every time you call srv
(it's basically the same as including a parameterized class), the resource Exec["sleep 5"]
will also be included and thus the parser finds two or more resources with the same name.
By appending the $name
of the definition to the name of your Exec
resource, you make it unique. Well, at least most likely unique since when you have another resource with the same name (Exec["sleep 5 for foo"
) somewhere else in your manifests, you'll run into this error again.