Question

Is it possible at all? My use case is setting wildcard domain's docroot. I have a variable

$docroot = "/var/www"

and, inside apache::vhost {} I'm trying to set

virtual_docroot' => "{$docroot}/%-2+",

That however throws an error saying:

Error: Could not parse for environment production: Syntax error at ' => "$docroot/%-2+",
    docroot          => $docroot,
    serveraliases    => ['; expected '}' at /tmp/vagrant-puppet-1/manifests/init.pp:22 on node localhost

My guess is that the whole expression is treated as a regexp, and $ treated as a part of the whole expression. Hence my doubts whether that's possible at all.

Was it helpful?

Solution

The answer turns out to be an orphaned apostrophe, misplaced after virtual_docroot, and copied from puppetlabs-apache documentation, where the faulty code is:

apache::vhost { 'subdomain.loc':
  vhost_name => '*',
  port       => '80',
  virtual_docroot' => '/var/www/%-2+',
  docroot          => '/var/www',
  serveraliases    => ['*.loc',],
}

Removing the apostrophe fixed the problem. Answer to my question is to set that particular configuration line as:

virtual_docroot => "$docroot/%-2+",

Notice the omitted {} characters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top