Faidon has submitted this change and it was merged.

Change subject: Move geoip to a module.
......................................................................


Move geoip to a module.

Functionally, this works the same as before.
WMF specific puppet configs (volatile, etc.) have
been removed.  These are now passed in from classes in
puppetmaster.pp and from misc/geoip.pp

python-geoip is no longer included by these classes,
you must do so yourself.

In misc::geoip, if $::realm is production,
.dat files will be synced from the puppetmaster,
Else .dat files will be installed using the geoip-database
package.

* pass puppet-lint on all manifests:
 - get rid of tabs
 - enclose variables with ${} when in a string
 - replace double quotes with single quotes
 - remove double quotes when not needed
* Split very long lines, specially in parameterized classes having lot
  of parameters. One parameter per line seems easier to read.

Change-Id: I0259a6e8b68b8b35bcc1e12c5426f558c5af2097
---
D files/misc/GeoIP.dat
D files/misc/GeoIPcity.dat
D manifests/geoip.pp
A manifests/misc/geoip.pp
M manifests/misc/statistics.pp
M manifests/puppetmaster.pp
M manifests/role/analytics.pp
M manifests/role/applicationserver.pp
M manifests/role/cache.pp
M manifests/role/logging.pp
M manifests/role/statistics.pp
M manifests/site.pp
A modules/geoip/manifests/data.pp
A modules/geoip/manifests/data/maxmind.pp
A modules/geoip/manifests/data/package.pp
A modules/geoip/manifests/data/puppet.pp
A modules/geoip/manifests/init.pp
A modules/geoip/templates/GeoIP.conf.erb
A modules/geoip/templates/geoipupdate.logrotate.erb
19 files changed, 309 insertions(+), 227 deletions(-)

Approvals:
  Faidon: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/files/misc/GeoIP.dat b/files/misc/GeoIP.dat
deleted file mode 100644
index 2731d83..0000000
--- a/files/misc/GeoIP.dat
+++ /dev/null
Binary files differ
diff --git a/files/misc/GeoIPcity.dat b/files/misc/GeoIPcity.dat
deleted file mode 100644
index 2e09195..0000000
--- a/files/misc/GeoIPcity.dat
+++ /dev/null
Binary files differ
diff --git a/manifests/geoip.pp b/manifests/geoip.pp
deleted file mode 100644
index fa49e56..0000000
--- a/manifests/geoip.pp
+++ /dev/null
@@ -1,206 +0,0 @@
-# geoip.pp
-#
-# Classes to manage installation and update of
-# Maxmind GeoIP libraries and data files.
-#
-# To install geoip packages and ensure that you have up to date .dat files, 
just do
-#   include geoip
-#
-# If you want to manage the installation of the .dat files yourself,
-# use the geoip::data class.  The default provider is 'puppet', which means
-# the .dat files will be synced from the puppetmaster.  A provider of 'maxmind'
-# will download the files directly from maxmind.
-#
-# NOTE:  The $data_directory parameter (and a few others as well) are
-# used multiple times in a few classes.  I have defined them each time
-# with a default value so that you CAN use the lower level classes if you
-# so choose without having to worry about specifying defaults.  This is
-# less DRY than leaving off the default values in the low level classes,
-# but meh?  If someone doesn't like this we can remove the default values
-# from the low level classes.
-
-
-# == Class geoip
-# Installs Maxmind IP address Geocoding
-# packages and database files (via puppet).
-#
-# This is the only class you need to include if
-# you want to be able to use Maxmind GeoIP libs and data.
-#
-# == Parameters
-# $data_directory - Where the GeoIP data files should live.  default: 
/usr/share/GeoIP
-#
-class geoip($data_directory = "/usr/share/GeoIP") {
-       class { "geoip::packages":                                        }
-       class { "geoip::data":          data_directory => $data_directory }
-       class { "geoip::data::symlink": data_directory => $data_directory }
-}
-
-
-# == Class geoip::packages
-# Installs GeoIP packages.
-#
-class geoip::packages {
-       package { [ "libgeoip1", "libgeoip-dev", "geoip-bin" ]:
-               ensure => present;
-       }
-}
-
-# == Class geoip::packages::python
-# Installs pygeoip package.
-#
-class geoip::packages::python {
-       include geoip::packages
-
-       package { "python-geoip":
-               ensure  => present,
-               require => Class["geoip::packages"],
-       }
-}
-
-# == Class geoip::data::symlink
-# sets up symlink from /usr/local/share/GeoIP
-# to /usr/share/GeoIP.  Some scripts expect GeoIP
-# databases to be in this location.
-#
-# == Parameters
-# $data_directory - Where the data files should live.  default: 
/usr/share/GeoIP
-#
-class geoip::data::symlink($data_directory = "/usr/share/GeoIP") {
-       file { "/usr/local/share/GeoIP":
-               ensure  => "$data_directory",
-               require => File["$data_directory"],
-       }
-}
-
-
-
-# == Class geoip::data
-# Conditionally includes either
-# geoip::data::sync or geoip::data::download.
-#
-# The sync class assumes that the data files are
-# available via puppet in puppet:///volatile/GeoIP/
-#
-# The download class runs geoipupdate to download the
-# files from maxmind directly.
-#
-# Currently, source => 'maxmind' is only used by puppetmaster
-# to download the files.  All other nodes get these files
-# via the default source => 'puppet'.  You shouldn't have
-# to worry about this as a user of GeoIP data anyway.  You
-# Should just be includeing geoip to get the data files
-# and geoip packages.
-#
-# == Parameters
-# $provider       - either 'puppet' or 'maxmind'.      default: puppet.
-# $data_directory - Where the data files should live.  default: 
/usr/share/GeoIP
-# $config_file    - the config file for the geoipupdate command.  This will be 
put in place from puppet:///private/geoip/GeoIP.conf.  This will not be used if 
the provider is 'puppet'.  default: /etc/GeoIP.conf
-# $source         - puppet file source for data_directory.  This is not used 
if provider is 'maxmind'. default: puppet:///volatile/GeoIP
-# $environment    - the environment paramter to pass to exec and cron for the 
geoipupdate download command.  This will not be used if the provider is 
'puppet'.  default: ''
-#
-class geoip::data(
-       $provider       = "puppet",
-       $data_directory = "/usr/share/GeoIP",
-       $config_file    = "/etc/GeoIP.conf",
-       $source         = "puppet:///volatile/GeoIP",
-       $environment    = "") {
-
-       # if installing data files from puppet, use
-       # geoip::data::sync class
-       if $provider == "puppet" {
-               class { "geoip::data::sync":
-                       data_directory => $data_directory,
-                       source         => $source,
-               }
-       }
-
-       # else install the files from the maxmind download
-       # by including geoip::data::download
-       else {
-               class { "geoip::data::download":
-                       data_directory => $data_directory,
-                       config_file    => $config_file,
-                       environment    => $environment,
-               }
-       }
-
-}
-
-
-
-# == Class geoip::data::sync
-# Installs GeoIP database files from puppetmaster.
-#
-# == Parameters
-# $data_directory - Where the data files should live.  default: 
/usr/share/GeoIP
-# $source         - A valid puppet source directory.   default: 
puppet:///volatile/GeoIP
-#
-class geoip::data::sync($data_directory = "/usr/share/GeoIP", $source = 
"puppet:///volatile/GeoIP") {
-       # recursively copy the $data_directory from $source.
-       file { "$data_directory":
-               source  => "$source",
-               recurse => true,
-               backup => false
-       }
-}
-
-
-# == Class geoip::data::download
-# Installs Maxmind GeoIP database files by downloading
-# them from Maxmind with the geoipupdate command.
-# This also installs a cron job to do this weekly.
-#
-# == Parameters
-# $data_directory - Where the data files should live.  default: 
/usr/share/GeoIP
-# $config_file    - the config file for the geoipupdate command.  This will be 
put in place from puppet:///private/geoip/GeoIP.conf.  default: /etc/GeoIP.conf
-# $environment    - the environment paramter to pass to exec and cron for the 
geoipupdate download command.  default: ''
-#
-class geoip::data::download($data_directory = "/usr/share/GeoIP", $config_file 
= "/etc/GeoIP.conf", $environment = "") {
-       # Need this to get /usr/bin/geoipupdate installed.
-       include geoip::packages
-
-       # Install GeoIP.conf with Maxmind license keys.
-       file { "$config_file":
-               source => "puppet:///private/geoip/GeoIP.conf"
-       }
-
-       # Make sure the volatile GeoIP directory exists.
-       # Data files will be downloaded by geoipupdate into
-       # this directory.
-       file { "$data_directory":
-               ensure => "directory",
-       }
-
-       # command to run to update the GeoIP database files
-       $geoipupdate_command = "/usr/bin/geoipupdate -f $config_file -d 
$data_directory"
-
-       # Go ahead and exec geoipupdate now, so that
-       # we can be sure we have these files if
-       # this is the first time puppetmaster is
-       # running this class.
-       exec { "geoipupdate":
-               command     => "$geoipupdate_command",
-               environment => $environment,
-               refreshonly => true,
-               subscribe   => File["$config_file"],
-               require     => [Package["geoip-bin"], File["$data_directory"]],
-       }
-
-       # Set up a cron to run geoipupdate weekly.
-       # This will download GeoIP.dat and GeoIPCity.dat
-       # into /usr/share/GeoIP.  If there are other
-       # Maxmind .dat files you want, then
-       # modify GeoIP.conf and add the Maxmind
-       # product IDs for those files.
-       cron { "geoipupdate":
-               command     => "/bin/echo -en \"\$(/bin/date):\t\" >> 
/var/log/geoipupdate.log && $geoipupdate_command &>> /var/log/geoipupdate.log",
-               environment => $environment,
-               user        => root,
-               weekday     => 0,
-               hour        => 3,
-               minute      => 30,
-               ensure      => present,
-               require     => [File["$config_file"], Package["geoip-bin"], 
File["$data_directory"]],
-       }
-}
diff --git a/manifests/misc/geoip.pp b/manifests/misc/geoip.pp
new file mode 100644
index 0000000..cf231f7
--- /dev/null
+++ b/manifests/misc/geoip.pp
@@ -0,0 +1,26 @@
+# == Class misc::geoip
+# Installs MaxMind geoip packages and data files.
+# This uses the geoip module to sync .dat files
+# from puppetmaster from puppet:///volatile/GeoIP.
+#
+# TODO:  How should we move this out of misc/ into another
+# location.  This isn't a role, but I don't want to reference $::realm
+# in the geoip module itself.  What to do?  hmmm hooo...
+#
+class misc::geoip {
+  # If running in production,
+  # then sync GeoIP .dat files from puppetmaster.
+  if ($::realm == 'production') {
+    class { '::geoip':
+      data_provider => 'puppet',
+      puppet_source => 'puppet:///volatile/GeoIP',
+    }
+  }
+
+  # Else just use the geoip-database package
+  else {
+    class { '::geoip':
+      data_provider => 'package',
+    }
+  }
+}
diff --git a/manifests/misc/statistics.pp b/manifests/misc/statistics.pp
index abef878..5f7629c 100644
--- a/manifests/misc/statistics.pp
+++ b/manifests/misc/statistics.pp
@@ -93,6 +93,7 @@
 # on statistics servers.
 class misc::statistics::packages::python {
        package { [
+               "python-geoip",
                "libapache2-mod-python",
                "python-django",
                "python-mysqldb",
diff --git a/manifests/puppetmaster.pp b/manifests/puppetmaster.pp
index c3a1831..ec20732 100644
--- a/manifests/puppetmaster.pp
+++ b/manifests/puppetmaster.pp
@@ -280,20 +280,12 @@
                # data_directory.  By downloading these files into the
                # volatiledir they will be available for other nodes to get via
                # puppet by including geoip::data with provider => 'puppet'.
-               class { "geoip::data":
-                       provider       => 'maxmind',
-                       data_directory => "$puppetmaster::volatiledir/GeoIP",
-                       environment    => 
"http_proxy=http://brewster.wikimedia.org:8080";,  # use brewster as http proxy, 
since puppetmaster probably does not have internet access
-               }
-
-               cron {
-                       updategeoipdb:
-                               environment => 
"http_proxy=http://brewster.wikimedia.org:8080";,
-                               command => "wget -qO - 
http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz 
| gunzip > $puppetmaster::volatiledir/misc/GeoIP.dat.new && mv 
$puppetmaster::volatiledir/misc/GeoIP.dat.new 
$puppetmaster::volatiledir/misc/GeoIP.dat; wget -qO - 
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | gunzip 
> $puppetmaster::volatiledir/misc/GeoIPcity.dat.new && mv 
$puppetmaster::volatiledir/misc/GeoIPcity.dat.new 
$puppetmaster::volatiledir/misc/GeoIPcity.dat",
-                               user => root,
-                               hour => 3,
-                               minute => 26,
-                               ensure => absent;  # this has been replaced by 
class geoip::data, included below
+               class { 'geoip::data::maxmind':
+                       data_directory => "${puppetmaster::volatiledir}/GeoIP",
+                       environment    => 
'http_proxy=http://brewster.wikimedia.org:8080',  # use brewster as http proxy, 
since puppetmaster probably does not have internet access
+                       license_key    => $passwords::geoip::license_key,
+                       user_id        => $passwords::geoip::user_id,
+                       product_ids    => [106, 133, 115],
                }
        }
 
diff --git a/manifests/role/analytics.pp b/manifests/role/analytics.pp
index ce328f8..07e3e60 100644
--- a/manifests/role/analytics.pp
+++ b/manifests/role/analytics.pp
@@ -75,7 +75,7 @@
     # include java on all analytics servers
     include role::analytics::java
     # We want to be able to geolocate IP addresses
-    include geoip
+    include misc::geoip
     # udp-filter is a useful thing!
     include misc::udp2log::udp_filter
 
diff --git a/manifests/role/applicationserver.pp 
b/manifests/role/applicationserver.pp
index 27a572a..888e11e 100644
--- a/manifests/role/applicationserver.pp
+++ b/manifests/role/applicationserver.pp
@@ -54,7 +54,7 @@
                if $::realm == 'production' {
                        include admins::roots,
                                admins::mortals,
-                               geoip,
+                               misc::geoip,
                                mediawiki
 
                        nrpe::monitor_service { "twemproxy":
diff --git a/manifests/role/cache.pp b/manifests/role/cache.pp
index 5d9fca6..1a44d9e 100644
--- a/manifests/role/cache.pp
+++ b/manifests/role/cache.pp
@@ -817,7 +817,7 @@
 
                system_role { "role::cache::bits": description => "bits Varnish 
cache server" }
 
-               require geoip
+               require misc::geoip
 
                include standard,
                        nrpe
diff --git a/manifests/role/logging.pp b/manifests/role/logging.pp
index 72bdd43..a652c67 100644
--- a/manifests/role/logging.pp
+++ b/manifests/role/logging.pp
@@ -34,7 +34,7 @@
                groups::wikidev,
                admins::restricted,
                nrpe,
-               geoip
+               misc::geoip
 }
 
 # mediawiki udp2log instance.  Does not use monitoring.
diff --git a/manifests/role/statistics.pp b/manifests/role/statistics.pp
index 4c5a514..f2a72ef 100644
--- a/manifests/role/statistics.pp
+++ b/manifests/role/statistics.pp
@@ -13,8 +13,7 @@
        system_role { "role::statistics": description => "statistics number 
crunching server" }
 
        # include classes needed for crunching data on stat1.
-       include geoip,
-               geoip::packages::python,
+       include misc::geoip,
                misc::statistics::dataset_mount,
                misc::statistics::mediawiki,
                misc::statistics::plotting,
diff --git a/manifests/site.pp b/manifests/site.pp
index 25a3aed..26d350b 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -11,7 +11,6 @@
 import "drac.pp"
 import "facilities.pp"
 import "ganglia.pp"
-import "geoip.pp"
 import "gerrit.pp"
 import "imagescaler.pp"
 import "iptables.pp"
diff --git a/modules/geoip/manifests/data.pp b/modules/geoip/manifests/data.pp
new file mode 100644
index 0000000..fe192f0
--- /dev/null
+++ b/modules/geoip/manifests/data.pp
@@ -0,0 +1,21 @@
+# == Class geoip::data
+# Base class for geoip data sources.
+# Do not include this class directly.
+# Instead, use geoip::data::maxmind or geoip::data::puppet.
+#
+class geoip::data($data_directory = '/usr/share/GeoIP')
+{
+  # Make sure the volatile GeoIP directory exists.
+  file { $data_directory:
+    ensure => 'directory',
+  }
+
+  # symlink /usr/local/share/GeoIP
+  # to /usr/share/GeoIP.  Some scripts expect GeoIP
+  # databases to be in this location.
+  file { '/usr/local/share/GeoIP':
+    ensure  => link,
+    target  => $data_directory,
+    require => File[$data_directory],
+  }
+}
diff --git a/modules/geoip/manifests/data/maxmind.pp 
b/modules/geoip/manifests/data/maxmind.pp
new file mode 100644
index 0000000..2123846
--- /dev/null
+++ b/modules/geoip/manifests/data/maxmind.pp
@@ -0,0 +1,95 @@
+# == Class geoip::data::maxmind
+# Installs Maxmind GeoIP database files by downloading
+# them from Maxmind with the geoipupdate command.
+# This also installs a cron job to do this weekly.
+#
+# == Parameters
+# $data_directory - Where the data files should live.  default: 
$geoip::data::data_directory
+# $environment    - The environment parameter to pass to exec and cron for the
+#                   geoipupdate download command. default: undef
+# $license_key    - MaxMind license key.  Required.
+# $user_id        - MaxMind user id.      Required.
+# $product_ids    - Array of MaxMind product ids to specify which data files
+#                   to download.  default: [106] (Country)
+# == Example
+# You can use this class on your puppetmaster to stick the GeoIP .dat files
+# into a fileserver module.  Once the files are there, you can use the
+# default geoip::data::puppet class to sync the files from your puppetmaster,
+# instead of downloading them from maxmind on all your nodes.
+# node puppetmaster {
+#   class { 'geoip::data::maxmind':
+#      $data_directory => '/etc/puppet/files/GeoIP',
+#      ...
+#   }
+# }
+# ...
+# # Include the geoip module (which uses puppet sync for .dat files by 
default):
+# node client_node1 {
+#   include geoip
+# }
+#
+# # Or if you only want the .dat files:
+# node client_node2 {
+#   include geoip::data::puppet
+# }
+#
+class geoip::data::maxmind(
+  $data_directory = $geoip::data::data_directory,
+  $environment    = undef,
+  $license_key    = false,
+  $user_id        = false,
+  $product_ids    = [106]) inherits geoip::data
+{
+  $config_file = '/etc/GeoIP.conf'
+
+  validate_string($license_key)
+  validate_string($user_id)
+  validate_array($product_ids)
+
+  # Install GeoIP.conf with Maxmind user_id, licence_key, and product_ids.
+  file { $config_file:
+    content => template('geoip/GeoIP.conf.erb'),
+  }
+
+  # command to run to update the GeoIP database files
+  $geoipupdate_command = "/usr/bin/geoipupdate -f ${config_file} -d 
${data_directory}"
+
+  # Go ahead and exec geoipupdate now, so that
+  # we can be sure we have these files if
+  # this is the first time puppetmaster is
+  # running this class.
+  exec { 'geoipupdate':
+    command     => $geoipupdate_command,
+    refreshonly => true,
+    subscribe   => File[$config_file],
+    # geoipupdate comes from package geoip-bin
+    require     => [Package['geoip-bin'], File[$config_file], 
File[$data_directory]],
+  }
+
+  $geoipupdate_log = '/var/log/geoipupdate.log'
+  # Set up a cron to run geoipupdate weekly.
+  # This will download .dat files for the specified
+  # Maxmind Product IDs.
+  cron { 'geoipupdate':
+    ensure      => present,
+    command     => "/bin/echo -e \"\$(/bin/date): geoipupdate downloading 
MaxMind .dat files into ${data_directory}\" >> ${geoipupdate_log} && 
${geoipupdate_command} &>> /var/log/geoipupdate.log",
+    user        => root,
+    weekday     => 0,
+    hour        => 3,
+    minute      => 30,
+    require     => [Package['geoip-bin'], File[$config_file], 
File[$data_directory]],
+  }
+
+  # logrotate for geoipupdate.log
+  file { '/etc/logrotate.d/geoipupdate':
+    content => template('geoip/geoipupdate.logrotate.erb'),
+    require => Cron['geoipupdate'],
+  }
+
+  # if $environment was passed in,
+  # set it on the geoipupdate commands
+  if ($environment != undef) {
+    Exec['geoipupdate'] { environment => $environment }
+    Cron['geoipupdate'] { environment => $environment }
+  }
+}
diff --git a/modules/geoip/manifests/data/package.pp 
b/modules/geoip/manifests/data/package.pp
new file mode 100644
index 0000000..29f2ff4
--- /dev/null
+++ b/modules/geoip/manifests/data/package.pp
@@ -0,0 +1,9 @@
+# == Class geoip::data::package
+#
+# Installs GeoIP .dat files from the Ubuntu package,
+# rather than from puppet or maxmind.
+class geoip::data::package inherits geoip::data {
+  package { 'geoip-database':
+    ensure => installed,
+  }
+}
\ No newline at end of file
diff --git a/modules/geoip/manifests/data/puppet.pp 
b/modules/geoip/manifests/data/puppet.pp
new file mode 100644
index 0000000..5c467a7
--- /dev/null
+++ b/modules/geoip/manifests/data/puppet.pp
@@ -0,0 +1,19 @@
+# == Class geoip::data::puppet
+# Installs GeoIP database files from puppetmaster.
+#
+# == Parameters
+# $source         - A valid puppet source directory.
+# $data_directory - Where the data files should live. Default: 
$geoip::data::data_directory
+#
+class geoip::data::puppet(
+  $source,
+  $data_directory = $geoip::data::data_directory,
+) inherits geoip::data
+{
+  # Recursively copy the $data_directory from $source.
+  # (The file resource for $data_directory is defined in geoip::data.)
+  File[$data_directory] {
+    source  => $source,
+    recurse => true,
+  }
+}
diff --git a/modules/geoip/manifests/init.pp b/modules/geoip/manifests/init.pp
new file mode 100644
index 0000000..a218d65
--- /dev/null
+++ b/modules/geoip/manifests/init.pp
@@ -0,0 +1,95 @@
+# geoip.pp
+#
+# Classes to manage installation and update of
+# Maxmind GeoIP libraries and data files.
+#
+# To install geoip packages and ensure that you have up to date .dat files,
+# just do:
+#
+#   include geoip
+#
+# If you want to manage the installation of the .dat files yourself,
+# use the geoip::data::puppet or geoip::data::maxmind class.  The default
+# data_provider is 'package', which means the .dat files will installed from
+# the Ubuntu geoip-database package.
+#
+# If you want to sync files from your puppetmaster, then use a provider of
+# 'puppet'. If you do so, ou should use a provider of 'maxmind' on your 
puppetmaster
+# to ensure that the .dat files are updated weekly and in a place
+# that your puppet clients can sync from.  See manifests/data/maxmind.pp
+# class documentation for an example.
+
+# == Class geoip
+# Installs Maxmind IP address Geocoding
+# packages and database files (via puppet).
+#
+# This is the only class you need to include if
+# you want to be able to use Maxmind GeoIP libs and data.
+#
+# == Parameters
+# $data_directory - Where the GeoIP data files should live.  default: 
/usr/share/GeoIP
+# $data_provider  - How the Maxmind data files should be obtained.
+#                   'puppet' will sync them from the puppetmaster, and 
requires that the
+#                   $puppet_source parameter is passed with a valid puppet 
source path.
+#                   'maxmind' will download the files using geoipupdate 
directly from MaxMind.
+#                   You must pass your MaxMind $license_key and $user_id, as 
well as the MaxMind
+#                   $product_ids for the data files that you want to download.
+#                   'package' will just install the 'geoip-database' package.
+#                   If provider is 'none' or anything else, MaxMind data files 
will not be installed.
+#                   Default: 'package'.
+#
+# $puppet_source  - Puppet source path for GeoIP files.  Only used if 
$data_provider is 'puppet'.
+#
+## The following parameters are only used if $data_provider is 'maxmind'.
+# $environment    - Shell environment to pass to exec and cron for geoipupdate 
command.
+# $license_key    - MaxMind license key.
+# $user_id        - MaxMind user id.
+# $product_ids    - Array of MaxMind product ids to specify which data files 
to download.  Default: [106] (Country)
+#
+class geoip(
+  $data_directory = '/usr/share/GeoIP',
+  $data_provider  = 'package',
+
+  $puppet_source  = undef,
+
+  $environment    = undef,
+  $license_key    = false,
+  $user_id        = false,
+  $product_ids    = [106])
+{
+  package { ['libgeoip1', 'libgeoip-dev', 'geoip-bin']:
+    ensure => present;
+  }
+
+  # if installing via geoip-database
+  if $data_provider == 'package' {
+    class { 'geoip::data::package': }
+  }
+
+  # if installing data files from puppet, use
+  # geoip::data::puppet class
+  elsif $data_provider == 'puppet' {
+      if ($puppet_source == undef) {
+          fail('Must provide puppet_source to GeoIP.dat files when using 
\'puppet\' geoip data_provider.')
+      }
+      
+    # recursively copy the $data_directory from $source.
+    class { 'geoip::data::puppet':
+      data_directory  => $data_directory,
+      source          => $puppet_source
+    }
+  }
+
+  # else install the files by maxmind download
+  # by including geoip::data::maxmind
+  elsif $data_provider == 'maxmind' {
+    class { 'geoip::data::maxmind':
+      data_directory => $data_directory,
+      environment    => $environment,
+      license_key    => $license_key,
+      user_id        => $user_id,
+      product_ids    => $product_ids,
+    }
+  }
+  # else don't install .dat files at all.
+}
diff --git a/modules/geoip/templates/GeoIP.conf.erb 
b/modules/geoip/templates/GeoIP.conf.erb
new file mode 100644
index 0000000..a18ec38
--- /dev/null
+++ b/modules/geoip/templates/GeoIP.conf.erb
@@ -0,0 +1,21 @@
+# GeoIP.conf file - used by geoipupdate program
+# to update databases from http://www.maxmind.com
+# UserId, LicenseKey, ProductIds from [email protected] account
+#
+# Running geoipupdate will update the .dat files in
+# /usr/share/GeoIP/ for the given product IDs below.
+
+# see https://www.maxmind.com/app/license_key_login to obtain License Key,
+# UserId, and available ProductIds
+# Enter your license key here
+LicenseKey <%= license_key %>
+
+# Enter your User ID here
+UserId <%= user_id %>
+
+# Enter the (space separated) Product ID(s) of the
+# database(s) you would like to update.  e.g.:
+# 106 - GeoIP.dat        Country database
+# 133 - GeoIPCity.dat    City database
+# 115 - GeoIPRegion.dat  Region database
+ProductIds <%= product_ids.join(' ') %>
diff --git a/modules/geoip/templates/geoipupdate.logrotate.erb 
b/modules/geoip/templates/geoipupdate.logrotate.erb
new file mode 100644
index 0000000..6846ad0
--- /dev/null
+++ b/modules/geoip/templates/geoipupdate.logrotate.erb
@@ -0,0 +1,11 @@
+# Note:  This file is managed by Puppet.
+
+# Rotate geoipupdate.log generated by
+# the geoipupdate cron job.
+
+<%= geoipupdate_log %>  {
+  size 1M
+  rotate 1
+  missingok
+  notifempty
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/53714
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0259a6e8b68b8b35bcc1e12c5426f558c5af2097
Gerrit-PatchSet: 7
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Hashar <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Faidon <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
Gerrit-Reviewer: Ryan Lane <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to