2009/8/26 Matthias Saou <th...@spam.spam.spam.spam.spam.spam.spam.egg.and.spam.freshrpms.net>: > > Hi, > > As often with puppet, I'm trying to do something I think is "simple", > yet I'm hitting a brick wall. > > What I want to do is have a client send back a list of members of a > system group so that the server can create some template-based > configuration files for a specific daemon, one per member. > > My problem here is that facter doesn't seem to be able to return > anything other than strings. Is that the case? Because it would be > really easier for me to have it return an array of the members :
Correct currently facter is essentially a flat key value map. This is something that is on the roadmap to have richer data structures for 2.0, which will begin work after 1.6 ships. > Then, my next problem is that once I get the comma separated string on > the server, I don't see how to convert that into an array I could > easily use inside classes and definitions. > > ...Help? :-) 0.25 puppet has split as a function in the puppet language: Split a string variable into an array using the specified split regexp. Usage:: $string = 'v1.v2:v3.v4' $array_var1 = split($string, ':') $array_var2 = split($string, '[.]') $array_var3 = split($string, '[.:]') $array_var1 now holds the result ['v1.v2', 'v3.v4'], while $array_var2 holds ['v1', 'v2:v3', 'v4'], and $array_var3 holds ['v1', 'v2', 'v3', 'v4']. Note that in the second example, we split on a string that contains a regexp meta-character (.), and that needs protection. A simple way to do that for a single character is to enclose it in square brackets.") Paul --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---