We moving to using Puppet to manage. Using the apache module (from Puppet).
Trying to figure out syntax to make puppet produce something like:
<Directory "/data/websites/mysite">
ExpiresActive On
ExpiresDefault "access plus 0 seconds"
ExpiresByType text/javascript "access plus 12 hours"
ExpiresByType application/x-javascript "access plus 12 hours"
ExpiresByType text/css "access plus 12 hours"
ExpiresByType image/gif "access plus 12 hours"
ExpiresByType image/jpeg "access plus 12 hours"
ExpiresByType application/x-shockwave-flash "access plus 12 hours"
</Directory>
I tried this:
apache::vhost { 'mysite':
servername => 'mysite.com',
vhost_name => $::ipaddress,
port => '80',
docroot => $docroot,
directories => [
{
path => '/var/www/mysite,
provider => 'directory',
options => ['-Indexes','FollowSymLinks'],
expires_active => 'On',
expires_default => 'access plus 0 seconds',
expires_by_type => [
{'text/javascript' => 'access plus 12 hours' },
{'application/x-javascript' => 'access plus 12 hours' },
{'text/css' => 'access plus 12 hours' },
{'image/gif' => 'access plus 12 hours' },
{'image/jpeg' => 'access plus 12 hours' },
{'application/x-shockwave-flash' => 'access plus 12 hours' },
],
},
],
}
This will create this which is not quite what I want:
<Directory "/var/www/mysite">
Options -Indexes FollowSymLinks
AllowOverride None
Require all granted
ExpiresActive On
ExpiresDefault access plus 0 seconds
ExpiresByType {"text/javascript"=>"access plus 12 hours"}
ExpiresByType {"application/x-javascript"=>"access plus 12 hours"}
ExpiresByType {"text/css"=>"access plus 12 hours"}
ExpiresByType {"image/gif"=>"access plus 12 hours"}
ExpiresByType {"image/jpeg"=>"access plus 12 hours"}
ExpiresByType {"application/x-shockwave-flash"=>"access plus 12 hours"}
</Directory>
The ExpiresDefault and ExpiresByType is not working. The rest looks good to me.
If you change your code to:
apache::vhost { 'mysite':
servername => 'mysite.com',
vhost_name => '1.1.1.1',
port => '80',
docroot => 'mydocroot',
directories => [
{
path => '/var/www/mysite',
provider => 'directory',
options => ['-Indexes','FollowSymLinks'],
expires_active => 'On',
expires_default => '"access plus 0 seconds"',
expires_by_type => [
'text/javascript "access plus 12 hours"',
'application/x-javascript "access plus 12 hours"',
'text/css "access plus 12 hours"',
'image/gif "access plus 12 hours"',
'image/jpeg "access plus 12 hours"',
'application/x-shockwave-flash "access plus 12 hours"',
],
},
],
}
You get:
<Directory "/var/www/mysite">
Options -Indexes FollowSymLinks
AllowOverride None
Require all granted
ExpiresActive On
ExpiresDefault "access plus 0 seconds"
ExpiresByType text/javascript "access plus 12 hours"
ExpiresByType application/x-javascript "access plus 12 hours"
ExpiresByType text/css "access plus 12 hours"
ExpiresByType image/gif "access plus 12 hours"
ExpiresByType image/jpeg "access plus 12 hours"
ExpiresByType application/x-shockwave-flash "access plus 12 hours"
</Directory>
I didn't dig deep enough to decide whether this behaviour is as-documented, is confusing and should be fixed, should be better documented, or is unexpected.
If it is anything other than as-documented, then definitely someone should raise a pull request to improve the Apache module.