module apache

Public Instance Methods

balancer( $proxy_set => '{}', $collect_exported => 'true' )

Define Resource Type: apache::balancer

This type will create an apache balancer cluster file inside the conf.d directory. Each balancer cluster needs one or more balancer members (that can be declared with the apache::balancermember defined resource type). Using storeconfigs, you can export the apache::balancermember resources on all balancer members, and then collect them on a single apache load balancer server.

Requirement/Dependencies:

Currently requires the puppetlabs/concat module on the Puppet Forge and uses storeconfigs on the Puppet Master to export/collect resources from all balancer members.

Parameters

name

The namevar of the defined resource type is the balancer clusters name. This name is also used in the name of the conf.d file

proxy_set

Hash, default empty. If given, each key-value pair will be used as a ProxySet line in the configuration.

collect_exported

Boolean, default 'true'. True means 'collect exported @@balancermember resources' (for the case when every balancermember node exports itself), false means 'rely on the existing declared balancermember resources' (for the case when you know the full set of balancermembers in advance and use apache::balancermember with array arguments, which allows you to deploy everything in 1 run)

Examples

Exporting the resource for a balancer member:

apache::balancer { 'puppet00': }

balancermember( $balancer_cluster, $url => '[( Puppet::Parser::AST::String "http://" nil ), ( Puppet::Parser::AST::Variable $::fqdn nil ), ( Puppet::Parser::AST::String "/" nil )]', $options => [] )

Define Resource Type: apache::balancermember

This type will setup a balancer member inside a listening service configuration block in /etc/apache/apache.cfg on the load balancer. currently it only has the ability to specify the instance name, url and an array of options. More features can be added as needed. The best way to implement this is to export this resource for all apache balancer member servers, and then collect them on the main apache load balancer.

Requirement/Dependencies:

Currently requires the puppetlabs/concat module on the Puppet Forge and uses storeconfigs on the Puppet Master to export/collect resources from all balancer members.

Parameters

name

The title of the resource is arbitrary and only utilized in the concat fragment name.

balancer_cluster

The apache service's instance name (or, the title of the apache::balancer resource). This must match up with a declared apache::balancer resource.

url

The url used to contact the balancer member server.

options

An array of options to be specified after the url.

Examples

Exporting the resource for a balancer member:

@@apache::balancermember { 'apache':

balancer_cluster => 'puppet00',
url              => "ajp://${::fqdn}:8009"
options          => ['ping=5', 'disablereuse=on', 'retry=5', 'ttl=120'],

}

listen( )
mod( $package => 'undef', $package_ensure => 'present', $lib => 'undef', $lib_path => '::apache::params::lib_path', $id => 'undef', $path => 'undef', $loadfiles => 'undef' )
mpm( $lib_path => '::apache::params::lib_path', $apache_version => '::apache::apache_version' )
namevirtualhost( )
vhost( $docroot, $virtual_docroot => 'false', $port => 'undef', $ip => 'undef', $ip_based => 'false', $add_listen => 'true', $docroot_owner => 'root', $docroot_group => '::apache::params::root_group', $docroot_mode => 'undef', $serveradmin => 'undef', $ssl => 'false', $ssl_cert => '::apache::default_ssl_cert', $ssl_key => '::apache::default_ssl_key', $ssl_chain => '::apache::default_ssl_chain', $ssl_ca => '::apache::default_ssl_ca', $ssl_crl_path => '::apache::default_ssl_crl_path', $ssl_crl => '::apache::default_ssl_crl', $ssl_certs_dir => '::apache::params::ssl_certs_dir', $ssl_protocol => 'undef', $ssl_cipher => 'undef', $ssl_honorcipherorder => 'undef', $ssl_verify_client => 'undef', $ssl_verify_depth => 'undef', $ssl_options => 'undef', $ssl_proxyengine => 'false', $priority => 'undef', $default_vhost => 'false', $servername => 'name', $serveraliases => [], $options => ["Indexes", "FollowSymLinks", "MultiViews"], $override => ["None"], $directoryindex => '', $vhost_name => '*', $logroot => '::apache::logroot', $log_level => 'undef', $access_log => 'true', $access_log_file => 'undef', $access_log_pipe => 'undef', $access_log_syslog => 'undef', $access_log_format => 'undef', $access_log_env_var => 'undef', $aliases => 'undef', $directories => 'undef', $error_log => 'true', $error_log_file => 'undef', $error_log_pipe => 'undef', $error_log_syslog => 'undef', $error_documents => [], $fallbackresource => 'undef', $scriptalias => 'undef', $scriptaliases => [], $proxy_dest => 'undef', $proxy_pass => 'undef', $suphp_addhandler => '::apache::params::suphp_addhandler', $suphp_engine => '::apache::params::suphp_engine', $suphp_configpath => '::apache::params::suphp_configpath', $php_admin_flags => [], $php_admin_values => [], $no_proxy_uris => [], $redirect_source => '/', $redirect_dest => 'undef', $redirect_status => 'undef', $redirectmatch_status => 'undef', $redirectmatch_regexp => 'undef', $rack_base_uris => 'undef', $headers => 'undef', $request_headers => 'undef', $rewrites => 'undef', $rewrite_base => 'undef', $rewrite_rule => 'undef', $rewrite_cond => 'undef', $setenv => [], $setenvif => [], $block => [], $ensure => 'present', $wsgi_application_group => 'undef', $wsgi_daemon_process => 'undef', $wsgi_daemon_process_options => 'undef', $wsgi_import_script => 'undef', $wsgi_import_script_options => 'undef', $wsgi_process_group => 'undef', $wsgi_script_aliases => 'undef', $custom_fragment => 'undef', $itk => 'undef', $action => 'undef', $fastcgi_server => 'undef', $fastcgi_socket => 'undef', $fastcgi_dir => 'undef', $additional_includes => [], $apache_version => '::apache::apache_version', $suexec_user_group => 'undef' )

Definition: apache::vhost

This class installs Apache Virtual Hosts

Parameters:

  • The $port to configure the host on

  • The $docroot provides the DocumentRoot variable

  • The $virtual_docroot provides VirtualDocumentationRoot variable

  • The $serveradmin will specify an email address for Apache that it will display when it renders one of it's error pages

  • The $ssl option is set true or false to enable SSL for this Virtual Host

  • The $priority of the site

  • The $servername is the primary name of the virtual host

  • The $serveraliases of the site

  • The $ip to configure the host on, defaulting to *

  • The $options for the given vhost

  • The $override for the given vhost (list of AllowOverride arguments)

  • The $vhost_name for name based virtualhosting, defaulting to *

  • The $logroot specifies the location of the virtual hosts logfiles, default to /var/log/<apache log location>/

  • The $log_level specifies the verbosity of the error log for this vhost. Not set by default for the vhost, instead the global server configuration default of 'warn' is used.

  • The $access_log specifies if *_access.log directives should be configured.

  • The $ensure specifies if vhost file is present or absent.

  • The $headers is a list of Header statement strings as per httpd.apache.org/docs/2.2/mod/mod_headers.html#header

  • The $request_headers is a list of RequestHeader statement strings as per httpd.apache.org/docs/2.2/mod/mod_headers.html#requestheader

  • $aliases is a list of Alias hashes for mod_alias as per httpd.apache.org/docs/current/mod/mod_alias.html each statement is a hash in the form of { alias => '/alias', path => '/real/path/to/directory' }

  • $directories is a lost of hashes for creating <Directory> statements as per httpd.apache.org/docs/2.2/mod/core.html#directory each statement is a hash in the form of { path => '/path/to/directory', <directive> => <value>} see README.md for list of supported directives.

Actions:

  • Install Apache Virtual Hosts

Requires:

  • The apache class

Sample Usage:

# Simple vhost definition:
apache::vhost { 'site.name.fqdn':
  port => '80',
  docroot => '/path/to/docroot',
}

# Multiple Mod Rewrites:
apache::vhost { 'site.name.fqdn':
  port => '80',
  docroot => '/path/to/docroot',
  rewrites => [
    {
      comment       => 'force www domain',
      rewrite_cond => ['%{HTTP_HOST} ^([a-z.]+)?example.com$ [NC]', '%{HTTP_HOST} !^www. [NC]'],
      rewrite_rule => ['.? http://www.%1example.com%{REQUEST_URI} [R=301,L]']
    },
    {
      comment       => 'prevent image hotlinking',
      rewrite_cond => ['%{HTTP_REFERER} !^$', '%{HTTP_REFERER} !^http://(www.)?example.com/ [NC]'],
      rewrite_rule => ['.(gif|jpg|png)$ - [F]']
    },
  ]
}

# SSL vhost with non-SSL rewrite:
apache::vhost { 'site.name.fqdn':
  port    => '443',
  ssl     => true,
  docroot => '/path/to/docroot',
}
apache::vhost { 'site.name.fqdn':
  port            => '80',
  docroot         => '/path/to/other_docroot',
  custom_fragment => template("${module_name}/my_fragment.erb"),
}