[Puppet Users] Re: How to refer to exported resource parameters in a template

2016-08-09 Thread Matthew Pounsett


On Tuesday, 9 August 2016 06:12:33 UTC-7, jcbollinger wrote:
>
>
>
> Some people do hack together means to do the job more or less as you 
> initially envisioned, but don't confuse mechanism with result.  I would not 
> be surprised if you had seen examples of exactly what I describe, without 
> recognizing that they, or something like them, would serve your purpose 
> perfectly well.
>

Using concat for this purpose represents the worst of ugly hacks to get 
around a missing feature.   I've been forced to use it before for similar 
purposes.. and in any kind of large infrastructure it can quickly become an 
unmanageable collection of thousands of files being concatenated into a 
single (or small number of) config files.

If accessing the values in exported resources is such anathema, then 
perhaps the puppet core aught to consider including a function that exposes 
facts across nodes.

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/01feb2e9-7404-47b2-b436-2fa4a35e5ad4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: How to refer to exported resource parameters in a template

2016-08-09 Thread jcbollinger


On Monday, August 8, 2016 at 3:55:38 PM UTC-5, 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.
>
> 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).
>

You've already received a response in that general direction, but I want to 
observe that the underlying idea is unnatural for Puppet.  Yes, exported 
resources are a good fit to the task, but resources are not well suited to 
be vehicles for communication and data storage within the master.  Rather, 
their role and purpose is to encapsulate details of machine state in a 
manner that can be applied to the (a) target machine.

Thus, if you use exported resources for your purpose, the natural approach 
is for the various machines to export resources that serve their purpose by 
being *applied* to the target machine.  Since you want all of them to 
contribute to a single list in a single file, you're looking for a resource 
type that represents a piece of a file.  No such resource type is included 
in the Puppet core, but this is the bread & butter of the widely-used Concat 
module .


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


Yes, because applying resources to a node is the natural and intended usage 
of resources.  The trick is to choose the right resources for the job.

 

>
> How do people normally go about doing something like this?  Are there some 
> examples I've just failed to find?
>
>  

Some people do hack together means to do the job more or less as you 
initially envisioned, but don't confuse mechanism with result.  I would not 
be surprised if you had seen examples of exactly what I describe, without 
recognizing that they, or something like them, would serve your purpose 
perfectly well.


John

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/f561b199-9a02-479e-a5f6-d63a1782e627%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.