Ambiguous error message when setting up an invalid requirement in the ruby dsl
|Assignee:||Deepak Giridharagopal||% Done:|
|Affected Puppet version:||2.7.9||Branch:|
Say I were to have a regular puppet class called mysql::backup, and in this class i ‘include’ a ruby DSL class called mysql::backup::grants near the top of the file… now a few lines after the include statement, i have a resource defined we’ll call foo… if i require foo inside the ruby dsl class, I get this really ambiguous error message:
@@@ text Jul 31 10:40:06 puppet puppet-master: Anonymous modules have no name to be referenced by at /etc/puppet/production/grumps-modules/mysql/manifests/backup.pp:45 on node puppet @@@
Basically I just mucked around til I discovered that if I put the include AFTER the resource that I require inside the subclass, it works.
#2 Updated by Joe McDonagh 11 months ago
ok so, after hacking on this code i realized a couple things:
- The problem resource (being created with create_resource), I was erroneously exporting. I removed the export do end part.
- Changed the parse order of the include as mentioned in the first post so that the subclass was included after the resource it required was.
- the require itself, i had done it in the style of actual puppet code, ie:
:require => Database_user[“email@example.com”]
First problem is I needed to put single quotes around it. However, I also discovered that having double quotes around the name confused Puppet and made it unable to locate the resource… presumably it is doing a simple string comparison without stripping first and last quotes.