Bug #1889
Variable aren't Exported with Resources
| Status: | Rejected | Start date: | 01/24/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | - | |||
| Target version: | - | |||
| Affected Puppet version: | 0.24.7 | Branch: | ||
| Keywords: | ||||
| Votes: | 0 |
Description
I would expect the variable to be the values defined on node that is exporting the resource.
class export::collect_test {
Export::Collect_define <<||>>
}
define export::collect_define () {
$target_fqdn = $fqnd
file {
"$name":
ensure => file,
owner => "root", group => "root", mode => 755,
content => template(remote_export/test.erb);
}
}
class remote_export::remote_test {
file {
"/tmp/testrequirefile":
ensure => file,
owner => "root", group => "root", mode => 755,
content => "I am only required on remote host";
}
@@export::collect_define {
$name:
}
}
test.erb:
remote_fqdn = <%=target_fqdn%>
History
Updated by James Turnbull over 3 years ago
- Status changed from Unreviewed to Needs Decision
- Assignee set to Luke Kanies
Luke? I don’t see why this shouldn’t be the case.
Updated by Luke Kanies over 3 years ago
- Status changed from Needs Decision to Needs More Information
I don’t understand the problem; does that code not work? If it doesn’t work, what’s the behaviour?
Updated by D K over 3 years ago
The result will be “remote_fqdn = [FQDN of machine collecting]” instead of machine exporting.
Updated by Luke Kanies over 3 years ago
- Status changed from Needs More Information to Rejected
Ah, I see what’s happening here.
The defined resource is evaluated on the collecting side rather than the exporting side, so that’s whose information you get.
The way to fix this is to provide the data you need in your template as arguments to the definition.
There’s essentially no way we could evaluate the collected, defined resource in the context of the exporting host unless we evaluated it there and exported all of the resulting contained resources. We used to do a form of that, but it was incredibly messy.
It’s much easier to just be explicit in the data your defined resource needs.