Skip to content

Commit

Permalink
Working on #1 :
Browse files Browse the repository at this point in the history
Feeding the linter.
Refactoring camelCase defines as all-lower.
  • Loading branch information
Tim McLaughlin committed Aug 7, 2017
1 parent b936c81 commit 1e3b3b2
Show file tree
Hide file tree
Showing 11 changed files with 435 additions and 435 deletions.
64 changes: 32 additions & 32 deletions manifests/access.pp
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
class apache2::access {
include apache2::params
include apache2::params

#
# Create the file we're storing these in
#
concat { $params::accessConfigPath :
ensure => present,
notify => $apache2::serviceNotify,
}
#
# Create the file we're storing these in
#
concat { $apache2::params::accessConfigPath :
ensure => present,
notify => $apache2::serviceNotify,
}
}

define apache2::grantAccessToHost
define apache2::grantaccesstohost
(
$location,
$host
$location,
$host
)
{
include apache2::params
include apache2::params

validate_string( $location )
validate_string( $host )
validate_string( $location )
validate_string( $host )

concat::fragment { "${location}_${host}" :
target => $params::accessConfigPath,
order => 10,
content => template( "apache2/default${params::accessConfigPath}-grantToHost-frag.erb" ),
}
concat::fragment { "${location}_${host}" :
target => $apache2::params::accessConfigPath,
order => 10,
content => template( "apache2/default${apache2::params::accessConfigPath}-grantToHost-frag.erb" ),
}
}

define apache2::grantAccessToIp
define apache2::grantaccesstoip
(
$location,
$ip
$location,
$ip
)
{
include apache2::params
include apache2::params

validate_string( $location )
validate_string( $ip )
validate_string( $location )
validate_string( $ip )

if ( is_ip_address( $ip ) ) {
concat::fragment { "${location}_${ip}" :
target => $params::accessConfigPath,
order => 10,
content => template( "apache2/default${params::accessConfigPath}-grantToIp-frag.erb" ),
}
}
if ( is_ip_address( $ip ) ) {
concat::fragment { "${location}_${ip}" :
target => $apache2::params::accessConfigPath,
order => 10,
content => template( "apache2/default${apache2::params::accessConfigPath}-grantToIp-frag.erb" ),
}
}
}
268 changes: 134 additions & 134 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,143 +1,143 @@
File {
owner => root,
group => root,
ignore => [ '.svn', '.git' ],
owner => root,
group => root,
ignore => [ '.svn', '.git' ],
}

class apache2
(
$loadModules = [],
$unloadModules = [],
$extraPackages = [],
$useDefaultModules = true,
$remoteIpHeader = 'X-Forwarded-For',
$serverSignature = 'off',
$serverTokens = 'prod',
$traceEnable = false,
$reloadOnChange = false,
$serverInfoAccessIp = undef,
$serverStatusAccessIp = undef
$loadModules = [],
$unloadModules = [],
$extraPackages = [],
$useDefaultModules = true,
$remoteIpHeader = 'X-Forwarded-For',
$serverSignature = 'off',
$serverTokens = 'prod',
$traceEnable = false,
$reloadOnChange = false,
$serverInfoAccessIp = undef,
$serverStatusAccessIp = undef
)
{
#
# Get our configs
#
include apache2::params


validate_array( $loadModules )
validate_array( $unloadModules )
validate_array( $extraPackages )
validate_bool( $useDefaultModules )
validate_string( $remoteIpHeader )
validate_string( $serverSignature )
validate_string( $serverTokens )
validate_bool( $traceEnable )
validate_bool( $reloadOnChange )
validate_string( $serverInfoAccessIp )
validate_string( $serverStatusAccessIp )

#
# Figure out if we're doing any "ensure" stuff with the service
#
if ( $reloadOnChange ) {
$serviceNotify = Service[ $params::serviceName ]
}
else {
$serviceNotify = []
}


#
# Package and Service
#
package { $params::packageName :
ensure => latest,
}

service { $params::serviceName :
ensure => running,
enable => true,
require => Package[ $params::packageName ],
provider => systemd,
}


#
# Add whatever extra packages were asked for
#
if ( is_array( $extraPackages ) ) {
ensure_resource( 'package', $extraPackages, { ensure => latest } )
}


#
# Make the log dir readable
#
file { '/var/log/apache2' :
ensure => directory,
mode => 'a+rx',
require => Package[ $params::packageName ],
}


#
# Give the ability to add special access to locations
#
include apache2::access


#
# Set serverSignature and serverTokens
#
class { 'apache2::sysconfig' :
serverSignature => $serverSignature,
serverTokens => $serverTokens,
}


#
# Default Modules
# See params::a2modDefaults for default module list
# Other modules are turned on in their configuration definitions
#
if ( is_array( $loadModules ) ) { $a2modLoad = $loadModules }
else { $a2modLoad = [] }

if ( is_array( $unloadModules ) ) { $a2modUnload = $unloadModules }
else { $a2modUnload = [] }

if ( is_bool( $useDefaultModules ) and $useDefaultModules ) { $a2modDefaultLoad = $params::a2modDefaults }
else { $a2modDefaultLoad = [] }

class { 'apache2::modules':
modules => difference( union( $a2modLoad, $a2modDefaultLoad ), $a2modUnload )
}


#
# Turn TraceEnable off
#
apache2::traceenable { 'class_default' :
enable => $traceEnable,
require => Package[ $params::packageName ],
}


#
# Turn on remoteIpHeader logging
#
apache2::remoteip { 'class_default' :
remoteIpHeader => $remoteIpHeader,
}


#
# Defaults for server-info and server-status
#
class { 'apache2::statusAndInfo' :
serverInfoAccessIp => $serverInfoAccessIp,
serverStatusAccessIp => $serverStatusAccessIp,
}
#
# Get our configs
#
include apache2::params


validate_array( $loadModules )
validate_array( $unloadModules )
validate_array( $extraPackages )
validate_bool( $useDefaultModules )
validate_string( $remoteIpHeader )
validate_string( $serverSignature )
validate_string( $serverTokens )
validate_bool( $traceEnable )
validate_bool( $reloadOnChange )
validate_string( $serverInfoAccessIp )
validate_string( $serverStatusAccessIp )

#
# Figure out if we're doing any "ensure" stuff with the service
#
if ( $reloadOnChange ) {
$serviceNotify = Service[ $apache2::params::serviceName ]
}
else {
$serviceNotify = []
}


#
# Package and Service
#
package { $apache2::params::packageName :
ensure => latest,
}

service { $apache2::params::serviceName :
ensure => running,
enable => true,
require => Package[ $apache2::params::packageName ],
provider => systemd,
}


#
# Add whatever extra packages were asked for
#
if ( is_array( $extraPackages ) ) {
ensure_resource( 'package', $extraPackages, { ensure => latest } )
}


#
# Make the log dir readable
#
file { '/var/log/apache2' :
ensure => directory,
mode => 'a+rx',
require => Package[ $apache2::params::packageName ],
}


#
# Give the ability to add special access to locations
#
include apache2::access


#
# Set serverSignature and serverTokens
#
class { 'apache2::sysconfig' :
serverSignature => $serverSignature,
serverTokens => $serverTokens,
}


#
# Default Modules
# See apache2::params::a2modDefaults for default module list
# Other modules are turned on in their configuration definitions
#
if ( is_array( $loadModules ) ) { $a2modLoad = $loadModules }
else { $a2modLoad = [] }

if ( is_array( $unloadModules ) ) { $a2modUnload = $unloadModules }
else { $a2modUnload = [] }

if ( is_bool( $useDefaultModules ) and $useDefaultModules ) { $a2modDefaultLoad = $apache2::params::a2modDefaults }
else { $a2modDefaultLoad = [] }

class { 'apache2::modules':
modules => difference( union( $a2modLoad, $a2modDefaultLoad ), $a2modUnload )
}


#
# Turn TraceEnable off
#
apache2::traceenable { 'class_default' :
enable => $traceEnable,
require => Package[ $apache2::params::packageName ],
}


#
# Turn on remoteIpHeader logging
#
apache2::remoteip { 'class_default' :
remoteIpHeader => $remoteIpHeader,
}


#
# Defaults for server-info and server-status
#
class { 'apache2::statusAndInfo' :
serverInfoAccessIp => $serverInfoAccessIp,
serverStatusAccessIp => $serverStatusAccessIp,
}

}
Loading

0 comments on commit 1e3b3b2

Please sign in to comment.