Index: modules/geoip/manifests/init.pp |
diff --git a/modules/geoip/manifests/init.pp b/modules/geoip/manifests/init.pp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b36d08a92fbedf1d8cae5dac8e9f237f91e909bb |
--- /dev/null |
+++ b/modules/geoip/manifests/init.pp |
@@ -0,0 +1,67 @@ |
+# == Class: geoip |
+# |
+# Manage GeoIP (http://dev.maxmind.com/geoip/) databases. |
+# |
+# === Parameters: |
+# |
+# [*cron*] |
+# Default options for Cron['geoip'], e.g. $minute, $monthday etc. |
+# |
+# [*ensure*] |
+# Either 'present', 'absent' or 'purged'. |
+# |
+# [*hook*] |
+# A command to execute when Cron['geoip'] has succeeded, optional. |
+# |
+# [*packages*] |
+# The names of the GeoIP packages. |
+# |
+# [*script*] |
+# Where to store the update script executed by Cron['geoip']. |
+# |
+# [*version*] |
+# A specific version to ensure for all $packages, optional. |
+# |
+# === Examples: |
+# |
+# class {'geoip': |
+# cron => { |
+# 'environment' => ['PYTHONPATH=/opt/custom'], |
+# 'minute' => 0, |
+# 'hour' => 8, |
+# 'monthday' => 15, |
+# }, |
+# } |
+# |
+class geoip ( |
+ $cron = {}, |
+ $ensure = 'present', |
+ $hook = undef, |
+ $packages = ['geoip-database'], |
+ $script = '/usr/local/sbin/update-geoip-database', |
+ $version = undef, |
+) { |
+ |
+ ensure_resource('package', $packages, { |
+ ensure => $ensure ? { |
+ /^(absent|purged)$/ => $ensure, |
+ default => $version ? {undef => 'present', default => $version}, |
+ }, |
+ }) |
+ |
+ create_resources('cron', {geoip => $cron}, { |
+ command => $hook ? {undef => $script, default => "$script && $hook"}, |
+ ensure => $ensure ? {/^(absent|purged)$/ => 'absent', default => 'present'}, |
+ hour => 0, |
+ minute => 0, |
+ user => 'root', |
+ }) |
+ |
+ file {$script: |
+ before => Cron['geoip'], |
+ ensure => $ensure ? {/^(absent|purged)$/ => 'absent', default => 'present'}, |
+ mode => 0755, |
+ require => Package[$packages], |
+ source => 'puppet:///modules/geoip/update.py', |
+ } |
+} |