Puppet Class: dmlite::accounting

Defined in:
manifests/accounting.pp

Overview

EGI StaR accounting - wiki.egi.eu/wiki/APEL/Storage For publishing data in the EGI it is necessary to create eu.egi.storage.accounting service for DPM headnode in GOCDB (goc.egi.eu) with “Host DN” set to certificate subject Usage:

class { '::dmlite::accounting':
  site_name => 'praguelcg2',
}

Parameters:

  • enabled (Boolean) (defaults to: hiera('dmlite::accounting::enabled',true))
  • cron_interval (String) (defaults to: hiera('dmlite::accounting::cron_interval','daily'))
  • bdii_url (String) (defaults to: hiera('dmlite::accounting::bdii_url','ldap://lcg-bdii.cern.ch:2170'))
  • broker_network (String) (defaults to: hiera('dmlite::accounting::broker_network','PROD'))
  • broker_host (Optional[Stdlib::Host]) (defaults to: hiera('dmlite::accounting::broker_host',undef))
  • broker_port (Optional[Stdlib::Port]) (defaults to: hiera('dmlite::accounting::broker_port',undef))
  • use_ssl (Boolean) (defaults to: hiera('dmlite::accounting::use_ssl',true))
  • certificate (Optional[Stdlib::Unixpath]) (defaults to: hiera('dmlite::accounting::certificate','/etc/grid-security/dpmmgr/dpmcert.pem'))
  • key (Optional[Stdlib::Unixpath]) (defaults to: hiera('dmlite::accounting::key','/etc/grid-security/dpmmgr/dpmkey.pem'))
  • capath (Optional[Stdlib::Unixpath]) (defaults to: hiera('dmlite::accounting::capath','/etc/grid-security/certificates'))
  • server_cert (Optional[String]) (defaults to: hiera('dmlite::accounting::server_cert',undef))
  • messaging_destination (String) (defaults to: hiera('dmlite::accounting::messaging_destination','/queue/global.accounting.storage.central'))
  • messaging_path (Stdlib::Unixpath) (defaults to: hiera('dmlite::accounting::messaging_path','/var/spool/apel/outgoing'))
  • site_name (String) (defaults to: hiera('dmlite::accounting::site_name',''))
  • nsconfig (Stdlib::Unixpath) (defaults to: hiera('dmlite::accounting::nsconfig','/usr/etc/NSCONFIG'))
  • dbhost (Stdlib::Host) (defaults to: hiera('dmlite::accounting::dbhost','localhost'))
  • dbuser (String) (defaults to: hiera('dmlite::accounting::dbuser',''))
  • dbpwd (String) (defaults to: hiera('dmlite::accounting::dbpwd',''))
  • nsdbname (String) (defaults to: hiera('dmlite::accounting::nsdbname','cns_db'))
  • dpmdbname (String) (defaults to: hiera('dmlite::accounting::dpmdbname','dpm_db'))
  • log_file (Stdlib::Unixpath) (defaults to: hiera('dmlite::accounting::log_file','/var/log/apel/ssmsend.log'))
  • log_level (String) (defaults to: hiera('dmlite::accounting::log_level', 'INFO'))
  • console (Boolean) (defaults to: hiera('dmlite::accounting::console', true))
  • ssm_url (String) (defaults to: hiera('dmlite::accounting::ssm_url', ''))


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
106
107
108
109
110
111
112
113
114
115
# File 'manifests/accounting.pp', line 9

class dmlite::accounting (
  Boolean $enabled = hiera('dmlite::accounting::enabled',true),
  String $cron_interval = hiera('dmlite::accounting::cron_interval','daily'),
  String $bdii_url = hiera('dmlite::accounting::bdii_url','ldap://lcg-bdii.cern.ch:2170'),
  String $broker_network = hiera('dmlite::accounting::broker_network','PROD'),
  Optional[Stdlib::Host] $broker_host = hiera('dmlite::accounting::broker_host',undef),
  Optional[Stdlib::Port] $broker_port = hiera('dmlite::accounting::broker_port',undef),
  Boolean $use_ssl = hiera('dmlite::accounting::use_ssl',true),
  Optional[Stdlib::Unixpath] $certificate = hiera('dmlite::accounting::certificate','/etc/grid-security/dpmmgr/dpmcert.pem'),
  Optional[Stdlib::Unixpath] $key = hiera('dmlite::accounting::key','/etc/grid-security/dpmmgr/dpmkey.pem'),
  Optional[Stdlib::Unixpath] $capath = hiera('dmlite::accounting::capath','/etc/grid-security/certificates'),

  Optional[String] $server_cert = hiera('dmlite::accounting::server_cert',undef),
  String $messaging_destination = hiera('dmlite::accounting::messaging_destination','/queue/global.accounting.storage.central'),
  Stdlib::Unixpath $messaging_path = hiera('dmlite::accounting::messaging_path','/var/spool/apel/outgoing'),

  String $site_name = hiera('dmlite::accounting::site_name',''),

  Stdlib::Unixpath $nsconfig = hiera('dmlite::accounting::nsconfig','/usr/etc/NSCONFIG'),

  Stdlib::Host $dbhost = hiera('dmlite::accounting::dbhost','localhost'),
  String $dbuser = hiera('dmlite::accounting::dbuser',''),
  String $dbpwd = hiera('dmlite::accounting::dbpwd',''),
  String $nsdbname = hiera('dmlite::accounting::nsdbname','cns_db'),
  String $dpmdbname = hiera('dmlite::accounting::dpmdbname','dpm_db'),

  Stdlib::Unixpath $log_file = hiera('dmlite::accounting::log_file','/var/log/apel/ssmsend.log'),
  String $log_level = hiera('dmlite::accounting::log_level', 'INFO'),
  Boolean $console = hiera('dmlite::accounting::console', true),
  String $ssm_url = hiera('dmlite::accounting::ssm_url', ''),

) {

  if $site_name == '' {
    fail("'site_name' not defined")
  }

  # install
  if $enabled {
    package {['python-daemon','python-ldap','python-lockfile','stomppy']:
      ensure => 'installed',
    }
  }
  # apel-ssm also available in UMD repository
  if $enabled and $ssm_url == '' {
    if $facts['os']['family'] == 'RedHat' {
      $ssm_package_url = $facts['os']['release']['major'] ? {
        '6' => 'https://github.com/apel/ssm/releases/download/2.3.0-2/apel-ssm-2.3.0-2.el6.noarch.rpm',
        '7' => 'https://github.com/apel/ssm/releases/download/2.3.0-2/apel-ssm-2.3.0-2.el7.noarch.rpm',
        default => fail("EGI StaR accounting enabled but ${facts['os']['name']}${facts['os']['release']['major']} is not supported")
      }
    }
  } else {
    $ssm_package_url = $ssm_url
  }
  if !$ssm_package_url {
    fail("missing ssm_url on unsupported os ${facts['os']['family']} (${facts['os']['name']} ${facts['os']['release']['major']})")
  }
  package { 'apel-ssm':
    ensure   => $enabled ? {
      true  => 'installed',
      false => absent,
    },
    source   => $ssm_package_url,
    provider => 'rpm'
  }

  file {'/etc/apel/sender.cfg':
    ensure  => $enabled ? {
      true  => present,
      false => absent,
    },
    owner   => 'root',
    group   => 'root',
    content => template('dmlite/ssm/sender.cfg.erb'),
    require => Package['apel-ssm']
  }

  # do not break in case the new parameters are not defined
  if $dbuser == '' {
    $cron_content = inline_template('#!/bin/sh
/bin/mkdir -p /var/spool/apel/outgoing/`date +%Y%m%d` && /usr/share/dmlite/StAR-accounting/star-accounting.py --reportgroups --nsconfig=<%= @nsconfig %> --site=<%= @site_name %> > /var/spool/apel/outgoing/`date +%Y%m%d`/`date +%Y%m%d%H%M%S` && ssmsend
')
  } else {
    $cron_content = inline_template('#!/bin/sh
/bin/mkdir -p /var/spool/apel/outgoing/`date +%Y%m%d` && /usr/share/dmlite/StAR-accounting/star-accounting.py --reportgroups --dbhost=<%= @dbhost %> --dbuser=<%= @dbuser %> --dbpwd=<%= @dbpwd %> --nsdbname=<%= @nsdbname %> --dpmdbname=<%= @dpmdbname %> --site=<%= @site_name %> > /var/spool/apel/outgoing/`date +%Y%m%d`/`date +%Y%m%d%H%M%S` && ssmsend
')
  }

  file {"/etc/cron.${cron_interval}/dmlite-StAR-accounting":
    ensure  => $enabled ? {
      true  => present,
      false => absent,
    },
    owner   => 'root',
    group   => 'root',
    mode    => '0755',
    content => $cron_content,
    require => Package['apel-ssm']
  }
  
  #purge old cron
  cron { 'dmlite-star-accounting':
    ensure => absent,
  }

}