Skip to content

Commit

Permalink
Merge pull request #1083 from roman-mueller/MODULES-1789
Browse files Browse the repository at this point in the history
MODULES-1789 add initial mod_geoip support
  • Loading branch information
igalic committed Mar 24, 2015
2 parents 7dde9fc + fefaa40 commit 0cba390
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 => false,
$db_file => '/usr/share/GeoIP/GeoIP.dat',
$flag => 'Standard',
$output => 'All',
}
```

The parameter `db_file` 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 => true,
},
],
}
```

######`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 = false,
$db_file = '/usr/share/GeoIP/GeoIP.dat',
$flag = 'Standard',
$output = 'All',
$enable_utf8 = undef,
$scan_proxy_headers = undef,
$use_last_xforwarededfor_ip = undef,
) {
::apache::mod { 'geoip': }

# Template uses:
# - enable
# - db_file
# - flag
# - output
# - enable_utf8
# - scan_proxy_headers
# - use_last_xforwarededfor_ip
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 <%= scope.function_bool2httpd([@enable]) %>

<%- if @db_file and ! [ false, 'false', '' ].include?(@db_file) -%>
<%- if @db_file.kind_of?(Array) -%>
<%- Array(@db_file).each do |file| -%>
GeoIPDBFile <%= file %> <%= @flag %>
<%- end -%>
<%- else -%>
GeoIPDBFile <%= @db_file %> <%= @flag %>
<%- end -%>
<%- end -%>
GeoIPOutput <%= @output %>
<% if ! @enable_utf8.nil? -%>
GeoIPEnableUTF8 <%= scope.function_bool2httpd([@enable_utf8]) %>
<% end -%>
<% if ! @scan_proxy_headers.nil? -%>
GeoIPScanProxyHeaders <%= scope.function_bool2httpd([@scan_proxy_headers]) %>
<% end -%>
<% if ! @use_last_xforwarededfor_ip.nil? -%>
GeoIPUseLastXForwardedForIP <%= scope.function_bool2httpd([@use_last_xforwarededfor_ip]) %>
<% 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'].nil? -%>
GeoIPEnable <%= scope.function_bool2httpd([directory['geoip_enable']]) %>
<%- end -%>
<%- if directory['options'] -%>
Options <%= Array(directory['options']).join(' ') %>
<%- end -%>
Expand Down

0 comments on commit 0cba390

Please sign in to comment.