Ask Your Question
0

Duplicate declaration: Apache::Mod[expires]

asked 2016-09-29 04:58:50 -0500

KevW77 gravatar image

Hello all,

I've written an puppet module to configure my apache webservers, I have the following parameter set:

default_mods => true

I'd like to instert the following code:

class { 'apache::mod::expires':
    expires_by_type => [
    {'image/gif' => 'now plus 12 hours'},
    {'image/jpeg' => 'now plus 12 hours'},
    {'text/css' => 'now plus 12 hours'},
    {'text/javascript' => 'now plus 12 hours'}],
}

but when I do I see the following error when I perform a rake:

error during compilation: Duplicate declaration: Apache::Mod[expires] is already declared in file

setting default_mods => false means that the rake completes successfully but I'm missing a lot of modules that I need. I was wondering if anyone has had a similar problem and what the best way around it is...

Any help is much appreciated!

Cheers

Kev

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-09-30 07:37:46 -0500

domcleal gravatar image

Use Hiera to set the apache::mod::expires::expires_by_type parameter to the value you want: Hiera docs.

It need not even be very complex - just a basic hiera.yaml (example) and single common.yaml YAML data file containing:

---
apache::mod::expires::expires_by_type:
- 'image/gif': 'now plus 12 hours'
- 'image/jpeg': 'now plus 12 hours'
- 'text/css': 'now plus 12 hours'
- 'text/javascript': 'now plus 12 hours'
edit flag offensive delete link more

Comments

Thanks for replying, I've just tried this but I think this module loads an erb template and hiera doesn't seem to want to override the defaults :( I'm now going down the default_mods => false way and manually adding the modules...

KevW77 gravatar imageKevW77 ( 2016-10-03 06:07:04 -0500 )edit
0

answered 2016-10-05 06:02:55 -0500

KevW77 gravatar image

To Clarify, I used the following command:

default_mods => false

Then I inserted the following text inside my puppet apache class (including my expiresbytype information):

include ::apache::mod::actions
include ::apache::mod::authn_core
include ::apache::mod::cache
include ::apache::mod::ext_filter
include ::apache::mod::mime
include ::apache::mod::mime_magic
include ::apache::mod::rewrite
include ::apache::mod::speling
include ::apache::mod::suexec
include ::apache::mod::version
include ::apache::mod::vhost_alias
include ::apache::mod::alias
include ::apache::mod::authn_file
include ::apache::mod::autoindex
include ::apache::mod::dav
include ::apache::mod::dav_fs
include ::apache::mod::deflate
include ::apache::mod::dir
include ::apache::mod::mime
include ::apache::mod::negotiation
include ::apache::mod::setenvif
include ::apache::mod::authz_default
include ::apache::mod::cgi
include ::apache::mod::filter
include ::apache::mod::authz_default
include ::apache::mod::authz_user
include ::apache::mod::filter
include ::apache::mod::filter
::apache::mod { 'auth_digest': }
::apache::mod { 'authn_anon': }
::apache::mod { 'authn_dbm': }
::apache::mod { 'authz_dbm': }
::apache::mod { 'authz_owner': }
::apache::mod { 'expires': }
class { 'apache::mod::expires':
    expires_by_type => [
    {'image/gif' => 'now plus 12 hours'},
    {'image/jpeg' => 'now plus 12 hours'},
    {'text/css' => 'now plus 12 hours'},
    {'text/javascript' => 'now plus 12 hours'}],
}
::apache::mod { 'include': }
::apache::mod { 'logio': }
::apache::mod { 'substitute': }
::apache::mod { 'usertrack': }
::apache::mod { 'access_compat': }
::apache::mod { 'auth_basic': }
::apache::mod { 'env': }

I was able to confirm that all modules were loaded by checking the /etc/httpd/conf.modules.d/*.load files contents before making changes.

Although it seems to have loaded successfully, I'm not sure I can see any expires by type information in my configuration files so I guess its a case of watch this space...

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-09-29 04:58:50 -0500

Seen: 97 times

Last updated: Oct 05 '16