Skip to content

Obviate.io

To anticipate and prevent

Puppet Quick Tip: Enabling an Apache module

Posted on 2012-04-05 By Jon No Comments on Puppet Quick Tip: Enabling an Apache module

Recently, I was asked to enable mod_rewrite for Apache on our webservers, which are controlled by the sexy puppet master server. I did a quick google to see if anyone had any recipes published. On the puppet wiki there is a recipe for Apache on Etch, but their module portion installs Apache modules. In the case of mod_rewrite it comes with Apache2 so it doesn’t need to be as complicated as they suggest.

My solution is as close to a “one liner” as it gets in puppet. You just check to see if the symlink for the loaded module exists and if it doesn’t, run

a2enmod. Of course it’ll double check to make sure Apache gets restarted too.

define apache::loadmodule () {
     exec { "/usr/sbin/a2enmod $name" :
  unless => "/bin/readlink -e /etc/apache2/mods-enabled/${name}.load",
  notify => Service[apache2]
     }
}

Call it with apache::loadmodule{"rewrite": } and you’re good to go. You do need to double check that you use the .load file name from /etc/apache2/mods-available/ . In my example it is ‘rewrite’ for ‘mod_rewrite’. You can also create a recipe to disable the module with a2dismod, should you find yourself needing to disable a lot of modules.

Puppet Tags:a2dismod, a2enmod, apache, Debian, puppet, recipe, Ubuntu

Post navigation

Previous Post: Is the era of $60 PC video games coming to an end?
Next Post: Microsoft Flight has taken off

Related Posts

Initial publishing of Puppet scripts Puppet
Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type Puppet

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 Obviate.io.

Powered by PressBook Masonry Dark