Skip to content

Commit

Permalink
Add support for user modifiable installation of mod_systemd and pidfi…
Browse files Browse the repository at this point in the history
…le locations.

default_mods.pp --> added use_systemd option, if running a custom build of apache on
                    centos7, user modifiable boolean option provided

init.pp --> added pidfile and use_systemd option both of which go to params.pp and allow
            these values to be set in hiera. changed all osfamily choices for conf_dir
            removed setting the $pidfile variable (now done in params).

params.pp --> added $use_systemd, by default set to true to mimic original behaviour.
              added $pidfile, set to mimic exact same behaviour as used in init.pp,
              except now user changeable via hiera.

updated documentation, to include the 2 new options.
  • Loading branch information
vamegh committed Jul 24, 2015
1 parent 48a72ea commit 3f0a5a1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ Determines which MPM is loaded and configured for the HTTPD process. Valid value

Allows control over the package ensure attribute. Can be 'present','absent', or a version string.

#####`pidfile`

Allows settting a custom location for the pid file - useful if using a custom built Apache rpm. Defaults to 'run/httpd.pid' on RedHat, '/var/run/httpd.pid on FreeBSD and '\${APACHE_PID_FILE}' on Debian.

#####`ports_file`

Changes the name of the file containing Apache ports configuration. Default is `${conf_dir}/ports.conf`.
Expand Down Expand Up @@ -498,6 +502,10 @@ Sets the amount of seconds the server will wait for certain events before failin

Controls how TRACE requests per RFC 2616 are handled. More information about [TraceEnable](http://httpd.apache.org/docs/current/mod/core.html#traceenable). Defaults to 'On'.

#####`use_systemd`

Controls whether the systemd module should be installed on Centos 7 servers, this is especially useful if using custom built rpms. This can either be 'true' or 'false, defaults to 'true'.

#####`vhost_dir`

Changes the location of the configuration directory your virtual host configuration files are placed in. Defaults to 'etc/httpd/conf.d' on RedHat, '/etc/apache2/sites-available' on Debian, '/usr/local/etc/apache22/Vhosts' on FreeBSD, and '/etc/apache2/vhosts.d' on Gentoo.
Expand Down
7 changes: 5 additions & 2 deletions manifests/default_mods.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class apache::default_mods (
$all = true,
$mods = undef,
$apache_version = $::apache::apache_version
$apache_version = $::apache::apache_version,
$use_systemd = $::apache::use_systemd,
) {
# These are modules required to run the default configuration.
# They are not configurable at this time, so we just include
Expand All @@ -13,7 +14,9 @@
# Lets fork it
# Do not try to load mod_systemd on RHEL/CentOS 6 SCL.
if ( !($::osfamily == 'redhat' and versioncmp($::operatingsystemrelease, '7.0') == -1) and !($::operatingsystem == 'Amazon') ) {
::apache::mod { 'systemd': }
if ($use_systemd) {
::apache::mod { 'systemd': }
}
}
::apache::mod { 'unixd': }
}
Expand Down
7 changes: 2 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
$lib_path = $::apache::params::lib_path,
$conf_template = $::apache::params::conf_template,
$servername = $::apache::params::servername,
$pidfile = $::apache::params::pidfile,
$manage_user = true,
$manage_group = true,
$user = $::apache::params::user,
Expand All @@ -72,6 +73,7 @@
$allow_encoded_slashes = undef,
$package_ensure = 'installed',
$use_optional_includes = $::apache::params::use_optional_includes,
$use_systemd = $::apache::params::use_systemd,
) inherits ::apache::params {
validate_bool($default_vhost)
validate_bool($default_ssl_vhost)
Expand Down Expand Up @@ -247,24 +249,20 @@
if $::apache::conf_dir and $::apache::params::conf_file {
case $::osfamily {
'debian': {
$pidfile = "\${APACHE_PID_FILE}"
$error_log = 'error.log'
$scriptalias = '/usr/lib/cgi-bin'
$access_log_file = 'access.log'
}
'redhat': {
$pidfile = 'run/httpd.pid'
$error_log = 'error_log'
$scriptalias = '/var/www/cgi-bin'
$access_log_file = 'access_log'
}
'freebsd': {
$pidfile = '/var/run/httpd.pid'
$error_log = 'httpd-error.log'
$scriptalias = '/usr/local/www/apache24/cgi-bin'
$access_log_file = 'httpd-access.log'
} 'gentoo': {
$pidfile = '/run/apache2.pid'
$error_log = 'error.log'
$error_documents_path = '/usr/share/apache2/error'
$scriptalias = '/var/www/localhost/cgi-bin'
Expand All @@ -282,7 +280,6 @@
}
}
'Suse': {
$pidfile = '/var/run/httpd2.pid'
$error_log = 'error.log'
$scriptalias = '/usr/lib/cgi-bin'
$access_log_file = 'access.log'
Expand Down
7 changes: 7 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
$log_level = 'warn'
$use_optional_includes = false

# should we use systemd module?
$use_systemd = true

if $::operatingsystem == 'Ubuntu' and $::lsbdistrelease == '10.04' {
$verify_command = '/usr/sbin/apache2ctl -t'
} else {
Expand All @@ -50,6 +53,7 @@
$vhost_enable_dir = undef
$conf_file = 'httpd.conf'
$ports_file = "${conf_dir}/ports.conf"
$pidfile = 'run/httpd.pid'
$logroot = '/var/log/httpd'
$logroot_mode = undef
$lib_path = 'modules'
Expand Down Expand Up @@ -165,6 +169,7 @@
$vhost_enable_dir = "${httpd_dir}/sites-enabled"
$conf_file = 'apache2.conf'
$ports_file = "${conf_dir}/ports.conf"
$pidfile = "\${APACHE_PID_FILE}"
$logroot = '/var/log/apache2'
$logroot_mode = undef
$lib_path = '/usr/lib/apache2/modules'
Expand Down Expand Up @@ -308,6 +313,7 @@
$vhost_enable_dir = undef
$conf_file = 'httpd.conf'
$ports_file = "${conf_dir}/ports.conf"
$pidfile = '/var/run/httpd.pid'
$logroot = '/var/log/apache24'
$logroot_mode = undef
$lib_path = '/usr/local/libexec/apache24'
Expand Down Expand Up @@ -433,6 +439,7 @@
$vhost_enable_dir = "${httpd_dir}/sites-enabled"
$conf_file = 'httpd.conf'
$ports_file = "${conf_dir}/ports.conf"
$pidfile = '/var/run/httpd2.pid'
$logroot = '/var/log/apache2'
$logroot_mode = undef
$lib_path = '/usr/lib64/apache2-prefork/'
Expand Down

0 comments on commit 3f0a5a1

Please sign in to comment.