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'
}
Related
I'm seeing the following error on puppet agent run:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class ::nagios::server at /etc/puppetlabs/code/environments/production/site/role/manifests/nagios.pp:2:2 on node mynode.something.co.uk
i have a nagios module which has a server manifest
The issue was with metadata.json file, when I ran:
puppet config print modulepath --section master --environment production
I got the message:
Error: No dependencies module metadata provided for nagios
So I added empty array to metadata.json:
"dependencies": []
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.
I have set up Puppet master/agent in Oracle VirtualBox using Vagrant and installed netdev_stdlib on both master and agent according to instruction in the README.
I have set up module path to /etc/puppet/modules/netdev_stdlib where standard library stdlib also exists.
The master node is puppet.example.com and agent is node01.example.com.
My manifest file is as follows:
node default {
file { "/tmp/example_ip": ensure => present }
include stdlib # No error on this line
# include netdev_stdlib # Uncomment this line will cause error
netdev_device { $hostname: }
}
However, when I run puppet agent -t on the client I got
Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid
resource type netdev_device at /etc/puppet/manifests/site.pp:17 on node
node01.example.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
I tried to use include netdev_stdlib in the manifest file site.pp, but Puppet couldn't find the class netdev_stdlib. However, include stdlib is fine.
I tried to use include netdev_stdlib in manifest file site.pp but Puppet couldn't find the class netdev_stdlib, but include stdlib is fine.
The netdev_stdlib module doesn't provide a class that can simply be included. It's more of a programming framework for writing new Puppet types to manage network devices in Ruby.
You should either use the module to write a new network device module of your own for interfacing to some new type of device, per the README, or remove it and don't include the class.
If you're trying to manage a network device, you should look for an existing module that supports that type of device - it may then use this module as a dependency instead. If you're not managing a network device, I don't think you should be trying to use the module.
Note that most module READMEs will indicate class names that can be included; not all modules will contain Puppet classes.
Miss { in end of file type:
change from:
file { "/tmp/example_ip": ensure => present,
to
file { "/tmp/example_ip": ensure => present, }
I am testing puppet "file" type. I have added a simple manifests as following
root#pk121:/etc/puppet/manifests# cat site.pp
file { '/tmp/puppettest' :
source => "pk121.domain:///files/f1.txt",
}
Try to apply on master, but getting following error
root#pk121:/etc/puppet/manifests# puppet apply site.pp
Notice: Compiled catalog for pk121.domain in environment production in 0.17 seconds
Error: Validation of File[/tmp/puppettest] failed: You cannot specify more than one of content, source, target at /etc/puppet/manifests/site.pp:12
Wrapped exception:
You cannot specify more than one of content, source, target
root#pk121:/etc/puppet/manifests# ls -al ../files/f1.txt
-rw-r--r-- 1 root root 19 Mar 25 14:52 ../files/f1.txt
Edit
It is working fine locally, but still I am not able to sync f1.txt on agent, following is new configuration on master
root#pk121:/etc/puppet/environments/production/manifests# vi site.pp
node default {
file { '/tmp/puppettest' :
source => "pk121.domain:///files/f1.txt",
}
}
Agent
root#hire:~# puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for hire.domain
Error: Failed to apply catalog: Parameter source failed on File[/tmp/puppettest]: Cannot use URLs of type 'pk121.domain' as source for fileserving at /etc/puppet/environments/production/manifests/site.pp:3
Wrapped exception:
Cannot use URLs of type 'pk121.domain' as source for fileserving
Please let me know if you need any further information.
Your URI is malformed and tries to use your node FQDN as an address schema.
Try just using the vanilla
puppet:///files/f1.txt
When using puppet apply on a local system, you could conceivably also just sync files from one disk location to another.
source => 'file:///etc/puppet/files/f1.txt'
or
source => '/etc/puppet/files/f1.txt'
I have installed puppet on two nodes, and the server node hostname is "uys0115", and the cient node hostname is "uys0119", and the server node have siged the client node. When I exec the commad: puppet cert list --all, we can see:
+ "uys0115" (24:55:95:77:8E:60:33:77:C8:D4:74:EA:01:21:BD:5A)
+ "uys0119" (86:53:1B:81:E5:4F:88:23:E8:34:E1:AB:03:D4:AE:7C)
The puppet main directory is /etc/puppet/, I have write an example and the organization of files as follows:
/etc/puppet/--
|-/manifests/site.pp
|-/modules/test/--
|-/files/text.txt
|-/manifests/init.pp
|-/manifests/test.pp
The code in /etc/puppet/modules/test/manifests/test.pp is:
class test1 {
package { "bison":
ensure=>"installed",
}
exec { "puppet test":
command=>"/bin/touch /tmp/puppet-test",
}
file { "/tmp/test.txt":
ensure => "present",
source => "puppet:///modules/test/test.txt"
}
}
and the code in /etc/puppet/modules/test/manifests/init.pp is just import "*";
and the code in /etc/puppet/manifests/site.pp as follows:
import "test"
node default {
include "test1"
}
When I in the client node uys0119 and exec the command puppet agent --test --server uys0115.
It executed successfully and created two files puppet-test and test.txt in the directory /tmp/.
In the server node when I exec the command puppet apply site.pp, it also executed successfully and created two files. However, the terminal out put two warning messages:
warning: Could not retrieve fact fqdn
warning: Host is missing hostname and/or domain: uys0115
When I changed the code in /etc/puppet/manifests/site.pp as follows:
import "test"
node "uys0119" {
include "test1"
}
and exec the command puppet apply site.pp in the server node, it failed an output the error messages:
warning: Could not retrieve fact fqdn
warning: Host is missing hostname and/or domain: uys0115
warning: Host is missing hostname and/or domain: uys0115
Could not find default node or by name with 'uys0115' on node uys0115
But the client node can sucessfully exec the command puppet agent --test --server uys0115 too. Can anybody explain that?
If I want to the server node send some repuests to the client nodes and drive some client nodes responses the server and procduces results. How can I do when uses puppet? Can somebody give me an example? thanks very much!!!
The server puppet serves as both puppet master and puppet node.
When you edited site.pp as below:
import "test"
node default {
include "test1"
}
all puppet nodes connect to puppet master will do operations defined in class "test1". So you found two files in both uys0115 and uys0119(treat as a puppet node).
When changed your site.pp to the following:
import "test"
node "uys0119" {
include "test1"
}
puppet node uys0115 can not find its definition in site.pp (because it only defines uys0119) and puppet master output error info like this:
Could not find default node or by name with 'uys0115' on node uys0115
Here is a modified site.pp can eliminate this error:
import "test"
node "uys0119" {
include "test1"
}
node "uys0115" {
include "test1"
}
In puppet master/slave mode, you'd better use fqdn such as uys0115.localdomain, then the following warning will not show
warning: Host is missing hostname and/or domain: uys0115