0
votes

I am new to puppet and would like to avoid some of the common issues that I see and get away from using import statements since they are being deprecated. I am starting with very simple task of creating a class that copies a file to a single puppet agent.

So I have this on the master:

/etc/puppet/environments/production
/etc/puppet/environments/production/modules
/etc/puppet/environments/production/mainfests
/etc/puppet/environments/production/files

I am trying to create node definitions in a file called nodes.pp in the manifests directory and use a class that I have defined (class is test_monitor) in a module called test:

node /^web\d+.*.net/ {
     include test_monitor
    }

However when I run puppet agent -t on the agent I get :

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class test_monitor for server on node server
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

What is the proper way to configure this to work. I would like to have node definitions in a file or files which can have access to classes I build in custom modules.

Here is my puppet.conf:

[main]
environmentpath = $confdir/environments
default_manifest = $confdir/environments/production/manifests
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
factpath=$vardir/lib/facter

[master]
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY

I know this is probably something stupid that I am not doing correctly or have mis-configured but I cant seem to get it to work. Any help is appreciated!! To be clear I am just trying to keep things clean and have classes in separate files with specific node types also in their own files. I have a small to medium to size environment. (approx 150 servers in a data center)

2

2 Answers

1
votes

Let me guess, maybe the test module has wrong structure. You need some subfolders and files under folder modules

└── test
    ├── files
    ├── manifests
    │   ├── init.pp
    │   └── monitor.pp
    └── tests
        └── init.pp

I recommend change from test_monitor to test::monitor, it makes sense for me, if you need use test_monitor , you need a test_monitor module or test_monitor.pp file.

node /^web\d+.*.net/ {
     include test::monitor
    }

Then put monitor tasks in monitor.pp file

0
votes

And that was as simple as adding the proper module path to puppet.conf

basemodulepath = $confdir/environments/production/modules