xeor
xeor

Reputation: 5455

Notify if Puppet wants to change something

I am currently working on implementing Puppet in our environment, and I have a request I don’t know if Puppet itself can fulfill:

If I have a configuration file at /etc/myconfig.conf, and I want it to be written only if it does not already exist, then I could achieve that via an exec resource’s onlyif parameter. But is there any way that I can get Puppet to do something like a notify if it detects a change in a file?

I don’t want it to actually change the file, only to notify me that the file is not the way I want it to be.

Although there are no examples in this question, I hope someone is able to push me in the right direction here. If I create a solution for this based on tips, I will post the answer myself for others to learn from.

Upvotes: 4

Views: 2871

Answers (2)

Bezerker
Bezerker

Reputation: 108

It sounds like you want puppet to alert you of any changes it WOULD do rather than do them.

For this, just run with noop (--noop)

it will tell you every change it is going to do but not perform them.

Upvotes: 2

Justintime
Justintime

Reputation: 279

For only creating a file if it doesn't exist, try setting replace to false, like so:

file { "/etc/myconfig.conf":
  ensure => present,
  source => "puppet:///modules/${module_name}/myconfig.conf",
  replace => false,
}

Docs for that are here: http://docs.puppetlabs.com/references/2.7.0/type.html#file

For the notification, puppet auditing will do what you need: http://puppetlabs.com/blog/all-about-auditing-with-puppet/

Upvotes: 3

Related Questions