Defined Type: wikistats::cronjob::xmldump

Defined in:
modules/wikistats/manifests/cronjob/xmldump.pp

Overview

define a cronjob to dump xml tables

Parameters:

  • table (String)
  • minute (Integer)
  • db_pass (String)
  • db_user (String) (defaults to: 'wikistatsuser')
  • db_name (String) (defaults to: 'wikistats')
  • file_path (Stdlib::Unixpath) (defaults to: '/var/www/wikistats/xml')


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'modules/wikistats/manifests/cronjob/xmldump.pp', line 2

define wikistats::cronjob::xmldump(
    String $table,
    Integer $minute,
    String $db_pass,
    String $db_user = 'wikistatsuser',
    String $db_name = 'wikistats',
    Stdlib::Unixpath $file_path = '/var/www/wikistats/xml',
){

    $query = $table ? {
        'wikipedias' => 'SELECT *,good/total AS ratio FROM wikipedias WHERE total IS NOT NULL ORDER BY good desc,total desc',
        default      => "SELECT *,good/total AS ratio FROM ${table} ORDER BY good desc,total desc",
    }

    $command = "mysql --defaults-extra-file=/usr/lib/wikistats/.my.cnf -X -u ${db_user} -e '${query}' ${db_name} > ${file_path}/${table}.xml 2>&1"

    cron { "cron-wikistats-xmldump-${name}":
        ensure  => present,
        command => $command,
        user    => 'wikistatsuser',
        minute  => $minute,
    }
}