Puppet Class: xdmod::ondemand

Inherits:
xdmod::params
Defined in:
manifests/ondemand.pp

Summary

Manage XDMoD OnDemand plugin

Overview

Parameters:

  • geoip_userid (Optional[String]) (defaults to: undef)

    The MaxMind GeoIP user ID Must be set if you wish to use GeoIP database

  • geoip_licensekey (Optional[String]) (defaults to: undef)

    The MaxMind GeoIP license key Must be set if you wish to use GeoIP database

  • version (String) (defaults to: $xdmod::params::xdmod_ondemand_version)

    Version of XDMOD OnDemand to install

  • package_name (String) (defaults to: 'xdmod-ondemand')

    The XDMOD OnDemand package name

  • package_ensure (String) (defaults to: 'installed')

    The state of XDMOD OnDemand package when using local repo

  • package_url (Stdlib::HTTPSUrl) (defaults to: $xdmod::params::ondemand_package_url)

    The URL of the XDMOD OnDemand package when not using local repo

  • log_format (String) (defaults to: '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"')

    Log format to use for parsing access logs

  • cron_times (Array[Integer, 2, 2]) (defaults to: [0,7])

    The cron times for ondemand shred/ingest

  • manage_cron (Boolean) (defaults to: true)

    Manage OnDemand cron files



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'manifests/ondemand.pp', line 24

class xdmod::ondemand (
  Optional[String] $geoip_userid = undef,
  Optional[String] $geoip_licensekey = undef,
  String $version   = $xdmod::params::xdmod_ondemand_version,
  String $package_name = 'xdmod-ondemand',
  String $package_ensure = 'installed',
  Stdlib::HTTPSUrl $package_url  = $xdmod::params::ondemand_package_url,
  String $log_format = '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"',
  Array[Integer, 2, 2] $cron_times = [0,7],
  Boolean $manage_cron = true,
) inherits xdmod::params {
  include xdmod

  if $geoip_userid and $geoip_licensekey {
    $geoip_directory = '/usr/share/GeoIP'
    $geoip_database = "${geoip_directory}/GeoLite2-City.mmdb"
    $update_timer_hour = sprintf('%02d', ($cron_times[1] - 1))
    class { 'geoip':
      config        => {
        'userid'             => $geoip_userid,
        'licensekey'         => $geoip_licensekey,
        'database_directory' => $geoip_directory,
        'productids'         => ['GeoLite2-City'],
      },
      update_timers => [
        "*-*-* ${update_timer_hour}:00:00",
      ],
    }
    File <| title == $geoip::config_path |> {
      show_diff => false,
    }
  } else {
    $geoip_database = ''
  }

  if $xdmod::local_repo_name {
    package { 'xdmod-ondemand':
      ensure  => $package_ensure,
      name    => $package_name,
      require => $xdmod::_package_require,
      before  => File['/etc/xdmod/portal_settings.d/ondemand.ini'],
    }
    $package_resource = Package['xdmod-ondemand']
  } else {
    $_package_url = regsubst($package_url, 'VERSION', $version, 'G')
    yum::install { $package_name:
      ensure  => 'present',
      source  => $_package_url,
      require => $xdmod::_package_require,
      before  => File['/etc/xdmod/portal_settings.d/ondemand.ini'],
    }
    $package_resource = Yum::Install[$package_name]
  }

  file { '/etc/xdmod/portal_settings.d/ondemand.ini':
    ensure => 'file',
    owner  => 'apache',
    group  => 'xdmod',
    mode   => '0440',
  }

  xdmod_ondemand_setting { 'ondemand-general/geoip_database': value => $geoip_database }
  xdmod_ondemand_setting { 'ondemand-general/webserver_format_str': value => $log_format }

  file { '/usr/local/bin/xdmod-ondemand-ingest.sh':
    ensure  => 'file',
    owner   => 'root',
    group   => 'root',
    mode    => '0755',
    content => template('xdmod/ondemand/ingest.sh.erb'),
    before  => File['/etc/cron.d/xdmod-ondemand'],
  }
  if $manage_cron {
    file { '/etc/cron.d/xdmod-ondemand':
      ensure  => 'file',
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => template('xdmod/ondemand/cron.erb'),
    }
  }
}