Skip to content

Obviate.io

To anticipate and prevent

  • Home
  • About Us
  • History
  • Privacy Policy
  • Toggle search form

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

More Related Articles

Weekend Server Overhaul IPv6
Apache + WebDav + LDAP = Pure Bliss LDAP
Benchmarking: Ubuntu 9.04 i386 vs LPIA on Eee PC 1000 Netbooks

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

April 2012
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930  
« Mar   May »

Copyright © 2022 Obviate.io

Powered by PressBook Premium theme