On 02.12.2009 17:39, Thomas Bellman wrote:
> Silviu Paragina wrote:
>
>    
>> Are there any such things? For example
>> $ip_list_arr=split(ip_list,",")
>> $ip_external=*$ip_list_arr[0]*
>>
>> Or the only way to do it, is via custom functions?
>> I think I read something like this before, but can't remember where or
>> if it was with a custom function or not.
>>      
> Not at the moment.  There is some work being done to add hashes to
> the Puppet language, and then I think we will get array indexing at
> the same time.
>
> If you only need it once, you can abuse inline_template() to do it:
>
>       $ip_list_arr = split($ip_list, ",")
>       $ip_external = inline_template("<%= ip_list_arr[0] %>")
>    
What do you mean by once? It's slow? Or some other reason?
I need to get the first item, then the second, and if the second is not 
there pass the first.
(ip_list is a custom fact that lists the machines ip addresses sorted, 
except 127.0.0.1)


:-?
I think it might be better for my case to define the custom facts as 
iplist_1, iplist_2. But I'm not sure what are the downsides of using 
inline_template, if there are next to none I think I'll use it.

Thank you for the quick reply and info. :)


> Or, for this specific case, where you start by splitting a string, you
> can use regsubst():
>
>       $ip_external = regsubst($ip_list, "^([^,]*).*", "\\1")
>
>
> /Bellman
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-us...@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.
>
>
>    
Silviu

--

You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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.


Reply via email to