puppet apply 'could not find class'

Andrew picture Andrew · Feb 25, 2015 · Viewed 9.4k times · Source

This is a pretty simple problem, and I have read a number of suggested solutions, but I still can't get puppet apply to import the git::config class. Here is my file setup:

I import the git module via nodes.pp:

#/etc/puppet/manifests/nodes.pp
node default {
}
include git

site.pp imports nodes.pp:

#/etc/puppet/manifests/site.pp
import 'nodes.pp'

The git module is defined as follows:

#/etc/puppet/modules/git/manifests/init.pp
class git {
    include git::install
    include git::config
}
class git::install{
    package {'git': => present }
}

and the config file:

#/etc/puppet/modules/git/manifests/config.pp
define git::config{
    [some code here]
}

When I run puppet apply, puppet does not find the git::config class:

sudo puppet apply --modulepath=/etc/puppet/modules /etc/puppet/manifests/site.pp
Error: Could not find class git::config for xxxx on node xxxx.

The original module was puppetlabs-git (same folder structure), but I have recreated the error using the simplified file structure (above).

Update 1

Typo above, the git config.pp and init.pp are in folder /modules/git/manifests and the config.pp file reads 'define git::config'

Answer

BMW picture BMW · Feb 26, 2015

Your puppet code structure is wrong. You need move your pp file to manifests folders.

/etc/puppet/modules/git/init.pp
/etc/puppet/modules/git/config.pp

to

/etc/puppet/modules/git/manifests/init.pp
/etc/puppet/modules/git/manifests/config.pp