Cookbooks
apache2
documentation
Resource Apache2 Module

apache2_module

Enable or disable an Apache module in #{apache_dir/mods-available by calling a2enmod or a2dismod to manage the symbolic link in #{apache_dir}/mods-enabled. If the module has a configuration file, a template should be created in the cookbook where the definition is used. See Examples.

Properties

NameTypeDefaultDescription
nameStringName of the module enabled or disabled with the a2enmod or a2dismod scripts.
mod_nameString#mod_{name}.soFilename of the module. Override if the module has a different filename the the default.
identifierString#{name}_moduleString to identify the module for the LoadModule directive.
confBooleanhas_config?The default is set by the config_file? helper. Override to set whether the module should have a config file.
template_cookbookStringapache2Cookbook to source the template from. Override this to provide your own template.
mod_confHash{}Varables to pass to the config file template.

Examples

Enable the ssl module, which also has a configuration template in templates/default/mods/ssl.conf.erb. Simply call the resource. The cookbook contains a list of modules in library/helpers.rb in the #config_file? method.

apache2_module "ssl"

Enable the php5 module, which has a different filename than the module default:

apache2_module "php5" do
  mod_name "libphp5.so"
end

Disable a module:

apache2_module "disabled_module" do
  action :disable
end

Enable a module with a custom template from the foo cookbook:

apache2_module "module_name" do
  conf true
  template_cookbook 'foo'
end

See the recipes directory for many more examples of apache2_module.