Issue #2682 has been updated by Mirko Gebauer.

Markus, yes, that's exactly what I'd intended to do. I added the following:

@noop => $managed ? {
        default => false,
        false   => true,
},@

This way, the whole file, not just the content, won't be managed if $managed is 
set to false. I guess I can live with that, but it's a bit of a workaround to 
me. Considering Peter's comment, it seems that I might have misinterpreted the 
usage of replace? On the oher hand, a citation from 
http://reductivelabs.com/trac/puppet/wiki/TypeReference#file : "replace {...} 
This is useful for using file sources purely for initialization." So my thought 
was to use "file" to still manage all aspects of the specified file with the 
exception of it's content if $managed is set to false.

But Peter's usecase also is a valid scenario, never thought of this 
possibility. Puppet sometimes requires (or enforces...) some very creative 
thinking :-)

Nonetheless, thanks for the tip!
----------------------------------------
Bug #2682: file {...}: replace => false, notify => Service[...] always triggers 
notify if md5sums do not match
http://projects.reductivelabs.com/issues/2682

Author: Mirko Gebauer
Status: Needs design decision
Priority: Normal
Assigned to: 
Category: file
Target version: 
Affected version: 0.24.8
Keywords: 
Branch: 


Hi,

I've written a class to manage our local tomcat installations and presumably 
discovered a bug with the combination of "replace => false, notify => 
Service[...]" in the "file" type. Here's the relevant code snippet:

@class tomcat {
        include "java"

        define provider($ensure, $jdk, $adminpass, $managed = true) {
        {...}

        file { "/etc/$name/tomcat-users.xml":
                content => template("common/etc/$name/tomcat-users.xml.erb"),
                owner   => $name ? {
                        default     => "$name",
                        "tomcat5.5" => "tomcat55",
                },
                group   => $name ? {
                        default     => "adm",
                        "tomcat5.5" => "nogroup",
                },
                mode    => $name ? {
                        default     => "0640",
                        "tomcat5.5" => "0644",
                },
                replace => $managed,
                require => Package["$name"],
                notify  => Service["$name"],
        }

        {...}
        }
}@

Call on corresponding node:

@tomcat::provider { "tomcat5.5": ensure => installed, jdk => "sun-java6-jdk", 
adminpass => "something", managed => false }@

Now unfortunately, if the content of "/etc/$name/tomcat-users.xml" differs from 
the one provided by the template file, "notify  => Service["$name"]" will 
restart the corresponding tomcat service every time the file is checked, even 
though I had expected that notify would only be triggered if "replace => true", 
not for "replace => false". With other words, the file correctly won't be 
replaced, but notify incorrectly is triggered.

ad...@hudson:/var/log$ sudo puppetd --verbose --server puppetmaster.localdomain 
--test --noop
info: Caching catalog at /var/lib/puppet/state/localconfig.yaml
notice: Starting catalog run
notice: 
//Node[hudson.localdomain]/Tomcat::Provider[tomcat5.5]/File[/etc/tomcat5.5/tomcat-users.xml]/checksum:
 is {md5}fcc2a978591dc7890fcc3db84bcc2d18, should be md5 (noop)
info: 
//Node[hudson.localdomain]/Tomcat::Provider[tomcat5.5]/File[/etc/tomcat5.5/tomcat-users.xml]:
 Scheduling refresh of Service[tomcat5.5]
notice: 
//Node[hudson.localdomain]/Tomcat::Provider[tomcat5.5]/Service[tomcat5.5]: 
Would have triggered refresh from 1 dependencies
notice: Finished catalog run in 9.92 seconds

Please correct me if I'm doing something wrong, but I consider this a bug since 
the behaviour of the "file" type does not match the user's expectations.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://reductivelabs.com/redmine/my/account

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to