Ask Your Question

How to make a puppet-server executes the manifest is different from the default manifest

asked 2014-08-16 15:30:14 -0500

Vadim gravatar image

updated 2014-08-18 03:26:58 -0500

domcleal gravatar image

I use both the server-puppet and client-puppet. So, I wrote a detailed commands for the server-puppet and client-puppet... .

On puppet server:

[root@gold ~]# hostname

[root@gold ~]# cat /etc/hosts localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 gold.localdomain gold samuray.localdomain samuray

[root@gold ~]# ls -l /etc/puppet/manifests/
total 8
-rw-r--r--. 1 root root 123 Aug 16 20:19 new2.pp
-rw-r--r--. 1 root root 116 Aug 16 20:14 site.pp

[root@gold ~]# cat /etc/puppet/manifests/site.pp
class passwd {
file { "/etc/passwd":
owner => root,
group => root,
mode => 644,
node default {
include passwd

[root@gold ~]# cat /etc/puppet/manifests/new2.pp
class tmp {
file { "/tmp/tmp":
ensure => file,
owner => root,
group => root,
mode => 777,
node default {
include tmp

[root@gold ~]# /etc/init.d/puppetmaster restart
Stopping puppetmaster: [ OK ]
Starting puppetmaster: [ OK ]

On Puppet client:

[root@samuray ~]# hostname

[root@samuray ~]# cat /etc/hosts localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 samuray.localdomain samuray gold.localdomain gold

[root@samuray ~]# puppet agent --test
Notice: Ignoring --listen on onetime run
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for samuray.localdomain
Info: Applying configuration version '1408210443'
Notice: /Stage[main]/Passwd/File[/etc/passwd]/mode: mode changed '0644' to '0777'
Notice: Finished catalog run in 0.08 seconds

[root@samuray ~]# ls -l /tmp/tmp
-rw-r--r--. 1 root root 0 Aug 16 20:09 /tmp/tmp

It is clear that the right to file /etc/passwd, and in the file / tmp/ tmp is not changed -(

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-18 03:39:07 -0500

domcleal gravatar image

You need to change how you use the node { } definitions - rather than having separate manifests for different hosts or configurations, you might typically have one site.pp file with node { } definitions for each host that apply the configuration you need. e.g.

node '' {
  include apache
node '' {
  include mysql

Note that I'm using modules and classes (apache, mysql) which encapsulate the configuration, rather than individual files - you could do either. Learning Puppet - Modules and Classes is a good guide to this standard style of writing manifests.

Now, when either client1 or client2 pull their configuration from the Puppet master, they will receive their own configuration. This is different to your example, which only has a single possible configuration, as every host will match the default node.

Read more about the master/agent relationship and node definitions in Learning Puppet - Basic Agent/Master Puppet.

On a more advanced note, it is possible to have different environments that hosts connect to, often used for development/production, or for completely different sets of manifests - perhaps different organisations (Environments - Suggestions for use). I don't think this is what you really need, but if you want to explore more, read the Environments documentation.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-08-16 15:30:14 -0500

Seen: 175 times

Last updated: Aug 18 '14