1
votes

I am testing this out and getting an error on the Puppet agent node

[root@pagent1 ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::nginx for pagent1.testcentos7.com (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 3, column: 3) on node pagent1.testcentos7.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Content of these classes from the Puppet server:

[root@pmaster ~]# cat /etc/puppetlabs/code/environments/production/manifests/site.pp
node pagent1.testcentos7.com {
  class { 'nginx': }
}

[root@pmaster ~]# cat /etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp
class nginx {
  contain nginx::install
}

[root@pmaster ~]# cat /etc/puppetlabs/code/environments/production/modules/nginx/manifests/install.pp
class nginx::install {
  package { 'install_nginx':
    name    => 'nginx',
    ensure  => 'present',
  }
}

Syntax check shows this error:

[root@pmaster ~]# puppet parser validate /etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp
Error: Could not parse for environment production: Unacceptable location. The name 'nginx' is unacceptable in file '/etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp' (file: /etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp, line: 7, column: 1)

NOTE: Created module 'nginx' and its classes using Puppet Development Kit(PDK).

Is that a bug or something or I made a mistake with the class name?.

Related thread I found is https://groups.google.com/forum/embed/#!topic/puppet-users/nxbwCvWrgMI but would like to have someone simplify this for me

1
The class naming and arrangement appear to be correct. With that being the case, the most likely problem is an access-control issue. puppetserver ordinarily does not run as a privileged process, so it relies on the ownership and permissions (and SELinux context, and ...) of all your manifests and data to allow it access. If they don't then it is as if their contents do not exist. - John Bollinger
Thank you. Disabled SELinux and firewall and still this error was showing up. Found the fix and submitted solution in a separate answer here :) - vjwilson

1 Answers

0
votes

Solved this by moving 'init.pp' to the path /etc/puppetlabs/code/environments/production/modules/nginx/manifests where install class file 'install.pp' exists.

For more clarity, I put both the files 'init.pp' and 'install.pp' in the same location directory /etc/puppetlabs/code/environments/production/modules/nginx/manifests to solve this.