Puppet Apply: Could not find class for

David Lojudice Sb. picture David Lojudice Sb. · May 19, 2014 · Viewed 8.7k times · Source

It seems pretty simple thing, and it works on Vagrant, but I can't make it work on a EC2 server.

When:

 puppet apply manifests/init.pp

Error:

 Could not find class base for s1.ec2.internal at /var/lib/jenkins/jobs/s1/workspace/manifests/init.pp:1 on node s1.ec2.internal

File ./manifests/init.pp:

include base

File ./manifests/base.pp:

class base {

  exec { "apt-get update":
    command => "/usr/bin/apt-get update",
    timeout => 0
  }

  package { ["vim", "git", "build-essential"]:
    ensure  => present,
    require => Exec["apt-get update"]
  }

}

Puppet v2.7.23

Answer

Berry Ligtermoet picture Berry Ligtermoet · Sep 14, 2014

Like Felix stated the class base is being looked for in the modules of your puppet manifests. The directory structure of your modules as follows:

$confdir/
|- manifests
   |- init.pp <- The file you reference to when executing puppet apply
|- modules
   |- base
      |- manifests
         |- init.pp <- The file containing your base class

What Felix forgot to mention was that there needs to be another manifests directory within the base module directory.

See also https://docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html