Puppet Class: query_service::categories_reload_crontasks
- Defined in:
- modules/query_service/manifests/categories_reload_crontasks.pp
Overview
SPDX-License-Identifier: Apache-2.0
Class: query_service::categories_reload_crontasks
Installs all the major recurring jobs for Query service
Parameters:
-
$package_dir: Directory where the service is installed.
-
$data_dir: Where the data is installed.
-
$log_dir: Directory where the logs go
-
$username: Username owning the service
-
$load_categories: frequency of loading categories
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 116 117 118 119 120 121 122 123 124 125 126 |
# File 'modules/query_service/manifests/categories_reload_crontasks.pp', line 12
class query_service::categories_reload_crontasks(
String $package_dir,
String $data_dir,
String $log_dir,
String $username,
String $deploy_name,
Enum['none', 'daily', 'weekly'] $load_categories,
Stdlib::Httpurl $categories_endpoint,
) {
file { '/usr/local/bin/cronUtils.sh':
ensure => present,
source => 'puppet:///modules/query_service/cron/cronUtils.sh',
owner => 'root',
group => 'root',
mode => '0755',
}
file { '/usr/local/bin/reloadCategories.sh':
ensure => present,
source => 'puppet:///modules/query_service/cron/reloadCategories.sh',
owner => 'root',
group => 'root',
mode => '0755',
}
file { '/usr/local/bin/loadCategoriesDaily.sh':
ensure => present,
source => 'puppet:///modules/query_service/cron/loadCategoriesDaily.sh',
owner => 'root',
group => 'root',
mode => '0755',
}
file { '/usr/local/bin/reloadDCAT-AP.sh':
ensure => present,
source => 'puppet:///modules/query_service/cron/reloadDCAT-AP.sh',
owner => 'root',
group => 'root',
mode => '0755',
}
file { '/etc/default/category-endpoint':
ensure => present,
content => epp('query_service/category-endpoint-default.epp', { 'endpoint' => $categories_endpoint }),
owner => 'root',
group => 'root',
mode => '0755',
}
$reload_categories_log = "${log_dir}/reloadCategories.log"
# the reload-categories job needs to reload nginx once the categories are up to date
sudo::user { "${username}-reload-nginx":
ensure => present,
user => $username,
privileges => [ 'ALL = NOPASSWD: /bin/systemctl reload nginx' ],
}
$ensure_reload_categories = $load_categories ? {
'weekly' => 'present',
default => 'absent',
}
$ensure_daily_categories = $load_categories ? {
'daily' => 'present',
default => 'absent',
}
# Category dumps start on Sat 20:00. By Mon, they should be done.
# We want random time so that hosts don't reboot at the same time, but we
# do not want them to be too far from one another.
systemd::timer::job { 'reload-categories':
ensure => $ensure_reload_categories,
description => 'Query service category dump (weekly)',
command => "/usr/local/bin/reloadCategories.sh ${deploy_name}",
user => $username,
logfile_basedir => $log_dir,
logfile_name => 'reloadCategories.log',
interval => {'start' => 'OnCalendar', 'interval' => "Mon *-*-* ${fqdn_rand(2)}:${fqdn_rand(60)}:00"},
}
# Categories daily dump starts at 5:00. Currently it is done by 5:05, but just in case
# it ever takes longer, start at 7:00.
systemd::timer::job { 'load-categories-daily':
ensure => $ensure_daily_categories,
description => 'Query service category dump (daily)',
command => "/usr/local/bin/loadCategoriesDaily.sh ${deploy_name}",
user => $username,
logfile_basedir => $log_dir,
logfile_name => 'reloadCategories.log',
interval => {'start' => 'OnCalendar', 'interval' => "*-*-* 07:${fqdn_rand(60)}:00"},
}
systemd::timer::job{ 'load-dcatap-weekly':
ensure => $ensure_daily_categories,
description => 'Reload DCAT-AP',
command => "/usr/local/bin/reloadDCAT-AP.sh ${deploy_name}",
user => $username,
logfile_basedir => $log_dir,
logfile_name => 'reloadDCATAP.log',
interval => {'start' => 'OnCalendar', 'interval' => "Fri *-*-* 07:${fqdn_rand(60)}:00"},
}
logrotate::rule { 'query-service-reload-categories':
ensure => present,
file_glob => $reload_categories_log,
frequency => 'monthly',
missing_ok => true,
not_if_empty => true,
rotate => 3,
compress => true,
create => "0640 ${username} wikidev",
}
}
|