Skip to content

Commit

Permalink
MODULES-1789 add initial mod_geoip support
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-mueller committed Mar 22, 2015
1 parent 7dde9fc commit 43c5c5e
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* [Classes: apache::mod::*](#classes-apachemodname)
* [Class: apache::mod::alias](#class-apachemodalias)
* [Class: apache::mod::event](#class-apachemodevent)
* [Class: apache::mod::geoip](#class-apachemodgeoip)
* [Class: apache::mod::info](#class-apachemodinfo)
* [Class: apache::mod::pagespeed](#class-apachemodpagespeed)
* [Class: apache::mod::php](#class-apachemodphp)
Expand Down Expand Up @@ -624,6 +625,25 @@ Installs and manages mod_auth_cas. The parameters `cas_login_url` and `cas_valid

Full documentation on mod_auth_cas is available from [JASIG](https://github.com/Jasig/mod_auth_cas).

####Class: `apache::mod::geoip`

Installs and manages mod_geoip.

Full documentation on mod_geoip is available from [MaxMind](http://dev.maxmind.com/geoip/legacy/mod_geoip2/).

These are the default settings:

```puppet
class {'apache::mod::geoip':
$enable => 'Off',
$dbfile => '/usr/share/GeoIP/GeoIP.dat',
$flag => 'Standard',
$output => 'All',
}
```

The parameter `dbfile` can be a single directory or a hash of directories.

####Class: `apache::mod::info`

Installs and manages mod_info which provides a comprehensive overview of the server configuration.
Expand Down Expand Up @@ -1829,6 +1849,22 @@ An array of hashes used to override the [ErrorDocument](https://httpd.apache.org
}
```

######`geoip_enable`

Sets the [GeoIPEnable](http://dev.maxmind.com/geoip/legacy/mod_geoip2/#Configuration) directive.
Note that you must declare `class {'apache::mod::geoip': }` before using this directive.

```puppet
apache::vhost { 'first.example.com':
docroot => '/var/www/first',
directories => [
{ path => '/var/www/first',
geoip_enable => 'On',
},
],
}
```

######`headers`

Adds lines for [Header](http://httpd.apache.org/docs/current/mod/mod_headers.html#header) directives.
Expand Down
29 changes: 29 additions & 0 deletions manifests/mod/geoip.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class apache::mod::geoip (
$enable = 'Off',
$dbfile = '/usr/share/GeoIP/GeoIP.dat',
$flag = 'Standard',
$output = 'All',
$enableutf8 = undef,
$scanproxyheaders = undef,
$uselastxforwarededforip = undef,
) {
::apache::mod { 'geoip': }

# Template uses:
# - enable
# - dbfile
# - flag
# - output
# - enableutf8
# - scanproxyheaders
# - uselastxforwarededforip
file { 'geoip.conf':
ensure => file,
path => "${::apache::mod_dir}/geoip.conf",
content => template('apache/mod/geoip.conf.erb'),
require => Exec["mkdir ${::apache::mod_dir}"],
before => File[$::apache::mod_dir],
notify => Class['apache::service'],
}

}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
},
'fastcgi' => 'mod_fastcgi',
'fcgid' => 'mod_fcgid',
'geoip' => 'mod_geoip',
'ldap' => $::apache::version::distrelease ? {
'7' => 'mod_ldap',
default => undef,
Expand Down
22 changes: 22 additions & 0 deletions templates/mod/geoip.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
GeoIPEnable <%= @enable %>

<%- if @dbfile and ! [ false, 'false', '' ].include?(@dbfile) -%>
<%- if @dbfile.kind_of?(Array) -%>
<%- Array(@dbfile).each do |file| -%>
GeoIPDBFile <%= file %> <%= @flag %>
<%- end -%>
<%- else -%>
GeoIPDBFile <%= @dbfile %> <%= @flag %>
<%- end -%>
<%- end -%>
GeoIPOutput <%= @output %>
<% if @enableutf8 -%>
GeoIPEnableUTF8 <%= @enableutf8 %>
<% end -%>
<% if @scanproxyheaders -%>
GeoIPScanProxyHeaders <%= @scanproxyheaders %>
<% end -%>
<% if @uselastxforwarededforip -%>
GeoIPUseLastXForwardedForIP <%= @uselastxforwarededforip %>
<% end -%>

3 changes: 3 additions & 0 deletions templates/vhost/_directories.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
Header <%= header %>
<%- end -%>
<%- end -%>
<%- if directory['geoip_enable'] and directory['geoip_enable'] != '' -%>
GeoIPEnable <%= directory['geoip_enable'] %>
<%- end -%>
<%- if directory['options'] -%>
Options <%= Array(directory['options']).join(' ') %>
<%- end -%>
Expand Down

0 comments on commit 43c5c5e

Please sign in to comment.