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!!!
You can use the orchestrator to run Puppet from the console, command line, or API. You can use the orchestrator to enforce change based on a: selection of nodes – from the console or the command line: puppet job run --nodes <COMMA-SEPARATED LIST OF NODE NAMES>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With