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
|
# File 'manifests/systemd.pp', line 53
define service_autorestart::systemd (
String $systemd_dir = lookup('service_autorestart::systemd_dir') |$k| { '/usr/lib/systemd/system' },
String $path = "${systemd_dir}/${title}.service",
String $value = 'on-failure',
Optional[String] $delay = undef,
Boolean $autonotify_path = true,
Boolean $autonotify_systemctl_daemon_reload = true
) {
ini_setting { "systemd_${title}_restart":
ensure => present,
path => $path,
section => 'Service',
setting => 'Restart',
value => $value,
key_val_separator => '=',
tag => 'service_autorestart',
}
if $delay {
ini_setting { "systemd_${title}_restartsec":
ensure => present,
path => $path,
section => 'Service',
setting => 'RestartSec',
value => $delay,
key_val_separator => '=',
tag => 'service_autorestart',
}
}
# make sure the file exists before we modify it
if $autonotify_path and defined(File[$path]) {
File[$path] ~> Ini_setting<| tag == 'service_autorestart' |>
}
# if we're using the camptocamp/systemd module, invoke systemctl daemon_reload
# so systemd knows about our file changes
if $autonotify_systemctl_daemon_reload and defined(Class['systemd::systemctl::daemon_reload']) {
Ini_setting<| tag == 'service_autorestart' |> ~> Class['systemd::systemctl::daemon_reload']
}
}
|