Puppet configuration is getting applied everywhere - puppet

I am new in Puppet and just facing very unusual problem in that, my Puppet master is running and all agents are configured to that master perfectly.
Files in Puppet Master:
Now here is my site.pp file :
class fileForNodeA{
file { "/tmp/hello.txt" :
content => "This is hello.txt"
}
}
class fileForNodeB{
file{ "/tmp/hello.txt" :
content => "This is hello1.txt"
}
}
node 'NodeA'{
include fileForNodeA
}
node 'NodeB'{
include fileForNodeB
}
Now the hostnames of clients are NodeA and NodeB respectively :
On NodeA or NodeB when I say :
puppet agent --no-daemonize --verbose --waitforcert 60 --test
It shows this
Could not retrieve catalog from remote server : Error 400 on server : Could not find|
default node or by name with 'NodeA.com' .....
Notice : Using cached catalog
Info : Applying configuratiuon version '1234567890'
Notice : Finished catalog run in 0.06 seconds
After this statement when I browse the dir /tmp it says two files namely hello.txt
and hello1.txt, I am bit confused when it is saying "Could not find..blah blah", then why it applies both the part of NodeA and NodeB?
Please shed some light on to it, if I am doing something wrong how to configure the things according to the nodes setup ?
Please help>>>Thanks AV

Please add this as first line in your site.pp
node default {
}
Enjoy.

Related

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 :)

Puppet: Could not find class

About ready to pull out my hair - I have done this a few times with success, but now suddenly I am overlooking something.
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class profiles::base for <fqdn> on node <fqdn>
The path look ok:
[root#adm-01 ~]# cat /etc/puppet/modules/profiles/manifests/base.pp
class profiles::base {
include '::ntp'
}
The site manifest as well:
[root#adm-01 ~]# cat /etc/puppet/environments/production/manifests/site.pp
node default {
}
node adm-01 {
notify { "Test": }
include profiles::base
}
I have tried profiles::base as well as ::profiles::base
Environment looks sound:
[root#adm-01 ~]# puppet master --configprint modulepath
/etc/puppet/environments/production/modules:/etc/puppet/environments/common:/etc/puppet/modules:/usr/share/puppet/modules
If I omit the base module, it does return the notify test.
Sure I am missing something glaringly obvious....
Thanks guys, on deeper investigation I saw the daemon silently complained about a cert. Still weird that changing the path fixed it, but I uninstalled all things foreman, re-installed, and now it works.... Very odd that the agent did not complain though, found the references in the production log only.

Puppet module: No set of title patterns matched the title "name"

So I'm very very new with puppet modules, and decided to create one to try it out.
I want in my environment manifest to run something like that:
manifest_name { 'some_title':
ensure => present
}
However when I run the agent I get:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: No set of title patterns matched the title "some_title".
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
I thought I needed to add inside my type file:
newparam(:name, :namevar => true) {
desc "The name of the manifest."
}
but that didn't change a thing?
What am I missing?
Thanks,
Edit:
So the client is signed for sure.
Still not sure what happened there I just restarted the puppet master and the real error was shown.

Puppet ignores my node.pp entry

My Puppet master and agent are on the same machine. The master node.pp file contains this:
node 'pear.myserver.com' {
include ntp
}
The ntp.pp file contains this:
class ntp {
package { "ntp":
ensure => installed
}
service { "ntp":
ensure => running,
}
}
The /etc/hosts file contains the line:
96.124.119.41 pear.myserver.com pear
I was able to successfully launch puppetmaster, but when I execute this, ntp doesn't get installed (it is not installed already, I checked).
puppet agent --test --server='pear.myserver.com'
It just reports this:
info: Caching catalog for pear.myserver.com
info: Applying configuration version '1387782253'
notice: Finished catalog run in 0.01 seconds
I don't know what else I could have missed. Can you please help? Note that I replaced the actual server name with 'myserver' for security reasons.
I was following this tutorial: http://bitfieldconsulting.com/puppet-tutorial
$puppet agent --test
This will fetch compiled catalog from Master puppet, which is in /etc/puppetlabs/puppet/manifests/site.pp and run locally.
$puppet apply /etc/puppet/modules/ntp/manifests/ntp.pp
Will apply locally

puppet apply error: Could not find default node or by name with 'uys0115' on node uys0115

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

Resources