Search code examples
vagrantpuppet

Puppet - Not able to find a declared class


Im trying to use classes in puppet. I have the following setup:

  • manifest/
    • default.pp
    • web.pp

I tried to call the class web in my default.pp:

class { 'web': }

I've got the following error:

"Error: Could not find class web for ubuntu-14.localdomain on node ubuntu-14.localdomain"

What am I doing wrong?

The class is declared in web.pp as follows:

class web {
   package {'apache2':
          ensure => 'installed',
  }
}

I also tried to call the class as: include web


Solution

  • You should probably move the web class as a new module

    puppet
    ├── _manifest
    |   └── default.pp
    ├── _modules
    |   ├── _web
    |   |   └── _manifests
    |   |       └── init.pp
    

    Just rename your file web.pp as web/manifest/init.pp

    In the default.pp make sure to include your module:

    class { 'web': }
    include web
    

    PS: make sure to reference your module directory from the vagrant provisioning