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