On puppet server 3.8.2 here. And I have a file definition that I want to set as 'absent'. For example, this is what I have:
file { '/etc/newrelic/newrelic.cfg':
ensure => absent,
path => '/etc/newrelic/newrelic.cfg',
content => template('newrelic/newrelic.cfg.erb'),
before => Service[$newrelic_php_service],
notify => Service[$newrelic_php_service],
}
And if I remove the file I want on the target host:
[root@ops3:~] #rm -fv /etc/newrelic/newrelic.cfg
removed ‘/etc/newrelic/newrelic.cfg’
And then run the puppet agent again:
[root@ops3:~] #puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Could not retrieve fact='nr_java_found', resolution='<anonymous>': undefined method `start_with?' for nil:NilClass
Info: Applying configuration version '1444874991'
Notice: /Stage[main]/Newrelic::Agent::Php/File[/etc/newrelic/newrelic.cfg]/ensure: created
Info: /Stage[main]/Newrelic::Agent::Php/File[/etc/newrelic/newrelic.cfg]: Scheduling refresh of Service[newrelic-daemon]
Notice: /Stage[main]/Newrelic::Agent::Php/Service[newrelic-daemon]: Triggered 'refresh' from 1 events
Notice: /Stage[main]/Mcollective::Service/Service[mcollective]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Mcollective::Service/Service[mcollective]: Unscheduling refresh on Service[mcollective]
Notice: /Stage[main]/Apache::Service/Service[httpd]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Apache::Service/Service[httpd]: Unscheduling refresh on Service[httpd]
Notice: /Stage[main]/Puppet::Service/Service[puppet]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Puppet::Service/Service[puppet]: Unscheduling refresh on Service[puppet]
Notice: Finished catalog run in 7.17 seconds
Notice the newrelic.cfg file that I want to be 'absent' is created nontheless.
Is this some kind of flaw in the version of puppet I'm using? Or could I be doing something wrong?
Because this is not at all the way I understand the 'absent' value of the ensure setting is supposed to work!
I guess in the meantime I can comment out the file definition entirely. But I would like to understand why the 'absent' setting isn't working the way it's supposed to!
Thanks,
Tim
--