Puppet client error when using puppet agent -t - puppet

I m trying to use puppet to manage my servers.
I m using opensource puppet
Actually, I have downloaded a module 'docker' (from garther/docker) and I have it in my module list in my master agent :
/home/skahrz/.puppet/modules
├── garethr-docker (v4.1.1)
├── puppetlabs-apt (v2.2.0)
├── puppetlabs-stdlib (v4.9.0)
└── stahnma-epel (v1.1.1)
I have the following site.pp (I m actually learning step by step, not using environnements for the moment) :
node 'my.host.com' {
include 'docker'
docker::image { 'hello-world':
image_tag => 'precise',
}
}
When I try to use puppet agent -t on my client node, I got this error output :
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class docker for my.host.com on node my.host.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
So, I tried to follow this link :
https://docs.puppetlabs.com/pe/latest/console_accessing.html
I can telnet my master from nodes.
But I dont have the console since I use the opensource ... So I m a bit locked.
Can anybody help me with this error ?

Related

Puppet7 agent can't find catalog from server

I'm learning Puppet now. Everything is new to me... After installed a puppet7 server and agent on my two learning VMs--
192.168.160.131 puppet-mst.eisen #The puppet server
192.168.160.140 sles12.eisen #The puppet agent
And I've successfully signed the node "sles12.eisen" to the server "puppet-mst.eisen" --
[root#puppet-mst manifests]# puppetserver --version
puppetserver version: 7.4.1
[root#puppet-mst manifests]# puppetserver ca list --all
Signed Certificates:
puppet-mst.eisen (SHA256) 0B:3F:DA:60:2F:2D:D3:91:94:58:E2:B6:32:28:50:8E:D4:1C:A0:8F:A0:CF:94:99:6E:EE:99:46:B4:1D:30:58 alt names: ["DNS:puppet-mst.eisen"] authorization extensions: [pp_cli_auth: true]
puppet-mst (SHA256) C8:89:47:D2:15:74:6E:49:E7:9A:27:B5:EA:10:9B:81:C4:DC:68:E8:B4:01:07:5D:63:34:5A:AF:B6:66:C9:EE alt names: ["DNS:puppet-mst"]
sles12.eisen (SHA256) C5:40:D7:8A:C6:64:BD:E8:BF:D3:BB:5D:01:24:66:03:57:96:84:31:84:42:DF:36:AA:D1:25:14:76:4D:A5:99 alt names: ["DNS:sles12.eisen"]
Then I wrote a testing module --filetest1, and hope it can put a file to the agent node in /tmp/puppettest --
[root#puppet-mst manifests]# cat /etc/puppetlabs/code/environments/production/modules/filetest1/manifests/init.pp
class filetest1{
file {'/tmp/puppettest/filetest1':
ensure => file,
content => 'Hello World!',
}
}
[root#puppet-mst manifests]# cat /etc/puppetlabs/code/environments/production/manifests/site.pp
node 'sles12.eisen'{
include filetest1
}
But the "puppet agent --test" can't work, it's said it either server can't find agent node, or the test module's catalog is missing --
sles12:/tmp/puppettest # puppet --version
7.12.0
sles12:/tmp/puppettest # hostname -f
sles12.eisen
sles12:/tmp/puppettest # puppet agent --test --verbose
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Failed when searching for node sles12.eisen: Failed to find sles12.eisen via exec: Execution of '/etc/puppetlabs/puppet/node.rb sles12.eisen' returned 1:
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
I don't know what's wrong here. Please kind help. Thanks
Regards
Eisen
The error message suggests that you have configured Puppet to use an external node classifier (/etc/puppetlabs/puppet/node.rb), and either the attempt to execute it is failing altogether, or it is terminating with a failure status, or it is not outputting anything.
You may want to explore ENCs later, but now is probably not the time for that. To disable use of an ENC, edit /etc/puppetlabs/puppet/puppet.conf and either remove the node_terminus setting or change its value to plain.

Error while running Puppet Agent using class in node default

I am getting error while executing puppet script
on Puppet master site.pp file I wrote following code
node default {
class t {
package {'apache2':
ensure => installed,
}
}
}
On Slave machine when i execute it using puppet agent --test, it throws the error:
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: Could not parse for environment production: Classes, definitions, and nodes may only appear at toplevel or inside other classes (file: /etc/puppet/code/environments/production/manifests/site.pp, line: 3, column: 1) on node slave.ec2.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Can you please help me in this regard
Hi this is because you are not supposed to define classes inside site.pp
Have a module foo (as I prefer foo for examples instead of t) defined like this:
#modules/foo/manifests/init.pp
class foo {
package {'apache2':
ensure => installed,
}
}
and you have a node entry in your site.pp like this
# site.pp
node default {
include 'foo'
}

Troubleshooting Puppet Manifests for Windows puppet Node

I have puppet manifests which would download exe file and get installed in windows server.I am getting an error while running command: puppet agent -t on windows server.
Manifests file: /etc/puppet/modules/mercury/manifests/iisserver.pp
class mercury::iisserver {
download_file { "Download dotnet core 2":
url => 'http://download.microsoft.com/download/7/3/A/73A3E4DC-F019-47D1-9951-0453676E059B/dotnet-sdk-2.0.2-win-gs-x64.exe',
destination_directory => 'C:/dotnet-sdk-2.0.2-win-gs-x64.ex',
notify => Package["dotnercore2"],
}
package { "dotnercore2":
ensure => installed,
source => "C:/dotnet-sdk-2.0.2-win-gs-x64.exe",
require => File["C:/dotnet-sdk-2.0.2-win-gs-x64.exe"],
}
}
Error on windows server after running Puppet agent -t:
Error :Could not retreive catalog from remote server:error 400 on server:Syntax error at 'Stdlib::HTTPUrl'; Expected')' at /etc/puppet/modules/download_file/manifests/init.pp on node XXXX
Warning : not using cache on failed catalog.
Error: Could not retrieve catalog; Skipping run
If you look closely, your error output shows what is wrong. There is a Syntax error with your HTTPUrl on your /etc/puppet/modules/download_file/manifests/init.pp file. It is expecting a ')' character somewhere. Could you recheck your manifest for the download_file module or post it here so that we can review :)

Unable to call nested custom module - "Could not find class" error

I have created a custom module and i would like to keep it within a sub-directory (category) because there are several components that should logically fall under that category. So to segregate things in a better way, i created the following structure.
- hieradata
- manifests
- modules
- infra
- git
- files
- manifests
- init.pp
- install.pp
- configure.pp
- monitoring
- etc
- templates
$ cat modules/infra/git/manifests/init.pp
class infra::git {}
$ cat modules/infra/git/manifests/install.pp
class infra::git::install {
file { 'Install Git':
...
...
}
}
$ cat manifests/site.pp
node abc.com {
include infra::git::install
}
Now on the puppet agent, when i try puppet agent -t, i get the following error:
ruby 2.1.8p440 (2015-12-16 revision 53160) [x64-mingw32]
C:\puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: {"message":"Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::infra::git::install for abc.com at /etc/puppetlabs/code/environments/production/manifests/site.pp:15:2 on node abc.com","issue_kind":"RUNTIME_ERROR"}
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
I have already read this link but that suggests keeping custom module directly under main modules directory, which is not how i would like to structure the directories.
Any help will really be appreciated.

Puppet classes with environment directories

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)
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
And that was as simple as adding the proper module path to puppet.conf
basemodulepath = $confdir/environments/production/modules

Resources