Commit 9c6eecae authored by intrigeri's avatar intrigeri
Browse files

check_mirrors: refactoring (factorize) and fix Puppet syntax mistakes

refs: tails/tails#17755
parent 55169b12
......@@ -70,57 +70,28 @@ class tails::check_mirrors (
],
}
# Full run
cron { 'tails_check_mirrors':
command => "sleep \$(( \$( </dev/urandom od -N2 -t u2 -A none ) >> 5 )) && \"${repo_checkout}/check-mirrors.rb --ignore-failures failures.json\"",
user => $user,
hour => 0,
minute => 16,
require => [Vcsrepo[$repo_checkout], Package[$needed_packages],
Postfix::Mailalias[$user], Exec['Import Tails signing key']],
# By default, check-mirrors.rb would create its per-run temporary
# directory in $CWD, i.e. in this context $HOME, which is never
# cleaned up automatically; so interrupted runs would leave
# temporary files behind them forever. Let's ask check-mirrors.rb
# to instead create its per-run temporary directory in a place
# that is cleaned up on boot. This requires ~2.5 GiB free space
# in /tmp so if we ever need to include this class on a system
# that has a smaller tmpfs mounted there, we'll need to make
# this configurable.
environment => [ 'TMPDIR=/tmp' ],
tails::check_mirrors::cronjob { 'Full run':
args => ['--ignore-failures', 'failures.json'],
hour => 0,
minute => 16,
}
# Fast run #1: optimized for European morning
cron { 'tails_check_mirrors':
command => "sleep \$(( \$( </dev/urandom od -N2 -t u2 -A none ) >> 5 )) && \"${repo_checkout}/check-mirrors.rb --fast --store-failures failures.json\"",
user => $user,
hour => 4,
minute => 16,
require => [Vcsrepo[$repo_checkout], Package[$needed_packages],
Postfix::Mailalias[$user], Exec['Import Tails signing key']],
environment => [ "TMPDIR=/tmp" ],
tails::check_mirrors::cronjob { 'Fast run #1: optimized for European morning':
args => ['--fast', '--store-failures', 'failures.json'],
hour => 4,
minute => 16,
}
# Fast run #2: optimized for American morning
cron { 'tails_check_mirrors':
command => "sleep \$(( \$( </dev/urandom od -N2 -t u2 -A none ) >> 5 )) && \"${repo_checkout}/check-mirrors.rb --fast --store-failures failures.json\"",
user => $user,
hour => 12,
minute => 16,
require => [Vcsrepo[$repo_checkout], Package[$needed_packages],
Postfix::Mailalias[$user], Exec['Import Tails signing key']],
environment => [ "TMPDIR=/tmp" ],
tails::check_mirrors::cronjob { 'Fast run #2: optimized for American morning':
args => ['--fast', '--store-failures', 'failures.json'],
hour => 12,
minute => 16,
}
# Fast run #3: to complete the 3 × 8 shifts
cron { 'tails_check_mirrors':
command => "sleep \$(( \$( </dev/urandom od -N2 -t u2 -A none ) >> 5 )) && \"${repo_checkout}/check-mirrors.rb --fast --store-failures failures.json\"",
user => $user,
hour => 20,
minute => 16,
require => [Vcsrepo[$repo_checkout], Package[$needed_packages],
Postfix::Mailalias[$user], Exec['Import Tails signing key']],
environment => [ "TMPDIR=/tmp" ],
tails::check_mirrors::cronjob { 'Fast run #3: to complete the 3 × 8 shifts':
args => ['--fast', '--store-failures', 'failures.json'],
hour => 20,
minute => 16,
}
}
# Manage a cronjob that runs check-mirrors.rb
define tails::check_mirrors::cronjob (
Integer[0, 23] $hour,
Integer[0, 59] $minute,
Array[String] $args = [],
) {
assert_private()
$args_str = join($args, ' ')
cron { "tails_check_mirrors ${title}":
command => "sleep \$(( \$( </dev/urandom od -N2 -t u2 -A none ) >> 5 )) && \"${tails::check_mirrors::repo_checkout}/check-mirrors.rb\" ${args_str}", # lint:ignore:140chars -- command
user => $tails::check_mirrors::user,
hour => $hour,
minute => $minute,
require => [
Vcsrepo[$tails::check_mirrors::repo_checkout],
Package[$tails::check_mirrors::needed_packages],
Postfix::Mailalias[$tails::check_mirrors::user],
Exec['Import Tails signing key'],
],
# By default, check-mirrors.rb would create its per-run temporary
# directory in $CWD, i.e. in this context $HOME, which is never
# cleaned up automatically; so interrupted runs would leave
# temporary files behind them forever. Let's ask check-mirrors.rb
# to instead create its per-run temporary directory in a place
# that is cleaned up on boot. This requires ~2.5 GiB free space
# in /tmp so if we ever need to include this class on a system
# that has a smaller tmpfs mounted there, we'll need to make
# this configurable.
environment => [ 'TMPDIR=/tmp' ],
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment