>
> If you specify 'ensure => absent' then you should not have a 'content'
> line. They are contradictory parameters. (Also, but unrelated, the path
> parameter is duplicative since specifying the path as the file resource
> name serves the same purpose.)


Ok! Gothca. Actually not to deflect blame, but I didn't author this
manifest. I downloaded it from puppet forge for the newrelic module.

But the real problem I found out was that they duplicated the file
definition in two separate manifests. It was listed in:

Class: newrelic::php
environments/production/modules/newrelic/manifests/php.pp

And

Class: newrelic::agent::php
environments/production/modules/newrelic/manifests/agent/php.pp

Not sure how they did that and got away with it, since I thought you could
only define a resource once in a module.

But making the file absent by doing this in both files:

$newrelic_daemon_cfgfile_ensure                        = 'absent',

  file { '/etc/newrelic/newrelic.cfg':
    ensure  => $newrelic_daemon_cfgfile_ensure,
    path    => '/etc/newrelic/newrelic.cfg',
    content => template('newrelic/newrelic.cfg.erb'),
    before  => Service[$newrelic_php_service],
    notify  => Service[$newrelic_php_service],
  }

Is what worked. Also, I may go ahead and change the manifests per your
advice, but that's more of a style issue than a functional one I think.

Thanks!!
Tim

On Wed, Oct 14, 2015 at 10:24 PM, Peter Bukowinski <pmb...@gmail.com> wrote:

> Tim,
>
> On Oct 14, 2015, at 10:14 PM, Tim Dunphy <bluethu...@gmail.com> wrote:
>
> Hey guys,
>
>  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],
>   }
>
>
> If you specify 'ensure => absent' then you should not have a 'content'
> line. They are contradictory parameters. (Also, but unrelated, the path
> parameter is duplicative since specifying the path as the file resource
> name serves the same purpose.)
>
> 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: Caching catalog for ops3.jokefire.com
> 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
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/266E9C53-C845-474F-B3AD-54CA5D3D86B1%40gmail.com
> <https://groups.google.com/d/msgid/puppet-users/266E9C53-C845-474F-B3AD-54CA5D3D86B1%40gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOZy0ek-%3DuqDK0n8VZPvHOyVDCLsGpO%2BENP5JBhAvLsbYxocgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to