Ask Your Question
0

apache::mod::expires hiera format

asked 2018-03-14 09:39:28 -0500

cmseal84 gravatar image

updated 2018-03-14 09:59:54 -0500

Hi,

I'm trying to identify the correct format for listing MIME types and expiration times in hiera. The module uses the following .erb template, but it doesn't seem to work when passing the hiera below. I'm still getting used to moving code from puppet manifests to hiera, so I'm not 100% sure the formatting is right.

 ExpiresActive <%= scope.function_bool2httpd([@expires_active]) %>
    <%- if ! @expires_default.nil? and ! @expires_default.empty? -%>
    ExpiresDefault "<%= @expires_default %>"
    <%- end -%>
    <%- if ! @expires_by_type.nil? and ! @expires_by_type.empty? -%>
    <%- [@expires_by_type].flatten.each do |line| -%>
    <%- line.map do |type, seconds| -%>
    ExpiresByType <%= type %> "<%= seconds -%>"
    <%- end -%>
    <%- end -%>
    <%- end -%>

Using:

apache::mod::expires:
  expires_active: true
  expires_default: 'access plus 5 seconds'
  expires_by_type:
    'image/x-icon': 'access plus 2592000 seconds'
    'image/jpeg': 'access plus 2592000 seconds'
    'image/png': 'access plus 2592000 seconds'
    'image/gif': 'access plus 2592000 seconds'
    'text/css': 'access plus 604800 seconds'

I've also tried:

apache::mod::expires::expires_active: true
apache::mod::expires::expires_default: 'access plus 5 seconds'
apache::mod::expires::expires_by_type: [
    'image/x-icon': 'access plus 2592000 seconds',
    'image/jpeg': 'access plus 2592000 seconds', ]

Even with just below, no expires.conf appears in /etc/httpd/conf.modules.d/ and no errors either.

apache::mod::expires::expires_active: true
apache::mod::expires::expires_default: 'access plus 5 seconds'
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-03-14 19:26:21 -0500

natemccurdy gravatar image

You need to make an array in YAML. Array elements each start with a - on a new line.

Try this as your Hiera data:

apache::mod::expires:
  expires_active: true
  expires_default: 'access plus 5 seconds'
  expires_by_type:
    - 'image/x-icon': 'access plus 2592000 seconds'
    - 'image/jpeg': 'access plus 2592000 seconds'
    - 'image/png': 'access plus 2592000 seconds'
    - 'image/gif': 'access plus 2592000 seconds'
    - 'text/css': 'access plus 604800 seconds'
edit flag offensive delete link more

Comments

Hey - it turns out that the limiting factor is having apache::default_mods: true Although expires is listed as a default mod, anything within hiera to configure it isn't applied. I've only been able to have configuration set if I load all required modules explicitly and default_mods is false.

cmseal84 gravatar imagecmseal84 ( 2018-03-15 05:25:13 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-14 09:20:03 -0500

Seen: 34 times

Last updated: Mar 14