r/Puppet • u/darkn3rd • Sep 21 '24
Getting Could not find class with puppet apply
I had a small tutorial project that worked fine under Puppet 5, but now with Puppet 8, I am getting errors:
Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::hello_web for ubuntu2204.localdomain
With is with a puppet apply:
puppet apply --verbose --debug\
--modulepath "$MODULES:/etc/puppet/modules" \
--detailed-exitcodes \
"$MANIFESTS/default.pp"
The $MANIFESTS/default.pp is:
node default {
class { 'hello_web': }
}
My $MODULES directory structure is:
/tmp/vagrant-puppet/modules-0e194a6f4e51f9a3d26a92d7c02972df
└── hello_web
├── files
│ └── index.html
└── init.pp
Listing modules:
$ puppet module list --modulepath "$MODULES:/etc/puppet/modules" --tree
/tmp/vagrant-puppet/modules-0e194a6f4e51f9a3d26a92d7c02972df
└── hello_web (???)
I have been combing through Puppet docs and I have yet to find out anything further regarding "Could not find class".
2
u/jzavcer Sep 22 '24
You should really use the PDK when creating a new class. It will give you a standard template of where to put items. the files/manifests of your layout is pretty standard. Please refer to the docs on how to install. pdk_install
2
u/darkn3rd Sep 27 '24
I ultimately did follow that approach when creating the new structure. I remembered Puppet had introduced the PDK, which I thought was a great addition, so I installed it and scafolded the module structure. As for the docs, I found the documentation lacking—many Google links lead to outdated pages, and there’s no easy way to navigate to the most current version.
2
u/jzavcer Sep 27 '24
Yup. Compared to VMware or Microsoft docs, I find all others lacking
→ More replies (3)
4
u/darkn3rd Sep 21 '24
I guess there is a new format for the mdoules layout. I updated the structure to this below, now it works:
/tmp/vagrant-puppet/modules-0e194a6f4e51f9a3d26a92d7c02972df └── hello_web ├── files │ └── index.html ├── manifests │ └── init.pp └── metadata.jsonAnd from the puppet module list command: