Puppet: class already declared

debuggingpuppet

I'm currently in reorganising the structure of my puppet code to a model, which uses, profiles and roles.

I've started with profiles and was testing, but already run into issues :/

In my node definition I do the following:

node 'dev.server' {
  include profile::php
}
# modules/profiles/manifests/php.pp
class profile::php {
  include apache::mod::php
  class{ 'php': }
  php::module { "mcrypt": }
  php::module { "mysql": }
  php::module { "gd": }
}

When I run the puppet agent on the node I get the error

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Class[Profile::Php] is already declared; cannot redeclare at /etc/puppet/environments/production/modules/profile/manifests/php.pp:5 on node

However, when I rename the profile to profile::php2 it's working. What's causing the issue that it's already declared?

Best Answer

Changing class{ 'php': } to class{ '::php': } (note the double colon before php) fixed it.