Ask Your Question
0

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
gold

[root@gold ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.52.132 gold.localdomain gold
192.168.52.133 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
samuray

[root@samuray ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.52.133 samuray.localdomain samuray
192.168.52.132 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
1

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 'client1.example.com' {
  include apache
}
node 'client2.example.com' {
  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

Stats

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

Seen: 176 times

Last updated: Aug 18 '14