0

Here is the snippet from my manifest:

  apache::vhost { 'default-http':
    port     => 80,
    serveraliases => ['example.test.com', 'example2.test.com',],
    docroot  => '/var/www/html',
    rewrites => [
      {
        comment      => 'Bounce to https',
        rewrite_cond => ['"%{SERVER_PROTOCOL}"  "!^HTTP$"'],
        rewrite_rule => ['"^/?(.*)" "https://%{HTTP_HOST}/$1" [R=permanent,L]'],
      }
    ],
  }

As you can see in the following config, the aliases are nowhere to be found:

# Vhost template in module puppetlabs-apache
# Managed by Puppet
# ************************************

<VirtualHost *:80>
  ServerName default-http

  ## Vhost docroot
  DocumentRoot "/var/www/html"

  ## Directories, there should at least be a declaration for /var/www/html

  <Directory "/var/www/html">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
  </Directory>

  ## Logging
  ErrorLog "/var/log/httpd/default-http_error.log"
  ServerSignature Off
  CustomLog "/var/log/httpd/default-http_access.log" combined
  ## Rewrite rules
  RewriteEngine On

  #Bounce to https
  RewriteCond "%{SERVER_PROTOCOL}"  "!^HTTP$"
  RewriteRule "^/?(.*)" "https://%{HTTP_HOST}/$1" [R=permanent,L]

I assume there is something wrong with my serveraliases line, as everything else shows up in the config other than that line. Unfortunately I do not see any errors in the logs to guide me.

What am I doing wrong?

david
  • 135
  • 7

1 Answers1

1

For arrays, it's recommended in The Puppet Language Style Guide that...

To increase readability of arrays and hashes, it is almost always beneficial to break up the elements on separate lines.

Use a single line only if that results in overall better readability of the construct where it appears, such as when it is very short. When breaking arrays and hashes, they should have:

  • Each element on its on line,
  • Each new element line indented one level,
  • First and last lines used only for the syntax of that data type.

The example from Configuring virtual hosts looks like this:

apache::vhost { 'aliases.example.com':
  serveraliases => [
    'aliases.example.org',
    'aliases.example.net',
  ],
  port          => '80',
  docroot       => '/var/www/aliases',
}

The only thing different in your configuration is that you don't have spaces between [ ' and ', ],. That would have been automatically avoided by using the best practices for formatting arrays.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
  • 1
    This fixed it.. I didn't think it would, as it says "recommended for readability". Thanks – david Jul 19 '17 at 16:35