OLD | NEW |
(Empty) | |
| 1 # == Class: geoip |
| 2 # |
| 3 # Manage GeoIP (http://dev.maxmind.com/geoip/) databases. |
| 4 # |
| 5 # === Parameters: |
| 6 # |
| 7 # [*cron*] |
| 8 # Default options for Cron['geoip'], e.g. $minute, $monthday etc. |
| 9 # |
| 10 # [*ensure*] |
| 11 # Either 'present', 'absent' or 'purged'. |
| 12 # |
| 13 # [*hook*] |
| 14 # A command to execute when Cron['geoip'] has succeeded, optional. |
| 15 # |
| 16 # [*packages*] |
| 17 # The names of the GeoIP packages. |
| 18 # |
| 19 # [*script*] |
| 20 # Where to store the update script executed by Cron['geoip']. |
| 21 # |
| 22 # [*version*] |
| 23 # A specific version to ensure for all $packages, optional. |
| 24 # |
| 25 # === Examples: |
| 26 # |
| 27 # class {'geoip': |
| 28 # cron => { |
| 29 # 'environment' => ['PYTHONPATH=/opt/custom'], |
| 30 # 'minute' => 0, |
| 31 # 'hour' => 8, |
| 32 # 'monthday' => 15, |
| 33 # }, |
| 34 # } |
| 35 # |
| 36 class geoip ( |
| 37 $cron = {}, |
| 38 $ensure = 'present', |
| 39 $hook = undef, |
| 40 $packages = ['geoip-database'], |
| 41 $script = '/usr/local/sbin/update-geoip-database', |
| 42 $version = undef, |
| 43 ) { |
| 44 |
| 45 ensure_resource('package', $packages, { |
| 46 ensure => $ensure ? { |
| 47 /^(absent|purged)$/ => $ensure, |
| 48 default => $version ? {undef => 'present', default => $version}, |
| 49 }, |
| 50 }) |
| 51 |
| 52 create_resources('cron', {geoip => $cron}, { |
| 53 command => $hook ? {undef => $script, default => "$script && $hook"}, |
| 54 ensure => $ensure ? {/^(absent|purged)$/ => 'absent', default => 'present'}, |
| 55 hour => 0, |
| 56 minute => 0, |
| 57 user => 'root', |
| 58 }) |
| 59 |
| 60 file {$script: |
| 61 before => Cron['geoip'], |
| 62 ensure => $ensure ? {/^(absent|purged)$/ => 'absent', default => 'present'}, |
| 63 mode => 0755, |
| 64 require => Package[$packages], |
| 65 source => 'puppet:///modules/geoip/update.py', |
| 66 } |
| 67 } |
OLD | NEW |