On Mon, Aug 08, 2016 at 11:28:55AM -0700, Matthew Pounsett wrote:
> I'm using puppet 4.4.1. I have a case where I need the IP addresses of
> all the servers that fit a certain set of criteria to appear in a YAML
> list in a config file on a particular host.
Been there for an activemq.xml config file, ended up using Erik Dalén's puppetdbquery.
https://forge.puppet.com/dalen/puppetdbquery
This in a manifest:
$qf = query_facts('id=root', ['owner', 'datacenter'])
This in a template used in that manifest:
<%
list = {}
@qf.values.each do |h|
if h['owner']
owner = h['owner']
list[owner] = 1
end
if h['datacenter']
datacenter = h['datacenter']
list[datacenter] = 1
end
end
-%>
You get the idea, could output yaml there or whatever you wanted really.
> It seems like the first step would be to create an exported resource with
> the required data in it, but I haven't yet found a way to refer to those
> data from inside a template (or from inside a module in order to populate
> a variable I can use in a template). It seems like this would be a
> common pattern, but the closest examples I've been able to find are for
> realizing the exported resource to create a file or other resource on a
> system, rather than incorporate some of the exported resource's data in
> other resources.
> How do people normally go about doing something like this? Are there some
> examples I've just failed to find?
>
> --
> 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 [1]
puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]
https://groups.google.com/d/msgid/puppet-users/d60d5c64-babe-4b46-8529-ceac74cf576b%40googlegroups.com.
> For more options, visit [3]
https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:
puppet-users...@googlegroups.com
> 2.
https://groups.google.com/d/msgid/puppet-users/d60d5c64-babe-4b46-8529-ceac74cf576b%40googlegroups.com?utm_medium=email&utm_source=footer
> 3.
https://groups.google.com/d/optout