Faidon Liambotis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/93709


Change subject: geoip: simplify the module
......................................................................

geoip: simplify the module

Instead of having the main geoip class have the superset of all the
configuration options of all the classes, provide a sensible data
provide default (puppet) and let users mix and match with geoip::bin and
geoip::data::* classes, while still providing a single class that one
can "include geoip" and expect GeoIP databases to appear.

Change-Id: Ia98d7318ef6e02f480a5cb7bbd1df7b61bdce2dd
---
M manifests/misc/geoip.pp
M modules/authdns/manifests/init.pp
A modules/geoip/manifests/bin.pp
M modules/geoip/manifests/data/maxmind.pp
M modules/geoip/manifests/data/puppet.pp
M modules/geoip/manifests/init.pp
M modules/puppetmaster/manifests/geoip.pp
7 files changed, 31 insertions(+), 118 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/09/93709/1

diff --git a/manifests/misc/geoip.pp b/manifests/misc/geoip.pp
index cf231f7..19d6d26 100644
--- a/manifests/misc/geoip.pp
+++ b/manifests/misc/geoip.pp
@@ -8,19 +8,9 @@
 # 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',
-    }
+    include geoip::data::puppet
+  } else {
+    include geoip::data::package
   }
 }
diff --git a/modules/authdns/manifests/init.pp 
b/modules/authdns/manifests/init.pp
index 4c9f9a4..d3dbd84 100644
--- a/modules/authdns/manifests/init.pp
+++ b/modules/authdns/manifests/init.pp
@@ -11,11 +11,7 @@
 ) {
     require authdns::account
     require authdns::scripts
-
-    class { '::geoip':
-        data_provider => 'package',
-    }
-    Class['::geoip'] -> Class['authdns']
+    require geoip::data::package
 
     package { 'gdnsd':
         ensure => installed,
diff --git a/modules/geoip/manifests/bin.pp b/modules/geoip/manifests/bin.pp
new file mode 100644
index 0000000..3ea6dd0
--- /dev/null
+++ b/modules/geoip/manifests/bin.pp
@@ -0,0 +1,8 @@
+# == Class geoip::bin
+# Installs the MaxMind binaries & library.
+#
+class geoip::bin {
+  package { 'geoip-bin':
+    ensure => present,
+  }
+}
diff --git a/modules/geoip/manifests/data/maxmind.pp 
b/modules/geoip/manifests/data/maxmind.pp
index 4197fe8..62ae383 100644
--- a/modules/geoip/manifests/data/maxmind.pp
+++ b/modules/geoip/manifests/data/maxmind.pp
@@ -23,13 +23,7 @@
 #   }
 # }
 # ...
-# # 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 {
+# node client_node {
 #   include geoip::data::puppet
 # }
 #
@@ -40,6 +34,9 @@
   $user_id        = false,
   $product_ids    = [106])
 {
+  # we need the geoipupdate binary from geoip-bin
+  require geoip::bin
+
   if ! defined(File[$data_directory]) {
     file { $data_directory:
       ensure => directory,
diff --git a/modules/geoip/manifests/data/puppet.pp 
b/modules/geoip/manifests/data/puppet.pp
index 6f043e1..cbcfcab 100644
--- a/modules/geoip/manifests/data/puppet.pp
+++ b/modules/geoip/manifests/data/puppet.pp
@@ -6,7 +6,7 @@
 # $data_directory - Where the data files should live.
 #
 class geoip::data::puppet(
-  $source,
+  $source = 'puppet:///volatile/GeoIP',
   $data_directory = '/usr/share/GeoIP',
 )
 {
diff --git a/modules/geoip/manifests/init.pp b/modules/geoip/manifests/init.pp
index a218d65..9fb7efb 100644
--- a/modules/geoip/manifests/init.pp
+++ b/modules/geoip/manifests/init.pp
@@ -1,95 +1,22 @@
-# geoip.pp
+# Classes to manage the installation of MaxMind GeoIP libraries and databases
 #
-# 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:
+# To install the geoip utilities & all of the data you can use
 #
 #   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.
+# Otherwise, you can manually mix and match any of the geoip::data classes,
+# e.g. the easiest option would be to
 #
-# 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.
-
+#   include geoip::data::package
+#
+# which installs the Debian geoip-database package.
+#
 # == Class geoip
-# Installs Maxmind IP address Geocoding
-# packages and database files (via puppet).
+# Convenience class that installs the MaxMind binaries, library & all data
 #
-# 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.
+class geoip {
+  # load the data from the puppetmaster. You need to make sure the puppetmaster
+  # includes one or more of the other data classes
+  include geoip::data::puppet
+  include geoip::bin
 }
diff --git a/modules/puppetmaster/manifests/geoip.pp 
b/modules/puppetmaster/manifests/geoip.pp
index 18168d3..ea1f737 100644
--- a/modules/puppetmaster/manifests/geoip.pp
+++ b/modules/puppetmaster/manifests/geoip.pp
@@ -11,11 +11,6 @@
         ensure => directory,
     }
 
-    # installs the geoip-bin package
-    class { '::geoip':
-        data_provider  => undef,
-    }
-
     # fetch the GeoLite databases
     class { 'geoip::data::lite':
         data_directory => $geoip_destdir,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia98d7318ef6e02f480a5cb7bbd1df7b61bdce2dd
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <fai...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to