i am trying to install the tomcat6 module into the agent.i already download module from puppetlab.and try to connect to server i am getting the following error.
Error: Could not retrieve catalog from remote server: Error 400 on
SERVER: No matching value for selector param 'undef' at
/etc/puppet/modules/yum_priorities/manifests/init.pp:19..
the init.pp file contains for yum_priorities
14 class yum_priorities {
15
16 $yum_priorities = $lsbmajdistrelease ? {
17 /4|6/ => 'yum-plugin-priorities',
18 '5' => 'yum-priorities',
19 }
20
21 package {$yum_priorities :
22 ensure => installed,
23 }
my site.pp file in manifest
27 node 'puppet_client'
28 {
29 include tomcat6
30 }
tomcat have dependency on yum_priorities
I can't add comments so I have to "answer it" :). Anyways, as answered by Ger Apeldoorn facter can't get value of lsbmajdistrelease.
On Redhat/CentOS find which package you are missing:
yum whatprovides lsb_release
Or simply install it:
yum install redhat-lsb-core
This will fix it.
Looks like that $lsbmajdistrelease is not defined.
Try to add the proper scope (global): $::lsbmajdistrelease
Facter should give you that global variable, you can run facter manually and see if there's an error.
facter lsbmajdistrelease
Print out a notify statement on line 20 inside class yum_priorities. Something like :
notify {"I AM SEEING THIS ... ${yum_priorities}" :}
and also somewhere inside the module tomcat6.
and check what you get when you run puppet agent. If it is empty means it hasn't been propagated properly.
One other comment is that, it may not be a good coding example to have the same name for a class and a variable, i.e. yum_priorities.
Related
I double checked all settings but did not find the issue and that's why I try to get help here.
Let me show the configuration:
puppet.conf:
[...]
[master]
environmentpath = $confdir/environments/
hiera_config = $confdir/environments/production/sites/xy/config/hiera.yaml
default_manifest = ./sites/xy/config/
environment_timeout = 0
fileserver.conf:
[...]
[sites]
path /etc/puppet/environments/production/sites/
allow *
auth.conf:
[...]
# extra mountpoint
path /sites
allow *
[...]
Now whenever I run Puppet and it tries to implement a specific file I get this:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find any files from puppet:///sites/xy/files/xy/xy.key.pub at /etc/puppet/environments/production/modules/xy/manifests/xy.pp:88 on node xy
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Note that I had to replace sensitive information by xy but for debugging purposes I try to give every detail where possible.
So /sites points to /etc/puppet/environments/production/sites/ according to fileserver.conf and the directory exists like this (with correct permissions imho):
/etc/puppet % ls -ld /etc/puppet/environments/production/sites/
drwxr-xr-x 8 root puppet 4096 Oct 7 12:46 /etc/puppet/environments/production/sites/
The mentioned file puppet:///sites/xy/files/xy/xy.key.pub should therefore be located in /etc/puppet/environments/production/sites/xy/files/xy/xy.key.pub which looks like this:
/etc/puppet % ls -l /etc/puppet/environments/production/sites/*/files/*/*.key.pub
-rw-r--r-- 1 root puppet 725 Oct 7 12:46 /etc/puppet/environments/production/sites/xy/files/xy/xy.key.pub
And the in the error message mentioned line 88 of the module which loads the file it looks like this:
$sshpubkey = file("puppet:///${sitefiles}/xy/${s0_pubkey}")
where $s0_pubkey is xy.key.pub and ${sitefiles} is sites/$site/files which leads to the evaluated path of the requested file like this: puppet:///sites/xy/files/xy/xy.key.pub
The function file() in Puppet can not handle Puppet mountpoints with puppet://. The official docs at https://docs.puppet.com/puppet/latest/reference/function.html#file don't mention it specifically but obviously without mentioning it it means it can't handle extra mountpoints and wants to load files from a modules files directory.
My solution: I will use a variable which declares the absolute path to my "sites files" like this: $sitefiles_absolute = "/etc/puppet/environments/${environment}/sites/xy/files/" which will never change or at least not very often. And with keeping it in the site.pp file it can be used on every node and module.
I am starting the journey with Puppet.
I have installed stand-alone puppet on RHEL 6.0 (NO master/agent, just stand-alone)
Puppet version is 4.5.2
I have created a module /opt/puppetlabs/puppet/modules/common/manifests/init.pp as
class user {
user { 'wasadmin':
ensure => present,
comment => 'wasadmin user',
home => '/home/wasadmin',
managehome => true
}
}
my site.pp is here as /opt/puppetlabs/puppet/manifests/site.pp
node "CI-TEST-POC" {
include user
}
modulepath = /etc/puppetlabs/code/environments/production/modules:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules
when I execute with and without --modulepath, I am still getting the same error
root#CI-TEST-POC manifests# puppet apply site.pp
Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::user for ci-test-poc.corp.aal.au at /opt/puppetlabs/puppet/manifests/site.pp:2:4 on node ci-test-poc.corp.aal.au
root#CI-TEST-POC manifests# puppet apply site.pp --modulepath ../modules
Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::user for ci-test-poc.corp.aal.au at /opt/puppetlabs/puppet/manifests/site.pp:2:4 on node ci-test-poc.corp.aal.au
I have created a module /opt/puppetlabs/puppet/modules/common/manifests/init.pp as
class user {
The problem lies here, as Puppet requires that the layout of manifests matches the name of the classes/defines within them to help it quickly and correctly find the right file.
For your user class, it should be defined in /opt/puppetlabs/puppet/modules/user/manifests/init.pp.
I try to create a new entry in hosts.allow
augeas { "Add in hosts allow" :
context => '/files/etc/hosts.allow',
changes => [
'ins 01 after *[last()]',
'set 01/process[1] ssh',
'set 01/process[2] ssh2',
'set 01/client ipaddr'
],
}
But it doesn't work I get this error
Notice: Compiled catalog for server.local in environment production in 0.96 seconds
Error: /Stage[main]/Nfs::Server/Augeas[Add in hosts allow]: Could not evaluate: Error sending
command 'ins' with params ["01", "after", "/files/etc/hosts.allow/*[last()]"]/Error sending
command 'ins' with params ["01", "after", "/files/etc/hosts.allow/*[last()]"]
I can't see how to use the ins command, the message don't let me know what's went wrong.
CentOS6.4
Puppet version: 3.3.1
augeasversion (from facter): 0.9.0
I Can't find the version of augtools and I can't either execute a command as it is not installed (I don't know how puppet invoke it)
Try adding a leading "/" to the context?
(The logging is slightly odd, it doesn't show the "files" prefix at all, I wonder if your code sample and logging match.)
I'm using Puppet 3.5.1 on Linux 6 machine.
I have a local module "A" that includes a sub-module "B". Such that sub-module "B" is located in "/etc/puppet/modules/A/modules/B".
I refer to sub-module "B" in my module "A" classes: (/etc/puppet/modules/A/manifest/init.pp file)
class A::one (
...
class { 'B':
val1 => 'abc',
val2 => 'abc',
}
...
)
B is then not reference any were else.
When I start up puppet master and the puppet agent, I get the following error on the agent:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class B
What have I missed?
I saw some posts had the resolution as adding a 'include B' for the puppet agent node. If that's the solution, since this is a module inside another module, how do I refer to it?
Edit 1
I moved the sub module "B" into the main modules folder, from "/etc/puppet/modules/A/modules" to "/etc/puppet/modules". It gave the the error:
Error: Duplicate declaration: Class[B] is already declared; cannot redeclare at /etc/puppet/modules/A/manifest/init.pp
Having a modules/ subtree in a module is no valid structure as far as the autoloader is concerned. There is no semantics for submodules.
If you desperately want this particular case to work, you will have to add /etc/puppet/modules/A to your modulepath config setting.
You may wish to ask a new question and describe what you are actually trying to solve, because it seems that your code architecture is a little unclean.
Puppet on the tst-01 works fine when using:
node "tst-01" inherits basenode {
But it breaks when I try to organize servers into groups with this configuration:
node "tst-01" inherits redhat6server {
The error with "inherits redhat6server" is:
err: Could not retrieve catalog; skipping run
[root#tst-01 ~]# puppet agent --test
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template ldap/access.conf: Could not find value for 'netgroup' at 124:/etc/puppet/modules/ldap/templates/access.conf at /etc/puppet/modules/ldap/manifests/init.pp:82 on node tst-01.tst.it.test.com
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
This is the access.conf file, that works fine if inherits is set to "inherits basenode".
[root#puppet]# grep -v "#" /etc/puppet/modules/ldap/templates/access.conf
+ : root : LOCAL
+ : #<%= netgroup %> : ALL
- : ALL : ALL
[root#puppet]#
This is the configuration in /etc/puppet/manifests/nodes.pp.
# Basenode configuration
node "basenode" {
include resolv_conf
include sshd
include ntpd
include motd
}
# Groups
node "redhat6server" inherits basenode {
include ldap_auth
}
# Testservers
node "tst-01" inherits redhat6server {
$netgroup = tst-01
}
I am planning to bring more organisation (read: avoid configuration repetition) in the nodes.pp by grouping machines, e.g. RH5 and RH6 machines instead of adding multiple lines of includes for all RH5 and RH6 servers.
Your running into a variable scoping problem. The official documentation discusses this issue.
In short, redhat6server doesn't have access to the netgroup variable.
The method I employ to work around this is to use hiera. With this, the ldap_auth module can be defined this way, and it will pull the value from a hiera configuration file (typically a yaml file in /etc/puppet/hiera).
You would defined ldap_auth like this:
ldap_auth/manifests/init.pp:
class ldap_auth($netgroup=hiera('netgroup')) {
...
}
Or if your on puppet 3.x, you can use automatic parameter lookup:
class ldap_auth($netgroup) {
...
}
And have a yaml file with:
ldap_auth::netgroup = 'netgroup'