Skip to content

Commit

Permalink
refactoring so that sysconfig changes (including modules) are now don…
Browse files Browse the repository at this point in the history
…e without using a template; changes are made either via file_line (for sysconfig.pp) or a2enmod (for modules). Refactoring ldap.pp to use a template for future passing of tuning params. Normalizing the validation and enableModule call, too.
  • Loading branch information
sharumpe committed Dec 2, 2014
1 parent caca668 commit c54a5f8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 300 deletions.
34 changes: 27 additions & 7 deletions manifests/ldap.pp
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
class apache2::ldap
(
$ldapStatusAccessIp
)
{
#
include apache2::params

validate_string( $ldapStatusAccessIp )

# Enable the module
apache2::enableModule{ 'ldap': }

# Pick the template path we're going to use
$mod_path = get_module_path('apache2')
$specific = "$mod_path/templates/$operatingsystem/$operatingsystemrelease$params::ldapConfigPath.erb"
$default = "$mod_path/templates/default$params::ldapConfigPath.erb"

# Simply put in the default ldap config file,
# but using the new-style access control configurations
#
file { $params::ldapConfigPath :
ensure => present,
source => "puppet:///modules/apache2${params::statusConfigPath}",
owner => 'root',
group => 'root',
content => inline_template( file( $specific, $default ) ),
notify => $apache2::serviceNotify,
require => Package[ $params::packageName ],
}

#
# Enable the module
#
apache2::enableModule{ 'ldap': }
# Grant access to given IP
if ( is_string( $ldapStatusAccessIp ) ) {
apache2::grantAccessToIp { 'ldap-status' :
location => '/ldap-status',
ip => $ldapStatusAccessIp,
}
}

}
15 changes: 12 additions & 3 deletions manifests/defaultmodules.pp → manifests/modules.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class apache2::defaultModules
class apache2::modules
(
$modules = []
)
Expand All @@ -8,7 +8,16 @@
# List of default modules to enable
# defined in apache2::params::a2modDefaults
if ( is_array( $modules ) and ( size( $modules ) > 0 ) ) {
apache2::enableModule { $modules : }
# clear the module list
file_line { 'clear_module_list' :
path => $params::sysconfigPath,
line => 'APACHE_MODULES=""',
}

# enable the modules specified
apache2::enableModule { $modules :
require => File_line[ 'clear_module_list' ],
}
}
}

Expand All @@ -18,7 +27,7 @@
exec { "enable_${name}" :
command => "/usr/sbin/a2enmod ${name}",
unless => "/usr/sbin/a2enmod -q ${name}",
require => [ Package[ $params::packageName ], File[ $params::sysconfigPath ] ],
require => Package[ $params::packageName ],
notify => $apache2::serviceNotify,
}
}
28 changes: 19 additions & 9 deletions manifests/sysconfig.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@
{
include apache2::params

# Pick the template path we're going to use
$mod_path = get_module_path('apache2')
$specific = "$mod_path/templates/$operatingsystem/$operatingsystemrelease$params::sysconfigPath.erb"
$default = "$mod_path/templates/default$params::sysconfigPath.erb"
validate_string( $serverSignature )
validate_string( $serverTokens )

# Build the sysconfig file from the template
file { $params::sysconfigPath :
ensure => present,
content => inline_template( file( $specific, $default ) ),
notify => $apache2::serviceNotify,
# Pick the template path we're going to use
$mod_path = get_module_path('apache2')
$specific = "$mod_path/templates/$operatingsystem/$operatingsystemrelease$params::sysconfigPath.erb"
$default = "$mod_path/templates/default$params::sysconfigPath.erb"

# Replace lines in the existing file
file_line { 'serverSignatureRule' :
path => $params::sysconfigPath,
line => "APACHE_SERVERSIGNATURE = \"${serverSignature}\"",
match => "^APACHE_SERVERSIGNATURE\s*=",
notify => $apache2::serviceNotify,
}
file_line { 'serverTokensRule' :
path => $params::sysconfigPath,
line => "APACHE_SERVERTOKENS=\"${serverTokens}\"",
match => "^APACHE_SERVERTOKENS=",
notify => $apache2::serviceNotify,
}
}
File renamed without changes.
281 changes: 0 additions & 281 deletions templates/default/etc/sysconfig/apache2.erb

This file was deleted.

0 comments on commit c54a5f8

Please sign in to comment.