Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/geoip/manifests/init.pp

Issue 29326111: Issue 3010 - Introduce class geoip (Closed)
Patch Set: Created Sept. 8, 2015, 12:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « modules/geoip/files/update.py ('k') | modules/statsmaster/files/cron_geoipdb_update.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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',
+ }
+}
« no previous file with comments | « modules/geoip/files/update.py ('k') | modules/statsmaster/files/cron_geoipdb_update.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld