I would like to export "location" information from one node to another. And
stuck with that problem for weeks now.
In order to achieve that, I use exported resources. Here's the simplified
idea:
define location ($host) {
notify {"Location being defined ${title} -> ${host}": }
}
# export the location
node 'a' {
@@location { "mysql-server":
host => $hostname
}
}
node 'b' {
# later import it on another node
Location <<| title == "mysql-server" |>>
# extract the data
$mysql_server_host = getparam(Location["mysql-server"], "host")
}
Pretty much I use exported resources as some sort of exported "facts". The
problem with that, that puppet cannot realize the Location inside the
classes or at node level scope, but does it just fine within resources:
*DOES NOT WORK:*
class class_example() {
# something like realize Location["mysql-server"] doesn't even compile
Location <<| title == "mysql-server" |>>
$mysql_server_host = getparam(Location["mysql-server"], "host")
notify {"Example in class: ${mysql_server_host}": }
}
node 'b' {
class { class_example: }
}
Yields: "Notice: Example in class:"
*WORKS JUST FINE:*
define resource_example() {
Location <<| title == "mysql-server" |>>
$mysql_server_host = getparam(Location["mysql-server"], "host")
notify {"Example in resource: ${mysql_server_host}": }
}
Yields "Notice: Example in resource: hostname-x"
The problem with that, I my guess, the puppet evaluates stuff in two
stages, classes first, and then resources, including exported resources.
What is also interesting, that notify I've put for debug yields like that:
Example in class:
Example in resource: hostname-x
Location being defined mysql-server -> hostname-x
If I do "require => Location["mysql-server"]" for the resource, the
ordering shows right, but result is the same:
Example in class:
Location being defined mysql-server -> hostname-x
Example in resource: hostname-x
The question is, how do I enforce puppet to evaluate class AFTER exported
resource? Would "stages" help me out here? As a workaround, I have to wrap
classes in a single-instance resources.
Thank you very much in advance.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/e331a5fc-657a-47ae-aa0d-64f2a655ff10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.