0

I'm trying to get classes working in puppet, but it gives me an error when I try puppet agent -t on the node:

root@webserver01:/etc# puppet agent -t

Info: Retrieving plugin Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class roles::webserver for localhost on node localhost Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

note: I edited the localhost parts above. I have the following site.pp:

root@puppet:/etc/puppet/manifests# cat site.pp 
node 'default' {
}

node 'webserver01' {

include roles::webserver

file {'/etc/test':
  ensure  => file,
  owner   => 'root',
  group   => 'root',
  mode    => '0644',
  content => 'df',
}

}

the modulepath:

root@puppet:/etc/puppet/manifests# puppet config print modulepath
Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
(at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1139:in `issue_deprecation_warning')
/etc/puppet/modules:/usr/share/puppet/modules

the modules dir:

root@puppet:/etc/puppet/modules# tree --charset=ASCII
.
|-- roles
|   `-- webserver
|       |-- files
|       |-- manifests
|       |   `-- init.pp
|       `-- templates

and the webserver class:

root@puppet:/etc/puppet/modules/webserver/manifests# cat init.pp
class webserver {
package { apache2:
ensure => present,
}

notify {"in webserver class": }

file {'/etc/test2':
ensure  => file,
owner   => 'root',
group   => 'root',
mode    => '0644',
content => 'df',
}
}

It works fine if I have the module in /etc/puppet/modules/webserver (removing the roles part), but it keeps failing when I try it with the roles directory. It still fails if I rename init.pp to webserver.pp. Can someone help?

1

With roles::webserver, roles is the name of the module it will look under - that needs to be where the manifests directory is. Your directory structure makes webserver the module, which won't work since it's not actually in the module directory. For this to import, the roles::webserver class should be in either:

/etc/puppet/modules/roles/manifests/webserver.pp

or

/etc/puppet/modules/roles/manifests/webserver/init.pp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.