Search code examples
puppetpuppet-enterprise

puppet apply 'could not find class'


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'


Solution

  • You cannot call include on git::config. git::config is a defined type, not a class. The syntax to use a defined type is as follows:

    git::config { 'the_name_var':
      param1 => 'foo',
      param2 => 'bar'
    }
    

    Hope this helps