Faidon Liambotis has uploaded a new change for review.
https://gerrit.wikimedia.org/r/172444
Change subject: geoip: switch data::maxmind to geoiupdate
......................................................................
geoip: switch data::maxmind to geoiupdate
geoipupdate was forked off the GeoIP distribution and is maintained
separately. The newer version supports GeoIP2 databases, HTTPS, as well
as setting a proxy from the configuration file.
geoipupdate packages have been backported and are already in apt for
both precise and trusty.
Change-Id: I926b488c320035f591518d817ef6234c61889dbb
---
M modules/geoip/manifests/data/maxmind.pp
M modules/geoip/templates/GeoIP.conf.erb
M modules/puppetmaster/manifests/geoip.pp
3 files changed, 29 insertions(+), 27 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/44/172444/1
diff --git a/modules/geoip/manifests/data/maxmind.pp
b/modules/geoip/manifests/data/maxmind.pp
index 62ae383..70f0055 100644
--- a/modules/geoip/manifests/data/maxmind.pp
+++ b/modules/geoip/manifests/data/maxmind.pp
@@ -5,12 +5,11 @@
#
# == Parameters
# $data_directory - Where the data files should live.
-# $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)
+# $proxy - Proxy server to use to fetch files. Optional.
# == 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
@@ -29,13 +28,14 @@
#
class geoip::data::maxmind(
$data_directory = '/usr/share/GeoIP',
- $environment = undef,
$license_key = false,
$user_id = false,
- $product_ids = [106])
-{
- # we need the geoipupdate binary from geoip-bin
- require geoip::bin
+ $product_ids = [106],
+ $proxy = undef
+) {
+ package { 'geoipupdate':
+ ensure => present,
+ }
if ! defined(File[$data_directory]) {
file { $data_directory:
@@ -57,22 +57,23 @@
# 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.
+ # 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]],
+ require => [
+ Package['geoipupdate'],
+ 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.
+
+ # 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",
@@ -80,19 +81,16 @@
weekday => 0,
hour => 3,
minute => 30,
- require => [Package['geoip-bin'], File[$config_file],
File[$data_directory]],
+ require => [
+ Package['geoipupdate'],
+ 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/templates/GeoIP.conf.erb
b/modules/geoip/templates/GeoIP.conf.erb
index 9bc3b458..c527e46 100644
--- a/modules/geoip/templates/GeoIP.conf.erb
+++ b/modules/geoip/templates/GeoIP.conf.erb
@@ -19,3 +19,7 @@
# 133 - GeoIPCity.dat City database
# 115 - GeoIPRegion.dat Region database
ProductIds <%= @product_ids.join(' ') %>
+
+<% if @proxy then -%>
+Proxy <%= @proxy %>
+<% end -%>
diff --git a/modules/puppetmaster/manifests/geoip.pp
b/modules/puppetmaster/manifests/geoip.pp
index 292e9e3..8539ab1 100644
--- a/modules/puppetmaster/manifests/geoip.pp
+++ b/modules/puppetmaster/manifests/geoip.pp
@@ -4,7 +4,7 @@
# normal puppet File resource (see the geoip module for more)
$geoip_destdir = "${puppetmaster::volatiledir}/GeoIP"
- $environment = "http_proxy=http://webproxy.${::site}.wmnet:8080"
+ $webproxy = "http://webproxy.${::site}.wmnet:8080"
# geoip::data classes depend on this
file { $geoip_destdir:
@@ -14,7 +14,7 @@
# fetch the GeoLite databases
class { 'geoip::data::lite':
data_directory => $geoip_destdir,
- environment => $environment,
+ environment => "http_proxy=$webproxy",
}
if $is_labs_puppet_master {
@@ -34,7 +34,7 @@
class { 'geoip::data::maxmind':
data_directory => $geoip_destdir,
- environment => $environment,
+ proxy => $webproxy,
license_key => $passwords::geoip::license_key,
user_id => $passwords::geoip::user_id,
product_ids => [
--
To view, visit https://gerrit.wikimedia.org/r/172444
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I926b488c320035f591518d817ef6234c61889dbb
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits