forked from uyuni-project/uyuni-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattestationServiceTemplate.go
More file actions
62 lines (55 loc) · 1.92 KB
/
Copy pathattestationServiceTemplate.go
File metadata and controls
62 lines (55 loc) · 1.92 KB
1
2
3
4
5
6
7
8
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
// SPDX-FileCopyrightText: 2026 SUSE LLC
//
// SPDX-License-Identifier: Apache-2.0
package templates
import (
"io"
"text/template"
)
const attestationServiceTemplate = `
# uyuni-server-attestation.service, generated by mgradm
# Use an uyuni-server-attestation.service.d/local.conf file to override
[Unit]
Description=Uyuni server attestation container service
Wants=network.target uyuni-db.service
After=network-online.target uyuni-db.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
ExecStartPre=/bin/rm -f %t/uyuni-server-attestation-%i.pid %t/%n.ctr-id
ExecStartPre=/usr/bin/podman rm --ignore --force -t 10 {{ .NamePrefix }}-server-attestation-%i
ExecStart=/bin/sh -c '/usr/bin/podman run \
--conmon-pidfile %t/uyuni-server-attestation-%i.pid \
--cidfile=%t/%n-%i.ctr-id \
--cgroups=no-conmon \
--sdnotify=conmon \
-d \
-e database_connection \
--secret={{ .DBUserSecret }},type=env,target=database_user \
--secret={{ .DBPassSecret }},type=env,target=database_password \
--replace \
--name {{ .NamePrefix }}-server-attestation-%i \
--hostname {{ .NamePrefix }}-server-attestation-%i.mgr.internal \
--network {{ .Network }} \
${UYUNI_SERVER_ATTESTATION_IMAGE}'
ExecStop=/usr/bin/podman stop --ignore -t 10 --cidfile=%t/%n-%i.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore -t 10 --cidfile=%t/%n-%i.ctr-id
PIDFile=%t/uyuni-server-attestation-%i.pid
TimeoutStopSec=60
TimeoutStartSec=60
Type=forking
[Install]
WantedBy=multi-user.target default.target
`
// AttestationServiceTemplateData holds information to create systemd file for coco container.
type AttestationServiceTemplateData struct {
NamePrefix string
Network string
DBUserSecret string
DBPassSecret string
}
// Render will create the systemd configuration file.
func (data AttestationServiceTemplateData) Render(wr io.Writer) error {
t := template.Must(template.New("service").Parse(attestationServiceTemplate))
return t.Execute(wr, data)
}