Hello,

I have a small Puppet 2.7 module to configure Sonatype Nexus Professional. 
The module takes, among other things, a baseurl in the form of 
"http://example.com/path"; and I'd like it to extract the "/path" from that 
variable into a separate variable IF an optional "path" variable haven't 
been supplied.

Here is an extract:
class nexus::config(
...
  $baseurl,
  $webapp_context_path = '/'
) {
  if ($webapp_context_path != '')
  {
    $int_webapp_context_path = $webapp_context_path
    notify{"using webapp_context_path \"${webapp_context_path}\"":}
  }
  else
  {
    $extracted_url_path = regsubst($baseurl, '^https?://[^/]+(/.*)', '\1')
    if ($extracted_url_path)
    {
      $int_webapp_context_path = $extracted_url_path
    }
    else
    {
      # in case we were given a $baseurl without the tailing "/"
      $int_webapp_context_path = '/'
    }
    notify{"extracted int_webapp_context_path 
\"${int_webapp_context_path}\" from url \"${baseurl}\"": }
  }

  # use $int_webapp_context_path in the .erb template file

My question - this use of $int_webapp_context_path and $extracted_url_path 
looks a bit shabby. But I didn't find a way to use conditional assignments 
to remove these intermediate variables and either:
1. Assign the value I want to $webapp_context_path if it's not set yet.
2. Or at least get rid of the $extracted_url_path

Is there a nicer way to achieve the above?

Thanks.

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

Reply via email to