On Tuesday, October 2, 2012 10:10:13 AM UTC-5, Guzmán Brasó wrote: > > I'm in no way a puppet guru.... but rewritting it didnt work? from a logic > point of view this should work: > > > class .... > $baseurl, > $webapp_context_path = '' > ) { > if ($webapp_context_path == '') { > # Try to get value from baseurl > $webapp_context_path = regsubst($baseurl, '^https?://[^/]+(/.*)', '\1') > if ($webapp_context_path == '') { > #Set default > $webapp_context_path = '/' > } > } > notify{"rewritted webapp_context_path='${webapp_context_path}' from > url='${baseurl}'": } > } > >
No, that won't work, because Puppet variables, including class and definition parameters, can be assigned a value at most once. There are good reasons for that, but they're not really relevant to the present question. Anyway, for that very reason, constructs involving internal variables such as $int_webapp_context_path are fairly standard practice in Puppet. Among the alternatives could be to redesign your class parameterization or to drop the adaptive behavior. Or you could write a custom function implementing the logic for context path selection, or you could put it into your template instead of your class. (Note, by the way, that because you assign a default value of '/' to $webapp_context_path in your parameter list, in the class body that parameter will be observed to have an empty value only if such a value is explicitly set when the class is declared.) John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/sF_qog4IzWQJ. 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.