Issue #1885 has been updated by grim_radical.

Require/before express some dependencies for the machine where the resource is 
defined. However, the machine that collects those resources will likely have a 
completely different set of dependencies.

For example, let's say we want to use exported resources to maintain a database 
of services that runs on all machines (this example is a bit contrived, but is 
hopefully illustrative). On machine A:

<pre>
@@service_db::entry {
        "postfix":
                require => Package["postfix"];
}
</pre>

Now let's say machine B wants to collect all service_db::entry resources. When 
it realizes that resource, it will run a command to update the db. Puppet will 
fail trying to apply the exported resource, as Package[postfix] couldn't be 
found. And postfix will never be installed, as this box isn't an MTA.

I suppose that I view "ordering-related" attributes like "require" and "before" 
as really only useful on the machine that originally defined the resources. The 
machine that collects them for a completely different use will likely have very 
different dependency requirements.
----------------------------------------
Bug #1885: Requires are passed down to defines and exported with resources
http://projects.reductivelabs.com/issues/1885

Author: dkM1
Status: Accepted
Priority: High
Assigned to: luke
Category: plumbing
Target version: 0.25.0
Complexity: Unknown
Affected version: 0.24.7
Keywords: 


When an export is in a define and the define is called with a require the 
require is exported. 

Sample code.  
<pre>
class export::collect_test {

    Export::Collect_define <<||>>

}

define export::collect_define ($content) {

    file { 
       "$name":
            ensure => file, 
            owner => "root", group => "root", mode => 755,
            content => $content;
    }
    
}



class remote_export::remote_test1 {
    
    file { 
       "/tmp/testrequirefile1":
            ensure => file, 
            owner => "root", group => "root", mode => 755,
            content => "I am only required on remote host";
    }

    remote_export::remote_define {
        "remote_test1":
            content => "test file contents",
            require => File["/tmp/testrequirefile1"];
    }
    
}

class remote_export::remote_test2 {
    
    file { 
       "/tmp/testrequirefile2":
            ensure => file, 
            owner => "root", group => "root", mode => 755,
            content => "I am only required on remote host",
            before => Remote_export::Remote_define["remote_test2"];
    }

    remote_export::remote_define {
        "remote_test2":
            content => "test file contents";
    }
    
}

define remote_export::remote_define ($content) {

    file { 
       "/tmp/testlocalfile":
            ensure => file, 
            owner => "root", group => "root", mode => 755,
            content => $content;
    }
    
    @@export::collect_define {
        $name:
            content => $content;
    }
    
}
</pre>

When I use a "require" to require the order in remote_export1 class it does 
export the require. 

<pre>
    id    |                         value                         | 
param_name_id | line | resource_id |         updated_at         |         
created_at         
----------+-------------------------------------------------------+---------------+------+-------------+----------------------------+----------------------------
 12669414 | --- !ruby/object:Puppet::Parser::Resource::Reference 
title: /tmp/testrequirefile1
type: File
 |             2 |      |       94995 | 2009-01-23 12:36:06.533296 | 2009-01-23 
12:36:06.533296
 12669413 | test file contents                                    |            
10 |   46 |       94995 | 2009-01-23 12:35:06.005715 | 2009-01-23 
12:35:06.005715
</pre>




When I use a "before" to require the order in remote_export2 class it doesn't 
export the require. 
<pre>

puppet=# SELECT * from param_values where resource_id = 94995;  
    id    |       value        | param_name_id | line | resource_id |         
updated_at         |         created_at         
----------+--------------------+---------------+------+-------------+----------------------------+----------------------------
 12669413 | test file contents |            10 |   46 |       94995 | 
2009-01-23 12:35:06.005715 | 2009-01-23 12:35:06.005715
(1 row)
</pre>




----------------------------------------
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